Fix bug in hftest.py
Previous CL Ib4855281456d27627b9a5c6c7642a6cd5519b64f refactored
hftest.py but left a function call unresolved. When a test failed,
code which printed path to the log would throw. Fix the problem.
Test: modify test to fail, run ./kokoru/ubuntu/build.sh
Change-Id: I653a0410e4064ce45c729d1bac63ecce76d5c384
diff --git a/test/hftest/hftest.py b/test/hftest/hftest.py
index 99699b7..4192cef 100755
--- a/test/hftest/hftest.py
+++ b/test/hftest/hftest.py
@@ -78,12 +78,16 @@
self.sponge_log_path = self.create_file("sponge_log", ".log")
self.sponge_xml_path = self.create_file("sponge_log", ".xml")
+ def gen_file_path(self, basename, extension):
+ """Generate path to a file in the log directory."""
+ return os.path.join(self.log_dir, basename + extension)
+
def create_file(self, basename, extension):
"""Create and touch a new file in the log folder. Ensure that no other
file of the same name was created by this instance of ArtifactsManager.
"""
# Determine the path of the file.
- path = os.path.join(self.log_dir, basename + extension)
+ path = self.gen_file_path(basename, extension)
# Check that the path is unique.
assert(path not in self.created_files)
@@ -95,6 +99,13 @@
return path
+ def get_file(self, basename, extension):
+ """Return path to a file in the log folder. Assert that it was created
+ by this instance of ArtifactsManager."""
+ path = self.gen_file_path(basename, extension)
+ assert(path in self.created_files)
+ return path
+
# Tuple holding the arguments common to all driver constructors.
# This is to avoid having to pass arguments from subclasses to superclasses.
@@ -119,6 +130,10 @@
def __init__(self, args):
self.args = args
+ def get_run_log(self, run_name):
+ """Return path to the main log of a given test run."""
+ return self.args.artifacts.get_file(run_name, ".log")
+
def start_run(self, run_name):
"""Hook called by Driver subclasses before they invoke the target
platform."""
@@ -369,7 +384,7 @@
print(" PASS")
return TestRunnerResult(tests_run=1, tests_failed=0)
else:
- print("[x] FAIL --", self.driver.file_path(log_name))
+ print("[x] FAIL --", self.driver.get_run_log(log_name))
failure_xml = ET.SubElement(test_xml, "failure")
# TODO: set a meaningful message and put log in CDATA
failure_xml.set("message", "Test failed")