* [OSSTEST PATCH 2/4] cs-adjust-flight: Lift notspec_exfn out of for_things
2016-12-02 11:55 [OSSTEST PATCH 1/4] cs-ajust-flight: Use qr{} syntax Ian Jackson
@ 2016-12-02 11:55 ` Ian Jackson
2016-12-02 11:55 ` [OSSTEST PATCH 3/4] cs-ajust-flight: Provide runvar-build-set Ian Jackson
2016-12-02 11:55 ` [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line Ian Jackson
2 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2016-12-02 11:55 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Jackson
We are going to want to reuse this, so abstract it away.
As a side effect we now support negated exact matches.
No other functional change, except to debug output.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
cs-adjust-flight | 40 +++++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 11 deletions(-)
diff --git a/cs-adjust-flight b/cs-adjust-flight
index 02fd2cf..33ff9df 100755
--- a/cs-adjust-flight
+++ b/cs-adjust-flight
@@ -90,6 +90,28 @@ sub spec_re ($) {
return undef;
}
+sub notspec_exfn ($$) {
+ my ($what, $spec) = @_;
+ # returns ($fn, $exact)
+ # where $exact is undef, or a thing that can be tested with eq
+ # and $fn->($candidate) will be boolish
+ my $not = ($spec =~ s/^\!//) ? 'NOT' : '';
+ my $re = spec_re($spec);
+ debug("$what $not \`$spec' RE ",
+ (defined($re) ? "/$re/" : "<undef>"), "\n");
+ if (defined $re) {
+ debug("$what REMATCHER\n");
+ return (sub { $_[0] =~ qr{$re} xor $not },
+ undef);
+ } elsif ($not) {
+ return (sub { $_[0] ne $spec },
+ undef);
+ } else {
+ return (sub { $_[0] eq $spec },
+ $spec);
+ }
+}
+
sub debug { print STDERR @_ if $debug; }
sub verbose (@) { $verbose_buffer .= $_ foreach @_; }
@@ -109,20 +131,16 @@ sub for_things ($$$$$$$) {
my $things_q = $things_q{$table} ||= $dbh_tests->prepare
("SELECT * FROM $table WHERE $basecond");
- my $not = ($spec =~ s/^\!//) ? 'NOT' : '';
- my $re = spec_re($spec);
- debug("FOR_THINGS $table.$keycol $not \`$spec' RE ",
- (defined($re) ? "/$re/" : "<undef>"), "\n");
- if (!defined $re) {
- die "cannot negate <foo-name>" if $not;
- $thing_q->execute(@$basecondvals, $spec);
+ my ($specfn,$exact) = notspec_exfn("FOR_THINGS $table.$keycol",$spec);
+ if (defined $exact) {
+ $thing_q->execute(@$basecondvals, $exact);
my $row = $thing_q->fetchrow_hashref();
if ($row) {
debug("FOR_THINGS $table.$keycol \`$spec' EXACT\n");
- $fn->($spec,$row);
+ $fn->($exact,$row);
} elsif ($ifnone) {
debug("FOR_THINGS $table.$keycol \`$spec' MISSING REPORT\n");
- $ifnone->($spec);
+ $ifnone->($exact);
} else {
debug("FOR_THINGS $table.$keycol \`$spec' MISSING IGNORED\n");
}
@@ -130,8 +148,8 @@ sub for_things ($$$$$$$) {
$things_q->execute(@$basecondvals);
while (my $row = $things_q->fetchrow_hashref()) {
my $thing = $row->{$keycol};
- next unless $thing =~ m/$re/ xor $not;
- debug("FOR_THINGS $table.$keycol $not \`$spec' FOUND $row->{$keycol}\n");
+ next unless $specfn->($thing);
+ debug("FOR_THINGS $table.$keycol \`$spec' FOUND $row->{$keycol}\n");
$fn->($thing, $row);
}
}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread* [OSSTEST PATCH 3/4] cs-ajust-flight: Provide runvar-build-set
2016-12-02 11:55 [OSSTEST PATCH 1/4] cs-ajust-flight: Use qr{} syntax Ian Jackson
2016-12-02 11:55 ` [OSSTEST PATCH 2/4] cs-adjust-flight: Lift notspec_exfn out of for_things Ian Jackson
@ 2016-12-02 11:55 ` Ian Jackson
2016-12-02 11:55 ` [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line Ian Jackson
2 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2016-12-02 11:55 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Jackson
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
cs-adjust-flight | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/cs-adjust-flight b/cs-adjust-flight
index 33ff9df..45c1420 100755
--- a/cs-adjust-flight
+++ b/cs-adjust-flight
@@ -14,6 +14,7 @@
# runvar-del <job-spec> <var-spec>
# runvar-change <job-spec> <var-spec> <old-value> <new-value>
# runvar-perlop <job-spec> <var-spec> <perl-expr>
+# runvar-build-set <job-spec> <var-spec> <old-value> <flight>[.<job>]
# recipe-set <job-spec> <new-value>
# intended-blessing <intended-blessing>
# branch-set <new-branch>
@@ -26,6 +27,12 @@
# ^<pcre> means $foo =~ m/^<pcre>/
# /<pcre> means $foo =~ m/<pcre>/
#
+# runvar-build-set always only affects runvars m/buildjob$/
+# and may be further limited by <var-spec>;
+# and, <old-value> is matched against a value
+# containing the being-manipulated flight name
+# even if the actual runvar value omits it
+#
# <dst-flight>:
# <flight>
# new:<intended-blessing>
@@ -335,6 +342,39 @@ sub change__runvar_perlop {
}, 'IGNORE');
}
+sub change__runvar_build_set {
+ die unless @changes >= 4;
+ my $jobs = shift @changes;
+ my $vars = shift @changes;
+ my $specoldval = shift @changes;
+ my $specval = shift @changes;
+
+ my $matches=0;
+
+ my ($oldvalok_fn) = notspec_exfn(
+ "RUNVAR-BUILD-SET '$jobs' '$vars' SPECOLDVAL",
+ $specoldval);
+
+ for_runvars($jobs, $vars, sub {
+ my ($job, $name, $varrow) = @_;
+ return unless $name =~ m/buildjob$/;
+
+ my $oldval = $varrow->{val};
+ $oldval = flight_otherjob($dstflight,$oldval);
+ return unless $oldvalok_fn->($oldval);
+
+ $matches++;
+ $oldval =~ s/^\d+\.//; # strip out previous flight
+ my $newval = $specval =~ m/\./ ? $specval : "$specval.$oldval";
+ runvar_set($job, $name, $newval, " (modified from \`$oldval')")
+ if $newval ne $oldval;
+ }, 'IGNORE');
+
+ print STDERR
+ "runvar-build-set '$jobs' '$vars' '$specoldval' matched nothing!\n"
+ unless $matches;
+}
+
sub change__recipe_set {
die unless @changes >= 2;
my $jobs = shift @changes;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread* [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line
2016-12-02 11:55 [OSSTEST PATCH 1/4] cs-ajust-flight: Use qr{} syntax Ian Jackson
2016-12-02 11:55 ` [OSSTEST PATCH 2/4] cs-adjust-flight: Lift notspec_exfn out of for_things Ian Jackson
2016-12-02 11:55 ` [OSSTEST PATCH 3/4] cs-ajust-flight: Provide runvar-build-set Ian Jackson
@ 2016-12-02 11:55 ` Ian Jackson
2016-12-02 11:57 ` Wei Liu
2017-02-05 16:42 ` Wei Liu
2 siblings, 2 replies; 6+ messages in thread
From: Ian Jackson @ 2016-12-02 11:55 UTC (permalink / raw)
To: xen-devel; +Cc: Wei Liu, Ian Jackson, Andrew Cooper
Without this, it can be hard to use in ad hoc ways.
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
ts-xtf-fep | 4 +++-
ts-xtf-run | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/ts-xtf-fep b/ts-xtf-fep
index 6f0037a..91ac3ce 100755
--- a/ts-xtf-fep
+++ b/ts-xtf-fep
@@ -22,7 +22,9 @@ use Osstest::TestSupport;
tsreadconfig();
-our $ho = selecthost('host');
+our ($whhost) = @ARGV;
+$whhost ||= 'host';
+our $ho= selecthost($whhost);
sub fep_test () {
my $output = target_cmd_output_root($ho, <<END);
diff --git a/ts-xtf-run b/ts-xtf-run
index 2e69b27..d405bfb 100755
--- a/ts-xtf-run
+++ b/ts-xtf-run
@@ -22,7 +22,9 @@ use Osstest::TestSupport;
tsreadconfig();
-our $ho = selecthost('host');
+our ($whhost) = @ARGV;
+$whhost ||= 'host';
+our $ho= selecthost($whhost);
our $runner = "/home/xtf/xtf-runner";
our @tests;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line
2016-12-02 11:55 ` [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line Ian Jackson
@ 2016-12-02 11:57 ` Wei Liu
2017-02-05 16:42 ` Wei Liu
1 sibling, 0 replies; 6+ messages in thread
From: Wei Liu @ 2016-12-02 11:57 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel, Wei Liu, Andrew Cooper
On Fri, Dec 02, 2016 at 11:55:40AM +0000, Ian Jackson wrote:
> Without this, it can be hard to use in ad hoc ways.
>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line
2016-12-02 11:55 ` [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line Ian Jackson
2016-12-02 11:57 ` Wei Liu
@ 2017-02-05 16:42 ` Wei Liu
1 sibling, 0 replies; 6+ messages in thread
From: Wei Liu @ 2017-02-05 16:42 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel, Wei Liu, Andrew Cooper
On Fri, Dec 02, 2016 at 11:55:40AM +0000, Ian Jackson wrote:
> Without this, it can be hard to use in ad hoc ways.
>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Ian, I don't see this in master. You seem to have dropped it.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread