From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH OSSTEST 5/5 v3] mg-show-flight-runvars: recurse on buildjobs upon request
Date: Wed, 3 Feb 2016 12:37:33 +0000 [thread overview]
Message-ID: <1454503053-17361-1-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1454336912-28503-5-git-send-email-ian.campbell@citrix.com>
By looping over @rows looking for buildjobs runvars and adding those
jobs to the output until nothing changes.
The output is resorted by runvar name which is the desired default
behaviour. As usual can be piped to sort(1) to sort by flight+job.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
v2:
- Use $jobcond,@jobconfparams to avoid SQL injection
- Only recurse if the option was given
- Drop synth from ORDER BY
- Use a Schwatzian transform for the sort, at the same time allowing
retention of the sorting of synth runvars last.
v3:
- Fixup detection of already handle jobs to cope properly with jobs
with now rows.
- Iterate over @rows using an index var
---
mg-show-flight-runvars | 48 +++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/mg-show-flight-runvars b/mg-show-flight-runvars
index f96539f..c847456 100755
--- a/mg-show-flight-runvars
+++ b/mg-show-flight-runvars
@@ -46,19 +46,21 @@ for (;;) {
die unless @ARGV==1 && $ARGV[0] =~ m/^\w+$/;
-
our @cols = qw(job name val);
our @rows;
+our %jobs;
+
+sub collect ($;$@) {
+ my ($flight,$jobcond,@jobcondparams) = @_;
-sub collect ($) {
- my ($flight) = @_;
+ $jobcond //= "TRUE";
$flight =~ m/^\d+/ or $flight = "'$flight'";
- my $qfrom = "FROM runvars WHERE flight=$flight AND $synthcond";
+ my $qfrom = "FROM runvars WHERE flight=$flight AND $synthcond AND $jobcond";
my $q = $dbh_tests->prepare
- ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY synth, name, job");
- $q->execute();
+ ("SELECT synth, ".(join ',', @cols)." $qfrom ORDER BY name, job");
+ $q->execute(@jobcondparams);
while (my (@row) = $q->fetchrow_array()) {
my $synth = shift @row;
@@ -70,6 +72,34 @@ sub collect ($) {
collect($ARGV[0]);
+if ($recurse) {
+ # collect() appends to @rows, avoiding the need to recurse
+ # there. However this means we can't use foreach (since that is
+ # not guaranteed to work if the array is mutated under its feet),
+ # instead use an index.
+ for ( my $rowidx = 0; $rowidx < @rows ; $rowidx++ ) {
+ my $row = $rows[$rowidx];
+
+ next unless $row->[1] =~ m/^(?:.*_)?([^_]*)buildjob$/;
+
+ # parse this flight and job, which must be in $flight.$job
+ # form if $recurse is true (see collect())
+ my ($tflight, $tjob) = flight_otherjob(undef, $row->[0]);
+ die "$row->[1]" unless $tflight;
+
+ # parse the buildjob reference and recurse. might be a job in
+ # this flight, in which case we still recurse since it might
+ # be a chain from a non-top-level job which hasn't been
+ # included yet. %jobs will prevent us from duplicating or
+ # infinite loops.
+ my ($oflight, $ojob) = flight_otherjob($tflight, $row->[2]);
+
+ next if $jobs{$oflight,$ojob}++;
+
+ collect($oflight, "job = ?", $ojob);
+ }
+}
+
our @colws;
sub max ($$) { $_[$_[0] < $_[1]] }
foreach my $row (@rows) {
@@ -77,7 +107,11 @@ foreach my $row (@rows) {
}
$colws[1] += length $synthsufx;
-foreach my $row (@rows) {
+# Sort by runvar name, then (flight+)job, synth runvars come last.
+foreach my $row (map { $_->[0] }
+ sort { $a->[1] cmp $b->[1] }
+ map { [ $_, ($_->[1] =~ m/~$/)." $_->[1] $_->[0]" ] }
+ @rows) {
printf "%-*s %-*s %-*s\n", map { $colws[$_], $row->[$_] } qw(0 1 2)
or die $!;
}
--
2.6.1
next prev parent reply other threads:[~2016-02-03 12:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-01 14:28 [PATCH OSSTEST v1 0/5] mg-show-flight-runvars: recursively follow buildjob runvars Ian Campbell
2016-02-01 14:28 ` [PATCH OSSTEST v1 1/5] mg-show-flight-runvars: collect rows into @rows, output in second step Ian Campbell
2016-02-01 14:42 ` Ian Jackson
2016-02-01 14:28 ` [PATCH OSSTEST v1 2/5] mg-show-flight-runvars: move collection into a sub Ian Campbell
2016-02-01 14:55 ` Ian Jackson
2016-02-01 14:28 ` [PATCH OSSTEST v1 3/5] mg-show-flight-runvars: calculate @colsw from @rows not via SQL Ian Campbell
2016-02-01 14:56 ` Ian Jackson
2016-02-01 14:28 ` [PATCH OSSTEST v1 4/5] mg-show-flight-runvars: include $flight. prefix on job name if -r (recurse) Ian Campbell
2016-02-01 15:19 ` Ian Jackson
2016-02-01 14:28 ` [PATCH OSSTEST v1 5/5] mg-show-flight-runvars: recurse on buildjobs upon request Ian Campbell
2016-02-01 15:19 ` Ian Jackson
2016-02-01 16:16 ` Ian Campbell
2016-02-01 16:53 ` Ian Jackson
2016-02-03 9:48 ` [PATCH OSSTEST 5/5 v2] " Ian Campbell
2016-02-03 12:01 ` Ian Jackson
2016-02-03 12:37 ` Ian Campbell [this message]
2016-02-08 16:12 ` [PATCH OSSTEST 5/5 v3] " Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454503053-17361-1-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).