diff options
| author | Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com> | 2016-11-24 15:54:53 -0600 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-16 10:23:23 +0000 |
| commit | 23d1c4ffb7791e2f75f0eaa84dd6b936d3b861f7 (patch) | |
| tree | 777f48bcbc93a5cae7b0e0ef0c47772f010545f0 | |
| parent | 3f6e6f4e69f644bd466774607f43b8f306376b42 (diff) | |
| download | poky-23d1c4ffb7791e2f75f0eaa84dd6b936d3b861f7.tar.gz | |
selftest: Test needed to verify postinst order
It verifies the following:
1. Compile a minimal image.
2. The compiled image will add the layer with the recipe postinst,
previously created at:
"meta-selftest/recipes-test"
3. Run QEMU.
4. Validate the task execution order.
[YOCTO #5319]
(From OE-Core rev: a8ff789a3bfedcbc4358db7907a45270d8b1b76a)
Signed-off-by: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta-selftest/recipes-test/postinst/postinst_1.0.bb | 124 | ||||
| -rw-r--r-- | meta/lib/oeqa/selftest/runtime-test.py | 52 |
2 files changed, 176 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 0000000000..97a1987305 --- /dev/null +++ b/meta-selftest/recipes-test/postinst/postinst_1.0.bb | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | LICENSE = "MIT" | ||
| 2 | ALLOW_EMPTY_${PN}-at-rootfs = "1" | ||
| 3 | ALLOW_EMPTY_${PN}-delayed-a = "1" | ||
| 4 | ALLOW_EMPTY_${PN}-delayed-b = "1" | ||
| 5 | ALLOW_EMPTY_${PN}-delayed-d = "1" | ||
| 6 | ALLOW_EMPTY_${PN}-delayed-p = "1" | ||
| 7 | ALLOW_EMPTY_${PN}-delayed-t = "1" | ||
| 8 | |||
| 9 | PACKAGES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t" | ||
| 10 | PROVIDES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t" | ||
| 11 | FILES_${PN}-delayed-a = "" | ||
| 12 | FILES_${PN}-delayed-b = "" | ||
| 13 | FILES_${PN}-delayed-d = "" | ||
| 14 | FILES_${PN}-delayed-p = "" | ||
| 15 | FILES_${PN}-delayed-t = "" | ||
| 16 | |||
| 17 | # Runtime dependencies | ||
| 18 | RDEPENDS_${PN}-delayed-a = "${PN}-at-rootfs" | ||
| 19 | RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a" | ||
| 20 | RDEPENDS_${PN}-delayed-d = "${PN}-delayed-b" | ||
| 21 | RDEPENDS_${PN}-delayed-p = "${PN}-delayed-d" | ||
| 22 | RDEPENDS_${PN}-delayed-t = "${PN}-delayed-p" | ||
| 23 | |||
| 24 | # Main recipe post-install | ||
| 25 | pkg_postinst_${PN}-at-rootfs () { | ||
| 26 | tfile="/etc/postinsta-test" | ||
| 27 | if test "x$D" != "x" then | ||
| 28 | # Need to run on first boot | ||
| 29 | exit 1 | ||
| 30 | else | ||
| 31 | echo "lets write postinst" > $tfile | ||
| 32 | fi | ||
| 33 | } | ||
| 34 | |||
| 35 | # Dependency recipes post-installs | ||
| 36 | pkg_postinst_${PN}-delayed-a () { | ||
| 37 | efile="/etc/postinst-test" | ||
| 38 | tfile="/etc/postinsta-test" | ||
| 39 | rdeps="postinst" | ||
| 40 | |||
| 41 | if test "x$D" != "x"; then | ||
| 42 | # Need to run on first boot | ||
| 43 | exit 1 | ||
| 44 | else | ||
| 45 | if test -e $efile ; then | ||
| 46 | echo 'success' > $tfile | ||
| 47 | else | ||
| 48 | echo 'fail to install $rdeps first!' >&2 | ||
| 49 | exit 1 | ||
| 50 | fi | ||
| 51 | fi | ||
| 52 | } | ||
| 53 | |||
| 54 | pkg_postinst_${PN}-delayed-b () { | ||
| 55 | efile="/etc/postinsta-test" | ||
| 56 | tfile="/etc/postinstb-test" | ||
| 57 | rdeps="postinsta" | ||
| 58 | |||
| 59 | if test "x$D" != "x"; then | ||
| 60 | # Need to run on first boot | ||
| 61 | exit 1 | ||
| 62 | else | ||
| 63 | if test -e $efile ; then | ||
| 64 | echo 'success' > $tfile | ||
| 65 | else | ||
| 66 | echo 'fail to install $rdeps first!' >&2 | ||
| 67 | exit 1 | ||
| 68 | fi | ||
| 69 | fi | ||
| 70 | } | ||
| 71 | |||
| 72 | pkg_postinst_${PN}-delayed-d () { | ||
| 73 | efile="/etc/postinstb-test" | ||
| 74 | tfile="/etc/postinstd-test" | ||
| 75 | rdeps="postinstb" | ||
| 76 | |||
| 77 | if test "x$D" != "x"; then | ||
| 78 | # Need to run on first boot | ||
| 79 | exit 1 | ||
| 80 | else | ||
| 81 | if test -e $efile ; then | ||
| 82 | echo 'success' > $tfile | ||
| 83 | else | ||
| 84 | echo 'fail to install $rdeps first!' >&2 | ||
| 85 | exit 1 | ||
| 86 | fi | ||
| 87 | fi | ||
| 88 | } | ||
| 89 | |||
| 90 | pkg_postinst_${PN}-delayed-p () { | ||
| 91 | efile="/etc/postinstd-test" | ||
| 92 | tfile="/etc/postinstp-test" | ||
| 93 | rdeps="postinstd" | ||
| 94 | |||
| 95 | if test "x$D" != "x"; then | ||
| 96 | # Need to run on first boot | ||
| 97 | exit 1 | ||
| 98 | else | ||
| 99 | if test -e $efile ; then | ||
| 100 | echo 'success' > $tfile | ||
| 101 | else | ||
| 102 | echo 'fail to install $rdeps first!' >&2 | ||
| 103 | exit 1 | ||
| 104 | fi | ||
| 105 | fi | ||
| 106 | } | ||
| 107 | |||
| 108 | pkg_postinst_${PN}-delayed-t () { | ||
| 109 | efile="/etc/postinstp-test" | ||
| 110 | tfile="/etc/postinstt-test" | ||
| 111 | rdeps="postinstp" | ||
| 112 | |||
| 113 | if test "x$D" != "x"; then | ||
| 114 | # Need to run on first boot | ||
| 115 | exit 1 | ||
| 116 | else | ||
| 117 | if test -e $efile ; then | ||
| 118 | echo 'success' > $tfile | ||
| 119 | else | ||
| 120 | echo 'fail to install $rdeps first!' >&2 | ||
| 121 | exit 1 | ||
| 122 | fi | ||
| 123 | fi | ||
| 124 | } | ||
diff --git a/meta/lib/oeqa/selftest/runtime-test.py b/meta/lib/oeqa/selftest/runtime-test.py index c2d5b45a4b..1dbfae1106 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 | |||
| 2 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu | 2 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, runqemu |
| 3 | from oeqa.utils.decorators import testcase | 3 | from oeqa.utils.decorators import testcase |
| 4 | import os | 4 | import os |
| 5 | import re | ||
| 5 | 6 | ||
| 6 | class TestExport(oeSelfTest): | 7 | class TestExport(oeSelfTest): |
| 7 | 8 | ||
| @@ -103,3 +104,54 @@ class TestImage(oeSelfTest): | |||
| 103 | # Build core-image-sato and testimage | 104 | # Build core-image-sato and testimage |
| 104 | bitbake('core-image-full-cmdline socat') | 105 | bitbake('core-image-full-cmdline socat') |
| 105 | bitbake('-c testimage core-image-full-cmdline') | 106 | bitbake('-c testimage core-image-full-cmdline') |
| 107 | |||
| 108 | class Postinst(oeSelfTest): | ||
| 109 | @testcase(1540) | ||
| 110 | def test_verify_postinst(self): | ||
| 111 | """ | ||
| 112 | Summary: The purpose of this test is to verify the execution order of postinst Bugzilla ID: [5319] | ||
| 113 | Expected : | ||
| 114 | 1. Compile a minimal image. | ||
| 115 | 2. The compiled image will add the created layer with the recipes postinst[ abdpt] | ||
| 116 | 3. Run qemux86 | ||
| 117 | 4. Validate the task execution order | ||
| 118 | Author: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com> | ||
| 119 | """ | ||
| 120 | features = 'INHERIT += "testimage"\n' | ||
| 121 | features += 'CORE_IMAGE_EXTRA_INSTALL += "postinst-at-rootfs \ | ||
| 122 | postinst-delayed-a \ | ||
| 123 | postinst-delayed-b \ | ||
| 124 | postinst-delayed-d \ | ||
| 125 | postinst-delayed-p \ | ||
| 126 | postinst-delayed-t \ | ||
| 127 | "\n' | ||
| 128 | self.write_config(features) | ||
| 129 | |||
| 130 | bitbake('core-image-minimal -f ') | ||
| 131 | |||
| 132 | postinst_list = ['100-postinst-at-rootfs', | ||
| 133 | '101-postinst-delayed-a', | ||
| 134 | '102-postinst-delayed-b', | ||
| 135 | '103-postinst-delayed-d', | ||
| 136 | '104-postinst-delayed-p', | ||
| 137 | '105-postinst-delayed-t'] | ||
| 138 | path_workdir = get_bb_var('WORKDIR','core-image-minimal') | ||
| 139 | workspacedir = 'testimage/qemu_boot_log' | ||
| 140 | workspacedir = os.path.join(path_workdir, workspacedir) | ||
| 141 | rexp = re.compile("^Running postinst .*/(?P<postinst>.*)\.\.\.$") | ||
| 142 | with runqemu('core-image-minimal') as qemu: | ||
| 143 | with open(workspacedir) as f: | ||
| 144 | found = False | ||
| 145 | idx = 0 | ||
| 146 | for line in f.readlines(): | ||
| 147 | line = line.strip().replace("^M","") | ||
| 148 | if not line: # To avoid empty lines | ||
| 149 | continue | ||
| 150 | m = rexp.search(line) | ||
| 151 | if m: | ||
| 152 | self.assertEqual(postinst_list[idx], m.group('postinst'), "Fail") | ||
| 153 | idx = idx+1 | ||
| 154 | found = True | ||
| 155 | elif found: | ||
| 156 | self.assertEqual(idx, len(postinst_list), "Not found all postinsts") | ||
| 157 | break | ||
