selftest: remove unused variables (copy'n'paste...) from test_net_conf.sh
[Samba.git] / source3 / script / tests / test_net_conf.sh
blob1a773fa61fd13d12ec1e51a34a91683c350b05e2
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_usage()
427 echo '\nChecking usage' >>$LOG
428 $NETCMD conf setparm > $DIR/setparm_usage_exp
429 log_print $NETCMD conf setparm
430 test "x$?" = "x255" || {
431 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
432 return 1
435 grep "$RPC *conf setparm" $DIR/setparm_usage_exp >/dev/null 2>>$LOG
436 if [ "$?" = "1" ]; then
437 echo "ERROR: setparm no/wrong usage message printed" | tee -a $LOG
438 return 1
442 test_conf_delparm_delete_existing()
444 echo '\nTesting conf delparm' >> $LOG
445 echo ------------------------- >> $LOG
446 echo -n '\n' >>$LOG
448 $NETCMD conf drop
449 log_print $NETCMD conf drop
450 test "x$?" = "x0" || {
451 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
452 return 1
455 $NETCMD conf addshare share1 /tmp "writeable=y" "guest_ok=n" \
456 "test comment"
457 log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
458 "test comment"
460 $NETCMD conf delparm share1 "path"
461 log_print $NETCMD conf delparm share1 "path"
462 test "x$?" = "x0" || {
463 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
464 return 1
467 $NETCMD conf showshare share1 > $DIR/delparm_showshare_out
468 test "x$?" = "x0" || {
469 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
470 return 1
473 #test to see what delparm did delete and how
474 grep "read only *= *no" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
475 if [ "$?" = "1" ]; then
476 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
477 return 1
480 grep "path *= */tmp" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
481 if [ "$?" = "0" ]; then
482 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
483 return 1
487 test_conf_delparm_delete_non_existing()
489 echo '\nDelete non existing share' >> $LOG
491 $NETCMD conf drop
492 log_print $NETCMD conf drop
493 test "x$?" = "x0" || {
494 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
495 return 1
498 $NETCMD conf delparm share1 "path"
499 log_print $NETCMD conf delparm share1 "path"
500 test "x$?" = "x255" || {
501 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
502 return 1
506 test_conf_delparm_usage()
509 echo '\nChecking usage' >>$LOG
510 $NETCMD conf delparm > $DIR/delparm_usage_exp
511 log_print $NETCMD conf delparm
512 test "x$?" = "x255" || {
513 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
514 return 1
517 grep "$RPC *conf delparm" $DIR/delparm_usage_exp >/dev/null 2>>$LOG
518 if [ "$?" = "1" ]; then
519 echo "ERROR: delparm no/wrong usage message printed" | tee -a $LOG
520 return 1
525 test_conf_getparm()
528 echo '\nTesting conf getparm' >> $LOG
529 echo ------------------------- >> $LOG
530 echo -n '\n' >>$LOG
532 $NETCMD conf drop
533 log_print $NETCMD conf drop
534 test "x$?" = "x0" || {
535 return 1
538 $NETCMD conf addshare share1 /tmp/path_test "writeable=n" "guest_ok=n" \
539 "test comment"
540 log_print $NETCMD conf addshare share$i /tmp/path_test "writeable=n" "guest_ok=n" \
541 "test comment"
542 test "x$?" = "x0" || {
543 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
544 return 1
547 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
548 log_print $NETCMD conf getparm share1 "read only"
549 test "x$?" = "x0" || {
550 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
551 return 1
554 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
555 log_print $NETCMD conf getparm share1 "read only"
556 test "x$?" = "x0" || {
557 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
558 return 1
561 echo yes >$DIR/getparm_exp
562 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
563 if [ "$?" = "1" ]; then
564 echo "ERROR: getparm did not print correctly" | tee -a $LOG
565 return 1
568 $NETCMD conf getparm share1 "path" >$DIR/getparm_out
569 log_print $NETCMD conf getparm share1 "path"
570 test "x$?" = "x0" || {
571 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
572 return 1
575 echo /tmp/path_test >$DIR/getparm_exp
576 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
577 if [ "$?" = "1" ]; then
578 echo "ERROR: getparm did not print correctly" | tee -a $LOG
579 return 1
583 test_conf_getparm_usage()
585 echo '\nChecking usage' >>$LOG
586 $NETCMD conf getparm > $DIR/getparm_usage_exp
587 log_print $NETCMD conf getparm
588 test "x$?" = "x255" || {
589 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
590 return 1
593 grep "$RPC *conf getparm" $DIR/getparm_usage_exp >/dev/null 2>>$LOG
594 if [ "$?" = "1" ]; then
595 echo "ERROR: getparm no/wrong usage message printed" | tee -a $LOG
596 return 1
601 test_conf_getparm_non_existing()
603 echo '\nTesting getparm non existing' >>$LOG
604 $NETCMD conf getparm fictional_share fictional_param
605 log_print $NETCMD conf getparm fictional_share fictional_param
606 test "x$?" = "x255" || {
607 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
608 return 1
611 $NETCMD conf getparm share1 fictional_param
612 log_print $NETCMD conf getparm share1 fictional_param
613 test "x$?" = "x255" || {
614 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
615 return 1
619 test_conf_setincludes()
621 echo '\nTesting conf setincludes' >> $LOG
622 echo ------------------------- >> $LOG
623 echo '\nDropping existing configuration' >> $LOG
625 $NETCMD conf drop
626 log_print $NETCMD conf drop
627 test "x$?" = "x0" || {
628 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
629 return 1
632 $NETCMD conf addshare tmp_share /tmp
633 log_print $NETCMD conf addshare tmp_share /tmp
634 test "x$?" = "x0" || {
635 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
636 return 1
639 $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
640 log_print $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
641 test "x$?" = "x0" || {
642 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
643 return 1
646 $NETCMD conf list > $DIR/setincludes_list_out
647 log_print $NETCMD conf list
648 test "x$?" = "x0" || {
649 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
650 return 1
653 grep "include *= */tmp/include1$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
654 if [ "$?" = "1" ]; then
655 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
656 return 1
659 grep "include *= */tmp/include2$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
660 if [ "$?" = "1" ]; then
661 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
662 return 1
665 grep "include *= */tmp/include3$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
666 if [ "$?" = "1" ]; then
667 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
668 return 1
673 test_conf_setincludes_usage()
675 echo '\nChecking usage' >>$LOG
676 $NETCMD conf setincludes > $DIR/setincludes_usage_exp
677 log_print $NETCMD conf setincludes
678 test "x$?" = "x255" || {
679 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
680 return 1
683 grep "$RPC *conf setincludes" $DIR/setincludes_usage_exp >/dev/null 2>>$LOG
684 if [ "$?" = "1" ]; then
685 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
686 return 1
690 test_conf_getincludes()
692 $NETCMD conf getincludes tmp_share > $DIR/getincludes_out
693 log_print $NETCMD conf getincludes tmp_share
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/getincludes_out >/dev/null 2>>$LOG
700 if [ "$?" = "1" ]; then
701 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
702 return 1
705 grep "include *= */tmp/include2$" $DIR/getincludes_out >/dev/null 2>>$LOG
706 if [ "$?" = "1" ]; then
707 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
708 return 1
710 grep "include *= */tmp/include3$" $DIR/getincludes_out >/dev/null 2>>$LOG
711 if [ "$?" = "1" ]; then
712 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
713 return 1
717 test_conf_getincludes_usage()
719 $NETCMD conf getincludes > $DIR/getincludes_usage_exp
720 log_print $NETCMD conf getincludes
722 grep "$RPC *conf getincludes" $DIR/getincludes_usage_exp >/dev/null 2>>$LOG
723 if [ "$?" = "1" ]; then
724 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
725 return 1
729 test_conf_delincludes()
731 echo '\nTesting conf delincludes' >> $LOG
732 echo ------------------------- >> $LOG
734 $NETCMD conf delincludes tmp_share
735 log_print $NETCMD conf delincludes tmp_share
736 test "x$?" = "x0" || {
737 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
738 return 1
741 $NETCMD conf list > $DIR/delincludes_list_out
742 log_print $NETCMD conf list
743 test "x$?" = "x0" || {
744 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
745 return 1
748 grep "include" $DIR/delincludes_list_out >/dev/null 2>>$LOG
749 if [ "$?" = "0" ]; then
750 echo "ERROR: delincludes did not delete correctly" | tee -a $LOG
751 return 1
755 test_conf_delincludes_empty()
757 $NETCMD conf delincludes tmp_share
758 log_print $NETCMD conf delincludes tmp_share
759 test "x$?" = "x0" || {
760 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
761 return 1
764 $NETCMD conf delincludes fictional_share
765 log_print $NETCMD conf delincludes fictional_share
766 test "x$?" = "x255" || {
767 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
768 return 1
770 return 0
773 test_conf_delincludes_usage()
775 echo '\nChecking usage' >>$LOG
776 $NETCMD conf delincludes > $DIR/delincludes_usage_exp
777 log_print $NETCMD conf delincludes
778 test "x$?" = "x255" || {
779 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
780 return 1
783 grep "$RPC *conf delincludes" $DIR/delincludes_usage_exp >/dev/null 2>>$LOG
784 if [ "$?" = "1" ]; then
785 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
786 return 1
790 test_conf_import()
792 echo '\nTesting conf import' >> $LOG
793 echo ------------------------- >> $LOG
794 echo '\nDropping existing configuration' >> $LOG
796 $NETCMD conf drop
797 log_print $NETCMD conf drop
798 test "x$?" = "x0" || {
799 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
800 return 1
803 $NETCMD conf import $DIR/conf_import_in
804 log_print $NETCMD conf drop
805 test "x$?" = "x0" || {
806 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
807 return 1
810 $NETCMD conf list > $DIR/conf_import_out
811 log_print $NETCMD conf list
812 test "x$?" = "x0" || {
813 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
814 return 1
817 diff -q $DIR/conf_import_in $DIR/conf_import_out >> $LOG
818 if [ "$?" = "1" ]; then
819 echo "ERROR: import failed" | tee -a $LOG
820 return 1
824 test_conf_import_usage()
826 echo '\nChecking usage' >>$LOG
827 $NETCMD conf import > $DIR/import_usage_exp
828 log_print $NETCMD conf import
829 test "x$?" = "x255" || {
830 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
831 return 1
834 grep "$RPC *conf import" $DIR/import_usage_exp >/dev/null 2>>$LOG
835 if [ "$?" = "1" ]; then
836 echo "ERROR: conf import no/wrong usage message printed" | tee -a $LOG
837 return 1
841 CONF_FILES=$SERVERCONFFILE
843 testit "conf_drop" \
844 test_conf_drop \
845 || failed=`expr $failed + 1`
847 testit "conf_drop_empty" \
848 test_conf_drop_empty \
849 || failed=`expr $failed + 1`
851 testit "conf_drop_usage" \
852 test_conf_drop_usage \
853 || failed=`expr $failed + 1`
855 testit "conf_addshare" \
856 test_conf_addshare \
857 || failed=`expr $failed + 1`
859 testit "conf_addshare_existing" \
860 test_conf_addshare_existing \
861 || failed=`expr $failed + 1`
863 testit "conf_addshare_usage" \
864 test_conf_addshare_usage \
865 || failed=`expr $failed + 1`
867 testit "conf_delshare" \
868 test_conf_delshare \
869 || failed=`expr $failed + 1`
871 testit "conf_delshare_empty" \
872 test_conf_delshare_empty \
873 || failed=`expr $failed + 1`
875 testit "conf_delshare_usage" \
876 test_conf_delshare_usage \
877 || failed=`expr $failed + 1`
879 testit "conf_setparm" \
880 test_conf_setparm \
881 || failed=`expr $failed + 1`
883 testit "conf_setparm_existing" \
884 test_conf_setparm_existing \
885 || failed=`expr $failed + 1`
887 testit "conf_setparm_usage" \
888 test_conf_setparm_usage \
889 || failed=`expr $failed + 1`
891 testit "conf_delparm_delete_existing" \
892 test_conf_delparm_delete_existing \
893 || failed=`expr $failed + 1`
895 testit "conf_delparm_delete_non_existing" \
896 test_conf_delparm_delete_non_existing \
897 || failed=`expr $failed + 1`
899 testit "conf_delparm_delete_usage" \
900 test_conf_delparm_usage \
901 || failed=`expr $failed + 1`
903 testit "conf_getparm" \
904 test_conf_getparm \
905 || failed=`expr $failed + 1`
907 testit "conf_getparm_usage" \
908 test_conf_getparm_usage \
909 || failed=`expr $failed + 1`
911 testit "conf_setincludes" \
912 test_conf_setincludes \
913 || failed=`expr $failed + 1`
915 testit "conf_setincludes_usage" \
916 test_conf_setincludes_usage \
917 || failed=`expr $failed + 1`
919 testit "conf_getincludes" \
920 test_conf_getincludes \
921 || failed=`expr $failed + 1`
923 testit "conf_getincludes_usage" \
924 test_conf_getincludes_usage \
925 || failed=`expr $failed + 1`
927 testit "conf_delincludes" \
928 test_conf_delincludes \
929 || failed=`expr $failed + 1`
931 testit "conf_delincludes_empty" \
932 test_conf_delincludes_usage \
933 || failed=`expr $failed + 1`
935 testit "conf_delincludes_usage" \
936 test_conf_delincludes_empty \
937 || failed=`expr $failed + 1`
939 testit "conf_import" \
940 test_conf_import \
941 || failed=`expr $failed + 1`
943 testit "conf_import_usage" \
944 test_conf_import_usage \
945 || failed=`expr $failed + 1`
947 if [ $failed -eq 0 ]; then
948 rm -r $DIR
951 testok $0 $failed