From 9e0bd7b254ce422d7999bfc00cbf292a12f00890 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 12 Mar 2010 15:06:33 +0100 Subject: [PATCH] regress: add get_resource to function.pm --- regress/scripts/functions.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 -- 2.39.5