]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
mg-show-flight-runvars: move collection into a sub
authorIan Campbell <ian.campbell@citrix.com>
Mon, 1 Feb 2016 14:28:29 +0000 (14:28 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 8 Feb 2016 16:31:48 +0000 (16:31 +0000)
This will make it easier to collect more rows.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
mg-show-flight-runvars

index 820c5778d53f57239918e244b5acdd64e38aa694..0995430f535f04c95a85fe9b5342e9edf12cedc0 100755 (executable)
@@ -43,29 +43,35 @@ for (;;) {
 
 die unless @ARGV==1 && $ARGV[0] =~ m/^\w+$/;
 
-our ($flight) = @ARGV;
 
 our @cols = qw(job name val);
 our @rows;
+our @colws;
 
-$flight =~ m/^\d+/ or $flight = "'$flight'";
-my $qfrom = "FROM runvars WHERE flight=$flight AND $synthcond";
+sub collect ($) {
+    my ($flight) = @_;
 
-my @colws = $dbh_tests->selectrow_array
-    ("SELECT ".(join ',', map { "max(length($_))" } @cols)." $qfrom");
+    $flight =~ m/^\d+/ or $flight = "'$flight'";
+    my $qfrom = "FROM runvars WHERE flight=$flight AND $synthcond";
 
-my $q = $dbh_tests->prepare
-    ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY synth, name, job");
-$q->execute();
+    @colws = $dbh_tests->selectrow_array
+       ("SELECT ".(join ',', map { "max(length($_))" } @cols)." $qfrom");
 
-$colws[1] += length $synthsufx;
+    my $q = $dbh_tests->prepare
+       ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY synth, name, job");
+    $q->execute();
 
-while (my (@row) = $q->fetchrow_array()) {
-    my $synth = shift @row;
-    $row[1] .= $synthsufx if $synth && $synth ne 'f'; # sqlite3 is typeless
-    push @rows, \@row;
+    while (my (@row) = $q->fetchrow_array()) {
+       my $synth = shift @row;
+       $row[1] .= $synthsufx if $synth && $synth ne 'f'; # sqlite3 is typeless
+       push @rows, \@row;
+    }
 }
 
+$colws[1] += length $synthsufx;
+
+collect($ARGV[0]);
+
 foreach my $row (@rows) {
     printf "%-*s %-*s %-*s\n", map { $colws[$_], $row->[$_] } qw(0 1 2)
         or die $!;