]> git.sur5r.net Git - bacula/bacula/blob - regress/scripts/functions
3a0228cd3f2e53ddb87b179c3cc199e0547b2a73
[bacula/bacula] / regress / scripts / functions
1 #
2 # A set of useful functions to be sourced in each test
3 #
4
5 start_test()
6 {
7    echo " "
8    echo " "
9    echo " === Starting $TestName at `date +%R:%S` ==="
10    echo " === Starting $TestName at `date +%R:%S` ===" >>working/log
11    echo " "
12 }
13
14 set_debug()
15 {
16    debug=$1
17    if test "$debug" -eq 1 ; then
18      out="tee"
19    else
20      out="output"
21    fi
22
23
24 run_bacula()
25 {
26    if test "$debug" -eq 1 ; then
27      bin/bacula start
28      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
29    else
30      bin/bacula start 2>&1 >/dev/null
31      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
32    fi
33 }
34
35 run_bconsole()
36 {
37    if test "$debug" -eq 1 ; then
38      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
39    else
40      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
41    fi
42 }
43
44 stop_bacula()
45 {
46    bin/bacula stop 2>&1 >/dev/null
47 }
48
49 check_for_zombie_jobs()
50 {
51    scripts/check_for_zombie_jobs $1
52 }
53
54 change_jobname()
55 {
56    rm -f bin/1
57    mv bin/bacula-dir.conf bin/1
58    echo "s%NightlySave%$1%g" >/tmp/1
59    sed -f /tmp/1 bin/1 >bin/bacula-dir.conf
60 }
61
62 check_two_logs()
63 {
64    grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
65    bstat=$?
66    grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
67    rstat=$?
68 }
69
70 check_restore_diff()
71 {
72    diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
73    dstat=$?
74 }
75
76 check_restore_tmp_build_diff()
77 {
78    diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
79    dstat=$?
80 }
81
82 end_test()
83 {
84    if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
85       echo " "
86       echo " "
87       echo "  !!!!! $TestName Bacula source failed!!! !!!!! "
88       echo "  !!!!! $TestName failed!!! !!!!! " >>test.out
89       if [ $bstat != 0 -o $rstat != 0 ] ; then
90          echo "  !!!!! Bad Job termination status     !!!!! "
91          echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
92       else
93          echo "  !!!!! Restored files differ          !!!!! "
94          echo "  !!!!! Restored files differ          !!!!! " >>test.out
95       fi
96       echo " "
97    else
98       echo "  ===== $TestName Bacula source OK `date +%R:%S` ===== "
99       echo "  ===== $TestName OK `date +%R:%S` ===== " >>test.out
100       scripts/cleanup
101    fi
102 }