torture: Add a check to verify MS-SMB2 3.3.5.14.2
[Samba.git] / source3 / script / tests / test_net_conf.sh
bloba81b21e5332065af454ee27bee1aad35174f9061
1 #!/bin/sh
3 # Blackbox test for net [rpc] conf.
5 # Copyright (C) 2011 Vicentiu Ciorbaru <cvicentiu@gmail.com>
7 if [ $# -lt 3 ]; then
8 cat <<EOF
9 Usage: test_net_conf.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION [rpc]
10 EOF
11 exit 1;
14 SCRIPTDIR="$1"
15 SERVERCONFFILE="$2"
16 NET="$3"
17 CONFIGURATION="$4"
18 RPC="$5"
20 LOGDIR_PREFIX="conf_test"
22 # remove old logs:
23 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do
24 echo "removing old directory ${OLDDIR}"
25 rm -rf ${OLDDIR}
26 done
29 NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
30 DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX)
31 LOG=$DIR/log
34 if test "x${RPC}" = "xrpc" ; then
35 NETCMD="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc"
36 else
37 NETCMD="${NET}"
40 incdir=`dirname $0`/../../../testprogs/blackbox
41 . $incdir/subunit.sh
43 failed=0
45 log_print() {
46 RC=$?
47 echo "CMD: $*" >>$LOG
48 echo "RC: $RC" >> $LOG
49 return $RC
50 # echo -n .
53 test_conf_addshare()
55 echo '\nTesting conf addshare' >> $LOG
56 echo ------------------------- >> $LOG
57 echo '\nDropping existing configuration' >> $LOG
59 $NETCMD conf drop
60 log_print $NETCMD conf drop
61 test "x$?" = "x0" || {
62 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
63 return 1
66 #create a lot of shares
67 for i in $(seq 1 100); do
68 if [ $(($i % 2)) -eq 0 ]; then
69 $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
70 "test comment" >>$DIR/addshare_exp \
71 2>>$DIR/addshare_exp
72 log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
73 "test comment"
74 else
75 $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \
76 "test comment" >>$DIR/addshare_exp \
77 2>>$DIR/addshare_exp
78 log_print $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \
79 "test comment"
81 test "x$?" = "x0" || {
82 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
83 return 1
85 done
87 $NETCMD conf listshares > $DIR/listshares_out
88 log_print $NETCMD conf listshares
89 test "x$?" = "x0" || {
90 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
91 return 1
94 for i in $(seq 1 100); do
95 grep "share$i" $DIR/listshares_out >/dev/null 2>>$LOG
96 if [ "$?" = "1" ]; then
97 echo "ERROR: share not found" | tee -a $LOG
98 return 1
100 done
102 #check the integrity of the shares
103 #if it fails, it can also point to an error in showshare
104 for i in $(seq 1 100); do
105 $NETCMD conf showshare share$i > $DIR/showshare_out
106 test "x$?" = "x0" || {
107 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
108 return 1
111 grep "path" $DIR/showshare_out >/dev/null 2>>$LOG
112 if [ "$?" = "1" ]; then
113 echo "ERROR: share not found" | tee -a $LOG
114 return 1
117 if [ $(($i % 2)) -eq 0 ]; then
118 grep "read only *= *no" $DIR/showshare_out >/dev/null 2>>$LOG
119 if [ "$?" = "1" ]; then
120 echo "ERROR: share not set correctly" | tee -a $LOG
121 return 1
123 else
124 grep "read only *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG
125 if [ "$?" = "1" ]; then
126 echo "ERROR: share not set correctly" | tee -a $LOG
127 return 1
131 if [ $(($i % 2)) -eq 0 ]; then
132 grep "guest ok *= *no" $DIR/showshare_out >/dev/null 2>>$LOG
133 if [ "$?" = "1" ]; then
134 echo "ERROR: share not set correctly" | tee -a $LOG
135 return 1
137 else
138 grep "guest ok *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG
139 if [ "$?" = "1" ]; then
140 echo "ERROR: share not set correctly" | tee -a $LOG
141 return 1
145 grep "comment *= *test comment" $DIR/showshare_out >/dev/null 2>>$LOG
146 if [ "$?" = "1" ]; then
147 echo "ERROR: share not set correctly" | tee -a $LOG
148 return 1
150 done
152 echo '\nTaking a conf snapshot for later use' >> $LOG
153 $NETCMD conf list > $DIR/conf_import_in
154 log_print $NETCMD conf list
155 test "x$?" = "x0" || {
156 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
157 return 1
161 test_conf_addshare_existing()
163 #try adding an already existing share
164 echo '\nAdding an already existing share' >>$LOG
165 $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \
166 "test comment" >>$DIR/addshare_exp \
167 2>>$DIR/addshare_exp
168 log_print $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \
169 "test comment"
170 test "x$?" = "x255" || {
171 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
172 return 1
175 test -z `cat $DIR/addshare_exp` && {
176 echo "ERROR: addshare output does not match" >> $LOG
177 return 1
180 return 0
183 test_conf_addshare_usage()
185 #check to see if command prints usage
186 echo '\nChecking usage' >>$LOG
187 $NETCMD conf addshare > $DIR/addshare_usage_exp
188 log_print $NETCMD conf addshare
189 test "x$?" = "x255" || {
190 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
191 return 1
194 grep "$RPC *conf addshare" $DIR/addshare_usage_exp >/dev/null 2>>$LOG
195 if [ "$?" = "1" ]; then
196 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
197 return 1
201 test_conf_delshare()
203 echo '\nTesting conf delshare' >>$LOG
204 echo ------------------------- >> $LOG
205 echo -n '\n' >> $LOG
207 $NETCMD conf delshare share1
208 log_print $NETCMD conf delshare share1
209 test "x$?" = "x0" || {
210 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
211 return 1
214 $NETCMD conf listshares > $DIR/listshares_out
215 log_print $NETCMD conf listshares
216 test "x$?" = "x0" || {
217 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
218 return 1
221 grep "share1$" $DIR/listshares_out >/dev/null 2>>$LOG
222 if [ "$?" = "0" ]; then
223 echo "ERROR: delshare did not delete 'share1'" | tee -a $LOG
224 return 1
228 test_conf_delshare_empty()
230 echo '\nAttempting to delete non_existing share'
231 $NETCMD conf delshare share1
232 log_print $NETCMD conf delshare share1
233 test "x$?" = "x255" || {
234 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
235 return 1
240 test_conf_delshare_usage()
242 echo '\nChecking usage' >>$LOG
243 $NETCMD conf delshare > $DIR/delshare_usage_exp
244 log_print $NETCMD conf delshare
245 test "x$?" = "x255" || {
246 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
247 return 1
250 grep "$RPC *conf delshare" $DIR/delshare_usage_exp >/dev/null 2>>$LOG
251 if [ "$?" = "1" ]; then
252 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
253 return 1
257 test_conf_drop()
260 echo '\nTesting conf drop' >> $LOG
261 echo ------------------------- >> $LOG
262 echo '\nDropping existing configuration' >> $LOG
264 $NETCMD conf drop
265 log_print $NETCMD conf drop
266 test "x$?" = "x0" || {
267 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
268 return 1
271 #check to see if listing the configuration yields a blank file
272 $NETCMD conf list 1>>$DIR/list_out
273 log_print $NETCMD conf list
274 test "x$?" = "x0" || {
275 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
276 return 1
279 test -z "`cat $DIR/list_out`" || {
280 echo "ERROR: Expected list output did not match" | tee -a $LOG
281 return 1
285 test_conf_drop_empty()
287 #Drop an empty config, see if conf drop fails
288 echo '\nAttempting to drop an empty configuration' >>$LOG
290 $NETCMD conf drop
291 log_print $NETCMD conf drop
292 test "x$?" = "x0" || {
293 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
294 return 1
297 #check to see if listing the configuration yields a blank file
298 $NETCMD conf list 1>>$DIR/list_out
299 log_print $NETCMD conf list
300 test "x$?" = "x0" || {
301 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
302 return 1
305 test -z "`cat $DIR/list_out`" || {
306 echo ERROR:Expected list output did not match >> $LOG
307 return 1
311 test_conf_drop_usage()
313 #check to see if command prints usage
314 echo '\nChecking usage' >>$LOG
315 $NETCMD conf drop extra_arg > $DIR/drop_usage_exp
316 log_print $NETCMD conf drop extra_arg
317 test "x$?" = "x255" || {
318 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
319 return 1
322 grep "$RPC *conf drop" $DIR/drop_usage_exp >/dev/null 2>>$LOG
323 if [ "$?" = "1" ]; then
324 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
325 return 1
329 test_conf_setparm()
331 echo '\nTesting conf setparm' >> $LOG
332 echo ------------------------- >> $LOG
334 echo '\nDropping existing configuration' >> $LOG
335 $NETCMD conf drop
336 log_print $NETCMD conf drop
337 test "x$?" = "x0" || {
338 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
339 return 1
342 $NETCMD conf setparm share1 "read only" yes
343 log_print $NETCMD conf setparm share1 "read only" yes
344 test "x$?" = "x0" || {
345 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
346 return 1
349 $NETCMD conf setparm share1 "path" /tmp/test_path
350 log_print $NETCMD conf setparm share1 "path" /tmp/test_path
351 test "x$?" = "x0" || {
352 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
353 return 1
356 $NETCMD conf showshare share1 > $DIR/setparm_showshare_out
357 test "x$?" = "x0" || {
358 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
359 return 1
362 grep "read only *= *yes" $DIR/setparm_showshare_out >/dev/null 2>>$LOG
363 if [ "$?" = "1" ]; then
364 echo "ERROR: setparm did not set correctly" | tee -a $LOG
365 return 1
368 grep "path *= */tmp/test_path" $DIR/setparm_showshare_out >/dev/null 2>>$LOG
369 if [ "$?" = "1" ]; then
370 echo "ERROR: setparm did not set correctly" | tee -a $LOG
371 return 1
375 test_conf_setparm_existing()
378 echo '\nSetting already existing param with the same value'
379 $NETCMD conf setparm share1 "read only" yes
380 log_print $NETCMD conf setparm share1 "read only" yes
381 test "x$?" = "x0" || {
382 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
383 return 1
386 $NETCMD conf setparm share1 "read only" yes
387 log_print $NETCMD conf setparm share1 "read only" yes
388 test "x$?" = "x0" || {
389 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
390 return 1
393 $NETCMD conf showshare share1 > $DIR/setparm_existing_showshare_out
394 test "x$?" = "x0" || {
395 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
396 return 1
399 grep "read only *= *yes" $DIR/setparm_existing_showshare_out >/dev/null 2>>$LOG
400 if [ "$?" = "1" ]; then
401 echo "ERROR: setparm did not set correctly" | tee -a $LOG
402 return 1
405 $NETCMD conf setparm share1 "read only" no
406 log_print $NETCMD conf setparm share1 "read only" no
407 test "x$?" = "x0" || {
408 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
409 return 1
412 $NETCMD conf showshare share1 > $DIR/setparm_existing_showshare_out
413 test "x$?" = "x0" || {
414 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
415 return 1
418 grep "read only *= *no" $DIR/setparm_existing_showshare_out >/dev/null 2>>$LOG
419 if [ "$?" = "1" ]; then
420 echo "ERROR: setparm did not set correctly" | tee -a $LOG
421 return 1
425 test_conf_setparm_forbidden()
427 FORBIDDEN_PARAMS="state directory
428 lock directory
429 lock dir
430 config backend
431 include"
433 echo '\nTrying to set forbidden parameters' >> $LOG
435 echo '\nDropping existing configuration' >> $LOG
436 $NETCMD conf drop
437 log_print $NETCMD conf drop
438 test "x$?" = "x0" || {
439 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
440 return 1
443 OLD_IFS="$IFS"
444 IFS='
446 for PARAM in $FORBIDDEN_PARAMS ; do
447 IFS="$OLD_IFS"
448 echo "Trying to set parameter '$PARAM'" | tee -a $LOG
449 $NETCMD conf setparm global "$PARAM" "value" > $DIR/setparm_forbidden_out 2>&1
450 log_print $NETCMD conf setparm global \""$PARAM"\" "value"
451 test "x$?" = "x0" && {
452 echo "ERROR: setting forbidden parameter '$PARAM' succeeded" | tee -a $LOG
453 return 1
456 echo "output of net command: " | tee -a $LOG
457 cat $DIR/setparm_forbidden_out | tee -a $LOG
459 SEARCH="Parameter '$PARAM' not allowed in registry."
460 grep "$SEARCH" $DIR/setparm_forbidden_out >/dev/null 2>>$LOG
461 test "x$?" = "x0" || {
462 echo "ERROR: expected '$SEARCH'" | tee -a $LOG
463 return 1
465 done
467 IFS="$OLD_IFS"
468 return 0
471 test_conf_setparm_usage()
473 echo '\nChecking usage' >>$LOG
474 $NETCMD conf setparm > $DIR/setparm_usage_exp
475 log_print $NETCMD conf setparm
476 test "x$?" = "x255" || {
477 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
478 return 1
481 grep "$RPC *conf setparm" $DIR/setparm_usage_exp >/dev/null 2>>$LOG
482 if [ "$?" = "1" ]; then
483 echo "ERROR: setparm no/wrong usage message printed" | tee -a $LOG
484 return 1
488 test_conf_delparm_delete_existing()
490 echo '\nTesting conf delparm' >> $LOG
491 echo ------------------------- >> $LOG
492 echo -n '\n' >>$LOG
494 $NETCMD conf drop
495 log_print $NETCMD conf drop
496 test "x$?" = "x0" || {
497 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
498 return 1
501 $NETCMD conf addshare share1 /tmp "writeable=y" "guest_ok=n" \
502 "test comment"
503 log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
504 "test comment"
506 $NETCMD conf delparm share1 "path"
507 log_print $NETCMD conf delparm share1 "path"
508 test "x$?" = "x0" || {
509 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
510 return 1
513 $NETCMD conf showshare share1 > $DIR/delparm_showshare_out
514 test "x$?" = "x0" || {
515 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
516 return 1
519 #test to see what delparm did delete and how
520 grep "read only *= *no" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
521 if [ "$?" = "1" ]; then
522 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
523 return 1
526 grep "path *= */tmp" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
527 if [ "$?" = "0" ]; then
528 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
529 return 1
533 test_conf_delparm_delete_non_existing()
535 echo '\nDelete non existing share' >> $LOG
537 $NETCMD conf drop
538 log_print $NETCMD conf drop
539 test "x$?" = "x0" || {
540 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
541 return 1
544 $NETCMD conf delparm share1 "path"
545 log_print $NETCMD conf delparm share1 "path"
546 test "x$?" = "x255" || {
547 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
548 return 1
552 test_conf_delparm_usage()
555 echo '\nChecking usage' >>$LOG
556 $NETCMD conf delparm > $DIR/delparm_usage_exp
557 log_print $NETCMD conf delparm
558 test "x$?" = "x255" || {
559 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
560 return 1
563 grep "$RPC *conf delparm" $DIR/delparm_usage_exp >/dev/null 2>>$LOG
564 if [ "$?" = "1" ]; then
565 echo "ERROR: delparm no/wrong usage message printed" | tee -a $LOG
566 return 1
571 test_conf_getparm()
574 echo '\nTesting conf getparm' >> $LOG
575 echo ------------------------- >> $LOG
576 echo -n '\n' >>$LOG
578 $NETCMD conf drop
579 log_print $NETCMD conf drop
580 test "x$?" = "x0" || {
581 return 1
584 $NETCMD conf addshare share1 /tmp/path_test "writeable=n" "guest_ok=n" \
585 "test comment"
586 log_print $NETCMD conf addshare share$i /tmp/path_test "writeable=n" "guest_ok=n" \
587 "test comment"
588 test "x$?" = "x0" || {
589 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
590 return 1
593 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
594 log_print $NETCMD conf getparm share1 "read only"
595 test "x$?" = "x0" || {
596 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
597 return 1
600 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
601 log_print $NETCMD conf getparm share1 "read only"
602 test "x$?" = "x0" || {
603 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
604 return 1
607 echo yes >$DIR/getparm_exp
608 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
609 if [ "$?" = "1" ]; then
610 echo "ERROR: getparm did not print correctly" | tee -a $LOG
611 return 1
614 $NETCMD conf getparm share1 "path" >$DIR/getparm_out
615 log_print $NETCMD conf getparm share1 "path"
616 test "x$?" = "x0" || {
617 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
618 return 1
621 echo /tmp/path_test >$DIR/getparm_exp
622 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
623 if [ "$?" = "1" ]; then
624 echo "ERROR: getparm did not print correctly" | tee -a $LOG
625 return 1
629 test_conf_getparm_usage()
631 echo '\nChecking usage' >>$LOG
632 $NETCMD conf getparm > $DIR/getparm_usage_exp
633 log_print $NETCMD conf getparm
634 test "x$?" = "x255" || {
635 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
636 return 1
639 grep "$RPC *conf getparm" $DIR/getparm_usage_exp >/dev/null 2>>$LOG
640 if [ "$?" = "1" ]; then
641 echo "ERROR: getparm no/wrong usage message printed" | tee -a $LOG
642 return 1
647 test_conf_getparm_non_existing()
649 echo '\nTesting getparm non existing' >>$LOG
650 $NETCMD conf getparm fictional_share fictional_param
651 log_print $NETCMD conf getparm fictional_share fictional_param
652 test "x$?" = "x255" || {
653 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
654 return 1
657 $NETCMD conf getparm share1 fictional_param
658 log_print $NETCMD conf getparm share1 fictional_param
659 test "x$?" = "x255" || {
660 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
661 return 1
665 test_conf_setincludes()
667 echo '\nTesting conf setincludes' >> $LOG
668 echo ------------------------- >> $LOG
669 echo '\nDropping existing configuration' >> $LOG
671 $NETCMD conf drop
672 log_print $NETCMD conf drop
673 test "x$?" = "x0" || {
674 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
675 return 1
678 $NETCMD conf addshare tmp_share /tmp
679 log_print $NETCMD conf addshare tmp_share /tmp
680 test "x$?" = "x0" || {
681 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
682 return 1
685 $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
686 log_print $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
687 test "x$?" = "x0" || {
688 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
689 return 1
692 $NETCMD conf list > $DIR/setincludes_list_out
693 log_print $NETCMD conf list
694 test "x$?" = "x0" || {
695 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
696 return 1
699 grep "include *= */tmp/include1$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
700 if [ "$?" = "1" ]; then
701 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
702 return 1
705 grep "include *= */tmp/include2$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
706 if [ "$?" = "1" ]; then
707 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
708 return 1
711 grep "include *= */tmp/include3$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
712 if [ "$?" = "1" ]; then
713 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
714 return 1
719 test_conf_setincludes_usage()
721 echo '\nChecking usage' >>$LOG
722 $NETCMD conf setincludes > $DIR/setincludes_usage_exp
723 log_print $NETCMD conf setincludes
724 test "x$?" = "x255" || {
725 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
726 return 1
729 grep "$RPC *conf setincludes" $DIR/setincludes_usage_exp >/dev/null 2>>$LOG
730 if [ "$?" = "1" ]; then
731 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
732 return 1
736 test_conf_getincludes()
738 $NETCMD conf getincludes tmp_share > $DIR/getincludes_out
739 log_print $NETCMD conf getincludes tmp_share
740 test "x$?" = "x0" || {
741 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
742 return 1
745 grep "include *= */tmp/include1$" $DIR/getincludes_out >/dev/null 2>>$LOG
746 if [ "$?" = "1" ]; then
747 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
748 return 1
751 grep "include *= */tmp/include2$" $DIR/getincludes_out >/dev/null 2>>$LOG
752 if [ "$?" = "1" ]; then
753 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
754 return 1
756 grep "include *= */tmp/include3$" $DIR/getincludes_out >/dev/null 2>>$LOG
757 if [ "$?" = "1" ]; then
758 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
759 return 1
763 test_conf_getincludes_usage()
765 $NETCMD conf getincludes > $DIR/getincludes_usage_exp
766 log_print $NETCMD conf getincludes
768 grep "$RPC *conf getincludes" $DIR/getincludes_usage_exp >/dev/null 2>>$LOG
769 if [ "$?" = "1" ]; then
770 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
771 return 1
775 test_conf_delincludes()
777 echo '\nTesting conf delincludes' >> $LOG
778 echo ------------------------- >> $LOG
780 $NETCMD conf delincludes tmp_share
781 log_print $NETCMD conf delincludes tmp_share
782 test "x$?" = "x0" || {
783 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
784 return 1
787 $NETCMD conf list > $DIR/delincludes_list_out
788 log_print $NETCMD conf list
789 test "x$?" = "x0" || {
790 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
791 return 1
794 grep "include" $DIR/delincludes_list_out >/dev/null 2>>$LOG
795 if [ "$?" = "0" ]; then
796 echo "ERROR: delincludes did not delete correctly" | tee -a $LOG
797 return 1
801 test_conf_delincludes_empty()
803 $NETCMD conf delincludes tmp_share
804 log_print $NETCMD conf delincludes tmp_share
805 test "x$?" = "x0" || {
806 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
807 return 1
810 $NETCMD conf delincludes fictional_share
811 log_print $NETCMD conf delincludes fictional_share
812 test "x$?" = "x255" || {
813 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
814 return 1
816 return 0
819 test_conf_delincludes_usage()
821 echo '\nChecking usage' >>$LOG
822 $NETCMD conf delincludes > $DIR/delincludes_usage_exp
823 log_print $NETCMD conf delincludes
824 test "x$?" = "x255" || {
825 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
826 return 1
829 grep "$RPC *conf delincludes" $DIR/delincludes_usage_exp >/dev/null 2>>$LOG
830 if [ "$?" = "1" ]; then
831 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
832 return 1
836 test_conf_import()
838 echo '\nTesting conf import' >> $LOG
839 echo ------------------------- >> $LOG
840 echo '\nDropping existing configuration' >> $LOG
842 $NETCMD conf drop
843 log_print $NETCMD conf drop
844 test "x$?" = "x0" || {
845 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
846 return 1
849 $NETCMD conf import $DIR/conf_import_in
850 log_print $NETCMD conf drop
851 test "x$?" = "x0" || {
852 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
853 return 1
856 $NETCMD conf list > $DIR/conf_import_out
857 log_print $NETCMD conf list
858 test "x$?" = "x0" || {
859 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
860 return 1
863 diff -q $DIR/conf_import_in $DIR/conf_import_out >> $LOG
864 if [ "$?" = "1" ]; then
865 echo "ERROR: import failed" | tee -a $LOG
866 return 1
870 test_conf_import_usage()
872 echo '\nChecking usage' >>$LOG
873 $NETCMD conf import > $DIR/import_usage_exp
874 log_print $NETCMD conf import
875 test "x$?" = "x255" || {
876 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
877 return 1
880 grep "$RPC *conf import" $DIR/import_usage_exp >/dev/null 2>>$LOG
881 if [ "$?" = "1" ]; then
882 echo "ERROR: conf import no/wrong usage message printed" | tee -a $LOG
883 return 1
887 CONF_FILES=$SERVERCONFFILE
889 testit "conf_drop" \
890 test_conf_drop \
891 || failed=`expr $failed + 1`
893 testit "conf_drop_empty" \
894 test_conf_drop_empty \
895 || failed=`expr $failed + 1`
897 testit "conf_drop_usage" \
898 test_conf_drop_usage \
899 || failed=`expr $failed + 1`
901 testit "conf_addshare" \
902 test_conf_addshare \
903 || failed=`expr $failed + 1`
905 testit "conf_addshare_existing" \
906 test_conf_addshare_existing \
907 || failed=`expr $failed + 1`
909 testit "conf_addshare_usage" \
910 test_conf_addshare_usage \
911 || failed=`expr $failed + 1`
913 testit "conf_delshare" \
914 test_conf_delshare \
915 || failed=`expr $failed + 1`
917 testit "conf_delshare_empty" \
918 test_conf_delshare_empty \
919 || failed=`expr $failed + 1`
921 testit "conf_delshare_usage" \
922 test_conf_delshare_usage \
923 || failed=`expr $failed + 1`
925 testit "conf_setparm" \
926 test_conf_setparm \
927 || failed=`expr $failed + 1`
929 testit "conf_setparm_existing" \
930 test_conf_setparm_existing \
931 || failed=`expr $failed + 1`
933 testit "conf_setparm_forbidden" \
934 test_conf_setparm_forbidden \
935 || failed=`expr $failed + 1`
937 testit "conf_setparm_usage" \
938 test_conf_setparm_usage \
939 || failed=`expr $failed + 1`
941 testit "conf_delparm_delete_existing" \
942 test_conf_delparm_delete_existing \
943 || failed=`expr $failed + 1`
945 testit "conf_delparm_delete_non_existing" \
946 test_conf_delparm_delete_non_existing \
947 || failed=`expr $failed + 1`
949 testit "conf_delparm_delete_usage" \
950 test_conf_delparm_usage \
951 || failed=`expr $failed + 1`
953 testit "conf_getparm" \
954 test_conf_getparm \
955 || failed=`expr $failed + 1`
957 testit "conf_getparm_usage" \
958 test_conf_getparm_usage \
959 || failed=`expr $failed + 1`
961 testit "conf_setincludes" \
962 test_conf_setincludes \
963 || failed=`expr $failed + 1`
965 testit "conf_setincludes_usage" \
966 test_conf_setincludes_usage \
967 || failed=`expr $failed + 1`
969 testit "conf_getincludes" \
970 test_conf_getincludes \
971 || failed=`expr $failed + 1`
973 testit "conf_getincludes_usage" \
974 test_conf_getincludes_usage \
975 || failed=`expr $failed + 1`
977 testit "conf_delincludes" \
978 test_conf_delincludes \
979 || failed=`expr $failed + 1`
981 testit "conf_delincludes_empty" \
982 test_conf_delincludes_usage \
983 || failed=`expr $failed + 1`
985 testit "conf_delincludes_usage" \
986 test_conf_delincludes_empty \
987 || failed=`expr $failed + 1`
989 testit "conf_import" \
990 test_conf_import \
991 || failed=`expr $failed + 1`
993 testit "conf_import_usage" \
994 test_conf_import_usage \
995 || failed=`expr $failed + 1`
997 if [ $failed -eq 0 ]; then
998 rm -r $DIR
1001 testok $0 $failed