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