]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/btape-test
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / tests / btape-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 #
7 # Test the test command in btape
8 #
9 TestName="btape-test"
10 JobName=btapetest
11 . scripts/functions
12
13 require_vtape
14
15 scripts/cleanup
16 scripts/copy-tape-confs
17 cp $rscripts/bacula-dir-vtape.conf $conf/bacula-dir.conf
18 cp $rscripts/bacula-sd-vtape.conf $conf/bacula-sd.conf
19 scripts/prepare-fake-autochanger
20
21 # we need at least 2 or 3G for this test
22 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumVolumeSize', '3G', 'Device')"
23
24 change_jobname $JobName
25 start_test
26
27 $bin/disk-changer $working/ach load 1 $working/ach/drive0 0
28
29 if test "$debug" -eq 1 ; then
30   $bin/btape -w $tmp -c $conf/bacula-sd.conf LTO3_0 <<END_OF_DATA | tee $tmp/log1.out
31 test
32 y
33 quit
34 END_OF_DATA
35 else
36   $bin/btape -w $tmp -c $conf/bacula-sd.conf LTO3_0 <<END_OF_DATA >$tmp/log1.out 2>&1
37 test
38 y
39 quit
40 END_OF_DATA
41 fi
42
43 if [ $? != 0 ] ; then
44    echo " "
45    echo " "
46    echo "  !!!!! btape test failed!!! !!!!! "
47    echo "  !!!!! btape test failed!!! !!!!! " >>test.out
48    echo " "
49    exit 1
50 fi
51
52 grep "This is NOT correct" $tmp/log1.out >/dev/null
53 if [ $? != 1 ] ; then
54    print_debug "btape test command failed failed"
55    estat=1
56 fi
57
58
59 grep "The test autochanger worked" $tmp/log1.out > /dev/null
60 if [ $? != 0 ] ; then
61    print_debug "btape autochanger test failed"
62    estat=1
63 fi
64
65 grep "End Forward space files test" $tmp/log1.out > /dev/null
66 if [ $? != 0 ] ; then
67    print_debug "btape test failed"
68    estat=1
69 fi
70
71 # now try to use the fill command
72 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumVolumeSize', '400M', 'Device')"
73
74 $bin/disk-changer $working/ach load 1 $working/ach/drive0 0
75
76 if test "$debug" -eq 1 ; then
77   $bin/btape -w $tmp -c $conf/bacula-sd.conf LTO3_0 <<END_OF_DATA | tee $tmp/log2.out
78 fill
79 m
80 quit
81 END_OF_DATA
82 else
83   $bin/btape -w $tmp -c $conf/bacula-sd.conf LTO3_0 <<END_OF_DATA >$tmp/log2.out 2>&1
84 fill
85 m
86 quit
87 END_OF_DATA
88 fi
89
90
91 if [ $? != 0 ] ; then
92    echo " "
93    echo " "
94    echo "  !!!!! btape test failed!!! !!!!! "
95    echo "  !!!!! btape test failed!!! !!!!! " >>test.out
96    echo " "
97    exit 1
98 fi
99
100 grep "The last block of the first tape matches." $tmp/log2.out > /dev/null
101 if [ $? != 0 ] ; then
102    print_debug "Could not find: The last block of the first tape matches."
103    print_debug "btape fill test failed"
104    estat=1
105 fi
106
107 grep "The first block on the second tape matches." $tmp/log2.out > /dev/null
108 if [ $? != 0 ] ; then
109    print_debug "Could not find: The first block on the second tape matches."
110    print_debug "btape fill test failed"
111    estat=1
112 fi
113
114 end_test