cs-ajust-flight: Use qr{} syntax
PATCH 1/4 cs-ajust-flight: Use qr{} syntax
This is more regular and potentially more efficient, but has no functional change.
--- cs-adjust-flight | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
cs-adjust-flight +3 -3
@@ -84,9 +84,9 @@ our $dstflight; sub spec_re ($) { my ($spec) = @_; - if ($spec eq '.') { return '(?:)'; } - if ($spec =~ m/^\^/) { return $spec; } - if ($spec =~ m/^\//) { return $'; } #';} + if ($spec eq '.') { return qr{(?:)}; } + if ($spec =~ m/^\^/) { return qr{$spec}; } + if ($spec =~ m/^\//) { return qr{$'}; } #';} return undef; }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/4 cs-adjust-flight: Lift notspec_exfn out of for_things
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.
--- cs-adjust-flight | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-)
cs-adjust-flight +29 -11
@@ -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); } }
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 3/4 cs-ajust-flight: Provide runvar-build-set
In reply to Ian Jackson--- cs-adjust-flight | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
cs-adjust-flight +40 -0
@@ -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;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 4/4 ts-xtf-*: Provide for host specs on command line
In reply to Ian JacksonWithout this, it can be hard to use in ad hoc ways.
--- ts-xtf-fep | 4 +++- ts-xtf-run | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
ts-xtf-fep +3 -1
@@ -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);
ts-xtf-run +3 -1
@@ -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;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line
Quoted 5 lines · Ian Jackson
Without this, it can be hard to use in ad hoc ways.
CC Wei Liu <[email protected]>CC Andrew Cooper <[email protected]>Signed-off-by Ian Jackson <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [OSSTEST PATCH 4/4] ts-xtf-*: Provide for host specs on command line
In reply to Ian JacksonQuoted 5 lines · Ian Jackson
Without this, it can be hard to use in ad hoc ways.
CC Wei Liu <[email protected]>CC Andrew Cooper <[email protected]>Signed-off-by Ian Jackson <[email protected]>
Ian, I don't see this in master. You seem to have dropped it.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel