]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/weird-files2-test
Update tests with new debug code
[bacula/bacula] / regress / tests / weird-files2-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory
4 #   then restore it.
5 #
6 debug=0
7 if test "$debug" -eq 1 ; then
8   out="tee"
9 else
10   out="output"
11 fi
12
13 if test ! -d weird-files ; then
14    echo " "
15    echo "weird files not configured. Test not run."
16    exit 0
17 fi
18 cwd=`pwd`
19 scripts/copy-test-confs
20 scripts/cleanup
21 rm -rf weird-files2
22 cp -Rp weird-files weird-files2
23 echo "${cwd}/weird-files2" >/tmp/file-list
24
25 echo " "
26 echo " "
27 echo " === Starting weird-files2 test at `date +%R:%S` ==="
28 echo " === Starting weird-file2 test at `date +%R:%S` ===" >>working/log
29 echo " "
30
31 bin/testls weird-files2 >${cwd}/tmp/original
32
33 cat <<END_OF_DATA >tmp/bconcmds
34 @$out /dev/null
35 messages
36 @$out tmp/log1.out
37 label storage=File volume=TestVolume001
38 run job=NightlySave yes
39 wait
40 messages
41 @$out
42 quit
43 END_OF_DATA
44 if test "$debug" -eq 1 ; then
45   bin/bacula start
46   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
47 else
48   bin/bacula start 2>&1 >/dev/null
49   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
50 fi
51 scripts/check_for_zombie_jobs storage=File 
52 #
53 # Now mess up the a hard link, and a soft link
54 #
55 cd weird-files2
56 rm -f hard-file2
57 ln hard-file3 hard-file2
58 rm -f soft-file2
59 ln -s soft-file3 soft-file2
60 cd ${cwd}
61 cat <<END_OF_DATA >tmp/bconcmds
62 @$out /dev/null
63 messages
64 @# 
65 @# now do a restore
66 @#
67 @$out tmp/log2.out
68 restore where= storage=File
69 5
70 unmark *
71 mark *
72 done
73 yes
74 wait
75 messages
76 @$out
77 quit
78 END_OF_DATA
79
80 if test "$debug" -eq 1 ; then
81   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
82 else
83   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
84 fi
85 scripts/check_for_zombie_jobs storage=File 
86 bin/bacula stop 2>&1 >/dev/null
87 bin/testls weird-files2 >${cwd}/tmp/restored
88 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
89 bstat=$?
90 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
91 rstat=$?
92 diff ${cwd}/tmp/original ${cwd}/tmp/restored 2>&1 >/dev/null
93 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
94    echo " "
95    echo " "
96    echo "  !!!!! Weird files2 test failed!!! !!!!! "
97    echo "  !!!!! Weird files2 test failed!!! !!!!! " >>test.out
98    if [ $bstat != 0 -o $rstat != 0 ] ; then
99       echo "  !!!!! Bad Job termination status     !!!!! "
100       echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
101    else
102       echo "  !!!!! Restored files differ          !!!!! "
103       echo "  !!!!! Restored files differ          !!!!! " >>test.out
104    fi
105    echo " "
106 else
107    echo "  ===== Weird files2 test OK ===== "
108    echo "  ===== Weird files2 test OK ===== " >>test.out
109    cd ${cwd}
110    scripts/cleanup
111    rm -rf weird-files2
112 fi