From: Eric Bollengier Date: Fri, 12 Mar 2010 14:06:33 +0000 (+0100) Subject: regress: add get_resource to function.pm X-Git-Tag: Release-7.0.0~2067 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e0bd7b254ce422d7999bfc00cbf292a12f00890;p=bacula%2Fbacula regress: add get_resource to function.pm --- diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index 5838a090a7..193aaa18bc 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -39,7 +39,7 @@ use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(update_some_files create_many_files check_multiple_copies update_client $HOST $BASEPORT add_to_backup_list check_volume_size - create_many_dirs cleanup start_bacula stop_bacula + create_many_dirs cleanup start_bacula stop_bacula get_resource check_min_volume_size check_max_volume_size $estat $bstat $rstat $zstat $cwd $bin $scripts $conf $rscripts $tmp $working extract_resource $db_name $db_user $db_password $src $tmpsrc); @@ -118,18 +118,27 @@ sub stop_bacula return $? == 0; } -sub extract_resource +sub get_resource { my ($file, $type, $name) = @_; - + my $ret; open(FP, $file) or die "Can't open $file"; my $content = join("", ); if ($content =~ m/(^$type {[^}]+?Name\s*=\s*"?$name"?[^}]+?^})/ms) { - print $1, "\n"; + $ret = $1; } close(FP); + return $ret; +} + +sub extract_resource +{ + my $ret = get_resource(@_); + if ($ret) { + print $ret, "\n"; + } } sub check_min_volume_size