From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [OSSTEST PATCH 02/10] Flight restriction: Introduce restrictflight_arg and restrictflight_cond Date: Thu, 23 Jul 2015 19:19:16 +0100 Message-ID: <1437675564-16602-3-git-send-email-ian.jackson@eu.citrix.com> References: <1437675564-16602-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZIL6c-00084M-GB for xen-devel@lists.xenproject.org; Thu, 23 Jul 2015 18:20:30 +0000 In-Reply-To: <1437675564-16602-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org 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 --- 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