diff options
Diffstat (limited to 'import-layers/yocto-poky/meta/lib/oeqa/runtime')
6 files changed, 97 insertions, 109 deletions
diff --git a/import-layers/yocto-poky/meta/lib/oeqa/runtime/case.py b/import-layers/yocto-poky/meta/lib/oeqa/runtime/case.py index c1485c986..2f190acf1 100644 --- a/import-layers/yocto-poky/meta/lib/oeqa/runtime/case.py +++ b/import-layers/yocto-poky/meta/lib/oeqa/runtime/case.py @@ -8,10 +8,10 @@ class OERuntimeTestCase(OETestCase): # target instance set by OERuntimeTestLoader. target = None - def _oeSetUp(self): - super(OERuntimeTestCase, self)._oeSetUp() + def setUp(self): + super(OERuntimeTestCase, self).setUp() install_package(self) - def _oeTearDown(self): - super(OERuntimeTestCase, self)._oeTearDown() + def tearDown(self): + super(OERuntimeTestCase, self).tearDown() uninstall_package(self) diff --git a/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/_ptest.py b/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/_ptest.py deleted file mode 100644 index aaed9a535..000000000 --- a/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/_ptest.py +++ /dev/null @@ -1,103 +0,0 @@ -import os -import shutil -import subprocess - -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 skipIfNotDataVar, skipIfNotFeature -from oeqa.runtime.decorator.package import OEHasPackage - -from oeqa.runtime.cases.dnf import DnfTest -from oeqa.utils.logparser import * -from oeqa.utils.httpserver import HTTPService - -class PtestRunnerTest(DnfTest): - - @classmethod - def setUpClass(cls): - rpm_deploy = os.path.join(cls.tc.td['DEPLOY_DIR'], 'rpm') - cls.repo_server = HTTPService(rpm_deploy, cls.tc.target.server_ip) - cls.repo_server.start() - - @classmethod - def tearDownClass(cls): - cls.repo_server.stop() - - # a ptest log parser - def parse_ptest(self, logfile): - parser = Lparser(test_0_pass_regex="^PASS:(.+)", - test_0_fail_regex="^FAIL:(.+)", - section_0_begin_regex="^BEGIN: .*/(.+)/ptest", - section_0_end_regex="^END: .*/(.+)/ptest") - parser.init() - result = Result() - - with open(logfile, errors='replace') as f: - for line in f: - result_tuple = parser.parse_line(line) - if not result_tuple: - continue - result_tuple = line_type, category, status, name = parser.parse_line(line) - - if line_type == 'section' and status == 'begin': - current_section = name - continue - - if line_type == 'section' and status == 'end': - current_section = None - continue - - if line_type == 'test' and status == 'pass': - result.store(current_section, name, status) - continue - - if line_type == 'test' and status == 'fail': - result.store(current_section, name, status) - continue - - result.sort_tests() - return result - - def _install_ptest_packages(self): - # Get ptest packages that can be installed in the image. - packages_dir = os.path.join(self.tc.td['DEPLOY_DIR'], 'rpm') - ptest_pkgs = [pkg[:pkg.find('-ptest')+6] - for _, _, filenames in os.walk(packages_dir) - for pkg in filenames - if 'ptest' in pkg - and pkg[:pkg.find('-ptest')] in self.tc.image_packages] - - repo_url = 'http://%s:%s' % (self.target.server_ip, - self.repo_server.port) - dnf_options = ('--repofrompath=oe-ptest-repo,%s ' - '--nogpgcheck ' - 'install -y' % repo_url) - self.dnf('%s %s ptest-runner' % (dnf_options, ' '.join(ptest_pkgs))) - - @skipIfNotFeature('package-management', - 'Test requires package-management to be in DISTRO_FEATURES') - @skipIfNotFeature('ptest', - 'Test requires package-management to be in DISTRO_FEATURES') - @skipIfNotDataVar('IMAGE_PKGTYPE', 'rpm', - 'RPM is not the primary package manager') - @OEHasPackage(['dnf']) - @OETestDepends(['ssh.SSHTest.test_ssh']) - def test_ptestrunner(self): - self.ptest_log = os.path.join(self.tc.td['TEST_LOG_DIR'], - 'ptest-%s.log' % self.tc.td['DATETIME']) - self._install_ptest_packages() - - (runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0) - #exit code is !=0 even if ptest-runner executes because some ptest tests fail. - self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!") - self.target.copyFrom('/tmp/ptest.log', self.ptest_log) - shutil.copyfile(self.ptest_log, "ptest.log") - - result = self.parse_ptest("ptest.log") - log_results_to_location = "./results" - if os.path.exists(log_results_to_location): - shutil.rmtree(log_results_to_location) - os.makedirs(log_results_to_location) - - result.log_as_files(log_results_to_location, test_status = ['pass','fail']) diff --git a/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/buildcpio.py b/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/buildcpio.py index 59edc9c2c..79b22d04d 100644 --- a/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/buildcpio.py +++ b/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/buildcpio.py @@ -9,8 +9,7 @@ class BuildCpioTest(OERuntimeTestCase): @classmethod def setUpClass(cls): - uri = 'https://ftp.gnu.org/gnu/cpio' - uri = '%s/cpio-2.12.tar.bz2' % uri + uri = 'https://downloads.yoctoproject.org/mirror/sources/cpio-2.12.tar.gz' cls.project = TargetBuildProject(cls.tc.target, uri, dl_dir = cls.tc.td['DL_DIR']) diff --git a/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/parselogs.py b/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/parselogs.py index 6e929469c..1f36c6108 100644 --- a/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/parselogs.py +++ b/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/parselogs.py @@ -86,9 +86,11 @@ ignore_errors = { 'qemumips' : [ 'Failed to load module "glx"', 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)', + 'cacheinfo: Failed to find cpu0 device node', ] + common_errors, 'qemumips64' : [ 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)', + 'cacheinfo: Failed to find cpu0 device node', ] + common_errors, 'qemuppc' : [ 'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]', @@ -151,6 +153,8 @@ ignore_errors = { 'failed to read out thermal zone', 'Bluetooth: hci0: Setting Intel event mask failed', 'ttyS2 - failed to request DMA', + 'Bluetooth: hci0: Failed to send firmware data (-38)', + 'atkbd serio0: Failed to enable keyboard on isa0060/serio0', ] + x86_common, 'crownbay' : x86_common, 'genericx86' : x86_common, diff --git a/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/ptest.py b/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/ptest.py new file mode 100644 index 000000000..ec8c038a5 --- /dev/null +++ b/import-layers/yocto-poky/meta/lib/oeqa/runtime/cases/ptest.py @@ -0,0 +1,82 @@ +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.utils.logparser import Lparser, Result + +class PtestRunnerTest(OERuntimeTestCase): + + # a ptest log parser + def parse_ptest(self, logfile): + parser = Lparser(test_0_pass_regex="^PASS:(.+)", + test_0_fail_regex="^FAIL:(.+)", + test_0_skip_regex="^SKIP:(.+)", + section_0_begin_regex="^BEGIN: .*/(.+)/ptest", + section_0_end_regex="^END: .*/(.+)/ptest") + parser.init() + result = Result() + + with open(logfile, errors='replace') as f: + for line in f: + result_tuple = parser.parse_line(line) + if not result_tuple: + continue + result_tuple = line_type, category, status, name = parser.parse_line(line) + + if line_type == 'section' and status == 'begin': + current_section = name + continue + + if line_type == 'section' and status == 'end': + current_section = None + continue + + if line_type == 'test' and status == 'pass': + result.store(current_section, name, status) + continue + + if line_type == 'test' and status == 'fail': + result.store(current_section, name, status) + continue + + if line_type == 'test' and status == 'skip': + result.store(current_section, name, status) + continue + + result.sort_tests() + return result + + @OETestID(1600) + @skipIfNotFeature('ptest', 'Test requires ptest to be in DISTRO_FEATURES') + @skipIfNotFeature('ptest-pkgs', 'Test requires ptest-pkgs to be in IMAGE_FEATURES') + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_ptestrunner(self): + import datetime + + test_log_dir = self.td.get('TEST_LOG_DIR', '') + # The TEST_LOG_DIR maybe NULL when testimage is added after + # testdata.json is generated. + if not test_log_dir: + test_log_dir = os.path.join(self.td.get('WORKDIR', ''), 'testimage') + # Don't use self.td.get('DATETIME'), it's from testdata.json, not + # up-to-date, and may cause "File exists" when re-reun. + datetime = datetime.datetime.now().strftime('%Y%m%d%H%M%S') + ptest_log_dir_link = os.path.join(test_log_dir, 'ptest_log') + ptest_log_dir = '%s.%s' % (ptest_log_dir_link, datetime) + ptest_runner_log = os.path.join(ptest_log_dir, 'ptest-runner.log') + + status, output = self.target.run('ptest-runner', 0) + os.makedirs(ptest_log_dir) + with open(ptest_runner_log, 'w') as f: + f.write(output) + + # status != 0 is OK since some ptest tests may fail + self.assertTrue(status != 127, msg="Cannot execute ptest-runner!") + + # Parse and save results + parse_result = self.parse_ptest(ptest_runner_log) + parse_result.log_as_files(ptest_log_dir, test_status = ['pass','fail', 'skip']) + if os.path.exists(ptest_log_dir_link): + # Remove the old link to create a new one + os.remove(ptest_log_dir_link) + os.symlink(os.path.basename(ptest_log_dir), ptest_log_dir_link) diff --git a/import-layers/yocto-poky/meta/lib/oeqa/runtime/context.py b/import-layers/yocto-poky/meta/lib/oeqa/runtime/context.py index c4cd76cf4..0294003fc 100644 --- a/import-layers/yocto-poky/meta/lib/oeqa/runtime/context.py +++ b/import-layers/yocto-poky/meta/lib/oeqa/runtime/context.py @@ -92,6 +92,12 @@ class OERuntimeTestContextExecutor(OETestContextExecutor): def getTarget(target_type, logger, target_ip, server_ip, **kwargs): target = None + if target_ip: + target_ip_port = target_ip.split(':') + if len(target_ip_port) == 2: + target_ip = target_ip_port[0] + kwargs['port'] = target_ip_port[1] + if target_type == 'simpleremote': target = OESSHTarget(logger, target_ip, server_ip, **kwargs) elif target_type == 'qemu': |