From: Dan Langille Date: Sun, 10 Oct 2021 20:12:12 +0000 (+0000) Subject: Get regression testing working on FreeBSD X-Git-Tag: Release-11.0.6~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a4c5191520f5527f485b408b1f7b525ce83b327;p=thirdparty%2Fbacula.git Get regression testing working on FreeBSD --- diff --git a/regress/Makefile b/regress/Makefile index fc6c5712a..8b4986a9d 100644 --- a/regress/Makefile +++ b/regress/Makefile @@ -52,7 +52,7 @@ root_test: ./all-root-tests clean: - scripts/cleanup + ./scripts/cleanup rm -f tmp/file-list rm -fr tmp/* tmp2/* working/* dumps/* Testing rm -f test.out diff --git a/regress/scripts/cleanup b/regress/scripts/cleanup index 6cc332a16..fbeb28025 100755 --- a/regress/scripts/cleanup +++ b/regress/scripts/cleanup @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/scripts/regress-utils.sh b/regress/scripts/regress-utils.sh old mode 100644 new mode 100755 index b37d2c8b8..07963c4a1 --- a/regress/scripts/regress-utils.sh +++ b/regress/scripts/regress-utils.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS @@ -16,8 +16,8 @@ # $FileSetName - a FileSet prefix for restore job to execute # -# now check if we are running under a proper shell -if test "x$SHELL" != "x/bin/bash" + # now check if we are running under a proper shell +if test "x/$(basename $0)" != "x/bash" then echo "Regression script must use BASH for this utilities!" exit 1 diff --git a/regress/test_duration b/regress/test_duration index b2352a0aa..eb85cc256 100755 --- a/regress/test_duration +++ b/regress/test_duration @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # # Copyright (C) 2000-2015 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS @@ -13,4 +13,4 @@ diff = t - float(s) h = int(diff / 3600) m = int((diff - h * 3600) / 60) sec = diff - h * 3600 - m * 60 -print '%02d:%02d:%02d %ds' % (h, m, sec, t-float(s)) +print('%02d:%02d:%02d %ds' % (h, m, sec, t-float(s))) diff --git a/regress/tests/backup-bacula-test b/regress/tests/backup-bacula-test index ad4401c44..a7a3d4543 100755 --- a/regress/tests/backup-bacula-test +++ b/regress/tests/backup-bacula-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/dbcheck-test b/regress/tests/dbcheck-test index e4d98c6fe..84a037df5 100755 --- a/regress/tests/dbcheck-test +++ b/regress/tests/dbcheck-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/docker-plugin-test b/regress/tests/docker-plugin-test index f8bc88276..5f4290a19 100755 --- a/regress/tests/docker-plugin-test +++ b/regress/tests/docker-plugin-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/fast-nodisk-test b/regress/tests/fast-nodisk-test index cc9601664..14fd4499a 100755 --- a/regress/tests/fast-nodisk-test +++ b/regress/tests/fast-nodisk-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/fdsourceaddress-tryout b/regress/tests/fdsourceaddress-tryout index 0acdd341d..c3bbbbaf2 100755 --- a/regress/tests/fdsourceaddress-tryout +++ b/regress/tests/fdsourceaddress-tryout @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/hangup-blowup-test b/regress/tests/hangup-blowup-test index b6bac6379..285731e0c 100755 --- a/regress/tests/hangup-blowup-test +++ b/regress/tests/hangup-blowup-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/json-test b/regress/tests/json-test index 909860e68..34d473d5b 100755 --- a/regress/tests/json-test +++ b/regress/tests/json-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/maxdiffinterval-test b/regress/tests/maxdiffinterval-test index c8f75f4fc..1c52d418d 100755 --- a/regress/tests/maxdiffinterval-test +++ b/regress/tests/maxdiffinterval-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/remote-console-duplicate-test b/regress/tests/remote-console-duplicate-test index dcf738847..6f812a18b 100755 --- a/regress/tests/remote-console-duplicate-test +++ b/regress/tests/remote-console-duplicate-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2021 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/remote-console-test b/regress/tests/remote-console-test index 6da70d40b..59dd6d402 100755 --- a/regress/tests/remote-console-test +++ b/regress/tests/remote-console-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/runscript-test b/regress/tests/runscript-test index e66263782..a3f7bc69d 100755 --- a/regress/tests/runscript-test +++ b/regress/tests/runscript-test @@ -110,17 +110,23 @@ else bstat=1 fi +echo ' testing a' grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null a=$? +echo ' testing b' grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null b=$? +echo ' testing c' grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null c=$? +echo ' testing d' grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null d=$? +echo ' testing e' grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null e=$? -grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null +echo ' testing f' +grep '\*\*\* Backup Error \*\*\*' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null f=$? if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 -a $f = 0 ] then @@ -138,7 +144,7 @@ grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp c=$? grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null d=$? -grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null +grep '\*\*\* Backup Error \*\*\*' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null e=$? grep 'RUN_FD_FAILED4' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null f=$? diff --git a/regress/tests/show-test b/regress/tests/show-test index 0f3a62d01..d656d0420 100755 --- a/regress/tests/show-test +++ b/regress/tests/show-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/simple-test b/regress/tests/simple-test index 0607d90ba..85cac0d8c 100755 --- a/regress/tests/simple-test +++ b/regress/tests/simple-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/snapshot-btrfs-test b/regress/tests/snapshot-btrfs-test index 49b01cafa..35dc6a1dd 100755 --- a/regress/tests/snapshot-btrfs-test +++ b/regress/tests/snapshot-btrfs-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/snapshot-cmd-test b/regress/tests/snapshot-cmd-test index 61b82e94f..e96b9d67b 100755 --- a/regress/tests/snapshot-cmd-test +++ b/regress/tests/snapshot-cmd-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/snapshot-lvm-test b/regress/tests/snapshot-lvm-test index 4b41b9e01..973915369 100755 --- a/regress/tests/snapshot-lvm-test +++ b/regress/tests/snapshot-lvm-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/snapshot-mountopts-test b/regress/tests/snapshot-mountopts-test index 6a4bf954c..a50c15abd 100755 --- a/regress/tests/snapshot-mountopts-test +++ b/regress/tests/snapshot-mountopts-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/snapshot-zfs-test b/regress/tests/snapshot-zfs-test index 0236e30be..bd1be2654 100755 --- a/regress/tests/snapshot-zfs-test +++ b/regress/tests/snapshot-zfs-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/stop-waiting-for-res-job-test b/regress/tests/stop-waiting-for-res-job-test index 250246a1b..9b17e47b3 100755 --- a/regress/tests/stop-waiting-for-res-job-test +++ b/regress/tests/stop-waiting-for-res-job-test @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (C) 2000-2021 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS diff --git a/regress/tests/truncate-test b/regress/tests/truncate-test index fdc78e7cc..25ebec70e 100755 --- a/regress/tests/truncate-test +++ b/regress/tests/truncate-test @@ -19,6 +19,16 @@ echo $src > $tmp/file-list sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1 cp $tmp/1 $conf/bacula-dir.conf +case $(uname) in + FreeBSD ) + DU="du -A -B 1" + ;; + * ) + DU="du -b" + ;; +esac + + start_test cat >tmp/bconcmds < $tmp/file-list + +sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1 +cp $tmp/1 $conf/bacula-dir.conf + +start_test + +cat >tmp/bconcmds < $tmp/bconcmds +run_bconsole + +cd $tmp + +if test "$debug" -eq 1 ; then + echo "Volume TestVolume001 should be truncated ..." + ls -l TestVolume* +fi + +for i in 2 3 4 5 ; do + size=`du -b TestVolume00$i|cut -f1` + if test $size -lt 5000 ; then + print_debug "ERROR 3: Volume TestVolume00$i is too small $size" + ls -l TestVolume00$i + estat=3 + fi +done +for i in 1 ; do + size=`du -b TestVolume00${i} | cut -f1` + if test $size -gt 5000 ; then + print_debug "ERROR 4: Volume TestVolume00$i is not truncated (too big) $size" + ls -l TestVolume00$i + estat=4 + fi +done + +cd $cwd + +echo "truncate volume storage=File" > $tmp/bconcmds +run_bconsole + +cd $tmp +if test "$debug" -eq 1 ; then + echo "Volumes 001, 003, and 004 should be truncated ..." + ls -l TestVolume* +fi + +for i in 2 5 ; do + size=`du -b TestVolume00$i | cut -f1` + if test $size -lt 5000 ; then + print_debug "ERROR 5: Volume TestVolume00$i is too small $size" + ls -l TestVolume00$i + estat=5 + fi +done +for i in 1 3 4 ; do + size=`du -b TestVolume00$i | cut -f1` + if test $size -gt 5000 ; then + print_debug "ERROR 6: Volume TestVolume00$i is not truncated (too big) $size" + ls -l TestVolume00$i + estat=6 + fi +done + +if ! grep "No Volumes found to perform the command" log7.out > /dev/null ; then + print_debug "ERROR 10: Should not be able to truncate TestVolum001 that holds bakcups" + estat=1 +else + before=`grep $tmp/TestVolume001 log7.out | grep -v exec | head -n 1` + after=`grep $tmp/TestVolume001 log7.out | grep -v exec | tail -n 1` + if [ -z "$before" -o \( "$before" != "$after" \) ] ; then + print_debug "ERROR 11: TestVolum001 has been truncated while it was holding bakcups" + estat=1 + fi +fi + +cd $cwd + +cat < $tmp/bconcmds +@######################################################### +@# Display catalog settings for Pool and Media +@######################################################### +@$out $tmp/log4.out +setdebug level=0 director +sql +select VolumeName, ActionOnPurge FROM Media; +select Name, ActionOnPurge FROM Pool; + +wait +quit +END_OF_DATA + +run_bconsole + +stop_bacula + +touch $tmp/log2.out +check_two_logs + +print_debug "Test if Pool record is ok" +r=`awk '/Default/ { print $4 }' $tmp/log4.out` +if [ "$r" != 1 ]; then + print_debug "ERROR 5: ActionOnPurge on Pool record should be 1 ($r)" + estat=5 +fi + +print_debug "Test TestVolume001 if Media record is ok" +r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out` +if [ "$r" != 1 ]; then + print_debug "ERROR 6: ActionOnPurge on Media record should be 1" + estat=6 +fi + +print_debug "Test TestVolume002 if Media record is ok" +r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out` +if [ "$r" != 0 ]; then + print_debug "ERROR 7: ActionOnPurge on Media record should be 0" + estat=7 +fi + +end_test