summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-09-21 16:44:30 +0800
committerChase Qi <chase.qi@linaro.org>2017-09-21 18:15:23 +0800
commitea54335d54fa362659eff545857c1d0aae9d5045 (patch)
tree93321bb6a195a7133a34444d369a53566ee3cbaa
parentaf0bab1f4da3286a878266d4f2451c46c287d252 (diff)
test-runner: add support for remote execution in LAVA
When '-l' or '--lava_run' option specified, test-runner will use lava-test-case to send result to LAVA. It might be possible to detect if it is running in LAVA at running time by checking if 'lava-test-case' exists, but that is not reliable as local environment can also has the util installed. So the above option introduced with 'False' as default value. Change-Id: Ief0c9e75d12c07832214d2d4fa30836df964615a Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-xautomated/utils/test-runner.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/automated/utils/test-runner.py b/automated/utils/test-runner.py
index 5562d64..7783850 100755
--- a/automated/utils/test-runner.py
+++ b/automated/utils/test-runner.py
@@ -13,6 +13,7 @@ import sys
import textwrap
import time
from uuid import uuid4
+from distutils.spawn import find_executable
try:
@@ -624,6 +625,10 @@ class ResultParser(object):
test_version = subprocess.check_output("git rev-parse HEAD", shell=True).decode('utf-8')
self.results['version'] = test_version.rstrip()
os.chdir(path)
+ self.lava_run = args.lava_run
+ if self.lava_run and not find_executable('lava-test-case'):
+ self.logger.info("lava-test-case not found, '-l' or '--lava_run' option ignored'")
+ self.lava_run = False
def run(self):
self.parse_stdout()
@@ -670,6 +675,9 @@ class ResultParser(object):
self.metrics.append(data.copy())
+ if self.lava_run:
+ self.send_to_lava(data)
+
def parse_pattern(self):
with open('%s/stdout.log' % self.test['test_path'], 'r') as f:
for line in f:
@@ -685,6 +693,16 @@ class ResultParser(object):
self.metrics.append(data.copy())
+ if self.lava_run:
+ self.send_to_lava(data)
+
+ def send_to_lava(self, data):
+ cmd = 'lava-test-case {} --result {}'.format(data['test_case_id'], data['result'])
+ if data['measurement']:
+ cmd = '{} --measurement {} --units {}'.format(cmd, data['measurement'], data['units'])
+ self.logger.debug('lava-run: cmd: {}'.format(cmd))
+ subprocess.call(shlex.split(cmd))
+
def dict_to_json(self):
# Save test results to output/test_id/result.json
with open('%s/result.json' % self.test['test_path'], 'w') as f:
@@ -777,6 +795,9 @@ def get_args():
parser.add_argument('-e', '--skip_environment', dest='skip_environment',
default=False, action='store_true',
help='skip environmental data collection (board name, distro, etc)')
+ parser.add_argument('-l', '--lava_run', dest='lava_run',
+ default=False, action='store_true',
+ help='send test result to LAVA with lava-test-case.')
args = parser.parse_args()
return args