All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] oeqa/commands: don't break if get_bb_vars is passed a tuple
@ 2017-11-22 16:04 Ross Burton
  2017-11-22 16:04 ` [PATCH 2/3] postinst: fix and simplify the postinst test recipe Ross Burton
  2017-11-22 16:04 ` [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing Ross Burton
  0 siblings, 2 replies; 9+ messages in thread
From: Ross Burton @ 2017-11-22 16:04 UTC (permalink / raw)
  To: openembedded-core

get_bb_vars was using variables.copy() to duplicate the list of variables passed
but this function only exists in lists [1,2] and not tuples (1,2).

Instead of throwing an exception if the variables are in a tuple, simply
construct a new list using the passed sequence-like object.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/lib/oeqa/utils/commands.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 0bb90028dc6..cad0bea0be9 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -227,7 +227,7 @@ def get_bb_vars(variables=None, target=None, postconfig=None):
     bbenv = get_bb_env(target, postconfig=postconfig)
 
     if variables is not None:
-        variables = variables.copy()
+        variables = list(variables)
     var_re = re.compile(r'^(export )?(?P<var>\w+(_.*)?)="(?P<value>.*)"$')
     unset_re = re.compile(r'^unset (?P<var>\w+)$')
     lastline = None
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] postinst: fix and simplify the postinst test recipe
  2017-11-22 16:04 [PATCH 1/3] oeqa/commands: don't break if get_bb_vars is passed a tuple Ross Burton
@ 2017-11-22 16:04 ` Ross Burton
  2017-11-22 16:09   ` Alexander Kanavin
  2017-11-22 16:04 ` [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing Ross Burton
  1 sibling, 1 reply; 9+ messages in thread
From: Ross Burton @ 2017-11-22 16:04 UTC (permalink / raw)
  To: openembedded-core

Reduce the number of packages, and fix some syntax and logic errors in the
scripts.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 .../recipes-test/postinst/postinst_1.0.bb          | 158 +++++++--------------
 1 file changed, 51 insertions(+), 107 deletions(-)

diff --git a/meta-selftest/recipes-test/postinst/postinst_1.0.bb b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
index 6d497342779..112aa08c80f 100644
--- a/meta-selftest/recipes-test/postinst/postinst_1.0.bb
+++ b/meta-selftest/recipes-test/postinst/postinst_1.0.bb
@@ -1,126 +1,70 @@
+SUMMARY = "Packages to exercise postinstall functions"
 LICENSE = "MIT"
-ALLOW_EMPTY_${PN}-at-rootfs = "1"
+
+inherit allarch
+
+PACKAGES = "${PN}-rootfs ${PN}-delayed-a ${PN}-delayed-b"
+
+ALLOW_EMPTY_${PN}-rootfs = "1"
 ALLOW_EMPTY_${PN}-delayed-a = "1"
 ALLOW_EMPTY_${PN}-delayed-b = "1"
-ALLOW_EMPTY_${PN}-delayed-d = "1"
-ALLOW_EMPTY_${PN}-delayed-p = "1"
-ALLOW_EMPTY_${PN}-delayed-t = "1"
-
-PACKAGES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t"
-PROVIDES += "${PN}-at-rootfs ${PN}-delayed-a ${PN}-delayed-b ${PN}-delayed-d ${PN}-delayed-p ${PN}-delayed-t"
-FILES_${PN}-delayed-a = ""
-FILES_${PN}-delayed-b = ""
-FILES_${PN}-delayed-d = ""
-FILES_${PN}-delayed-p = ""
-FILES_${PN}-delayed-t = ""
-
-# Runtime dependencies
-RDEPENDS_${PN}-delayed-a = "${PN}-at-rootfs"
+
+RDEPENDS_${PN}-delayed-a = "${PN}-rootfs"
 RDEPENDS_${PN}-delayed-b = "${PN}-delayed-a"
-RDEPENDS_${PN}-delayed-d = "${PN}-delayed-b"
-RDEPENDS_${PN}-delayed-p = "${PN}-delayed-d"
-RDEPENDS_${PN}-delayed-t = "${PN}-delayed-p"
-
-# Main recipe post-install
-pkg_postinst_${PN}-at-rootfs () {
-    tfile="/etc/postinsta-test"
-    touch "$D"/this-was-created-at-rootfstime
-    if test "x$D" != "x" then
-        # Need to run on first boot
+
+TESTDIR = "${sysconfdir}/postinst-test"
+
+# At rootfs time touch $TESTDIR/rootfs.  Errors if the file already exists, or
+# if the function runs on first boot.
+pkg_postinst_${PN}-rootfs () {
+    set -e
+
+    if [ -z "$D" ]; then
+        echo "${PN}-rootfs should have finished at rootfs time"
+        exit 1
+    fi
+
+    if [ -e $D${TESTDIR}/rootfs ]; then
+        echo "$D${TESTDIR}/rootfs exists, but should not"
         exit 1
-    else
-        echo "lets write postinst" > $tfile
     fi
+
+    mkdir -p $D${TESTDIR}
+    touch $D${TESTDIR}/rootfs
 }
 
-# Dependency recipes post-installs
+# Depends on rootfs, delays until first boot, verifies that the rootfs file was
+# written.
 pkg_postinst_${PN}-delayed-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
-      touch /etc/this-was-created-at-first-boot
-      if test -e $efile ; then
-        echo 'success' > $tfile
-      else
-        echo 'fail to install $rdeps first!' >&2
+    set -e
+
+    if [ -n "$D" ]; then
+        echo "Delaying ${PN}-delayed-a until first boot"
         exit 1
-      fi
-   fi
-}
+    fi
 
-pkg_postinst_${PN}-delayed-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
+    if [ ! -e ${TESTDIR}/rootfs ]; then
+        echo "${PN}-delayed-a: ${TESTDIR}/rootfs not found"
         exit 1
-      fi
-   fi
+    fi
+
+    touch ${TESTDIR}/delayed-a
 }
 
-pkg_postinst_${PN}-delayed-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
+# Depends on delayed-a, delays until first boot, verifies that the delayed-a file was
+# written. This verifies the ordering between delayed postinsts.
+pkg_postinst_${PN}-delayed-b () {
+    set -e
+
+    if [ -n "$D" ]; then
+        echo "Delaying ${PN}-delayed-b until first boot"
         exit 1
-      fi
-   fi
-}
+    fi
 
-pkg_postinst_${PN}-delayed-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
+    if [ ! -e ${TESTDIR}/delayed-a ]; then
+        echo "${PN}-delayed-b: ${TESTDIR}/delayed-a not found"
         exit 1
-      fi
-   fi
-}
+    fi
 
-pkg_postinst_${PN}-delayed-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
+    touch ${TESTDIR}/delayed-b
 }
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing
  2017-11-22 16:04 [PATCH 1/3] oeqa/commands: don't break if get_bb_vars is passed a tuple Ross Burton
  2017-11-22 16:04 ` [PATCH 2/3] postinst: fix and simplify the postinst test recipe Ross Burton
@ 2017-11-22 16:04 ` Ross Burton
  2017-11-23  1:34   ` Joshua Lock
  1 sibling, 1 reply; 9+ messages in thread
From: Ross Burton @ 2017-11-22 16:04 UTC (permalink / raw)
  To: openembedded-core

Update the packages and file names to reflect the new postinst recipe.

Fix a sh syntax error in the run_serial file exists test which was hidden by a
logic problem in the status code.

Remove the older test_verify_postinst as it's effectively a subset of
test_postinst_rootfs_and_boot, and doesn't work: when booting under systemd the
strings it searches for are not output to the console, but the test still
passes.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/lib/oeqa/selftest/cases/runtime_test.py | 82 +++++++---------------------
 1 file changed, 19 insertions(+), 63 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
index 25270b7535b..1c69255b568 100644
--- a/meta/lib/oeqa/selftest/cases/runtime_test.py
+++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
@@ -167,55 +167,6 @@ class TestImage(OESelftestTestCase):
 
 class Postinst(OESelftestTestCase):
     @OETestID(1540)
-    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.
-        2. The compiled image will add the created layer with the recipes postinst[ abdpt]
-        3. Run qemux86
-        4. Validate the task execution order
-        Author: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com>
-        """
-        features = 'INHERIT += "testimage"\n'
-        features += 'CORE_IMAGE_EXTRA_INSTALL += "postinst-at-rootfs \
-postinst-delayed-a \
-postinst-delayed-b \
-postinst-delayed-d \
-postinst-delayed-p \
-postinst-delayed-t \
-"\n'
-        self.write_config(features)
-
-        bitbake('core-image-minimal -f ')
-
-        postinst_list = ['100-postinst-at-rootfs',
-                         '101-postinst-delayed-a',
-                         '102-postinst-delayed-b',
-                         '103-postinst-delayed-d',
-                         '104-postinst-delayed-p',
-                         '105-postinst-delayed-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
-
     @OETestID(1545)
     def test_postinst_rootfs_and_boot(self):
         """
@@ -234,16 +185,22 @@ postinst-delayed-t \
                         for initialization managers: sysvinit and systemd.
 
         """
-        file_rootfs_name = "this-was-created-at-rootfstime"
-        fileboot_name = "this-was-created-at-first-boot"
-        rootfs_pkg = 'postinst-at-rootfs'
-        boot_pkg = 'postinst-delayed-a'
+
+        import oe.path
+
+        vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal")
+        rootfs = vars["IMAGE_ROOTFS"]
+        self.assertIsNotNone(rootfs)
+        sysconfdir = vars["sysconfdir"]
+        self.assertIsNotNone(sysconfdir)
+        # Need to use oe.path here as sysconfdir starts with /
+        hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test")
+        targettestdir = os.path.join(sysconfdir, "postinst-test")
 
         for init_manager in ("sysvinit", "systemd"):
             for classes in ("package_rpm", "package_deb", "package_ipk"):
                 with self.subTest(init_manager=init_manager, package_class=classes):
-                    features = 'MACHINE = "qemux86"\n'
-                    features += 'CORE_IMAGE_EXTRA_INSTALL += "%s %s "\n'% (rootfs_pkg, boot_pkg)
+                    features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-delayed-b"\n'
                     features += 'IMAGE_FEATURES += "package-management empty-root-password"\n'
                     features += 'PACKAGE_CLASSES = "%s"\n' % classes
                     if init_manager == "systemd":
@@ -255,13 +212,12 @@ postinst-delayed-t \
 
                     bitbake('core-image-minimal')
 
-                    file_rootfs_created = os.path.join(get_bb_var('IMAGE_ROOTFS', "core-image-minimal"),
-                                                       file_rootfs_name)
-                    found = os.path.isfile(file_rootfs_created)
-                    self.assertTrue(found, "File %s was not created at rootfs time by %s" % \
-                                    (file_rootfs_name, rootfs_pkg))
+                    self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs")),
+                                    "rootfs state file was not created")
 
-                    testcommand = 'ls /etc/' + fileboot_name
                     with runqemu('core-image-minimal') as qemu:
-                        status, output = qemu.run_serial("-f /etc/" + fileboot_name)
-                        self.assertEqual(status, 0, 'File %s was not created at first boot (%s)' % (fileboot_name, output))
+                        # Make the test echo a string and search for that as
+                        # run_serial()'s status code is useless.'
+                        for filename in ("rootfs", "delayed-a", "delayed-b"):
+                            status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename))
+                            self.assertEqual(output, "found", "%s was not present on boot" % filename)
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] postinst: fix and simplify the postinst test recipe
  2017-11-22 16:04 ` [PATCH 2/3] postinst: fix and simplify the postinst test recipe Ross Burton
@ 2017-11-22 16:09   ` Alexander Kanavin
  2017-11-22 16:09     ` Burton, Ross
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Kanavin @ 2017-11-22 16:09 UTC (permalink / raw)
  To: Ross Burton, openembedded-core

On 11/22/2017 06:04 PM, Ross Burton wrote:

> +    if [ -n "$D" ]; then
> +        echo "Delaying ${PN}-delayed-b until first boot"
>           exit 1
> -      fi

I still think this 'exit 1' madness should be fixed. But maybe some 
other time.

Alex


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] postinst: fix and simplify the postinst test recipe
  2017-11-22 16:09   ` Alexander Kanavin
@ 2017-11-22 16:09     ` Burton, Ross
  2017-11-22 16:13       ` Alexander Kanavin
  0 siblings, 1 reply; 9+ messages in thread
From: Burton, Ross @ 2017-11-22 16:09 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 399 bytes --]

On 22 November 2017 at 16:09, Alexander Kanavin <
alexander.kanavin@linux.intel.com> wrote:

> On 11/22/2017 06:04 PM, Ross Burton wrote:
>
> +    if [ -n "$D" ]; then
>> +        echo "Delaying ${PN}-delayed-b until first boot"
>>           exit 1
>> -      fi
>>
>
> I still think this 'exit 1' madness should be fixed. But maybe some other
> time.
>

Yes, agreed totally.

Ross

[-- Attachment #2: Type: text/html, Size: 929 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] postinst: fix and simplify the postinst test recipe
  2017-11-22 16:09     ` Burton, Ross
@ 2017-11-22 16:13       ` Alexander Kanavin
  0 siblings, 0 replies; 9+ messages in thread
From: Alexander Kanavin @ 2017-11-22 16:13 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

On 11/22/2017 06:09 PM, Burton, Ross wrote:

>         +    if [ -n "$D" ]; then
>         +        echo "Delaying ${PN}-delayed-b until first boot"
>                    exit 1
>         -      fi
> 
> 
>     I still think this 'exit 1' madness should be fixed. But maybe some
>     other time.
> 
> 
> Yes, agreed totally.

In the meantime, I'll rebase my patchset that does it to these changes 
you made to the test :)

https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=akanavin/dnf-rpm4-postinst-fix&id=a7f61bc88e5dd1668e0f8adee8ed5e06d2b4989c

from

https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=akanavin/dnf-rpm4-postinst-fix


Alex


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing
  2017-11-22 16:04 ` [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing Ross Burton
@ 2017-11-23  1:34   ` Joshua Lock
  2017-11-23 10:21     ` Burton, Ross
  0 siblings, 1 reply; 9+ messages in thread
From: Joshua Lock @ 2017-11-23  1:34 UTC (permalink / raw)
  To: Ross Burton, openembedded-core



On 23/11/2017 00:04, Ross Burton wrote:
> Update the packages and file names to reflect the new postinst recipe.
> 
> Fix a sh syntax error in the run_serial file exists test which was hidden by a
> logic problem in the status code.
> 
> Remove the older test_verify_postinst as it's effectively a subset of
> test_postinst_rootfs_and_boot, and doesn't work: when booting under systemd the
> strings it searches for are not output to the console, but the test still
> passes.
> 
> Signed-off-by: Ross Burton <ross.burton@intel.com>
> ---
>   meta/lib/oeqa/selftest/cases/runtime_test.py | 82 +++++++---------------------
>   1 file changed, 19 insertions(+), 63 deletions(-)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py
> index 25270b7535b..1c69255b568 100644
> --- a/meta/lib/oeqa/selftest/cases/runtime_test.py
> +++ b/meta/lib/oeqa/selftest/cases/runtime_test.py
> @@ -167,55 +167,6 @@ class TestImage(OESelftestTestCase):
>   
>   class Postinst(OESelftestTestCase):
>       @OETestID(1540)

We're effectively stating that test ID 1540 and test ID 1545 are both 
covered by the same test method, right?

Perhaps we don't need to maintain both test cases in Testopia, as we'll 
only ever see both tests pass or fail?

> -    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.
> -        2. The compiled image will add the created layer with the recipes postinst[ abdpt]
> -        3. Run qemux86
> -        4. Validate the task execution order
> -        Author: Francisco Pedraza <francisco.j.pedraza.gonzalez@intel.com>
> -        """
> -        features = 'INHERIT += "testimage"\n'
> -        features += 'CORE_IMAGE_EXTRA_INSTALL += "postinst-at-rootfs \
> -postinst-delayed-a \
> -postinst-delayed-b \
> -postinst-delayed-d \
> -postinst-delayed-p \
> -postinst-delayed-t \
> -"\n'
> -        self.write_config(features)
> -
> -        bitbake('core-image-minimal -f ')
> -
> -        postinst_list = ['100-postinst-at-rootfs',
> -                         '101-postinst-delayed-a',
> -                         '102-postinst-delayed-b',
> -                         '103-postinst-delayed-d',
> -                         '104-postinst-delayed-p',
> -                         '105-postinst-delayed-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
> -
>       @OETestID(1545)
>       def test_postinst_rootfs_and_boot(self):
>           """
> @@ -234,16 +185,22 @@ postinst-delayed-t \
>                           for initialization managers: sysvinit and systemd.
>   
>           """
> -        file_rootfs_name = "this-was-created-at-rootfstime"
> -        fileboot_name = "this-was-created-at-first-boot"
> -        rootfs_pkg = 'postinst-at-rootfs'
> -        boot_pkg = 'postinst-delayed-a'
> +
> +        import oe.path
> +
> +        vars = get_bb_vars(("IMAGE_ROOTFS", "sysconfdir"), "core-image-minimal")
> +        rootfs = vars["IMAGE_ROOTFS"]
> +        self.assertIsNotNone(rootfs)
> +        sysconfdir = vars["sysconfdir"]
> +        self.assertIsNotNone(sysconfdir)
> +        # Need to use oe.path here as sysconfdir starts with /
> +        hosttestdir = oe.path.join(rootfs, sysconfdir, "postinst-test")
> +        targettestdir = os.path.join(sysconfdir, "postinst-test")
>   
>           for init_manager in ("sysvinit", "systemd"):
>               for classes in ("package_rpm", "package_deb", "package_ipk"):
>                   with self.subTest(init_manager=init_manager, package_class=classes):
> -                    features = 'MACHINE = "qemux86"\n'
> -                    features += 'CORE_IMAGE_EXTRA_INSTALL += "%s %s "\n'% (rootfs_pkg, boot_pkg)
> +                    features = 'CORE_IMAGE_EXTRA_INSTALL = "postinst-delayed-b"\n'
>                       features += 'IMAGE_FEATURES += "package-management empty-root-password"\n'

The indentation doesn't look right here?

>                       features += 'PACKAGE_CLASSES = "%s"\n' % classes
>                       if init_manager == "systemd":
> @@ -255,13 +212,12 @@ postinst-delayed-t \
>   
>                       bitbake('core-image-minimal')
>   
> -                    file_rootfs_created = os.path.join(get_bb_var('IMAGE_ROOTFS', "core-image-minimal"),
> -                                                       file_rootfs_name)
> -                    found = os.path.isfile(file_rootfs_created)
> -                    self.assertTrue(found, "File %s was not created at rootfs time by %s" % \
> -                                    (file_rootfs_name, rootfs_pkg))
> +                    self.assertTrue(os.path.isfile(os.path.join(hosttestdir, "rootfs")),
> +                                    "rootfs state file was not created")
>   
> -                    testcommand = 'ls /etc/' + fileboot_name
>                       with runqemu('core-image-minimal') as qemu:
> -                        status, output = qemu.run_serial("-f /etc/" + fileboot_name)
> -                        self.assertEqual(status, 0, 'File %s was not created at first boot (%s)' % (fileboot_name, output))
> +                        # Make the test echo a string and search for that as
> +                        # run_serial()'s status code is useless.'
> +                        for filename in ("rootfs", "delayed-a", "delayed-b"):
> +                            status, output = qemu.run_serial("test -f %s && echo found" % os.path.join(targettestdir, filename))
> +                            self.assertEqual(output, "found", "%s was not present on boot" % filename)
> 

Why not just test the status (return code of test -f) instead of echoing 
a known value? i.e.

self.assertEqual(status, 0, "%s was not present on boot" % filename)

Joshua


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing
  2017-11-23  1:34   ` Joshua Lock
@ 2017-11-23 10:21     ` Burton, Ross
  2017-11-23 12:08       ` Burton, Ross
  0 siblings, 1 reply; 9+ messages in thread
From: Burton, Ross @ 2017-11-23 10:21 UTC (permalink / raw)
  To: Joshua Lock; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]

On 23 November 2017 at 01:34, Joshua Lock <joshua.g.lock@linux.intel.com>
wrote:

>       @OETestID(1540)
>>
>
> We're effectively stating that test ID 1540 and test ID 1545 are both
> covered by the same test method, right?
>
> Perhaps we don't need to maintain both test cases in Testopia, as we'll
> only ever see both tests pass or fail?


Yes, reviewing and sanitising testopia was my next job.

-                    features = 'MACHINE = "qemux86"\n'
>> -                    features += 'CORE_IMAGE_EXTRA_INSTALL += "%s %s
>> "\n'% (rootfs_pkg, boot_pkg)
>> +                    features = 'CORE_IMAGE_EXTRA_INSTALL =
>> "postinst-delayed-b"\n'
>>                       features += 'IMAGE_FEATURES += "package-management
>> empty-root-password"\n'
>>
>
> The indentation doesn't look right here?


That would be Atom "helpfully" doing smart intentation.  I'll fix it up in
something else, thanks.


> +                            status, output = qemu.run_serial("test -f %s
>> && echo found" % os.path.join(targettestdir, filename))
>> +                            self.assertEqual(output, "found", "%s was
>> not present on boot" % filename)
>>
>>
> Why not just test the status (return code of test -f) instead of echoing a
> known value? i.e.
>
> self.assertEqual(status, 0, "%s was not present on boot" % filename)


Because run_serial() is a bit lame and I don't trust it to correctly report
the exit status.   Rewriting it is on my hitlist, yes.

Ross

[-- Attachment #2: Type: text/html, Size: 3164 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing
  2017-11-23 10:21     ` Burton, Ross
@ 2017-11-23 12:08       ` Burton, Ross
  0 siblings, 0 replies; 9+ messages in thread
From: Burton, Ross @ 2017-11-23 12:08 UTC (permalink / raw)
  To: Joshua Lock; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 298 bytes --]

On 23 November 2017 at 10:21, Burton, Ross <ross.burton@intel.com> wrote:

>
>> The indentation doesn't look right here?
>
>
> That would be Atom "helpfully" doing smart intentation.  I'll fix it up in
> something else, thanks.
>

Can't see any problems, what didn't look right?

Ross

[-- Attachment #2: Type: text/html, Size: 1008 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-23 12:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22 16:04 [PATCH 1/3] oeqa/commands: don't break if get_bb_vars is passed a tuple Ross Burton
2017-11-22 16:04 ` [PATCH 2/3] postinst: fix and simplify the postinst test recipe Ross Burton
2017-11-22 16:09   ` Alexander Kanavin
2017-11-22 16:09     ` Burton, Ross
2017-11-22 16:13       ` Alexander Kanavin
2017-11-22 16:04 ` [PATCH 3/3] oeqa/selftest/runtime_test: simplify postinst testing Ross Burton
2017-11-23  1:34   ` Joshua Lock
2017-11-23 10:21     ` Burton, Ross
2017-11-23 12:08       ` Burton, Ross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.