diff mbox

[v4,13/16] osstest: change the meaning of need_build_host

Message ID 20170706144227.36580-14-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné July 6, 2017, 2:42 p.m. UTC
Make need_build_host store a string instead of a boolean. This is
later going to be expanded to handle the FreeBSD build jobs.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v3:
 - New in this version (split from patch).
---
 sg-run-job | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

Comments

Ian Jackson July 6, 2017, 3:37 p.m. UTC | #1
Roger Pau Monne writes ("[PATCH v4 13/16] osstest: change the meaning of need_build_host"):
> Make need_build_host store a string instead of a boolean. This is
> later going to be expanded to handle the FreeBSD build jobs.
...
> -    if {$need_build_host} { catching-otherwise broken allocate-build-host }
> +    if {[llength $need_build_host]} {
> +        catching-otherwise broken allocate-build-host $need_build_host
> +    }

I think you mean

  +    if {[llength $need_build_host]} {
  +        catching-otherwise broken { allocate-build-host $need_build_host }
  +    }

catching-otherwise takes a script as its second argument.  The script
can be a whole { } block and can refer to variables in the same scope
(since it is invoked with uplevel).

Ie, catching-otherwise is a user-defined control construct.  You can
use it like "if" or something.  The omission of the braces in the old
code is simply because if the code to be executed is a single
argumentless procedure call, they aren't needed.

So:

> -    if {$need_build_host} { catching-otherwise broken prepare-build-host }
> +    if {[llength $need_build_host]} {
> +        catching-otherwise broken \
> +                           prepare-build-host-[string tolower $need_build_host]

Instead:

  +        catching-otherwise broken {
  +            prepare-build-host-[string tolower $need_build_host]
  +        }
> +    }

> -proc need-hosts/build {} { return BUILD }
> -proc need-hosts/build-kern {} { return BUILD }
> -proc need-hosts/build-libvirt {} { return BUILD }
> -proc need-hosts/build-rumprun {} { return BUILD }
> -proc need-hosts/build-xtf {} { return BUILD }
> +proc need-hosts/build {} { return BUILD_LINUX }
> +proc need-hosts/build-kern {} { return BUILD_LINUX }
> +proc need-hosts/build-libvirt {} { return BUILD_LINUX }
> +proc need-hosts/build-rumprun {} { return BUILD_LINUX }
> +proc need-hosts/build-xtf {} { return BUILD_LINUX }

I wish I had made these line up neatly!  Sorry.

Ian.
Roger Pau Monné July 7, 2017, 11:36 a.m. UTC | #2
On Thu, Jul 06, 2017 at 04:37:10PM +0100, Ian Jackson wrote:
> Roger Pau Monne writes ("[PATCH v4 13/16] osstest: change the meaning of need_build_host"):
> > Make need_build_host store a string instead of a boolean. This is
> > later going to be expanded to handle the FreeBSD build jobs.
> ...
> > -    if {$need_build_host} { catching-otherwise broken allocate-build-host }
> > +    if {[llength $need_build_host]} {
> > +        catching-otherwise broken allocate-build-host $need_build_host
> > +    }
> 
> I think you mean
> 
>   +    if {[llength $need_build_host]} {
>   +        catching-otherwise broken { allocate-build-host $need_build_host }
>   +    }
> 
> catching-otherwise takes a script as its second argument.  The script
> can be a whole { } block and can refer to variables in the same scope
> (since it is invoked with uplevel).
> 
> Ie, catching-otherwise is a user-defined control construct.  You can
> use it like "if" or something.  The omission of the braces in the old
> code is simply because if the code to be executed is a single
> argumentless procedure call, they aren't needed.

Heh, I told you I would try to do it the C way ;). Thanks for the
comment, it's now fixed.

> So:
> 
> > -    if {$need_build_host} { catching-otherwise broken prepare-build-host }
> > +    if {[llength $need_build_host]} {
> > +        catching-otherwise broken \
> > +                           prepare-build-host-[string tolower $need_build_host]
> 
> Instead:
> 
>   +        catching-otherwise broken {
>   +            prepare-build-host-[string tolower $need_build_host]
>   +        }
> > +    }
> 
> > -proc need-hosts/build {} { return BUILD }
> > -proc need-hosts/build-kern {} { return BUILD }
> > -proc need-hosts/build-libvirt {} { return BUILD }
> > -proc need-hosts/build-rumprun {} { return BUILD }
> > -proc need-hosts/build-xtf {} { return BUILD }
> > +proc need-hosts/build {} { return BUILD_LINUX }
> > +proc need-hosts/build-kern {} { return BUILD_LINUX }
> > +proc need-hosts/build-libvirt {} { return BUILD_LINUX }
> > +proc need-hosts/build-rumprun {} { return BUILD_LINUX }
> > +proc need-hosts/build-xtf {} { return BUILD_LINUX }
> 
> I wish I had made these line up neatly!  Sorry.

Would you like me to align the '{ return ...' block (align on the
first { of the body).

Roger.
Ian Jackson July 7, 2017, 1 p.m. UTC | #3
Roger Pau Monne writes ("Re: [PATCH v4 13/16] osstest: change the meaning of need_build_host"):
> On Thu, Jul 06, 2017 at 04:37:10PM +0100, Ian Jackson wrote:
> > Roger Pau Monne writes ("[PATCH v4 13/16] osstest: change the meaning of need_build_host"):
> > > -proc need-hosts/build {} { return BUILD }
> > > -proc need-hosts/build-kern {} { return BUILD }
> > > -proc need-hosts/build-libvirt {} { return BUILD }
> > > -proc need-hosts/build-rumprun {} { return BUILD }
> > > -proc need-hosts/build-xtf {} { return BUILD }
> > > +proc need-hosts/build {} { return BUILD_LINUX }
> > > +proc need-hosts/build-kern {} { return BUILD_LINUX }
> > > +proc need-hosts/build-libvirt {} { return BUILD_LINUX }
> > > +proc need-hosts/build-rumprun {} { return BUILD_LINUX }
> > > +proc need-hosts/build-xtf {} { return BUILD_LINUX }
> > 
> > I wish I had made these line up neatly!  Sorry.
> 
> Would you like me to align the '{ return ...' block (align on the
> first { of the body).

If you feel like it that would be nice :-).

Ian.
diff mbox

Patch

diff --git a/sg-run-job b/sg-run-job
index 87d81085..2ee57ace 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -52,12 +52,12 @@  proc run-job {job} {
     set skip_globs     [jobdb::read-runvar $flight $job skip_testids]
 
     set nh [need-hosts/$jobinfo(recipe)]
-    if {![string compare $nh BUILD]} {
+    if {[string match BUILD_* $nh]} {
         set need_xen_hosts {}
-        set need_build_host 1
+        set need_build_host [string range $nh [expr [string first _ $nh] + 1] end]
     } else {
         set need_xen_hosts $nh
-        set need_build_host 0
+        set need_build_host {}
     }
     set nested_layers_hosts {}
 
@@ -68,7 +68,9 @@  proc run-job {job} {
         eval run-ts broken  =             ts-hosts-allocate + $need_xen_hosts
     }
 
-    if {$need_build_host} { catching-otherwise broken allocate-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken allocate-build-host $need_build_host
+    }
 
     if {$ok} { setstatus running                                          }
 
@@ -77,7 +79,10 @@  proc run-job {job} {
 
     if {$ok} { set syslog [spawn-ts broken = | ts-syslog-server]          }
 
-    if {$need_build_host} { catching-otherwise broken prepare-build-host }
+    if {[llength $need_build_host]} {
+        catching-otherwise broken \
+                           prepare-build-host-[string tolower $need_build_host]
+    }
 
     per-host-ts broken  host-install/@(*) ts-host-install-twice
 
@@ -95,7 +100,7 @@  proc run-job {job} {
         set need_xen_hosts [lunappend nested_layers_hosts]
     }
 
-    if {$need_build_host && !$ok} {
+    if {[llength $need_build_host] && !$ok} {
 	run-ts  !broken capture-logs      ts-logs-capture + host
     }
 
@@ -116,7 +121,7 @@  proc run-job {job} {
 
     if {$ok} { setstatus pass                                             }
 
-    if {$need_build_host && $ok} { jobdb::preserve-task 90 }
+    if {[llength $need_build_host] && $ok} { jobdb::preserve-task 90 }
 
     if {!$ok} {
         jobdb::logputs stdout "job not ok"
@@ -671,11 +676,11 @@  proc need-hosts/host-examine-linux {} { examine-host-examine debian }
 
 #---------- builds ----------
 
-proc need-hosts/build {} { return BUILD }
-proc need-hosts/build-kern {} { return BUILD }
-proc need-hosts/build-libvirt {} { return BUILD }
-proc need-hosts/build-rumprun {} { return BUILD }
-proc need-hosts/build-xtf {} { return BUILD }
+proc need-hosts/build {} { return BUILD_LINUX }
+proc need-hosts/build-kern {} { return BUILD_LINUX }
+proc need-hosts/build-libvirt {} { return BUILD_LINUX }
+proc need-hosts/build-rumprun {} { return BUILD_LINUX }
+proc need-hosts/build-xtf {} { return BUILD_LINUX }
 
 proc run-job/build {} {
     run-ts . = ts-xen-build
@@ -702,11 +707,11 @@  proc run-job/build-xtf {} {
     run-ts . = ts-xtf-build
 }
 
-proc allocate-build-host {} {
+proc allocate-build-host {ostype} {
     global jobinfo
     run-ts broken = ts-hosts-allocate + host
 }
-proc prepare-build-host {} {
+proc prepare-build-host-linux {} {
     global jobinfo
     run-ts broken host-install(*) ts-host-install-twice
     run-ts . host-build-prep ts-xen-build-prep