diff mbox

[OSSTEST,12/17] substep logfiles: Set logfile and step columns correctly for substeps

Message ID 1498839920-17025-13-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson June 30, 2017, 4:25 p.m. UTC
If we are running under sg-run-job, OSSTEST_TESTID will be set to the
testid of the parent step (ie, the step created by sg-run-job which
relates to the execution of the whole script).

Unless the caller has specified otherwise, the log and script are
the same as for the parent step.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/JobDB/Executive.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/Osstest/JobDB/Executive.pm b/Osstest/JobDB/Executive.pm
index e1e2052..a7a6696 100644
--- a/Osstest/JobDB/Executive.pm
+++ b/Osstest/JobDB/Executive.pm
@@ -254,6 +254,19 @@  END
                            status,testid,started)
             VALUES (?,?,?,?, ?, 'running',?,?)
 END
+    my $parent_testid = $ENV{OSSTEST_TESTID};
+    if ((!defined $logfile || !defined $script) && defined $parent_testid) {
+	my $parentq = $dbh_tests->prepare(<<END);
+            SELECT logfile, step FROM steps
+             WHERE flight=? AND job=? AND testid=?
+END
+	db_retry($flight,[qw(running)], $dbh_tests,[],sub {
+            $parentq->execute($flight,$job,$parent_testid);
+            my $row = $parentq->fetchrow_hashref();
+	    $logfile //= $row->{logfile};
+	    $script //= $row->{script};
+	});
+    }
     if (!defined $script) {
 	$script = $0;
 	$script =~ s{^.*/}{};