]> xenbits.xensource.com Git - osstest.git/commitdiff
test host reuse: Switch to principled sharing scope runvar scheme
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 21 Aug 2020 14:22:19 +0000 (15:22 +0100)
committerIan Jackson <iwj@xenproject.org>
Wed, 7 Oct 2020 16:52:02 +0000 (17:52 +0100)
* When selecthost is passed an @host ident, indicating prep work,
  engage restricted runvar access.  If no call to sharing_for_build
  was made, this means it can access only the runvars in
  the default value of @accessible_runvar_pats.

* Make the sharetype for host reuse be based on the values of
  precisely those same runvars, rather than using an adhoc scheme.

The set of covered runvars is bigger now as a result of testing...

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/TestSupport.pm
ts-host-reuse

index 752c36c563fa2ea6f8038c73e2d6352be6bdad4f..28381f050ef7f6295d6c129ae1f04f66af501399 100644 (file)
@@ -162,7 +162,22 @@ our $logm_prefix= '';
 
 # When runvar_access_restrict is called, it will limit reading
 # of non-synth runvars to ones which match these glob patterns.
-our @accessible_runvar_pats = qw(test-host-setup-runvars-will-appear-here);
+# The initial list is the runvars whih affect how a test host is
+# set up, and for test jobs it isn't modified.  synth runvars
+# which are read-modify-write by host setup must be listed too.
+our @accessible_runvar_pats =
+  qw(
+      *_dmrestrict *buildjob
+      arch console di_version dom0_mem enable_xsm freebsd_distpath
+      linux_boot_append os suite toolstack xen_boot_append xenable_xsm
+      host                           *_host 
+      host_console                   *_host_console
+      host_hostflagadjust            *_host_hostflagadjust
+      host_hostflags                 *_host_hostflags
+      host_linux_boot_append         *_host_linux_boot_append
+      host_ip                        *_host_ip
+      host_power_install             *_host_power_install
+   );
 
 #---------- test script startup ----------
 
@@ -1274,6 +1289,12 @@ sub selecthost ($;$$) {
        return $child;
     }
 
+    #----- if we're sharing an actual host, make sure we do it right -----
+
+    if ($isprep) {
+       runvar_access_restrict();
+    }
+
     #----- calculation of the host's properties -----
 
     # Firstly, hardcoded defaults
index 29abe987e9aa9fd422dc6d1e8af24eb8ce3d90bf..c852a85810701eede0390ddc98ede3abb75d2ff8 100755 (executable)
@@ -64,18 +64,14 @@ sub sharetype_add ($$) {
 }
 
 sub compute_test_sharetype () {
-    $sharetype =
-       "test-$flight/$r{arch}/$r{xenbuildjob}/$r{kernbuildjob}/$r{buildjob}";
-
-    sharetype_add('suite', $ho->{Suite});
-    sharetype_add('di', $ho->{DiVersion});
-
-    foreach my $runvar (qw(freebsd_distpath freebsdbuildjob
-                          xenable_xsm toolstack kernkind
-                          xen_boot_append toolstack)) {
-       my $val = $r{$runvar};
-       die "$runvar $val ?" if defined $val && $val =~ m{[,/\%\\]};
-       sharetype_add($runvar, $val);
+    $sharetype = "test-$flight";
+    my %done;
+    foreach my $key (runvar_glob(@accessible_runvar_pats)) {
+       next if runvar_is_synth($key);
+       my $val = $r{$key};
+       next if $done{$key}++;
+       $val =~ s{[^\"-\~]|\%}{ sprintf "%%%02x", ord $& }ge;
+       $sharetype .= "!$key=$r{$key}";
     }
 
     return $sharetype;