All of lore.kernel.org
 help / color / mirror / Atom feed
From: leonardo.sandoval.gonzalez@linux.intel.com
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] selftest/pkgdata: support musl on unit tests
Date: Wed, 29 Mar 2017 23:39:21 -0700	[thread overview]
Message-ID: <20170330063921.31988-1-leonardo.sandoval.gonzalez@linux.intel.com> (raw)

From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

Test cases should be agnostic to supported distro/tclibc, so consider
musl libc on pkgdata unit tests.

[YOCTO #10890]

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
---
 meta/lib/oeqa/selftest/pkgdata.py | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/meta/lib/oeqa/selftest/pkgdata.py b/meta/lib/oeqa/selftest/pkgdata.py
index 36d8b34..ae402ab 100644
--- a/meta/lib/oeqa/selftest/pkgdata.py
+++ b/meta/lib/oeqa/selftest/pkgdata.py
@@ -3,6 +3,7 @@ import os
 import tempfile
 import logging
 import fnmatch
+import collections
 
 import oeqa.utils.ftools as ftools
 from oeqa.selftest.base import oeSelfTest
@@ -16,21 +17,27 @@ class OePkgdataUtilTests(oeSelfTest):
         # Ensure we have the right data in pkgdata
         logger = logging.getLogger("selftest")
         logger.info('Running bitbake to generate pkgdata')
-        bitbake('glibc busybox zlib m4')
+        bitbake('virtual/libc busybox zlib m4')
+
+        # recipe-runtime-package relation for virtual/libc provider
+        Libc = collections.namedtuple('Libc', ['recipe', 'runtime_pkg', 'libpath', 'staticdev', 'utils', 'rutils'])
+        cls.libc = Libc('glibc', 'libc6', '/lib/libc.so.6', 'libc6-staticdev', 'glibc-utils', 'lib6-utils')
+        if get_bb_var('TCLIBC') == 'musl':
+            cls.libc = Libc('musl', 'musl', '/usr/lib/libc.so', 'musl-staticdev', None, None)
 
     @testcase(1203)
     def test_lookup_pkg(self):
         # Forward tests
-        result = runCmd('oe-pkgdata-util lookup-pkg "glibc busybox"')
-        self.assertEqual(result.output, 'libc6\nbusybox')
+        result = runCmd('oe-pkgdata-util lookup-pkg "%s busybox"' % self.libc.recipe)
+        self.assertEqual(result.output, '%s\nbusybox' % self.libc.runtime_pkg)
         result = runCmd('oe-pkgdata-util lookup-pkg zlib-dev')
         self.assertEqual(result.output, 'libz-dev')
         result = runCmd('oe-pkgdata-util lookup-pkg nonexistentpkg', ignore_status=True)
         self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output)
         self.assertEqual(result.output, 'ERROR: The following packages could not be found: nonexistentpkg')
         # Reverse tests
-        result = runCmd('oe-pkgdata-util lookup-pkg -r "libc6 busybox"')
-        self.assertEqual(result.output, 'glibc\nbusybox')
+        result = runCmd('oe-pkgdata-util lookup-pkg -r "%s busybox"' % self.libc.runtime_pkg)
+        self.assertEqual(result.output, '%s\nbusybox' % self.libc.recipe)
         result = runCmd('oe-pkgdata-util lookup-pkg -r libz-dev')
         self.assertEqual(result.output, 'zlib-dev')
         result = runCmd('oe-pkgdata-util lookup-pkg -r nonexistentpkg', ignore_status=True)
@@ -49,8 +56,8 @@ class OePkgdataUtilTests(oeSelfTest):
 
     @testcase(1198)
     def test_find_path(self):
-        result = runCmd('oe-pkgdata-util find-path /lib/libc.so.6')
-        self.assertEqual(result.output, 'glibc: /lib/libc.so.6')
+        result = runCmd('oe-pkgdata-util find-path %s' % self.libc.libpath)
+        self.assertEqual(result.output, '%s: %s' % (self.libc.recipe, self.libc.libpath))
         result = runCmd('oe-pkgdata-util find-path /usr/bin/m4')
         self.assertEqual(result.output, 'm4: /usr/bin/m4')
         result = runCmd('oe-pkgdata-util find-path /not/exist', ignore_status=True)
@@ -59,8 +66,8 @@ class OePkgdataUtilTests(oeSelfTest):
 
     @testcase(1204)
     def test_lookup_recipe(self):
-        result = runCmd('oe-pkgdata-util lookup-recipe "libc6-staticdev busybox"')
-        self.assertEqual(result.output, 'glibc\nbusybox')
+        result = runCmd('oe-pkgdata-util lookup-recipe "%s busybox"' % self.libc.staticdev)
+        self.assertEqual(result.output, '%s\nbusybox' % self.libc.recipe)
         result = runCmd('oe-pkgdata-util lookup-recipe libz-dbg')
         self.assertEqual(result.output, 'zlib')
         result = runCmd('oe-pkgdata-util lookup-recipe nonexistentpkg', ignore_status=True)
@@ -72,12 +79,14 @@ class OePkgdataUtilTests(oeSelfTest):
         # No arguments
         result = runCmd('oe-pkgdata-util list-pkgs')
         pkglist = result.output.split()
-        self.assertIn('glibc-utils', pkglist, "Listed packages: %s" % result.output)
+        # musl does not have the glibc-utils counterpart so just test on glibc
+        self.libc.utils and self.assertIn(self.libc.utils, pkglist, "Listed packages: %s" % result.output)
         self.assertIn('zlib-dev', pkglist, "Listed packages: %s" % result.output)
         # No pkgspec, runtime
         result = runCmd('oe-pkgdata-util list-pkgs -r')
         pkglist = result.output.split()
-        self.assertIn('libc6-utils', pkglist, "Listed packages: %s" % result.output)
+        # musl does not have the libc6-utils counterpart so just test on glibc
+        self.libc.rutils and self.assertIn(self.libc.rutils, pkglist, "Listed packages: %s" % result.output)
         self.assertIn('libz-dev', pkglist, "Listed packages: %s" % result.output)
         # With recipe specified
         result = runCmd('oe-pkgdata-util list-pkgs -p zlib')
@@ -208,11 +217,11 @@ class OePkgdataUtilTests(oeSelfTest):
         self.track_for_cleanup(tempdir)
         pkglistfile = os.path.join(tempdir, 'pkglist')
         with open(pkglistfile, 'w') as f:
-            f.write('libc6\n')
+            f.write('%s\n' % self.libc.runtime_pkg)
             f.write('libz1\n')
             f.write('busybox\n')
         result = runCmd('oe-pkgdata-util glob %s "*-dev"' % pkglistfile)
-        desiredresult = ['libc6-dev', 'libz-dev', 'busybox-dev']
+        desiredresult = ['%s-dev' % self.libc.runtime_pkg, 'libz-dev', 'busybox-dev']
         self.assertEqual(sorted(result.output.split()), sorted(desiredresult))
         # The following should not error (because when we use this during rootfs construction, sometimes the complementary package won't exist)
         result = runCmd('oe-pkgdata-util glob %s "*-nonexistent"' % pkglistfile)
@@ -225,5 +234,5 @@ class OePkgdataUtilTests(oeSelfTest):
 
     @testcase(1206)
     def test_specify_pkgdatadir(self):
-        result = runCmd('oe-pkgdata-util -p %s lookup-pkg glibc' % get_bb_var('PKGDATA_DIR'))
-        self.assertEqual(result.output, 'libc6')
+        result = runCmd('oe-pkgdata-util -p %s lookup-pkg %s' % (get_bb_var('PKGDATA_DIR'), self.libc.recipe))
+        self.assertEqual(result.output, self.libc.runtime_pkg)
-- 
2.10.2



             reply	other threads:[~2017-03-29 23:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  6:39 leonardo.sandoval.gonzalez [this message]
2017-03-30 11:45 ` [PATCH] selftest/pkgdata: support musl on unit tests Burton, Ross
2017-03-30 14:38   ` Leonardo Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170330063921.31988-1-leonardo.sandoval.gonzalez@linux.intel.com \
    --to=leonardo.sandoval.gonzalez@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.