From d6f460cdb1ee2c804167a8516ce72bd897e1d773 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 14 Feb 2010 15:34:53 +0100 Subject: [PATCH] Add function to extract resource from config file --- regress/scripts/functions.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index 2208ee32a3..bfabe11049 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -40,7 +40,7 @@ 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 check_min_volume_size check_max_volume_size $estat $bstat $rstat $zstat - $cwd $bin $scripts $conf $rscripts $tmp $working + $cwd $bin $scripts $conf $rscripts $tmp $working extract_resource $db_name $db_user $db_password $src $tmpsrc); @@ -91,6 +91,20 @@ BEGIN { $estat = $rstat = $bstat = $zstat = 0; } +sub extract_resource +{ + my ($file, $type, $name) = @_; + + open(FP, $file) or die "Can't open $file"; + my $content = join("", ); + + if ($content =~ m/(^$type {.+?Name\s*=\s*"?$name"?.+?^})/ms) { + print $1, "\n"; + } + + close(FP); +} + sub check_min_volume_size { my ($size, @vol) = @_; -- 2.39.5