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