]> xenbits.xensource.com Git - osstest.git/commitdiff
mg-show-flight-runvars: Decorate synth runvar names with ~
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 16 Sep 2015 12:09:01 +0000 (13:09 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 21 Sep 2015 13:39:28 +0000 (14:39 +0100)
Make mg-show-flight-runvars -a append ~ to the names of synth runvars.
(This is consistent with the new syntax in cs-job-create.)

We do this by editing $row[1] (and $colws[1]) so we can avoid
disturbing the general column format calculation and printing.

We switch to fetchrow_array rather than fetchrow_arrayref.  This is
clearer and also avoids having to copy $row (because the value in the
DB $row from fetchrow_hashref would be readonly).

We have to check for $synth eq 'f' as well as $synth being boolean
false, because SQLite's typeless nature (or, to put it another way,
DBD::SQLite's failure to look at the schema) means that a boolean
field's value of 'f' or 't' is simply returned as a string to Perl.
But of course "f" is trueish in Perl.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Use fetchrow_array instead.
    Do not mistakenly drop the $synthcond assignment (!)

mg-show-flight-runvars

index e33a3f06ca5f6803d0bb6afccdfc913b1a99b9a2..c800110e6587e9470e5f9a37fc66896872c8cec2 100755 (executable)
@@ -26,6 +26,7 @@ use Osstest;
 csreadconfig();
 
 my $synthcond = '(NOT synth)';
+my $synthsufx = '';
 
 for (;;) {
     last unless @ARGV;
@@ -34,6 +35,7 @@ for (;;) {
     last if m/^\-\-?$/;
     if (m/^-a$/) {
        $synthcond = '(1=1)';
+       $synthsufx = '~';
     } else {
        die "$_ ?";
     }
@@ -52,10 +54,14 @@ my @colws = $dbh_tests->selectrow_array
     ("SELECT ".(join ',', map { "max(length($_))" } @cols)." $qfrom");
 
 my $q = $dbh_tests->prepare
-    ("SELECT ".(join ',', @cols)." $qfrom ORDER BY name, job");
+    ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY synth, name, job");
 $q->execute();
 
-while (my $row = $q->fetchrow_arrayref()) {
-    printf "%-*s %-*s %-*s\n", map { $colws[$_], $row->[$_] } qw(0 1 2)
+$colws[1] += length $synthsufx;
+
+while (my (@row) = $q->fetchrow_array()) {
+    my $synth = shift @row;
+    $row[1] .= $synthsufx if $synth && $synth ne 'f'; # sqlite3 is typeless
+    printf "%-*s %-*s %-*s\n", map { $colws[$_], $row[$_] } qw(0 1 2)
         or die $!;
 }