]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/dev-test-root
Final changes
[bacula/bacula] / regress / tests / dev-test-root
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory
4 #   then restore it.
5 #
6 MUID=`/usr/bin/id -u`
7 if [ $MUID != 0 ] ; then
8    echo " "
9    echo "You must be root to run this test."
10    echo "  ===== !!!! dev-test-root not run !!!! ===== "
11    echo "  ===== !!!! dev-test-root not run !!!! ===== " >>test.out
12    echo " "
13    exit 1
14 fi
15 cwd=`pwd`
16 scripts/copy-test-confs
17 scripts/cleanup
18 echo "/dev" >/tmp/file-list
19
20 echo " "
21 echo " "
22 echo " ===     Starting dev-test-root test       ==="
23 echo " "
24 echo " ===  Note, this test can fail for trivial ==="
25 echo " ===  reasons on non-Linux systems.        ==="
26 echo " "
27 echo " "
28
29 bin/bacula start 2>&1 >/dev/null
30 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
31 @output /dev/null
32 messages
33 @output tmp/log1.out
34 label storage=File volume=TestVolume001
35 run job=NightlySave yes
36 wait
37 messages
38 @# 
39 @# now do a restore
40 @#
41 @output tmp/log2.out
42 restore where=${cwd}/tmp/bacula-restores select all done
43 yes
44 wait
45 messages
46 @output
47 quit
48 END_OF_DATA
49 bin/bacula stop 2>&1 >/dev/null
50 cd /
51 ${cwd}/bin/testls -e ${cwd}/scripts/exclude-etc-test dev >${cwd}/tmp/original
52 cd ${cwd}/tmp/bacula-restores
53 ${cwd}/bin/testls -e ${cwd}/scripts/exclude-etc-test dev >${cwd}/tmp/restored
54 cd ${cwd}/tmp
55 #
56 # Use sed to cut out parts that *always* change
57 #
58 cat >sed.scr <<END_OF_DATA
59 s%.*dev$%dev%
60 s%.*[0-9][0-9]:[0-9][0-9]:[0-9][0-9] dev/ptmx%dev/ptmx%
61 s%.*[0-9][0-9]:[0-9][0-9]:[0-9][0-9] dev/ttyp1%dev/ttyp1%
62 s%.*[0-9][0-9]:[0-9][0-9]:[0-9][0-9] dev/null%dev/null%
63 END_OF_DATA
64
65 # strip file system change messages then sed and sort
66 grep -v "Skip: File system change prohibited." original >1
67 sed -f sed.scr 1 | sort >original
68 #
69 mv -f restored 1
70 sed -f sed.scr 1 | sort >restored
71 rm -f sed.scr
72 #
73 cd ${cwd}
74 diff tmp/original tmp/restored 2>&1 1>/dev/null
75 if [ $? != 0 ] ; then
76    echo " "
77    echo " "
78    echo "  ===== !!!! dev-test-root failed !!!! ===== "
79    echo "  ===== !!!! dev-test-root failed !!!! ===== " >>test.out
80    echo " "
81 else
82    echo "  ===== dev-test-root OK ===== "
83    echo "  ===== dev-test-root OK ===== " >>test.out
84    scripts/cleanup
85 fi