From 0f4a4ec779665eb6aba238a18160c4c4ef166064 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 1 Feb 2010 18:02:06 +0100 Subject: [PATCH] regress: Add perl functions to check volume size --- regress/scripts/functions.pm | 60 ++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index 0b6da0b07e..2208ee32a3 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -38,16 +38,23 @@ package scripts::functions; use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(update_some_files create_many_files check_multiple_copies - update_client $HOST $BASEPORT + update_client $HOST $BASEPORT add_to_backup_list check_volume_size + check_min_volume_size check_max_volume_size $estat $bstat $rstat $zstat $cwd $bin $scripts $conf $rscripts $tmp $working $db_name $db_user $db_password $src $tmpsrc); use File::Copy qw/copy/; -our ($cwd, $bin, $scripts, $conf, $rscripts, $tmp, $working, +our ($cwd, $bin, $scripts, $conf, $rscripts, $tmp, $working, $estat, $bstat, $zstat, $rstat, $db_name, $db_user, $db_password, $src, $tmpsrc, $HOST, $BASEPORT); +END { + if ($estat || $rstat || $zstat || $bstat) { + exit 1; + } +} + BEGIN { # start by loading the ./config file my ($envar, $enval); @@ -80,6 +87,55 @@ BEGIN { $ENV{rscripts} = $rscripts = $ENV{rscripts} || "$cwd/scripts"; $ENV{HOST} = $HOST = $ENV{HOST} || "localhost"; $ENV{BASEPORT} = $BASEPORT = $ENV{BASEPORT} || "8101"; + + $estat = $rstat = $bstat = $zstat = 0; +} + +sub check_min_volume_size +{ + my ($size, @vol) = @_; + my $ret=0; + + foreach my $v (@vol) { + if (! -f "$tmp/$v") { + print "ERR: $tmp/$v not accessible\n"; + $ret++; + next; + } + if (-s "$tmp/$v" < $size) { + print "ERR: $tmp/$v too small\n"; + $ret++; + } + } + $estat+=$ret; + return $ret; +} + +sub check_max_volume_size +{ + my ($size, @vol) = @_; + my $ret=0; + + foreach my $v (@vol) { + if (! -f "$tmp/$v") { + print "ERR: $tmp/$v not accessible\n"; + $ret++; + next; + } + if (-s "$tmp/$v" > $size) { + print "ERR: $tmp/$v too big\n"; + $ret++; + } + } + $estat+=$ret; + return $ret; +} + +sub add_to_backup_list +{ + open(FP, ">>$tmp/file-list") or die "Can't open $tmp/file-list for update $!"; + print FP join("\n", @_); + close(FP); } # update client definition for the current test -- 2.39.5