]> git.sur5r.net Git - bacula/bacula/blob - regress/scripts/functions
Update tests
[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    debug_wait
27    if test "$debug" -eq 1 ; then
28      bin/bacula-ctl-sd start
29      bin/bacula-ctl-fd start
30      bin/bacula-ctl-dir start
31      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
32    else
33      bin/bacula start 2>&1 >/dev/null
34      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
35    fi
36 }
37
38 run_bconsole()
39 {
40    if test "$debug" -eq 1 ; then
41      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
42    else
43      cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
44    fi
45 }
46
47 run_btape()
48 {
49    if test "$debug" -eq 1 ; then
50      cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out
51    else
52      cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 2>&1 >tmp/log1.out
53    fi
54 }
55
56 run_bscan()
57 {
58    if test "$debug" -eq 1 ; then
59       bin/bscan $* | tee tmp/log.out
60    else
61       bin/bscan $* 2>&1 >/dev/null
62    fi
63 }
64
65
66 stop_bacula()
67 {
68    bin/bacula stop 2>&1 >/dev/null
69 }
70
71 check_for_zombie_jobs()
72 {
73    scripts/check_for_zombie_jobs $1
74 }
75
76 change_jobname()
77 {
78    if test $# -eq 1; then
79       oldname=NightlySave
80       newname=$1
81    else
82       oldname=$1
83       newname=$2
84    fi
85    rm -f bin/1
86    mv bin/bacula-dir.conf bin/1
87    echo "s%${oldname}%${newname}%g" >tmp/1
88    sed -f tmp/1 bin/1 >bin/bacula-dir.conf
89 #  echo "Job ${oldname} changed to ${newname}"
90 }
91
92 check_two_logs()
93 {
94    grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
95    bstat=$?
96    grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
97    rstat=$?
98 }
99
100 check_restore_diff()
101 {
102    diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
103    dstat=$?
104 }
105
106 check_restore_tmp_build_diff()
107 {
108    diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
109    dstat=$?
110 }
111
112 end_test()
113 {
114    if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
115       echo " "
116       echo " "
117       echo "  !!!!! $TestName failed!!! !!!!! "
118       echo "  !!!!! $TestName failed!!! !!!!! " >>test.out
119       if [ $bstat != 0 -o $rstat != 0 ] ; then
120          echo "  !!!!! Bad Job termination status     !!!!! "
121          echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
122       else
123          echo "  !!!!! Restored files differ          !!!!! "
124          echo "  !!!!! Restored files differ          !!!!! " >>test.out
125       fi
126       echo " "
127    else
128       echo "  ===== $TestName OK `date +%R:%S` ===== "
129       echo "  ===== $TestName OK `date +%R:%S` ===== " >>test.out
130       if test "$debug" -eq 0 ; then
131          scripts/cleanup
132       fi
133    fi
134 }
135
136 copy_tape_confs()
137 {
138    scripts/copy-tape-confs
139    scripts/cleanup-tape
140 }
141
142 copy_test_confs()
143 {
144    scripts/copy-test-confs
145    scripts/cleanup
146 }
147
148 debug_wait()
149 {
150   if test "x${REGRESS_WAIT}" = "x1"; then
151      echo "Start Bacula under debugger and enter anything when ready ..."
152      read a
153   fi
154 }
155
156 # Save current directory
157 cwd=`pwd`
158 if test "x${REGRESS_DEBUG}" = "x1"; then
159    set_debug 1
160 else
161    set_debug 0
162 fi