summaryrefslogtreecommitdiff
path: root/automated
diff options
context:
space:
mode:
authorNicolas Dechesne <nicolas.dechesne@linaro.org>2017-02-04 00:45:48 +0100
committerNicolas Dechesne <nicolas.dechesne@linaro.org>2017-03-17 12:23:24 +0100
commit51b85a8cf754a55cbebf3f3344637170eab8ce34 (patch)
treea08662f308cdae8325ea5fbbcdc6a36eac3c5ae6 /automated
parent1f2a9a0701cd3f3f3419768704d5f09800694bdf (diff)
downloadtest-definitions-pipe-51b85a8cf754a55cbebf3f3344637170eab8ce34.tar.gz
automated: test-runner: encapsulate the TestRun object into TestDef
There is no need to create an additional object in main(). Instead we can create the 'runner' object in the TestDef init() and directly invoke the run() and check_result() function. Also rename TestDefinition.run() function as TestDefinition.mkrun(). This function really generates the run script, calling it run() is confusing, as this is not where the test runs. Change-Id: I4348e1e834e7083174aa60a8f4533747e49c3757 Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-xautomated/utils/test-runner.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/automated/utils/test-runner.py b/automated/utils/test-runner.py
index 888107f..d057cad 100755
--- a/automated/utils/test-runner.py
+++ b/automated/utils/test-runner.py
@@ -155,6 +155,12 @@ class TestDefinition(object):
self.testdef = yaml.safe_load(f)
if self.testdef['metadata']['format'].startswith("Manual Test Definition"):
self.is_manual = True
+ if self.is_manual:
+ self.runner = ManualTestRun(test, args)
+ if self.args.target is None:
+ self.runner = AutomatedTestRun(test, args)
+ else:
+ self.runner = RemoteTestRun(test, args)
def definition(self):
with open('%s/testdef.yaml' % self.test['test_path'], 'w') as f:
@@ -164,7 +170,7 @@ class TestDefinition(object):
with open('%s/testdef_metadata' % self.test['test_path'], 'w') as f:
f.write(yaml.dump(self.testdef['metadata'], encoding='utf-8', allow_unicode=True))
- def run(self):
+ def mkrun(self):
if not self.is_manual:
with open('%s/run.sh' % self.test['test_path'], 'a') as f:
f.write('#!/bin/sh\n')
@@ -193,12 +199,8 @@ class TestDefinition(object):
os.chmod('%s/run.sh' % self.test['test_path'], 0755)
- def get_test_run(self):
- if self.is_manual:
- return ManualTestRun(self.test, self.args)
- if self.args.target is None:
- return AutomatedTestRun(self.test, self.args)
- return RemoteTestRun(self.test, self.args)
+ def run(self):
+ self.runner.run()
def handle_parameters(self):
ret_val = ['###default parameters from test definition###\n']
@@ -652,11 +654,10 @@ def main():
if test_def.exists:
test_def.definition()
test_def.metadata()
- test_def.run()
+ test_def.mkrun()
# Run test.
- test_run = test_def.get_test_run()
- test_run.run()
+ test_def.run()
# Parse test output, save results in json and csv format.
result_parser = ResultParser(test, args)