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