2008-06-19 19:14:39 +04:00
#!/bin/sh
# Tests for lp_load() via testparm.
#
# The main purpose (for now) is to test all the special handlers
# and the macro expansions.
2011-02-21 08:01:44 +03:00
if [ $# -lt 1 ] ; then
2022-04-22 16:34:11 +03:00
cat <<EOF
2023-09-05 07:21:19 +03:00
Usage: test_testparm_s3.sh LOCAL_PATH
2011-02-21 08:01:44 +03:00
EOF
2022-04-22 16:34:11 +03:00
exit 1
2011-02-21 08:01:44 +03:00
fi
LOCAL_PATH = " $1 "
2010-08-13 20:28:48 +04:00
TEMP_CONFFILE = ${ LOCAL_PATH } /smb.conf.tmp
2008-07-15 14:52:25 +04:00
TESTPARM = " $VALGRIND ${ TESTPARM :- $BINDIR /testparm } --suppress-prompt --skip-logic-checks "
2008-06-19 19:14:39 +04:00
2022-04-22 16:34:11 +03:00
incdir = $( dirname $0 ) /../../../testprogs/blackbox
2011-02-19 02:32:06 +03:00
. $incdir /subunit.sh
2008-06-19 19:14:39 +04:00
failed = 0
test_include_expand_macro( )
{
MACRO = $1
rm -f ${ TEMP_CONFFILE }
2022-04-22 16:34:11 +03:00
cat >${ TEMP_CONFFILE } <<EOF
2008-06-19 19:14:39 +04:00
[ global]
include = ${ TEMP_CONFFILE } .%${ MACRO }
EOF
${ TESTPARM } ${ TEMP_CONFFILE }
}
test_one_global_option( )
{
2008-10-22 01:24:44 +04:00
OPTION = " $@ "
2008-06-19 19:14:39 +04:00
rm -f ${ TEMP_CONFFILE }
2022-04-22 16:34:11 +03:00
cat >${ TEMP_CONFFILE } <<EOF
2008-06-19 19:14:39 +04:00
[ global]
${ OPTION }
EOF
${ TESTPARM } ${ TEMP_CONFFILE }
}
test_copy( )
{
rm -f ${ TEMP_CONFFILE }
2022-04-22 16:34:11 +03:00
cat >${ TEMP_CONFFILE } <<EOF
2008-06-19 19:14:39 +04:00
[ share1]
path = /tmp
read only = no
[ share2]
copy = share1
EOF
${ TESTPARM } ${ TEMP_CONFFILE }
}
2020-08-10 03:18:07 +03:00
test_testparm_deprecated( )
{
2022-04-22 16:34:11 +03:00
name = $1
old_SAMBA_DEPRECATED_SUPPRESS = $SAMBA_DEPRECATED_SUPPRESS
SAMBA_DEPRECATED_SUPPRESS =
export SAMBA_DEPRECATED_SUPPRESS
testit_grep $name 'WARNING: The "lsaovernetlogon" option is deprecated' $VALGRIND ${ TESTPARM } ${ TEMP_CONFFILE } --option= 'lsaovernetlogon=true'
SAMBA_DEPRECATED_SUPPRESS = $old_SAMBA_DEPRECATED_SUPPRESS
export SAMBA_DEPRECATED_SUPPRESS
2020-08-10 03:18:07 +03:00
}
test_testparm_deprecated_suppress( )
{
2022-04-22 16:34:11 +03:00
name = $1
subunit_start_test " $name "
output = $( SAMBA_DEPRECATED_SUPPRESS = 1 $VALGRIND ${ TESTPARM } ${ TEMP_CONFFILE } --option= 'lsa over netlogon = true' 2>& 1)
status = $?
if [ " $status " = "0" ] ; then
echo " $output " | grep --quiet 'WARNING: The "lsa over netlogon " option is deprecated'
status = $?
if [ " $status " = "1" ] ; then
subunit_pass_test " $name "
else
echo $output | subunit_fail_test " $name "
fi
else
echo $output | subunit_fail_test " $name "
fi
2020-08-10 03:18:07 +03:00
}
2022-04-22 16:34:11 +03:00
testit "name resolve order = lmhosts wins host bcast" \
test_one_global_option "name resolve order = lmhosts wins host bcast" ||
failed = $( expr ${ failed } + 1)
2017-04-11 16:38:34 +03:00
2022-04-22 16:34:11 +03:00
testit_expect_failure "name resolve order = bad wins host bcast" \
test_one_global_option "name resolve order = bad wins host bcast" ||
failed = $( expr ${ failed } + 1)
2017-04-11 16:38:34 +03:00
2022-04-22 16:34:11 +03:00
testit_expect_failure "name resolve order = lmhosts bad host bcast" \
test_one_global_option "name resolve order = lmhosts bad host bcast" ||
failed = $( expr ${ failed } + 1)
2017-04-11 16:38:34 +03:00
2022-04-22 16:34:11 +03:00
testit_expect_failure "name resolve order = lmhosts wins bad bcast" \
test_one_global_option "name resolve order = lmhosts wins bad bcast" ||
failed = $( expr ${ failed } + 1)
2017-04-11 16:38:34 +03:00
2022-04-22 16:34:11 +03:00
testit_expect_failure "name resolve order = lmhosts wins host bad" \
test_one_global_option "name resolve order = lmhosts wins host bad" ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
testit "netbios name" \
2022-04-22 16:34:11 +03:00
test_one_global_option "netbios name = funky" ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
testit "netbios aliases" \
2022-04-22 16:34:11 +03:00
test_one_global_option "netbios aliases = funky1 funky2 funky3" ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
testit "netbios scope" \
2022-04-22 16:34:11 +03:00
test_one_global_option "netbios scope = abc" ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
testit "workgroup" \
2022-04-22 16:34:11 +03:00
test_one_global_option "workgroup = samba" ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
testit "display charset" \
2022-04-22 16:34:11 +03:00
test_one_global_option "display charset = UTF8" ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
testit "ldap debug level" \
2022-04-22 16:34:11 +03:00
test_one_global_option "ldap debug level = 7" ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
2022-04-22 16:34:11 +03:00
for LETTER in U G D I i L N M R T a d h m v w V; do
testit " include with % ${ LETTER } macro expansion " \
test_include_expand_macro " ${ LETTER } " ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
done
testit "copy" \
2022-04-22 16:34:11 +03:00
test_copy ||
failed = $( expr ${ failed } + 1)
2008-06-19 19:14:39 +04:00
2020-08-10 03:18:07 +03:00
test_testparm_deprecated "test_deprecated_warning_printed"
test_testparm_deprecated_suppress "test_deprecated_warning_suppressed"
2008-06-19 19:14:39 +04:00
rm -f ${ TEMP_CONFFILE }
testok $0 ${ failed }