|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH 02/10] Flight restriction: Introduce restrictflight_arg and restrictflight_cond
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@xxxxxxxxxxxxx>
---
Osstest/Executive.pm | 15 +++++++++++++++
sg-report-host-history | 10 +++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index ec41ca1..05a7268 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -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';
diff --git a/sg-report-host-history b/sg-report-host-history
index be51483..79dc519 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -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
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |