]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
Flight restriction: Introduce restrictflight_arg and restrictflight_cond
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 23 Jul 2015 16:38:27 +0000 (17:38 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 28 Jul 2015 14:30:21 +0000 (15:30 +0100)
Provide the new functions which we will eventually use everywhere.

* Introduce restrictflight_arg which can be used in an argument loop.
* Introduce restrictflight_cond which generates a SQL condition.
* Have restrictflight_cond's value include surrounding ( ) for safety.
* Use the above in sg-report-host-history, renaming $maxflightcond.

No overall functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Osstest/Executive.pm
sg-report-host-history

index ec41ca14e4f8d60fe360375bde9fb2642f75627b..05a7268a0c8c8c13ea75aa6cfc105fc60036e522 100644 (file)
@@ -46,6 +46,7 @@ BEGIN {
     @ISA         = qw(Exporter);
     @EXPORT      = qw(get_harness_rev grabrepolock_reexec
                       findtask @all_lock_tables
+                      restrictflight_arg restrictflight_cond
                       $maxflight
                       report_run_getinfo report_altcolour
                       report_blessingscond report_find_push_age_info
@@ -196,6 +197,20 @@ sub opendb ($) {
 
 our $maxflight;
 
+sub restrictflight_arg ($) {
+    my ($arg) = @_;
+    if ($arg =~ m/^--max-flight\=([1-9]\d*)$/) {
+       $maxflight = $1;
+       return 1;
+    } else {
+       return 0;
+    }
+}
+
+sub restrictflight_cond () {
+    return defined($maxflight) ? "(flight <= $maxflight)" : "TRUE";
+}
+
 our $green=  '#008800';
 our $red=    '#ff8888';
 our $yellow= '#ffff00';
index be51483d4cbb64effd1fc1624f87c19025060708..79dc519e3cef3386befa8f2984ca86f238b03def 100755 (executable)
@@ -44,8 +44,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
         $$1= $2;
     } elsif (m/^--flight-limit\=([1-9]\d*)$/) {
        $flightlimit= $1;
-    } elsif (m/^--max-flight\=([1-9]\d*)$/) {
-       $maxflight= $1;
+    } elsif (restrictflight_arg($_)) {
+       # handled by Executive
     } elsif (m/^--blessings?=(.*)$/) {
         push @blessings, split ',', $1;
     } elsif (m/^--html-dir=(.*)$/) {
@@ -61,7 +61,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
 
 @ARGV or die $!;
 
-our $maxflightcond = defined($maxflight) ? "flight <= $maxflight" : "TRUE";
+our $restrictflight_cond = restrictflight_cond();
 our $flightcond;
 
 sub computeflightsrange () {
@@ -88,7 +88,7 @@ END
          FROM (
            SELECT flight
              FROM flights
-             WHERE $maxflightcond
+             WHERE $restrictflight_cond
             ORDER BY flight DESC
             LIMIT $flightlimit
          ) f
@@ -120,7 +120,7 @@ sub mainquery () {
         WHERE $namecond
           AND ($valcond)
           AND $flightcond
-           AND $maxflightcond
+           AND $restrictflight_cond
         ORDER BY flight DESC
         LIMIT ($limit * 3 + 100) * ?
 END