]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/btape-test
Big backport from Enterprise
[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
44 if [ $? != 0 ] ; then
45    echo " "
46    echo " "
47    echo "  !!!!! btape test failed!!! !!!!! "
48    echo "  !!!!! btape test failed!!! !!!!! " >>test.out
49    echo " "
50    exit 1
51 fi
52
53 grep "The test autochanger worked" $tmp/log1.out > /dev/null
54 if [ $? != 0 ] ; then
55    print_debug "btape autochanger test failed"
56    estat=1
57 fi
58
59 grep "End Forward space files test" $tmp/log1.out > /dev/null
60 if [ $? != 0 ] ; then
61    print_debug "btape test failed"
62    estat=1
63 fi
64
65 # now try to use the fill command
66 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumVolumeSize', '400M', 'Device')"
67
68 $bin/disk-changer $working/ach load 1 $working/ach/drive0 0
69
70 if test "$debug" -eq 1 ; then
71   $bin/btape -w $tmp -c $conf/bacula-sd.conf LTO3_0 <<END_OF_DATA | tee $tmp/log2.out
72 fill
73 m
74 quit
75 END_OF_DATA
76 else
77   $bin/btape -w $tmp -c $conf/bacula-sd.conf LTO3_0 <<END_OF_DATA >$tmp/log2.out 2>&1
78 fill
79 m
80 quit
81 END_OF_DATA
82 fi
83
84
85 if [ $? != 0 ] ; then
86    echo " "
87    echo " "
88    echo "  !!!!! btape test failed!!! !!!!! "
89    echo "  !!!!! btape test failed!!! !!!!! " >>test.out
90    echo " "
91    exit 1
92 fi
93
94 grep "The last block of the first tape matches." $tmp/log2.out > /dev/null
95 if [ $? != 0 ] ; then
96    print_debug "Could not find: The last block of the first tape matches."
97    print_debug "btape fill test failed"
98    estat=1
99 fi
100
101 grep "The first block on the second tape matches." $tmp/log2.out > /dev/null
102 if [ $? != 0 ] ; then
103    print_debug "Could not find: The first block on the second tape matches."
104    print_debug "btape fill test failed"
105    estat=1
106 fi
107
108 end_test