]> git.sur5r.net Git - bacula/bacula/blob - regress/scripts/functions
Add Frank Sweetser's tls test
[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          echo "        bstat=$bstat rstat=$rstat dstat=$dstat"
123       else
124          echo "  !!!!! Restored files differ          !!!!! "
125          echo "  !!!!! Restored files differ          !!!!! " >>test.out
126          echo "        bstat=$bstat rstat=$rstat dstat=$dstat"
127       fi
128       echo " "
129    else
130       echo "  ===== $TestName OK `date +%R:%S` ===== "
131       echo "  ===== $TestName OK `date +%R:%S` ===== " >>test.out
132       if test "$debug" -eq 0 ; then
133          scripts/cleanup
134       fi
135    fi
136 }
137
138 copy_tape_confs()
139 {
140    scripts/copy-tape-confs
141    scripts/cleanup-tape
142 }
143
144 copy_test_confs()
145 {
146    scripts/copy-test-confs
147    scripts/cleanup
148 }
149
150 debug_wait()
151 {
152   if test "x${REGRESS_WAIT}" = "x1"; then
153      echo "Start Bacula under debugger and enter anything when ready ..."
154      read a
155   fi
156 }
157
158 # Save current directory
159 cwd=`pwd`
160 if test "x${REGRESS_DEBUG}" = "x1"; then
161    set_debug 1
162 else
163    set_debug 0
164 fi
165
166 # Source the second drive variables
167 touch ${cwd}/config.out
168 . ${cwd}/config.out