]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/runscript-test
Update
[bacula/bacula] / regress / tests / runscript-test
index 6deb7e266aa800938fb50b7a8c08495b3017985e..bd87c9d3a853d96c22d2fdc6d087d53aed361d17 100755 (executable)
 #!/bin/sh
 #
-#  Test if Bacula can automatically create a Volume label.
+#  Test RunScript
 #
 
 TestName="runscript-test"
+JobName=backup
 
 . scripts/functions
-set_debug 0
 copy_test_confs
 
 rm -f bin/bacula-dir.conf
+rm -f tmp/RUN*log
+rm -f tmp/RUN_FD_FAILED
+
+touch tmp/log1.out
 /bin/cp -f scripts/bacula-dir.conf.testrunscript bin/bacula-dir.conf
 
-echo "${cwd}/build" >/tmp/file-list
+echo "${cwd}/build/po" >/tmp/file-list
 
 start_test
 
 cat <<END_OF_DATA >tmp/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 label volume=TestVolume001
-@#setdebug level=100 storage=File
-@output tmp/log.RUN1.out
-run job=RUN_ALL_OK yes
+@$out tmp/RUN_FD_WARNING.log
+run job=RUN_FD_WARNING yes
 wait
-@sleep 5
 messages
-run job=RUN_FD_WARNING yes
+@sleep 1
+@$out tmp/RUN_ALL_OK.log
+run job=RUN_ALL_OK yes
 wait
-@sleep 5
 messages
+@sleep 1
+@$out tmp/RUN_FD_FAILED.log
 run job=RUN_FD_FAILED yes
 wait
-@sleep 5
 messages
+@sleep 1
+@$out tmp/RUN_DIR_FAILED.log
 run job=RUN_DIR_FAILED yes
 wait
-@sleep 5
+messages
+@sleep 1
+@$out tmp/RUN_FD_FAILED2.log
+run job=RUN_FD_FAILED2 yes
+wait
 messages
 st dir
 quit
 END_OF_DATA
 
 run_bacula
+check_for_zombie_jobs storage=File
 stop_bacula
 
-if grep -q 'dir: BeforeJob: run command "/bin/echo RunBeforeJob"'          tmp/log.RUN1.out   &&
-   grep -q 'fd: ClientRunBeforeJob: ClientRunBeforeJob'                    tmp/log.RUN1.out   &&
-   grep -q 'fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob'  tmp/log.RUN1.out   &&
-   grep -q 'dir: AfterJob: run command "/bin/echo RunAfterJob'             tmp/log.RUN1.out
+dstat=0
+bstat=0
+rstat=0
+export dstat
+export bstat
+export rstat
+
+grep 'dir: BeforeJob: run command "/bin/echo RunBeforeJob"' tmp/RUN_ALL_OK.log >/dev/null 2>&1 
+a=$?
+grep 'fd: ClientRunBeforeJob: ClientRunBeforeJob' tmp/RUN_ALL_OK.log >/dev/null 2>&1
+b=$?
+grep 'fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob' tmp/RUN_ALL_OK.log >/dev/null 2>&1
+c=$?
+grep 'dir: AfterJob: run command "/bin/echo RunAfterJob' tmp/RUN_ALL_OK.log >/dev/null 2>&1
+d=$?
+if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 ]
 then
-   [ "$debug" -eq 1 ] && echo RUN_ALL_OK ok
+   [ "$debug" = 1 ] && echo RUN_ALL_OK ok
 else
    echo "RUN_ALL_OK in error"
    rstat=1
 fi
 
-if grep -q 'dir: BeforeJob: run command "/bin/false RUN_DIR_FAILED"' tmp/log.RUN1.out   &&
-   grep -q 'dir: BeforeJob: RunAfterFailedJob'                       tmp/log.RUN1.out   &&
-   true # grep -q 'Backup OK -- with warnings'                       tmp/log.RUN1.out
+grep 'dir: BeforeJob: run command "/bin/false RUN_DIR_FAILED"' tmp/RUN_DIR_FAILED.log >/dev/null 2>&1
+a=$?
+grep 'dir: AfterJob: RunAfterFailedJob' tmp/RUN_DIR_FAILED.log >/dev/null 2>&1
+b=$?
+if [ $a = 0 -a $b = 0 ]
 then
-   [ "$debug" -eq 1 ] && echo RUN_DIR_FAILED ok
+   [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok
 else
    echo "RUN_DIR_FAILED in error"
    rstat=1
 fi
 
-if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"'  tmp/log.RUN1.out   &&
-   grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"'  tmp/log.RUN1.out   &&
-   grep -q 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"'      tmp/log.RUN1.out
+grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
+a=$?
+grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
+b=$?
+grep 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
+c=$?
+#grep 'touching' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
+test -f tmp/RUN_FD_FAILED
+d=$?
+grep '*** Backup Error ***' tmp/RUN_FD_FAILED.log >/dev/null 2>&1
+e=$?
+if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
 then
-   [ "$debug" -eq 1 ] && echo RUN_FD_FAILED ok
+   [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
 else
    echo "RUN_FD_FAILED in error"
    rstat=1
 fi
 
-if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' tmp/log.RUN1.out   &&
-   grep -q 'Backup OK -- with warnings'                                   tmp/log.RUN1.out
+grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
+a=$?
+grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
+b=$?
+grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
+c=$?
+grep 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
+d=$?
+grep  '*** Backup Error ***' tmp/RUN_FD_FAILED2.log >/dev/null 2>&1
+e=$?
+if [ $a = 0 -a $b != 0 -a $c = 0 -a $d = 0 -a $e = 0 ]
+then
+   [ "$debug" = 1 ] && echo RUN_FD_FAILED ok
+else
+   echo "RUN_FD_FAILED2 in error"
+   rstat=1
+fi
+
+grep 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' tmp/RUN_FD_WARNING.log >/dev/null 2>&1
+a=$?
+grep 'RunAfterFailedJob' tmp/RUN_FD_WARNING.log >/dev/null 2>&1
+b=$?
+grep 'Backup OK -- with warnings' tmp/RUN_FD_WARNING.log >/dev/null 2>&1
+c=$?
+if [ $a = 0 -a $b != 0 -a $c = 0 ]
 then
-   [ "$debug" -eq 1 ] && echo RUN_FD_WARNING ok
+   [ "$debug" = 1 ] && echo RUN_FD_WARNING ok
 else
    echo "RUN_FD_WARNING in error"
    rstat=1
 fi
 
+end_test