]> xenbits.xensource.com Git - osstest.git/commitdiff
config: support :-separated lists of config files
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 14 Feb 2013 16:23:05 +0000 (16:23 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 14 Feb 2013 16:23:05 +0000 (16:23 +0000)
Osstest.pm
README

index 386b7ea0bbd8178e9df447bd27cfd6d9df3ad1a0..5d2bb2a1e2bf0d5ab0c17c25d5134814b2cc98a7 100644 (file)
@@ -98,41 +98,45 @@ sub readglobalconfig () {
 
     my $cfgvar_re = '[A-Z][0-9a-zA-Z-_]*';
 
-    my $cfgfile = $ENV{'OSSTEST_CONFIG'} || "$ENV{'HOME'}/.xen-osstest/config";
-    if (!open C, '<', "$cfgfile") {
-       die "$cfgfile $!" unless $!==&ENOENT;
-    } else {
-       while (<C>) {
-           die "missing newline" unless chomp;
-           s/^\s*//;
-           s/\s+$//;
-           next if m/^\#/;
-           next unless m/\S/;
-           if (m/^($cfgvar_re)\s+(\S.*)$/) {
-               $c{$1} = $2;
-           } elsif (m/^($cfgvar_re)=\s*\<\<(\'?)(.*)\2\s*$/) {
-               my ($vn,$qu,$delim) = ($1,$2,$3);
-               my $val = '';
-               $!=0; while (<C>) {
-                   last if $_ eq "$delim\n";
-                   $val .= $_;
+    my $cfgfiles = $ENV{'OSSTEST_CONFIG'} || "$ENV{'HOME'}/.xen-osstest/config";
+
+    foreach my $cfgfile (split /\:/, $cfgfiles) {
+       if (!open C, '<', "$cfgfile") {
+           die "$cfgfile $!" unless $!==&ENOENT;
+       } else {
+           while (<C>) {
+               die "missing newline" unless chomp;
+               s/^\s*//;
+               s/\s+$//;
+               next if m/^\#/;
+               next unless m/\S/;
+               if (m/^($cfgvar_re)\s+(\S.*)$/) {
+                   $c{$1} = $2;
+               } elsif (m/^($cfgvar_re)=\s*\<\<(\'?)(.*)\2\s*$/) {
+                   my ($vn,$qu,$delim) = ($1,$2,$3);
+                   my $val = '';
+                   $!=0; while (<C>) {
+                       last if $_ eq "$delim\n";
+                       $val .= $_;
+                   }
+                   die $! unless length $_;
+                   die unless $val =~ m/\n$/;
+                   if ($qu eq '') {
+                       my $reconstruct =
+                           "\$val = <<${qu}${delim}${qu}; 1;\n".
+                           "${val}${delim}\n";
+                       eval $reconstruct or
+                           die "$1 here doc ($reconstruct) $@";
+                   }
+                   $c{$vn} = $val;
+               } elsif (m/^($cfgvar_re)=(.*)$/) {
+                   eval "\$c{$1} = ( $2 ); 1;" or die "$1 parsed val ($2) $@";
+               } else {
+                   die "bad syntax";
                }
-               die $! unless length $_;
-               die unless $val =~ m/\n$/;
-               if ($qu eq '') {
-                   my $reconstruct =
-                       "\$val = <<${qu}${delim}${qu}; 1;\n".
-                       "${val}${delim}\n";
-                   eval $reconstruct or die "$1 here doc ($reconstruct) $@";
-               }
-               $c{$vn} = $val;
-           } elsif (m/^($cfgvar_re)=(.*)$/) {
-               eval "\$c{$1} = ( $2 ); 1;" or die "$1 parsed val ($2) $@";
-           } else {
-               die "bad syntax";
            }
+           close C or die "$cfgfile $!";
        }
-       close C or die "$cfgfile $!";
     }
 
     # dynamic default config settings
diff --git a/README b/README
index e75b7adf479fd3faeb08f555f6889a8980572213..92d992ba1f4dfcfeaad48aa3f718e527bca8f603 100644 (file)
--- a/README
+++ b/README
@@ -43,7 +43,7 @@ To run osstest in standalone mode:
 ========================================
 
 Format of config file ~/.xen-osstest/config (you may set OSSTEST_CONFIG to
-point to a different file):
+point to a different file, or :-separates series of files):
 
 Lines containing:
    Name value
@@ -60,6 +60,7 @@ To set a value to the empty string, say
 #-comments and blank lines are ignored.
 
 For an example see  ./standalone-config-example
+Values later in the file, or in a later file, take precedence.
 
 ========================================