From 1c7d6584a7811b7785ae5c1e378f14b5ba0971cf Mon Sep 17 00:00:00 2001 From: takeshi_hoshina Date: Mon, 2 Nov 2020 11:07:33 +0900 Subject: basesystem-jj recipes --- external/poky/meta/lib/oeqa/runtime/cases/ptest.py | 33 +++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'external/poky/meta/lib/oeqa/runtime/cases/ptest.py') diff --git a/external/poky/meta/lib/oeqa/runtime/cases/ptest.py b/external/poky/meta/lib/oeqa/runtime/cases/ptest.py index 2a28ca59..ef0470da 100644 --- a/external/poky/meta/lib/oeqa/runtime/cases/ptest.py +++ b/external/poky/meta/lib/oeqa/runtime/cases/ptest.py @@ -1,22 +1,38 @@ +# +# SPDX-License-Identifier: MIT +# + +import os import unittest import pprint import datetime from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends -from oeqa.core.decorator.oeid import OETestID from oeqa.core.decorator.data import skipIfNotFeature from oeqa.runtime.decorator.package import OEHasPackage from oeqa.utils.logparser import PtestParser class PtestRunnerTest(OERuntimeTestCase): - @OETestID(1600) @skipIfNotFeature('ptest', 'Test requires ptest to be in DISTRO_FEATURES') @OETestDepends(['ssh.SSHTest.test_ssh']) @OEHasPackage(['ptest-runner']) @unittest.expectedFailure - def test_ptestrunner(self): + def test_ptestrunner_expectfail(self): + if not self.td.get('PTEST_EXPECT_FAILURE'): + self.skipTest('Cannot run ptests with @expectedFailure as ptests are required to pass') + self.do_ptestrunner() + + @skipIfNotFeature('ptest', 'Test requires ptest to be in DISTRO_FEATURES') + @OETestDepends(['ssh.SSHTest.test_ssh']) + @OEHasPackage(['ptest-runner']) + def test_ptestrunner_expectsuccess(self): + if self.td.get('PTEST_EXPECT_FAILURE'): + self.skipTest('Cannot run ptests without @expectedFailure as ptests are expected to fail') + self.do_ptestrunner() + + def do_ptestrunner(self): status, output = self.target.run('which ptest-runner', 0) if status != 0: self.skipTest("No -ptest packages are installed in the image") @@ -26,6 +42,10 @@ class PtestRunnerTest(OERuntimeTestCase): # testdata.json is generated. if not test_log_dir: test_log_dir = os.path.join(self.td.get('WORKDIR', ''), 'testimage') + # Make the test output path absolute, otherwise the output content will be + # created relative to current directory + if not os.path.isabs(test_log_dir): + test_log_dir = os.path.join(self.td.get('TOPDIR', ''), test_log_dir) # Don't use self.td.get('DATETIME'), it's from testdata.json, not # up-to-date, and may cause "File exists" when re-reun. timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S') @@ -65,8 +85,13 @@ class PtestRunnerTest(OERuntimeTestCase): extras[testname] = {'status': result} failed_tests = {} + + for section in sections: + if 'exitcode' in sections[section].keys(): + failed_tests[section] = sections[section]["log"] + for section in results: - failed_testcases = [ "_".join(test.translate(trans).split()) for test in results[section] if results[section][test] == 'fail' ] + failed_testcases = [ "_".join(test.translate(trans).split()) for test in results[section] if results[section][test] == 'FAILED' ] if failed_testcases: failed_tests[section] = failed_testcases -- cgit 1.2.3-korg