diff options
-rw-r--r-- | meta-selftest/recipes-test/postinst/postinst_1.0.bb | 124 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/runtime-test.py | 49 |
2 files changed, 173 insertions, 0 deletions
diff --git a/meta-selftest/recipes-test/postinst/postinst_1.0.bb b/meta-selftest/recipes-test/postinst/postinst_1.0.bb new file mode 100644 index 00000000000..403462e7f2c --- /dev/null +++ b/meta-selftest/recipes-test/postinst/postinst_1.0.bb @@ -0,0 +1,124 @@ +LICENSE = "MIT" + +ALLOW_EMPTY_${PN} = "1" +ALLOW_EMPTY_${PN}-a = "1" +ALLOW_EMPTY_${PN}-b = "1" +ALLOW_EMPTY_${PN}-d = "1" +ALLOW_EMPTY_${PN}-p = "1" +ALLOW_EMPTY_${PN}-t = "1" + +PACKAGES =+ "${PN}-a ${PN}-b ${PN}-d ${PN}-p ${PN}-t" +FILES_${PN}-a = "" +FILES_${PN}-b = "" +FILES_${PN}-d = "" +FILES_${PN}-p = "" +FILES_${PN}-t = "" + +# Runtime dependencies +RDEPENDS_${PN}-a = "${PN}" +RDEPENDS_${PN}-b = "${PN}-a" +RDEPENDS_${PN}-d = "${PN}-b" +RDEPENDS_${PN}-p = "${PN}-d" +RDEPENDS_${PN}-t = "${PN}-p" + +# Main recipe post-install +pkg_postinst_${PN} () { + tfile="/etc/postinsta-test" + if test "x$D" != "x" then + # Need to run on first boot + exit 1 + else + echo "lets write postinst" > $tfile + fi +} + +# Dependency recipes post-installs +pkg_postinst_${PN}-a () { + efile="/etc/postinst-test" + tfile="/etc/postinsta-test" + rdeps="postinst" + + if test "x$D" != "x"; then + # Need to run on first boot + exit 1 + else + if test -e $efile ; then + echo 'success' > $tfile + else + echo 'fail to install $rdeps first!' >&2 + exit 1 + fi + fi +} + +pkg_postinst_${PN}-b () { + efile="/etc/postinsta-test" + tfile="/etc/postinstb-test" + rdeps="postinsta" + + if test "x$D" != "x"; then + # Need to run on first boot + exit 1 + else + if test -e $efile ; then + echo 'success' > $tfile + else + echo 'fail to install $rdeps first!' >&2 + exit 1 + fi + fi +} + +pkg_postinst_${PN}-d () { + efile="/etc/postinstb-test" + tfile="/etc/postinstd-test" + rdeps="postinstb" + + if test "x$D" != "x"; then + # Need to run on first boot + exit 1 + else + if test -e $efile ; then + echo 'success' > $tfile + else + echo 'fail to install $rdeps first!' >&2 + exit 1 + fi + fi +} + +pkg_postinst_${PN}-p () { + efile="/etc/postinstd-test" + tfile="/etc/postinstp-test" + rdeps="postinstd" + + if test "x$D" != "x"; then + # Need to run on first boot + exit 1 + else + if test -e $efile ; then + echo 'success' > $tfile + else + echo 'fail to install $rdeps first!' >&2 + exit 1 + fi + fi +} + +pkg_postinst_${PN}-t () { + efile="/etc/postinstp-test" + tfile="/etc/postinstt-test" + rdeps="postinstp" + + if test "x$D" != "x"; then + # Need to run on first boot + exit 1 + else + if test -e $efile ; then + echo 'success' > $tfile + else + echo 'fail to install $rdeps first!' >&2 + exit 1 + fi + fi +} diff --git a/meta/lib/oeqa/selftest/runtime-test.py b/meta/lib/oeqa/selftest/runtime-test.py index c2d5b45a4b1..1df7f7039ad 100644 --- a/meta/lib/oeqa/selftest/runtime-test.py +++ b/meta/lib/oeqa/selftest/runtime-test.py @@ -2,6 +2,7 @@ from oeqa.selftest.base import oeSelfTest from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu from oeqa.utils.decorators import testcase import os +import re class TestExport(oeSelfTest): @@ -103,3 +104,51 @@ class TestImage(oeSelfTest): # Build core-image-sato and testimage bitbake('core-image-full-cmdline socat') bitbake('-c testimage core-image-full-cmdline') + +class Postinst(oeSelfTest): + def test_verify_postinst(self): + """ + Summary: The purpose of this test is to verify the execution order of postinst Bugzilla ID: [5319] + Expected 1. Compile a minimal image. + 1. The compiled image will add the created layer with the recipes postinst[ abdpt] + 2. Run qemux86 + 3. Validate the task execution order + """ + features = 'INHERIT += "testimage"\n' + features += 'CORE_IMAGE_EXTRA_INSTALL += "postinst \ +postinst-a \ +postinst-b \ +postinst-d \ +postinst-p \ +postinst-t \ +"\n' + self.write_config(features) + + bitbake('core-image-minimal -f ') + + postinst_list = ['100-postinst', + '101-postinst-a', + '102-postinst-b', + '103-postinst-d', + '104-postinst-p', + '105-postinst-t'] + path_workdir = get_bb_var('WORKDIR','core-image-minimal') + workspacedir = 'testimage/qemu_boot_log' + workspacedir = os.path.join(path_workdir, workspacedir) + rexp = re.compile("^Running postinst .*/(?P<postinst>.*)\.\.\.$") + with runqemu('core-image-minimal') as qemu: + with open(workspacedir) as f: + found = False + idx = 0 + for line in f.readlines(): + line = line.strip().replace("^M","") + if not line: # To avoid empty lines + continue + m = rexp.search(line) + if m: + self.assertEqual(postinst_list[idx], m.group('postinst'), "Fail") + idx = idx+1 + found = True + elif found: + self.assertEqual(idx, len(postinst_list), "Not found all postinsts") + break |