All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2][PATCH] manual tests migrate to selftest
@ 2019-04-30 14:46 Armin Kuster
  2019-05-02 11:00 ` Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Armin Kuster @ 2019-04-30 14:46 UTC (permalink / raw)
  To: openembedded-core

[v2]
add check for python cairo module
pybootchartgui.py needs it

don't use relative path to pybootchartgui.py, use absolute

fix endline check data to reflect current output

Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
 meta/lib/oeqa/selftest/cases/oescripts.py | 97 +++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/oescripts.py b/meta/lib/oeqa/selftest/cases/oescripts.py
index bcdc2d5..81dd786 100644
--- a/meta/lib/oeqa/selftest/cases/oescripts.py
+++ b/meta/lib/oeqa/selftest/cases/oescripts.py
@@ -1,8 +1,11 @@
+import os, sys
 from oeqa.selftest.case import OESelftestTestCase
+from oeqa.core.decorator.depends import OETestDepends
 from oeqa.selftest.cases.buildhistory import BuildhistoryBase
 from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer
 from oeqa.core.decorator.oeid import OETestID
 
+
 class BuildhistoryDiffTests(BuildhistoryBase):
 
     @OETestID(295)
@@ -26,3 +29,97 @@ class BuildhistoryDiffTests(BuildhistoryBase):
                 self.fail('Unexpected line:\n%s\nExpected line endings:\n  %s' % (line, '\n  '.join(expected_endlines)))
         if expected_endlines:
             self.fail('Missing expected line endings:\n  %s' % '\n  '.join(expected_endlines))
+
+class OEScriptTests(OESelftestTestCase):
+    def setUp(self):
+        try:
+            import cairo
+        except ImportError:
+            self.skipTest('Python module cairo is not present')
+
+    scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts')
+
+    def check_endlines(self, results,  expected_endlines): 
+        for line in results.output.splitlines():
+            for el in expected_endlines:
+                if line == el:
+                    expected_endlines.remove(el)
+                    break
+
+        if expected_endlines:
+            self.fail('Missing expected line endings:\n  %s' % '\n  '.join(expected_endlines))
+
+
+class OEPybootchartguyTests(OEScriptTests):
+
+    def test_pybootchartguy_help(self):
+        runCmd('%s/pybootchartgui/pybootchartgui.py  --help' % self.scripts_dir)
+
+    def test_pybootchartguy_to_generate_build_png_output(self):
+        tmpdir = get_bb_var('TMPDIR')
+        runCmd('%s/pybootchartgui/pybootchartgui.py  %s/buildstats -o %s/charts -f png' % (self.scripts_dir, tmpdir, tmpdir))
+
+    def test_pybootchartguy_to_generate_build_svg_output(self):
+        tmpdir = get_bb_var('TMPDIR')
+        runCmd('%s/pybootchartgui/pybootchartgui.py  %s/buildstats -o %s/charts -f svg' % (self.scripts_dir, tmpdir, tmpdir))
+
+    def test_pybootchartguy_to_generate_build_pdf_output(self):
+        tmpdir = get_bb_var('TMPDIR')
+        runCmd('%s/pybootchartgui/pybootchartgui.py  %s/buildstats -o %s/charts -f pdf' % (self.scripts_dir, tmpdir, tmpdir))
+
+
+class OEListPackageconfigTests(OEScriptTests):
+    #oe-core.scripts.List_all_the_PACKAGECONFIG's_flags
+    def test_packageconfig_flags_help(self):
+        runCmd('%s/contrib/list-packageconfig-flags.py -h' % self.scripts_dir)
+
+    def test_packageconfig_flags_default(self):
+        results = runCmd('%s/contrib/list-packageconfig-flags.py' % self.scripts_dir)
+        expected_endlines = []
+        expected_endlines.append("RECIPE NAME                                                        PACKAGECONFIG FLAGS")
+        expected_endlines.append("xserver-xorg-1.20.4                                                dri dri2 dri3 gcrypt glamor glx nettle openssl systemd systemd-logind udev unwind xinerama xmlto xshmfence xwayland")
+        expected_endlines.append("znc-1.7.1                                                          ipv6")
+
+        self.check_endlines(results, expected_endlines)
+
+
+    def test_packageconfig_flags_option_flags(self):
+        results = runCmd('%s/contrib/list-packageconfig-flags.py -f' % self.scripts_dir)
+        expected_endlines = []
+        expected_endlines.append("PACKAGECONFIG FLAG     RECIPE NAMES")
+        expected_endlines.append("xshmfence              xserver-xorg-1.20.4")
+
+        self.check_endlines(results, expected_endlines)
+
+    def test_packageconfig_flags_option_all(self):
+        results = runCmd('%s/contrib/list-packageconfig-flags.py -a' % self.scripts_dir)
+        expected_endlines = []
+        expected_endlines.append("xserver-xorg-1.20.4")
+        expected_endlines.append("PACKAGECONFIG dri2 udev openssl")
+        expected_endlines.append("PACKAGECONFIG[udev] --enable-config-udev,--disable-config-udev,udev")
+        expected_endlines.append("PACKAGECONFIG[dri] --enable-dri,--disable-dri,xorgproto virtual/mesa")
+        expected_endlines.append("PACKAGECONFIG[dri2] --enable-dri2,--disable-dri2,xorgproto")
+        expected_endlines.append("PACKAGECONFIG[dri3] --enable-dri3,--disable-dri3,xorgproto")
+        expected_endlines.append("PACKAGECONFIG[glx] --enable-glx,--disable-glx,xorgproto virtual/libgl virtual/libx11")
+        expected_endlines.append("PACKAGECONFIG[glamor] --enable-glamor,--disable-glamor,libepoxy virtual/libgbm,libegl")
+        expected_endlines.append("PACKAGECONFIG[unwind] --enable-libunwind,--disable-libunwind,libunwind")
+        expected_endlines.append("PACKAGECONFIG[xshmfence] --enable-xshmfence,--disable-xshmfence,libxshmfence")
+        expected_endlines.append("PACKAGECONFIG[xmlto] --with-xmlto, --without-xmlto, xmlto-native docbook-xml-dtd4-native docbook-xsl-stylesheets-native")
+        expected_endlines.append("PACKAGECONFIG[systemd-logind] --enable-systemd-logind=yes,--enable-systemd-logind=no,dbus,")
+        expected_endlines.append("PACKAGECONFIG[systemd] --with-systemd-daemon,--without-systemd-daemon,systemd")
+        expected_endlines.append("PACKAGECONFIG[xinerama] --enable-xinerama,--disable-xinerama,xorgproto")
+        expected_endlines.append("PACKAGECONFIG[xwayland] --enable-xwayland,--disable-xwayland,wayland wayland-native wayland-protocols libepoxy")
+        expected_endlines.append("PACKAGECONFIG[openssl] --with-sha1=libcrypto,,openssl")
+        expected_endlines.append("PACKAGECONFIG[nettle] --with-sha1=libnettle,,nettle")
+        expected_endlines.append("PACKAGECONFIG[gcrypt] --with-sha1=libgcrypt,,libgcrypt")
+
+        self.check_endlines(results, expected_endlines)
+
+    def test_packageconfig_flags_optiins_preferred_only(self):
+        results = runCmd('%s/contrib/list-packageconfig-flags.py -p' % self.scripts_dir)
+        expected_endlines = []
+        expected_endlines.append("RECIPE NAME                                                        PACKAGECONFIG FLAGS")
+        expected_endlines.append("xserver-xorg-1.20.4                                                dri dri2 dri3 gcrypt glamor glx nettle openssl systemd systemd-logind udev unwind xinerama xmlto xshmfence xwayland")
+
+        self.check_endlines(results, expected_endlines)
+
-- 
2.7.4



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

* Re: [v2][PATCH] manual tests migrate to selftest
  2019-04-30 14:46 [v2][PATCH] manual tests migrate to selftest Armin Kuster
@ 2019-05-02 11:00 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2019-05-02 11:00 UTC (permalink / raw)
  To: Armin Kuster, openembedded-core

Hi Armin,

This patch needs quite a bit more work unfortunately.

On Tue, 2019-04-30 at 07:46 -0700, Armin Kuster wrote:
> [v2]
> add check for python cairo module
> pybootchartgui.py needs it
> 
> don't use relative path to pybootchartgui.py, use absolute
> 
> fix endline check data to reflect current output
> 
> Signed-off-by: Armin Kuster <akuster808@gmail.com>
> ---
>  meta/lib/oeqa/selftest/cases/oescripts.py | 97 +++++++++++++++++++++++++++++++
>  1 file changed, 97 insertions(+)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/oescripts.py b/meta/lib/oeqa/selftest/cases/oescripts.py
> index bcdc2d5..81dd786 100644
> --- a/meta/lib/oeqa/selftest/cases/oescripts.py
> +++ b/meta/lib/oeqa/selftest/cases/oescripts.py
> @@ -1,8 +1,11 @@
> +import os, sys

The convention is we put these on separate lines:

import os
import sys

>  from oeqa.selftest.case import OESelftestTestCase
> +from oeqa.core.decorator.depends import OETestDepends
>  from oeqa.selftest.cases.buildhistory import BuildhistoryBase
>  from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer
>  from oeqa.core.decorator.oeid import OETestID
>  
> +
>  class BuildhistoryDiffTests(BuildhistoryBase):
>  
>      @OETestID(295)
> @@ -26,3 +29,97 @@ class BuildhistoryDiffTests(BuildhistoryBase):
>                  self.fail('Unexpected line:\n%s\nExpected line endings:\n  %s' % (line, '\n  '.join(expected_endlines)))
>          if expected_endlines:
>              self.fail('Missing expected line endings:\n  %s' % '\n  '.join(expected_endlines))
> +
> +class OEScriptTests(OESelftestTestCase):
> +    def setUp(self):
> +        try:
> +            import cairo
> +        except ImportError:
> +            self.skipTest('Python module cairo is not present')

This breaks things for me:

2019-05-02 10:37:00,488 - oe-selftest - INFO - ======================================================================
2019-05-02 10:37:00,488 - oe-selftest - INFO - ERROR: test_packageconfig_flags_default (oescripts.OEListPackageconfigTests)
2019-05-02 10:37:00,488 - oe-selftest - INFO - ----------------------------------------------------------------------
2019-05-02 10:37:00,489 - oe-selftest - INFO - Traceback (most recent call last):
  File "/media/build1/poky/meta/lib/oeqa/core/case.py", line 46, in _oeTearDown
    self.tearDownMethod()
  File "/media/build1/poky/meta/lib/oeqa/selftest/case.py", line 166, in tearDown
    logit("Finishing %s (%ss)" % (self.id(), "{0:.2f}".format(self.endtime - self.starttime)))
AttributeError: 'OEListPackageconfigTests' object has no attribute 'starttime'

It needs something like:

    @classmethod
    def setUpClass(cls):
        super(OEScriptTests, cls).setUpClass()

adding to ensure we call the parent class function rather than replace
it.

> +
> +    scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts')
> +
> +    def check_endlines(self, results,  expected_endlines): 
> +        for line in results.output.splitlines():

I'd suggest adding:

            # turn all duplicate spaces to single spaces
            line = re.sub(' +', ' ', line)

> +            for el in expected_endlines:
> +                if line == el:
> +                    expected_endlines.remove(el)
> +                    break
> +
> +        if expected_endlines:
> +            self.fail('Missing expected line endings:\n  %s' % '\n  '.join(expected_endlines))
> +
> +
> +class OEPybootchartguyTests(OEScriptTests):
> +
> +    def test_pybootchartguy_help(self):
> +        runCmd('%s/pybootchartgui/pybootchartgui.py  --help' % self.scripts_dir)
> +
> +    def test_pybootchartguy_to_generate_build_png_output(self):
> +        tmpdir = get_bb_var('TMPDIR')
> +        runCmd('%s/pybootchartgui/pybootchartgui.py  %s/buildstats -o %s/charts -f png' % (self.scripts_dir, tmpdir, tmpdir))
> +
> +    def test_pybootchartguy_to_generate_build_svg_output(self):
> +        tmpdir = get_bb_var('TMPDIR')
> +        runCmd('%s/pybootchartgui/pybootchartgui.py  %s/buildstats -o %s/charts -f svg' % (self.scripts_dir, tmpdir, tmpdir))
> +
> +    def test_pybootchartguy_to_generate_build_pdf_output(self):
> +        tmpdir = get_bb_var('TMPDIR')
> +        runCmd('%s/pybootchartgui/pybootchartgui.py  %s/buildstats -o %s/charts -f pdf' % (self.scripts_dir, tmpdir, tmpdir))
> +
> +
> +class OEListPackageconfigTests(OEScriptTests):
> +    #oe-core.scripts.List_all_the_PACKAGECONFIG's_flags
> +    def test_packageconfig_flags_help(self):
> +        runCmd('%s/contrib/list-packageconfig-flags.py -h' % self.scripts_dir)
> +
> +    def test_packageconfig_flags_default(self):
> +        results = runCmd('%s/contrib/list-packageconfig-flags.py' % self.scripts_dir)
> +        expected_endlines = []
> +        expected_endlines.append("RECIPE NAME                                                        PACKAGECONFIG FLAGS")
> +        expected_endlines.append("xserver-xorg-1.20.4                                                dri dri2 dri3 gcrypt glamor glx nettle openssl systemd systemd-logind udev unwind xinerama xmlto xshmfence xwayland")
> +        expected_endlines.append("znc-1.7.1                                                          ipv6")

with the above addition you can remove the duplicate whitespaces here
and we're no longer reliant on the maximum recipe name+version string
length.

znc must come from meta-oe so adding that to an OE-Core test seems
unusual? Could we test something else in OE-Core?

I also don't like the idea of hardcoding the xserver-xorg version here
as we'd have to remember to change it for every xserver-xorg version
bump.

Perhaps we should make the above regexs to avoid this?

Whilst we're looking at the patch could you split it into two, one for
the packageconfig tests and one for the pybootchart ones so one can
merge without the other. The commit message also needs tweaking,
something like:

selftest: Convert manual packageconfig tests to automated selftest

and you could delete the manual test case it covers in the same patch.

Cheers,

Richard



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

end of thread, other threads:[~2019-05-02 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 14:46 [v2][PATCH] manual tests migrate to selftest Armin Kuster
2019-05-02 11:00 ` Richard Purdie

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.