Merge branch 'master' of ssh://git.samba.org/data/git/samba
[amitay/samba.git] / source3 / script / tests / test_testparm_s3.sh
1 #!/bin/sh
2
3 # Tests for lp_load() via testparm.
4 #
5 # The main purpose (for now) is to test all the special handlers
6 # and the macro expansions.
7
8 TEMP_CONFFILE=${LIBDIR}/smb.conf.tmp
9 TESTPARM="$VALGRIND ${TESTPARM:-$BINDIR/testparm} --suppress-prompt --skip-logic-checks"
10
11 test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && {
12 incdir=`dirname $0`
13 . $incdir/test_functions.sh
14 }
15
16 failed=0
17
18 test_include_expand_macro()
19 {
20         MACRO=$1
21         rm -f ${TEMP_CONFFILE}
22         cat >${TEMP_CONFFILE}<<EOF
23 [global]
24         include = ${TEMP_CONFFILE}.%${MACRO}
25 EOF
26         ${TESTPARM} ${TEMP_CONFFILE}
27 }
28
29 test_one_global_option()
30 {
31         OPTION="$@"
32         rm -f ${TEMP_CONFFILE}
33         cat > ${TEMP_CONFFILE}<<EOF
34 [global]
35         ${OPTION}
36 EOF
37         ${TESTPARM} ${TEMP_CONFFILE}
38 }
39
40 test_copy()
41 {
42         rm -f ${TEMP_CONFFILE}
43         cat > ${TEMP_CONFFILE}<<EOF
44 [share1]
45         path = /tmp
46         read only = no
47
48 [share2]
49         copy = share1
50 EOF
51         ${TESTPARM} ${TEMP_CONFFILE}
52 }
53
54
55 testit "netbios name" \
56         test_one_global_option "netbios name = funky" || \
57         failed=`expr ${failed} + 1`
58
59 testit "netbios aliases" \
60         test_one_global_option "netbios aliases = funky1 funky2 funky3" || \
61         failed=`expr ${failed} + 1`
62
63 testit "netbios scope" \
64         test_one_global_option "netbios scope = abc" || \
65         failed=`expr ${failed} + 1`
66
67 testit "workgroup" \
68         test_one_global_option "workgroup = samba" || \
69         failed=`expr ${failed} + 1`
70
71 testit "display charset" \
72         test_one_global_option "display charset = UTF8" || \
73         failed=`expr ${failed} + 1`
74
75 testit "ldap debug level" \
76         test_one_global_option "ldap debug level = 7" || \
77         failed=`expr ${failed} + 1`
78
79 for LETTER in U G D I i L N M R T a d h m v w V ; do
80 testit "include with %${LETTER} macro expansion" \
81         test_include_expand_macro "${LETTER}" || \
82         failed=`expr ${failed} + 1`
83 done
84
85 testit "copy" \
86         test_copy || \
87         failed=`expr ${failed} + 1`
88
89 rm -f ${TEMP_CONFFILE}
90
91 testok $0 ${failed}
92