s3: Remove a call to procid_self()
[Samba/gebeck_regimport.git] / source3 / script / tests / test_net_conf.sh
blob6d3d2a1eecde0eb6656680f358aeb74f1ddbac21
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 SED_INVALID_PARAMS="{
46 s/lock directory/;&/g
47 s/lock dir/;&/g
48 s/modules dir/;&/g
49 s/logging/;&/g
50 s/status/;&/g
51 s/logdir/;&/g
52 s/read prediction/;&/g
53 s/mkprofile/;&/g
54 s/valid chars/;&/g
55 s/timesync/;&/g
56 s/sambaconf/;&/g
57 s/logtype/;&/g
58 s/servername/;&/g
59 s/postscript/;&/g
62 REGPATH="HKLM\Software\Samba"
64 log_print() {
65 RC=$?
66 echo "CMD: $*" >>$LOG
67 echo "RC: $RC" >> $LOG
68 return $RC
69 # echo -n .
72 test_conf_addshare()
74 echo '\nTesting conf addshare' >> $LOG
75 echo ------------------------- >> $LOG
76 echo '\nDropping existing configuration' >> $LOG
78 $NETCMD conf drop
79 log_print $NETCMD conf drop
80 test "x$?" = "x0" || {
81 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
82 return 1
85 #create a lot of shares
86 for i in $(seq 1 100); do
87 if [ $(($i % 2)) -eq 0 ]; then
88 $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
89 "test comment" >>$DIR/addshare_exp \
90 2>>$DIR/addshare_exp
91 log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
92 "test comment"
93 else
94 $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \
95 "test comment" >>$DIR/addshare_exp \
96 2>>$DIR/addshare_exp
97 log_print $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \
98 "test comment"
100 test "x$?" = "x0" || {
101 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
102 return 1
104 done
106 $NETCMD conf listshares > $DIR/listshares_out
107 log_print $NETCMD conf listshares
108 test "x$?" = "x0" || {
109 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
110 return 1
113 for i in $(seq 1 100); do
114 grep "share$i" $DIR/listshares_out >/dev/null 2>>$LOG
115 if [ "$?" = "1" ]; then
116 echo "ERROR: share not found" | tee -a $LOG
117 return 1
119 done
121 #check the integrity of the shares
122 #if it fails, it can also point to an error in showshare
123 for i in $(seq 1 100); do
124 $NETCMD conf showshare share$i > $DIR/showshare_out
125 test "x$?" = "x0" || {
126 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
127 return 1
130 grep "path" $DIR/showshare_out >/dev/null 2>>$LOG
131 if [ "$?" = "1" ]; then
132 echo "ERROR: share not found" | tee -a $LOG
133 return 1
136 if [ $(($i % 2)) -eq 0 ]; then
137 grep "read only *= *no" $DIR/showshare_out >/dev/null 2>>$LOG
138 if [ "$?" = "1" ]; then
139 echo "ERROR: share not set correctly" | tee -a $LOG
140 return 1
142 else
143 grep "read only *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG
144 if [ "$?" = "1" ]; then
145 echo "ERROR: share not set correctly" | tee -a $LOG
146 return 1
150 if [ $(($i % 2)) -eq 0 ]; then
151 grep "guest ok *= *no" $DIR/showshare_out >/dev/null 2>>$LOG
152 if [ "$?" = "1" ]; then
153 echo "ERROR: share not set correctly" | tee -a $LOG
154 return 1
156 else
157 grep "guest ok *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG
158 if [ "$?" = "1" ]; then
159 echo "ERROR: share not set correctly" | tee -a $LOG
160 return 1
164 grep "comment *= *test comment" $DIR/showshare_out >/dev/null 2>>$LOG
165 if [ "$?" = "1" ]; then
166 echo "ERROR: share not set correctly" | tee -a $LOG
167 return 1
169 done
171 echo '\nTaking a conf snapshot for later use' >> $LOG
172 $NETCMD conf list > $DIR/conf_import_in
173 log_print $NETCMD conf list
174 test "x$?" = "x0" || {
175 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
176 return 1
180 test_conf_addshare_existing()
182 #try adding an already existing share
183 echo '\nAdding an already existing share' >>$LOG
184 $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \
185 "test comment" >>$DIR/addshare_exp \
186 2>>$DIR/addshare_exp
187 log_print $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \
188 "test comment"
189 test "x$?" = "x255" || {
190 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
191 return 1
194 test -z `cat $DIR/addshare_exp` && {
195 echo "ERROR: addshare output does not match" >> $LOG
196 return 1
199 return 0
202 test_conf_addshare_usage()
204 #check to see if command prints usage
205 echo '\nChecking usage' >>$LOG
206 $NETCMD conf addshare > $DIR/addshare_usage_exp
207 log_print $NETCMD conf addshare
208 test "x$?" = "x255" || {
209 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
210 return 1
213 grep "$RPC *conf addshare" $DIR/addshare_usage_exp >/dev/null 2>>$LOG
214 if [ "$?" = "1" ]; then
215 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
216 return 1
220 test_conf_delshare()
222 echo '\nTesting conf delshare' >>$LOG
223 echo ------------------------- >> $LOG
224 echo -n '\n' >> $LOG
226 $NETCMD conf delshare share1
227 log_print $NETCMD conf delshare share1
228 test "x$?" = "x0" || {
229 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
230 return 1
233 $NETCMD conf listshares > $DIR/listshares_out
234 log_print $NETCMD conf listshares
235 test "x$?" = "x0" || {
236 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
237 return 1
240 grep "share1$" $DIR/listshares_out >/dev/null 2>>$LOG
241 if [ "$?" = "0" ]; then
242 echo "ERROR: delshare did not delete 'share1'" | tee -a $LOG
243 return 1
247 test_conf_delshare_empty()
249 echo '\nAttempting to delete non_existing share'
250 $NETCMD conf delshare share1
251 log_print $NETCMD conf delshare share1
252 test "x$?" = "x255" || {
253 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
254 return 1
259 test_conf_delshare_usage()
261 echo '\nChecking usage' >>$LOG
262 $NETCMD conf delshare > $DIR/delshare_usage_exp
263 log_print $NETCMD conf delshare
264 test "x$?" = "x255" || {
265 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
266 return 1
269 grep "$RPC *conf delshare" $DIR/delshare_usage_exp >/dev/null 2>>$LOG
270 if [ "$?" = "1" ]; then
271 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
272 return 1
276 test_conf_drop()
279 echo '\nTesting conf drop' >> $LOG
280 echo ------------------------- >> $LOG
281 echo '\nDropping existing configuration' >> $LOG
283 $NETCMD conf drop
284 log_print $NETCMD conf drop
285 test "x$?" = "x0" || {
286 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
287 return 1
290 #check to see if listing the configuration yields a blank file
291 $NETCMD conf list 1>>$DIR/list_out
292 log_print $NETCMD conf list
293 test "x$?" = "x0" || {
294 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
295 return 1
298 test -z "`cat $DIR/list_out`" || {
299 echo "ERROR: Expected list output did not match" | tee -a $LOG
300 return 1
304 test_conf_drop_empty()
306 #Drop an empty config, see if conf drop fails
307 echo '\nAttempting to drop an empty configuration' >>$LOG
309 $NETCMD conf drop
310 log_print $NETCMD conf drop
311 test "x$?" = "x0" || {
312 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
313 return 1
316 #check to see if listing the configuration yields a blank file
317 $NETCMD conf list 1>>$DIR/list_out
318 log_print $NETCMD conf list
319 test "x$?" = "x0" || {
320 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
321 return 1
324 test -z "`cat $DIR/list_out`" || {
325 echo ERROR:Expected list output did not match >> $LOG
326 return 1
330 test_conf_drop_usage()
332 #check to see if command prints usage
333 echo '\nChecking usage' >>$LOG
334 $NETCMD conf drop extra_arg > $DIR/drop_usage_exp
335 log_print $NETCMD conf drop extra_arg
336 test "x$?" = "x255" || {
337 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
338 return 1
341 grep "$RPC *conf drop" $DIR/drop_usage_exp >/dev/null 2>>$LOG
342 if [ "$?" = "1" ]; then
343 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
344 return 1
348 test_conf_setparm()
350 echo '\nTesting conf setparm' >> $LOG
351 echo ------------------------- >> $LOG
353 echo '\nDropping existing configuration' >> $LOG
354 $NETCMD conf drop
355 log_print $NETCMD conf drop
356 test "x$?" = "x0" || {
357 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
358 return 1
361 $NETCMD conf setparm share1 "read only" yes
362 log_print $NETCMD conf setparm share1 "read only" yes
363 test "x$?" = "x0" || {
364 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
365 return 1
368 $NETCMD conf setparm share1 "path" /tmp/test_path
369 log_print $NETCMD conf setparm share1 "path" /tmp/test_path
370 test "x$?" = "x0" || {
371 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
372 return 1
375 $NETCMD conf showshare share1 > $DIR/setparm_showshare_out
376 test "x$?" = "x0" || {
377 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
378 return 1
381 grep "read only *= *yes" $DIR/setparm_showshare_out >/dev/null 2>>$LOG
382 if [ "$?" = "1" ]; then
383 echo "ERROR: setparm did not set correctly" | tee -a $LOG
384 return 1
387 grep "path *= */tmp/test_path" $DIR/setparm_showshare_out >/dev/null 2>>$LOG
388 if [ "$?" = "1" ]; then
389 echo "ERROR: setparm did not set correctly" | tee -a $LOG
390 return 1
394 test_conf_setparm_existing()
397 echo '\nSetting already existing param with the same value'
398 $NETCMD conf setparm share1 "read only" yes
399 log_print $NETCMD conf setparm share1 "read only" yes
400 test "x$?" = "x0" || {
401 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
402 return 1
405 $NETCMD conf setparm share1 "read only" yes
406 log_print $NETCMD conf setparm share1 "read only" yes
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 *= *yes" $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
424 $NETCMD conf setparm share1 "read only" no
425 log_print $NETCMD conf setparm share1 "read only" no
426 test "x$?" = "x0" || {
427 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
428 return 1
431 $NETCMD conf showshare share1 > $DIR/setparm_existing_showshare_out
432 test "x$?" = "x0" || {
433 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
434 return 1
437 grep "read only *= *no" $DIR/setparm_existing_showshare_out >/dev/null 2>>$LOG
438 if [ "$?" = "1" ]; then
439 echo "ERROR: setparm did not set correctly" | tee -a $LOG
440 return 1
444 test_conf_setparm_usage()
446 echo '\nChecking usage' >>$LOG
447 $NETCMD conf setparm > $DIR/setparm_usage_exp
448 log_print $NETCMD conf setparm
449 test "x$?" = "x255" || {
450 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
451 return 1
454 grep "$RPC *conf setparm" $DIR/setparm_usage_exp >/dev/null 2>>$LOG
455 if [ "$?" = "1" ]; then
456 echo "ERROR: setparm no/wrong usage message printed" | tee -a $LOG
457 return 1
461 test_conf_delparm_delete_existing()
463 echo '\nTesting conf delparm' >> $LOG
464 echo ------------------------- >> $LOG
465 echo -n '\n' >>$LOG
467 $NETCMD conf drop
468 log_print $NETCMD conf drop
469 test "x$?" = "x0" || {
470 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
471 return 1
474 $NETCMD conf addshare share1 /tmp "writeable=y" "guest_ok=n" \
475 "test comment"
476 log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
477 "test comment"
479 $NETCMD conf delparm share1 "path"
480 log_print $NETCMD conf delparm share1 "path"
481 test "x$?" = "x0" || {
482 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
483 return 1
486 $NETCMD conf showshare share1 > $DIR/delparm_showshare_out
487 test "x$?" = "x0" || {
488 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
489 return 1
492 #test to see what delparm did delete and how
493 grep "read only *= *no" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
494 if [ "$?" = "1" ]; then
495 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
496 return 1
499 grep "path *= */tmp" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
500 if [ "$?" = "0" ]; then
501 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
502 return 1
506 test_conf_delparm_delete_non_existing()
508 echo '\nDelete non existing share' >> $LOG
510 $NETCMD conf drop
511 log_print $NETCMD conf drop
512 test "x$?" = "x0" || {
513 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
514 return 1
517 $NETCMD conf delparm share1 "path"
518 log_print $NETCMD conf delparm share1 "path"
519 test "x$?" = "x255" || {
520 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
521 return 1
525 test_conf_delparm_usage()
528 echo '\nChecking usage' >>$LOG
529 $NETCMD conf delparm > $DIR/delparm_usage_exp
530 log_print $NETCMD conf delparm
531 test "x$?" = "x255" || {
532 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
533 return 1
536 grep "$RPC *conf delparm" $DIR/delparm_usage_exp >/dev/null 2>>$LOG
537 if [ "$?" = "1" ]; then
538 echo "ERROR: delparm no/wrong usage message printed" | tee -a $LOG
539 return 1
544 test_conf_getparm()
547 echo '\nTesting conf getparm' >> $LOG
548 echo ------------------------- >> $LOG
549 echo -n '\n' >>$LOG
551 $NETCMD conf drop
552 log_print $NETCMD conf drop
553 test "x$?" = "x0" || {
554 return 1
557 $NETCMD conf addshare share1 /tmp/path_test "writeable=n" "guest_ok=n" \
558 "test comment"
559 log_print $NETCMD conf addshare share$i /tmp/path_test "writeable=n" "guest_ok=n" \
560 "test comment"
561 test "x$?" = "x0" || {
562 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
563 return 1
566 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
567 log_print $NETCMD conf getparm share1 "read only"
568 test "x$?" = "x0" || {
569 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
570 return 1
573 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
574 log_print $NETCMD conf getparm share1 "read only"
575 test "x$?" = "x0" || {
576 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
577 return 1
580 echo yes >$DIR/getparm_exp
581 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
582 if [ "$?" = "1" ]; then
583 echo "ERROR: getparm did not print correctly" | tee -a $LOG
584 return 1
587 $NETCMD conf getparm share1 "path" >$DIR/getparm_out
588 log_print $NETCMD conf getparm share1 "path"
589 test "x$?" = "x0" || {
590 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
591 return 1
594 echo /tmp/path_test >$DIR/getparm_exp
595 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
596 if [ "$?" = "1" ]; then
597 echo "ERROR: getparm did not print correctly" | tee -a $LOG
598 return 1
602 test_conf_getparm_usage()
604 echo '\nChecking usage' >>$LOG
605 $NETCMD conf getparm > $DIR/getparm_usage_exp
606 log_print $NETCMD conf getparm
607 test "x$?" = "x255" || {
608 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
609 return 1
612 grep "$RPC *conf getparm" $DIR/getparm_usage_exp >/dev/null 2>>$LOG
613 if [ "$?" = "1" ]; then
614 echo "ERROR: getparm no/wrong usage message printed" | tee -a $LOG
615 return 1
620 test_conf_getparm_non_existing()
622 echo '\nTesting getparm non existing' >>$LOG
623 $NETCMD conf getparm fictional_share fictional_param
624 log_print $NETCMD conf getparm fictional_share fictional_param
625 test "x$?" = "x255" || {
626 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
627 return 1
630 $NETCMD conf getparm share1 fictional_param
631 log_print $NETCMD conf getparm share1 fictional_param
632 test "x$?" = "x255" || {
633 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
634 return 1
638 test_conf_setincludes()
640 echo '\nTesting conf setincludes' >> $LOG
641 echo ------------------------- >> $LOG
642 echo '\nDropping existing configuration' >> $LOG
644 $NETCMD conf drop
645 log_print $NETCMD conf drop
646 test "x$?" = "x0" || {
647 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
648 return 1
651 $NETCMD conf addshare tmp_share /tmp
652 log_print $NETCMD conf addshare tmp_share /tmp
653 test "x$?" = "x0" || {
654 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
655 return 1
658 $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
659 log_print $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
660 test "x$?" = "x0" || {
661 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
662 return 1
665 $NETCMD conf list > $DIR/setincludes_list_out
666 log_print $NETCMD conf list
667 test "x$?" = "x0" || {
668 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
669 return 1
672 grep "include *= */tmp/include1$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
673 if [ "$?" = "1" ]; then
674 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
675 return 1
678 grep "include *= */tmp/include2$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
679 if [ "$?" = "1" ]; then
680 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
681 return 1
684 grep "include *= */tmp/include3$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
685 if [ "$?" = "1" ]; then
686 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
687 return 1
692 test_conf_setincludes_usage()
694 echo '\nChecking usage' >>$LOG
695 $NETCMD conf setincludes > $DIR/setincludes_usage_exp
696 log_print $NETCMD conf setincludes
697 test "x$?" = "x255" || {
698 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
699 return 1
702 grep "$RPC *conf setincludes" $DIR/setincludes_usage_exp >/dev/null 2>>$LOG
703 if [ "$?" = "1" ]; then
704 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
705 return 1
709 test_conf_getincludes()
711 $NETCMD conf getincludes tmp_share > $DIR/getincludes_out
712 log_print $NETCMD conf getincludes tmp_share
713 test "x$?" = "x0" || {
714 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
715 return 1
718 grep "include *= */tmp/include1$" $DIR/getincludes_out >/dev/null 2>>$LOG
719 if [ "$?" = "1" ]; then
720 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
721 return 1
724 grep "include *= */tmp/include2$" $DIR/getincludes_out >/dev/null 2>>$LOG
725 if [ "$?" = "1" ]; then
726 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
727 return 1
729 grep "include *= */tmp/include3$" $DIR/getincludes_out >/dev/null 2>>$LOG
730 if [ "$?" = "1" ]; then
731 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
732 return 1
736 test_conf_getincludes_usage()
738 $NETCMD conf getincludes > $DIR/getincludes_usage_exp
739 log_print $NETCMD conf getincludes
741 grep "$RPC *conf getincludes" $DIR/getincludes_usage_exp >/dev/null 2>>$LOG
742 if [ "$?" = "1" ]; then
743 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
744 return 1
748 test_conf_delincludes()
750 echo '\nTesting conf delincludes' >> $LOG
751 echo ------------------------- >> $LOG
753 $NETCMD conf delincludes tmp_share
754 log_print $NETCMD conf delincludes tmp_share
755 test "x$?" = "x0" || {
756 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
757 return 1
760 $NETCMD conf list > $DIR/delincludes_list_out
761 log_print $NETCMD conf list
762 test "x$?" = "x0" || {
763 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
764 return 1
767 grep "include" $DIR/delincludes_list_out >/dev/null 2>>$LOG
768 if [ "$?" = "0" ]; then
769 echo "ERROR: delincludes did not delete correctly" | tee -a $LOG
770 return 1
774 test_conf_delincludes_empty()
776 $NETCMD conf delincludes tmp_share
777 log_print $NETCMD conf delincludes tmp_share
778 test "x$?" = "x0" || {
779 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
780 return 1
783 $NETCMD conf delincludes fictional_share
784 log_print $NETCMD conf delincludes fictional_share
785 test "x$?" = "x255" || {
786 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
787 return 1
789 return 0
792 test_conf_delincludes_usage()
794 echo '\nChecking usage' >>$LOG
795 $NETCMD conf delincludes > $DIR/delincludes_usage_exp
796 log_print $NETCMD conf delincludes
797 test "x$?" = "x255" || {
798 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
799 return 1
802 grep "$RPC *conf delincludes" $DIR/delincludes_usage_exp >/dev/null 2>>$LOG
803 if [ "$?" = "1" ]; then
804 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
805 return 1
809 test_conf_import()
811 echo '\nTesting conf import' >> $LOG
812 echo ------------------------- >> $LOG
813 echo '\nDropping existing configuration' >> $LOG
815 $NETCMD conf drop
816 log_print $NETCMD conf drop
817 test "x$?" = "x0" || {
818 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
819 return 1
822 $NETCMD conf import $DIR/conf_import_in
823 log_print $NETCMD conf drop
824 test "x$?" = "x0" || {
825 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
826 return 1
829 $NETCMD conf list > $DIR/conf_import_out
830 log_print $NETCMD conf list
831 test "x$?" = "x0" || {
832 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
833 return 1
836 diff -q $DIR/conf_import_in $DIR/conf_import_out >> $LOG
837 if [ "$?" = "1" ]; then
838 echo "ERROR: import failed" | tee -a $LOG
839 return 1
843 test_conf_import_usage()
845 echo '\nChecking usage' >>$LOG
846 $NETCMD conf import > $DIR/import_usage_exp
847 log_print $NETCMD conf import
848 test "x$?" = "x255" || {
849 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
850 return 1
853 grep "$RPC *conf import" $DIR/import_usage_exp >/dev/null 2>>$LOG
854 if [ "$?" = "1" ]; then
855 echo "ERROR: conf import no/wrong usage message printed" | tee -a $LOG
856 return 1
860 CONF_FILES=$SERVERCONFFILE
862 testit "conf_drop" \
863 test_conf_drop \
864 || failed=`expr $failed + 1`
866 testit "conf_drop_empty" \
867 test_conf_drop_empty \
868 || failed=`expr $failed + 1`
870 testit "conf_drop_usage" \
871 test_conf_drop_usage \
872 || failed=`expr $failed + 1`
874 testit "conf_addshare" \
875 test_conf_addshare \
876 || failed=`expr $failed + 1`
878 testit "conf_addshare_existing" \
879 test_conf_addshare_existing \
880 || failed=`expr $failed + 1`
882 testit "conf_addshare_usage" \
883 test_conf_addshare_usage \
884 || failed=`expr $failed + 1`
886 testit "conf_delshare" \
887 test_conf_delshare \
888 || failed=`expr $failed + 1`
890 testit "conf_delshare_empty" \
891 test_conf_delshare_empty \
892 || failed=`expr $failed + 1`
894 testit "conf_delshare_usage" \
895 test_conf_delshare_usage \
896 || failed=`expr $failed + 1`
898 testit "conf_setparm" \
899 test_conf_setparm \
900 || failed=`expr $failed + 1`
902 testit "conf_setparm_existing" \
903 test_conf_setparm_existing \
904 || failed=`expr $failed + 1`
906 testit "conf_setparm_usage" \
907 test_conf_setparm_usage \
908 || failed=`expr $failed + 1`
910 testit "conf_delparm_delete_existing" \
911 test_conf_delparm_delete_existing \
912 || failed=`expr $failed + 1`
914 testit "conf_delparm_delete_non_existing" \
915 test_conf_delparm_delete_non_existing \
916 || failed=`expr $failed + 1`
918 testit "conf_delparm_delete_usage" \
919 test_conf_delparm_usage \
920 || failed=`expr $failed + 1`
922 testit "conf_getparm" \
923 test_conf_getparm \
924 || failed=`expr $failed + 1`
926 testit "conf_getparm_usage" \
927 test_conf_getparm_usage \
928 || failed=`expr $failed + 1`
930 testit "conf_setincludes" \
931 test_conf_setincludes \
932 || failed=`expr $failed + 1`
934 testit "conf_setincludes_usage" \
935 test_conf_setincludes_usage \
936 || failed=`expr $failed + 1`
938 testit "conf_getincludes" \
939 test_conf_getincludes \
940 || failed=`expr $failed + 1`
942 testit "conf_getincludes_usage" \
943 test_conf_getincludes_usage \
944 || failed=`expr $failed + 1`
946 testit "conf_delincludes" \
947 test_conf_delincludes \
948 || failed=`expr $failed + 1`
950 testit "conf_delincludes_empty" \
951 test_conf_delincludes_usage \
952 || failed=`expr $failed + 1`
954 testit "conf_delincludes_usage" \
955 test_conf_delincludes_empty \
956 || failed=`expr $failed + 1`
958 testit "conf_import" \
959 test_conf_import \
960 || failed=`expr $failed + 1`
962 testit "conf_import_usage" \
963 test_conf_import_usage \
964 || failed=`expr $failed + 1`
966 if [ $failed -eq 0 ]; then
967 rm -r $DIR
970 testok $0 $failed