Skip to contentSkip to conversation

oeqa/selftest: support sets in devtool comparisons

PATCH In review Ross Burton 2 participants 2 messages Dec 23, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oeqa/selftest: support sets in devtool comparisons

The devtool and recipetool tests do literal string comparisons, but for some fields the ordering could be irrelevant and potentially non-deterministic. For example, the recipetool_create_simple test started failing with:

AssertionError: 'GPLv2 Unknown' != 'Unknown GPLv2' : values for LICENSE do not match

The ordering of the LICENSE field isn't relevant. So, if the expected value is a set(), split the string into a set too and compare those.

---
 meta/lib/oeqa/selftest/devtool.py    | 2 ++
 meta/lib/oeqa/selftest/recipetool.py | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/devtool.py +2 -0
index 6f76ce7..1eadd6b 100644
@@ -44,6 +44,8 @@ class DevtoolBase(oeSelfTest):
                     needvalue = checkvars.pop(var)
                     if needvalue is None:
                         self.fail('Variable %s should not appear in recipe')
+                    if isinstance(needvalue, set):
+                        value = set(value.split())
                     self.assertEqual(value, needvalue, 'values for %s do not match' % var)
 
 
meta/lib/oeqa/selftest/recipetool.py +1 -1
index 34e383f..85a40f7 100644
@@ -413,7 +413,7 @@ class RecipetoolTests(RecipetoolBase):
             self.fail('recipetool did not create recipe file; output:\n%s' % result.output)
         self.assertEqual(dirlist[0], 'socat_%s.bb' % pv, 'Recipe file incorrectly named')
         checkvars = {}
-        checkvars['LICENSE'] = 'Unknown GPLv2'
+        checkvars['LICENSE'] = set(['Unknown', 'GPLv2'])
         checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING.OpenSSL;md5=5c9bccc77f67a8328ef4ebaf468116f4 file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263'
         # We don't check DEPENDS since they are variable for this recipe depending on what's in the sysroot
         checkvars['S'] = None
Signature · 1 line
2.6.4
Acked-by on v1 1/1
#1 lore raw
Quoted 41 lines · On Wed, 23 Dec 2015 13:48:29 Ross Burton wrote:

The devtool and recipetool tests do literal string comparisons, but for some fields the ordering could be irrelevant and potentially non-deterministic. For example, the recipetool_create_simple test started failing with:

AssertionError: 'GPLv2 Unknown' != 'Unknown GPLv2' : values for LICENSE do not match

The ordering of the LICENSE field isn't relevant. So, if the expected value is a set(), split the string into a set too and compare those.

---
 meta/lib/oeqa/selftest/devtool.py    | 2 ++
 meta/lib/oeqa/selftest/recipetool.py | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/lib/oeqa/selftest/devtool.py index 6f76ce7..1eadd6b 100644

meta/lib/oeqa/selftest/devtool.py +0 -0
@@ -44,6 +44,8 @@ class DevtoolBase(oeSelfTest):
                     needvalue = checkvars.pop(var)
                     if needvalue is None:
                         self.fail('Variable %s should not appear in

recipe') + if isinstance(needvalue, set):
+ value = set(value.split())
self.assertEqual(value, needvalue, 'values for %s do
not match' % var)

(quoted diff) +0 -0

b/meta/lib/oeqa/selftest/recipetool.py index 34e383f..85a40f7 100644

meta/lib/oeqa/selftest/recipetool.py +0 -0
@@ -413,7 +413,7 @@ class RecipetoolTests(RecipetoolBase):
             self.fail('recipetool did not create recipe file; output:\n%s'

% result.output) self.assertEqual(dirlist[0], 'socat_%s.bb' % pv, 'Recipe file incorrectly named') checkvars = {}

meta/lib/oeqa/selftest/recipetool.py +1 -1
-        checkvars['LICENSE'] = 'Unknown GPLv2'
+        checkvars['LICENSE'] = set(['Unknown', 'GPLv2'])
         checkvars['LIC_FILES_CHKSUM'] =
Quoted 4 lines

'file://COPYING.OpenSSL;md5=5c9bccc77f67a8328ef4ebaf468116f4 file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263' # We don't check DEPENDS since they are variable for this recipe depending on what's in the sysroot checkvars['S'] = None

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre