From 41e4db0eeaaa19f9f4d425960011b02c29f01c1c Mon Sep 17 00:00:00 2001 From: Mariano Lopez Date: Tue, 3 Jan 2017 08:18:00 +0000 Subject: runtime/cases/smart.py: Migrate smart tests This migrates the smart test from the old framework to the new one. This has its own commit because smart test was using bb and oe libraries that are available when exporting the test cases to run in a different host. Because of the removal of bb and oe libraries index and packages feeds creation will be managed in testimage bbclass. [YOCTO #10234] (From OE-Core rev: 8d64ac4208e8dcb8a6fde6ea2959c9b3edfe2172) Signed-off-by: Mariano Lopez Signed-off-by: Richard Purdie --- meta/classes/testimage.bbclass | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'meta/classes') diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 016c1c136a..abcecca472 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass @@ -116,6 +116,10 @@ python do_testimage() { testimage_sanity(d) + if (d.getVar('IMAGE_PKGTYPE') == 'rpm' + and 'smart' in d.getVar('TEST_SUITES')): + create_rpm_index(d) + testimage_main(d) } @@ -284,6 +288,55 @@ def get_runtime_paths(d): paths.append(path) return paths +def create_index(arg): + import subprocess + + index_cmd = arg + try: + bb.note("Executing '%s' ..." % index_cmd) + result = subprocess.check_output(index_cmd, + stderr=subprocess.STDOUT, + shell=True) + result = result.decode('utf-8') + except subprocess.CalledProcessError as e: + return("Index creation command '%s' failed with return code " + '%d:\n%s' % (e.cmd, e.returncode, e.output.decode("utf-8"))) + if result: + bb.note(result) + return None + +def create_rpm_index(d): + # Index RPMs + rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo") + index_cmds = [] + archs = (d.getVar('ALL_MULTILIB_PACKAGE_ARCHS') or '').replace('-', '_') + + for arch in archs.split(): + rpm_dir = os.path.join(d.getVar('DEPLOY_DIR_RPM'), arch) + idx_path = os.path.join(d.getVar('WORKDIR'), 'rpm', arch) + db_path = os.path.join(d.getVar('WORKDIR'), 'rpmdb', arch) + + if not os.path.isdir(rpm_dir): + continue + if os.path.exists(db_path): + bb.utils.remove(dbpath, True) + + lockfilename = os.path.join(d.getVar('DEPLOY_DIR_RPM'), 'rpm.lock') + lf = bb.utils.lockfile(lockfilename, False) + oe.path.copyhardlinktree(rpm_dir, idx_path) + # Full indexes overload a 256MB image so reduce the number of rpms + # in the feed. Filter to p* since we use the psplash packages and + # this leaves some allarch and machine arch packages too. + bb.utils.remove(idx_path + "*/[a-oq-z]*.rpm") + bb.utils.unlockfile(lf) + cmd = '%s --dbpath %s --update -q %s' % (rpm_createrepo, + db_path, idx_path) + + # Create repodata + result = create_index(cmd) + if result: + bb.fatal('%s' % ('\n'.join(result))) + def test_create_extract_dirs(d): install_path = d.getVar("TEST_INSTALL_TMP_DIR") package_path = d.getVar("TEST_PACKAGED_DIR") -- cgit v1.2.3-54-g00ecf