s3-test: Added new testsuites for test net [rpc] conf
[Samba/gebeck_regimport.git] / source3 / script / tests / test_net_conf.sh
blobee2903be0281c747b16dc5a300915f9b0a175acb
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 CONFIGURATION [rpc]
10 EOF
11 exit 1;
14 SCRIPTDIR="$1"
15 SERVERCONFFILE="$2"
16 CONFIGURATION="$3"
17 RPC="$4"
19 LOGDIR_PREFIX="conf_test"
21 # remove old logs:
22 for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do
23 echo "removing old directory ${OLDDIR}"
24 rm -rf ${OLDDIR}
25 done
28 NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION"
29 DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX)
30 LOG=$DIR/log
33 if test "x${RPC}" = "xrpc" ; then
34 NETCMD="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc"
35 else
36 NETCMD="${NET}"
39 incdir=`dirname $0`/../../../testprogs/blackbox
40 . $incdir/subunit.sh
42 failed=0
44 SED_INVALID_PARAMS="{
45 s/lock directory/;&/g
46 s/lock dir/;&/g
47 s/modules dir/;&/g
48 s/logging/;&/g
49 s/status/;&/g
50 s/logdir/;&/g
51 s/read prediction/;&/g
52 s/mkprofile/;&/g
53 s/valid chars/;&/g
54 s/timesync/;&/g
55 s/sambaconf/;&/g
56 s/logtype/;&/g
57 s/servername/;&/g
58 s/postscript/;&/g
61 REGPATH="HKLM\Software\Samba"
63 log_print() {
64 RC=$?
65 echo "CMD: $*" >>$LOG
66 echo "RC: $RC" >> $LOG
67 return $RC
68 # echo -n .
71 test_conf_addshare()
73 echo '\nTesting conf addshare' >> $LOG
74 echo ------------------------- >> $LOG
75 echo '\nDropping existing configuration' >> $LOG
77 $NETCMD conf drop
78 log_print $NETCMD conf drop
79 test "x$?" = "x0" || {
80 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
81 return 1
84 #create a lot of shares
85 for i in $(seq 1 100); do
86 if [ $(($i % 2)) -eq 0 ]; then
87 $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
88 "test comment" >>$DIR/addshare_exp \
89 2>>$DIR/addshare_exp
90 log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
91 "test comment"
92 else
93 $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \
94 "test comment" >>$DIR/addshare_exp \
95 2>>$DIR/addshare_exp
96 log_print $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \
97 "test comment"
99 test "x$?" = "x0" || {
100 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
101 return 1
103 done
105 $NETCMD conf listshares > $DIR/listshares_out
106 log_print $NETCMD conf listshares
107 test "x$?" = "x0" || {
108 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
109 return 1
112 for i in $(seq 1 100); do
113 grep "share$i" $DIR/listshares_out >/dev/null 2>>$LOG
114 if [ "$?" = "1" ]; then
115 echo "ERROR: share not found" | tee -a $LOG
116 return 1
118 done
120 #check the integrity of the shares
121 #if it fails, it can also point to an error in showshare
122 for i in $(seq 1 100); do
123 $NETCMD conf showshare share$i > $DIR/showshare_out
124 test "x$?" = "x0" || {
125 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
126 return 1
129 grep "path" $DIR/showshare_out >/dev/null 2>>$LOG
130 if [ "$?" = "1" ]; then
131 echo "ERROR: share not found" | tee -a $LOG
132 return 1
135 if [ $(($i % 2)) -eq 0 ]; then
136 grep "read only *= *no" $DIR/showshare_out >/dev/null 2>>$LOG
137 if [ "$?" = "1" ]; then
138 echo "ERROR: share not set correctly" | tee -a $LOG
139 return 1
141 else
142 grep "read only *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG
143 if [ "$?" = "1" ]; then
144 echo "ERROR: share not set correctly" | tee -a $LOG
145 return 1
149 if [ $(($i % 2)) -eq 0 ]; then
150 grep "guest ok *= *no" $DIR/showshare_out >/dev/null 2>>$LOG
151 if [ "$?" = "1" ]; then
152 echo "ERROR: share not set correctly" | tee -a $LOG
153 return 1
155 else
156 grep "guest ok *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG
157 if [ "$?" = "1" ]; then
158 echo "ERROR: share not set correctly" | tee -a $LOG
159 return 1
163 grep "comment *= *test comment" $DIR/showshare_out >/dev/null 2>>$LOG
164 if [ "$?" = "1" ]; then
165 echo "ERROR: share not set correctly" | tee -a $LOG
166 return 1
168 done
170 echo '\nTaking a conf snapshot for later use' >> $LOG
171 $NETCMD conf list > $DIR/conf_import_in
172 log_print $NETCMD conf list
173 test "x$?" = "x0" || {
174 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
175 return 1
179 test_conf_addshare_existing()
181 #try adding an already existing share
182 echo '\nAdding an already existing share' >>$LOG
183 $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \
184 "test comment" >>$DIR/addshare_exp \
185 2>>$DIR/addshare_exp
186 log_print $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \
187 "test comment"
188 test "x$?" = "x255" || {
189 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
190 return 1
193 test -z `cat $DIR/addshare_exp` && {
194 echo "ERROR: addshare output does not match" >> $LOG
195 return 1
198 return 0
201 test_conf_addshare_usage()
203 #check to see if command prints usage
204 echo '\nChecking usage' >>$LOG
205 $NETCMD conf addshare > $DIR/addshare_usage_exp
206 log_print $NETCMD conf addshare
207 test "x$?" = "x255" || {
208 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
209 return 1
212 grep "$RPC *conf addshare" $DIR/addshare_usage_exp >/dev/null 2>>$LOG
213 if [ "$?" = "1" ]; then
214 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
215 return 1
219 test_conf_delshare()
221 echo '\nTesting conf delshare' >>$LOG
222 echo ------------------------- >> $LOG
223 echo -n '\n' >> $LOG
225 $NETCMD conf delshare share1
226 log_print $NETCMD conf delshare share1
227 test "x$?" = "x0" || {
228 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
229 return 1
232 $NETCMD conf listshares > $DIR/listshares_out
233 log_print $NETCMD conf listshares
234 test "x$?" = "x0" || {
235 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
236 return 1
239 grep "share1$" $DIR/listshares_out >/dev/null 2>>$LOG
240 if [ "$?" = "0" ]; then
241 echo "ERROR: delshare did not delete 'share1'" | tee -a $LOG
242 return 1
246 test_conf_delshare_empty()
248 echo '\nAttempting to delete non_existing share'
249 $NETCMD conf delshare share1
250 log_print $NETCMD conf delshare share1
251 test "x$?" = "x255" || {
252 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
253 return 1
258 test_conf_delshare_usage()
260 echo '\nChecking usage' >>$LOG
261 $NETCMD conf delshare > $DIR/delshare_usage_exp
262 log_print $NETCMD conf delshare
263 test "x$?" = "x255" || {
264 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
265 return 1
268 grep "$RPC *conf delshare" $DIR/delshare_usage_exp >/dev/null 2>>$LOG
269 if [ "$?" = "1" ]; then
270 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
271 return 1
275 test_conf_drop()
278 echo '\nTesting conf drop' >> $LOG
279 echo ------------------------- >> $LOG
280 echo '\nDropping existing configuration' >> $LOG
282 $NETCMD conf drop
283 log_print $NETCMD conf drop
284 test "x$?" = "x0" || {
285 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
286 return 1
289 #check to see if listing the configuration yields a blank file
290 $NETCMD conf list 1>>$DIR/list_out
291 log_print $NETCMD conf list
292 test "x$?" = "x0" || {
293 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
294 return 1
297 test -z "`cat $DIR/list_out`" || {
298 echo "ERROR: Expected list output did not match" | tee -a $LOG
299 return 1
303 test_conf_drop_empty()
305 #Drop an empty config, see if conf drop fails
306 echo '\nAttempting to drop an empty configuration' >>$LOG
308 $NETCMD conf drop
309 log_print $NETCMD conf drop
310 test "x$?" = "x0" || {
311 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
312 return 1
315 #check to see if listing the configuration yields a blank file
316 $NETCMD conf list 1>>$DIR/list_out
317 log_print $NETCMD conf list
318 test "x$?" = "x0" || {
319 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
320 return 1
323 test -z "`cat $DIR/list_out`" || {
324 echo ERROR:Expected list output did not match >> $LOG
325 return 1
329 test_conf_drop_usage()
331 #check to see if command prints usage
332 echo '\nChecking usage' >>$LOG
333 $NETCMD conf drop extra_arg > $DIR/drop_usage_exp
334 log_print $NETCMD conf drop extra_arg
335 test "x$?" = "x255" || {
336 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
337 return 1
340 grep "$RPC *conf drop" $DIR/drop_usage_exp >/dev/null 2>>$LOG
341 if [ "$?" = "1" ]; then
342 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
343 return 1
347 test_conf_setparm()
349 echo '\nTesting conf setparm' >> $LOG
350 echo ------------------------- >> $LOG
352 echo '\nDropping existing configuration' >> $LOG
353 $NETCMD conf drop
354 log_print $NETCMD conf drop
355 test "x$?" = "x0" || {
356 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
357 return 1
360 $NETCMD conf setparm share1 "read only" yes
361 log_print $NETCMD conf setparm share1 "read only" yes
362 test "x$?" = "x0" || {
363 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
364 return 1
367 $NETCMD conf setparm share1 "path" /tmp/test_path
368 log_print $NETCMD conf setparm share1 "path" /tmp/test_path
369 test "x$?" = "x0" || {
370 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
371 return 1
374 $NETCMD conf showshare share1 > $DIR/setparm_showshare_out
375 test "x$?" = "x0" || {
376 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
377 return 1
380 grep "read only *= *yes" $DIR/setparm_showshare_out >/dev/null 2>>$LOG
381 if [ "$?" = "1" ]; then
382 echo "ERROR: setparm did not set correctly" | tee -a $LOG
383 return 1
386 grep "path *= */tmp/test_path" $DIR/setparm_showshare_out >/dev/null 2>>$LOG
387 if [ "$?" = "1" ]; then
388 echo "ERROR: setparm did not set correctly" | tee -a $LOG
389 return 1
393 test_conf_setparm_existing()
396 echo '\nSetting already existing param with the same value'
397 $NETCMD conf setparm share1 "read only" yes
398 log_print $NETCMD conf setparm share1 "read only" yes
399 test "x$?" = "x0" || {
400 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
401 return 1
404 $NETCMD conf setparm share1 "read only" yes
405 log_print $NETCMD conf setparm share1 "read only" yes
406 test "x$?" = "x0" || {
407 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
408 return 1
411 $NETCMD conf showshare share1 > $DIR/setparm_existing_showshare_out
412 test "x$?" = "x0" || {
413 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
414 return 1
417 grep "read only *= *yes" $DIR/setparm_existing_showshare_out >/dev/null 2>>$LOG
418 if [ "$?" = "1" ]; then
419 echo "ERROR: setparm did not set correctly" | tee -a $LOG
420 return 1
423 $NETCMD conf setparm share1 "read only" no
424 log_print $NETCMD conf setparm share1 "read only" no
425 test "x$?" = "x0" || {
426 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
427 return 1
430 $NETCMD conf showshare share1 > $DIR/setparm_existing_showshare_out
431 test "x$?" = "x0" || {
432 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
433 return 1
436 grep "read only *= *no" $DIR/setparm_existing_showshare_out >/dev/null 2>>$LOG
437 if [ "$?" = "1" ]; then
438 echo "ERROR: setparm did not set correctly" | tee -a $LOG
439 return 1
443 test_conf_setparm_usage()
445 echo '\nChecking usage' >>$LOG
446 $NETCMD conf setparm > $DIR/setparm_usage_exp
447 log_print $NETCMD conf setparm
448 test "x$?" = "x255" || {
449 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
450 return 1
453 grep "$RPC *conf setparm" $DIR/setparm_usage_exp >/dev/null 2>>$LOG
454 if [ "$?" = "1" ]; then
455 echo "ERROR: setparm no/wrong usage message printed" | tee -a $LOG
456 return 1
460 test_conf_delparm_delete_existing()
462 echo '\nTesting conf delparm' >> $LOG
463 echo ------------------------- >> $LOG
464 echo -n '\n' >>$LOG
466 $NETCMD conf drop
467 log_print $NETCMD conf drop
468 test "x$?" = "x0" || {
469 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
470 return 1
473 $NETCMD conf addshare share1 /tmp "writeable=y" "guest_ok=n" \
474 "test comment"
475 log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \
476 "test comment"
478 $NETCMD conf delparm share1 "path"
479 log_print $NETCMD conf delparm share1 "path"
480 test "x$?" = "x0" || {
481 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
482 return 1
485 $NETCMD conf showshare share1 > $DIR/delparm_showshare_out
486 test "x$?" = "x0" || {
487 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
488 return 1
491 #test to see what delparm did delete and how
492 grep "read only *= *no" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
493 if [ "$?" = "1" ]; then
494 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
495 return 1
498 grep "path *= */tmp" $DIR/delparm_showshare_out >/dev/null 2>>$LOG
499 if [ "$?" = "0" ]; then
500 echo "ERROR: delparm did not delete correctly" | tee -a $LOG
501 return 1
505 test_conf_delparm_delete_non_existing()
507 echo '\nDelete non existing share' >> $LOG
509 $NETCMD conf drop
510 log_print $NETCMD conf drop
511 test "x$?" = "x0" || {
512 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
513 return 1
516 $NETCMD conf delparm share1 "path"
517 log_print $NETCMD conf delparm share1 "path"
518 test "x$?" = "x255" || {
519 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
520 return 1
524 test_conf_delparm_usage()
527 echo '\nChecking usage' >>$LOG
528 $NETCMD conf delparm > $DIR/delparm_usage_exp
529 log_print $NETCMD conf delparm
530 test "x$?" = "x255" || {
531 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
532 return 1
535 grep "$RPC *conf delparm" $DIR/delparm_usage_exp >/dev/null 2>>$LOG
536 if [ "$?" = "1" ]; then
537 echo "ERROR: delparm no/wrong usage message printed" | tee -a $LOG
538 return 1
543 test_conf_getparm()
546 echo '\nTesting conf getparm' >> $LOG
547 echo ------------------------- >> $LOG
548 echo -n '\n' >>$LOG
550 $NETCMD conf drop
551 log_print $NETCMD conf drop
552 test "x$?" = "x0" || {
553 return 1
556 $NETCMD conf addshare share1 /tmp/path_test "writeable=n" "guest_ok=n" \
557 "test comment"
558 log_print $NETCMD conf addshare share$i /tmp/path_test "writeable=n" "guest_ok=n" \
559 "test comment"
560 test "x$?" = "x0" || {
561 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
562 return 1
565 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
566 log_print $NETCMD conf getparm share1 "read only"
567 test "x$?" = "x0" || {
568 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
569 return 1
572 $NETCMD conf getparm share1 "read only" >$DIR/getparm_out
573 log_print $NETCMD conf getparm share1 "read only"
574 test "x$?" = "x0" || {
575 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
576 return 1
579 echo yes >$DIR/getparm_exp
580 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
581 if [ "$?" = "1" ]; then
582 echo "ERROR: getparm did not print correctly" | tee -a $LOG
583 return 1
586 $NETCMD conf getparm share1 "path" >$DIR/getparm_out
587 log_print $NETCMD conf getparm share1 "path"
588 test "x$?" = "x0" || {
589 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
590 return 1
593 echo /tmp/path_test >$DIR/getparm_exp
594 diff -q $DIR/getparm_out $DIR/getparm_exp >> $LOG
595 if [ "$?" = "1" ]; then
596 echo "ERROR: getparm did not print correctly" | tee -a $LOG
597 return 1
601 test_conf_getparm_usage()
603 echo '\nChecking usage' >>$LOG
604 $NETCMD conf getparm > $DIR/getparm_usage_exp
605 log_print $NETCMD conf getparm
606 test "x$?" = "x255" || {
607 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
608 return 1
611 grep "$RPC *conf getparm" $DIR/getparm_usage_exp >/dev/null 2>>$LOG
612 if [ "$?" = "1" ]; then
613 echo "ERROR: getparm no/wrong usage message printed" | tee -a $LOG
614 return 1
619 test_conf_getparm_non_existing()
621 echo '\nTesting getparm non existing' >>$LOG
622 $NETCMD conf getparm fictional_share fictional_param
623 log_print $NETCMD conf getparm fictional_share fictional_param
624 test "x$?" = "x255" || {
625 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
626 return 1
629 $NETCMD conf getparm share1 fictional_param
630 log_print $NETCMD conf getparm share1 fictional_param
631 test "x$?" = "x255" || {
632 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
633 return 1
637 test_conf_setincludes()
639 echo '\nTesting conf setincludes' >> $LOG
640 echo ------------------------- >> $LOG
641 echo '\nDropping existing configuration' >> $LOG
643 $NETCMD conf drop
644 log_print $NETCMD conf drop
645 test "x$?" = "x0" || {
646 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
647 return 1
650 $NETCMD conf addshare tmp_share /tmp
651 log_print $NETCMD conf addshare tmp_share /tmp
652 test "x$?" = "x0" || {
653 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
654 return 1
657 $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
658 log_print $NETCMD conf setincludes tmp_share /tmp/include1 /tmp/include2 /tmp/include3
659 test "x$?" = "x0" || {
660 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
661 return 1
664 $NETCMD conf list > $DIR/setincludes_list_out
665 log_print $NETCMD conf list
666 test "x$?" = "x0" || {
667 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
668 return 1
671 grep "include *= */tmp/include1$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
672 if [ "$?" = "1" ]; then
673 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
674 return 1
677 grep "include *= */tmp/include2$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
678 if [ "$?" = "1" ]; then
679 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
680 return 1
683 grep "include *= */tmp/include3$" $DIR/setincludes_list_out >/dev/null 2>>$LOG
684 if [ "$?" = "1" ]; then
685 echo "ERROR: setincludes did not set correctly" | tee -a $LOG
686 return 1
691 test_conf_setincludes_usage()
693 echo '\nChecking usage' >>$LOG
694 $NETCMD conf setincludes > $DIR/setincludes_usage_exp
695 log_print $NETCMD conf setincludes
696 test "x$?" = "x255" || {
697 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
698 return 1
701 grep "$RPC *conf setincludes" $DIR/setincludes_usage_exp >/dev/null 2>>$LOG
702 if [ "$?" = "1" ]; then
703 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
704 return 1
708 test_conf_getincludes()
710 $NETCMD conf getincludes tmp_share > $DIR/getincludes_out
711 log_print $NETCMD conf getincludes tmp_share
712 test "x$?" = "x0" || {
713 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
714 return 1
717 grep "include *= */tmp/include1$" $DIR/getincludes_out >/dev/null 2>>$LOG
718 if [ "$?" = "1" ]; then
719 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
720 return 1
723 grep "include *= */tmp/include2$" $DIR/getincludes_out >/dev/null 2>>$LOG
724 if [ "$?" = "1" ]; then
725 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
726 return 1
728 grep "include *= */tmp/include3$" $DIR/getincludes_out >/dev/null 2>>$LOG
729 if [ "$?" = "1" ]; then
730 echo "ERROR: getincludes did not print correctly" | tee -a $LOG
731 return 1
735 test_conf_getincludes_usage()
737 $NETCMD conf getincludes > $DIR/getincludes_usage_exp
738 log_print $NETCMD conf getincludes
740 grep "$RPC *conf getincludes" $DIR/getincludes_usage_exp >/dev/null 2>>$LOG
741 if [ "$?" = "1" ]; then
742 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
743 return 1
747 test_conf_delincludes()
749 echo '\nTesting conf delincludes' >> $LOG
750 echo ------------------------- >> $LOG
752 $NETCMD conf delincludes tmp_share
753 log_print $NETCMD conf delincludes tmp_share
754 test "x$?" = "x0" || {
755 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
756 return 1
759 $NETCMD conf list > $DIR/delincludes_list_out
760 log_print $NETCMD conf list
761 test "x$?" = "x0" || {
762 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
763 return 1
766 grep "include" $DIR/delincludes_list_out >/dev/null 2>>$LOG
767 if [ "$?" = "0" ]; then
768 echo "ERROR: delincludes did not delete correctly" | tee -a $LOG
769 return 1
773 test_conf_delincludes_empty()
775 $NETCMD conf delincludes tmp_share
776 log_print $NETCMD conf delincludes tmp_share
777 test "x$?" = "x0" || {
778 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
779 return 1
782 $NETCMD conf delincludes fictional_share
783 log_print $NETCMD conf delincludes fictional_share
784 test "x$?" = "x255" || {
785 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
786 return 1
788 return 0
791 test_conf_delincludes_usage()
793 echo '\nChecking usage' >>$LOG
794 $NETCMD conf delincludes > $DIR/delincludes_usage_exp
795 log_print $NETCMD conf delincludes
796 test "x$?" = "x255" || {
797 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
798 return 1
801 grep "$RPC *conf delincludes" $DIR/delincludes_usage_exp >/dev/null 2>>$LOG
802 if [ "$?" = "1" ]; then
803 echo "ERROR: no/wrong usage message printed" | tee -a $LOG
804 return 1
808 test_conf_import()
810 echo '\nTesting conf import' >> $LOG
811 echo ------------------------- >> $LOG
812 echo '\nDropping existing configuration' >> $LOG
814 $NETCMD conf drop
815 log_print $NETCMD conf drop
816 test "x$?" = "x0" || {
817 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
818 return 1
821 $NETCMD conf import $DIR/conf_import_in
822 log_print $NETCMD conf drop
823 test "x$?" = "x0" || {
824 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
825 return 1
828 $NETCMD conf list > $DIR/conf_import_out
829 log_print $NETCMD conf list
830 test "x$?" = "x0" || {
831 echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG
832 return 1
835 diff -q $DIR/conf_import_in $DIR/conf_import_out >> $LOG
836 if [ "$?" = "1" ]; then
837 echo "ERROR: import failed" | tee -a $LOG
838 return 1
842 test_conf_import_usage()
844 echo '\nChecking usage' >>$LOG
845 $NETCMD conf import > $DIR/import_usage_exp
846 log_print $NETCMD conf import
847 test "x$?" = "x255" || {
848 echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG
849 return 1
852 grep "$RPC *conf import" $DIR/import_usage_exp >/dev/null 2>>$LOG
853 if [ "$?" = "1" ]; then
854 echo "ERROR: conf import no/wrong usage message printed" | tee -a $LOG
855 return 1
859 CONF_FILES=$SERVERCONFFILE
861 testit "conf_drop" \
862 test_conf_drop \
863 || failed=`expr $failed + 1`
865 testit "conf_drop_empty" \
866 test_conf_drop_empty \
867 || failed=`expr $failed + 1`
869 testit "conf_drop_usage" \
870 test_conf_drop_usage \
871 || failed=`expr $failed + 1`
873 testit "conf_addshare" \
874 test_conf_addshare \
875 || failed=`expr $failed + 1`
877 testit "conf_addshare_existing" \
878 test_conf_addshare_existing \
879 || failed=`expr $failed + 1`
881 testit "conf_addshare_usage" \
882 test_conf_addshare_usage \
883 || failed=`expr $failed + 1`
885 testit "conf_delshare" \
886 test_conf_delshare \
887 || failed=`expr $failed + 1`
889 testit "conf_delshare_empty" \
890 test_conf_delshare_empty \
891 || failed=`expr $failed + 1`
893 testit "conf_delshare_usage" \
894 test_conf_delshare_usage \
895 || failed=`expr $failed + 1`
897 testit "conf_setparm" \
898 test_conf_setparm \
899 || failed=`expr $failed + 1`
901 testit "conf_setparm_existing" \
902 test_conf_setparm_existing \
903 || failed=`expr $failed + 1`
905 testit "conf_setparm_usage" \
906 test_conf_setparm_usage \
907 || failed=`expr $failed + 1`
909 testit "conf_delparm_delete_existing" \
910 test_conf_delparm_delete_existing \
911 || failed=`expr $failed + 1`
913 testit "conf_delparm_delete_non_existing" \
914 test_conf_delparm_delete_non_existing \
915 || failed=`expr $failed + 1`
917 testit "conf_delparm_delete_usage" \
918 test_conf_delparm_usage \
919 || failed=`expr $failed + 1`
921 testit "conf_getparm" \
922 test_conf_getparm \
923 || failed=`expr $failed + 1`
925 testit "conf_getparm_usage" \
926 test_conf_getparm_usage \
927 || failed=`expr $failed + 1`
929 testit "conf_setincludes" \
930 test_conf_setincludes \
931 || failed=`expr $failed + 1`
933 testit "conf_setincludes_usage" \
934 test_conf_setincludes_usage \
935 || failed=`expr $failed + 1`
937 testit "conf_getincludes" \
938 test_conf_getincludes \
939 || failed=`expr $failed + 1`
941 testit "conf_getincludes_usage" \
942 test_conf_getincludes_usage \
943 || failed=`expr $failed + 1`
945 testit "conf_delincludes" \
946 test_conf_delincludes \
947 || failed=`expr $failed + 1`
949 testit "conf_delincludes_empty" \
950 test_conf_delincludes_usage \
951 || failed=`expr $failed + 1`
953 testit "conf_delincludes_usage" \
954 test_conf_delincludes_empty \
955 || failed=`expr $failed + 1`
957 testit "conf_import" \
958 test_conf_import \
959 || failed=`expr $failed + 1`
961 testit "conf_import_usage" \
962 test_conf_import_usage \
963 || failed=`expr $failed + 1`
965 if [ $failed -eq 0 ]; then
966 rm -r $DIR
969 testok $0 $failed