diff options
author | Ross Burton <ross.burton@intel.com> | 2014-06-11 11:04:43 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-06-12 17:47:59 +0100 |
commit | 2261e9f4c8f27c4c0cd7a6f0786943ca166788b3 (patch) | |
tree | 708598e8bed9b3b9103acebe753239032e5f34d2 /bitbake/lib/bb/tests | |
parent | 065fb5dd565f37b56f69a91b4f7fa816b01996b9 (diff) | |
download | poky-2261e9f4c8f27c4c0cd7a6f0786943ca166788b3.tar.gz |
bitbake: bb/tests/data.py: add tests for contains() and contains_any()
contains_any is buggy so write a test case to demonstrate this.
(Bitbake rev: 25d10c349aab77bf99745c0a90dd8f9b90abccac)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r-- | bitbake/lib/bb/tests/data.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index 228f72c1f5..944a906653 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
@@ -299,3 +299,39 @@ class TestFlags(unittest.TestCase): | |||
299 | self.assertEqual(self.d.getVarFlag("foo", "flag2"), None) | 299 | self.assertEqual(self.d.getVarFlag("foo", "flag2"), None) |
300 | 300 | ||
301 | 301 | ||
302 | class Contains(unittest.TestCase): | ||
303 | def setUp(self): | ||
304 | self.d = bb.data.init() | ||
305 | self.d.setVar("SOMEFLAG", "a b c") | ||
306 | |||
307 | def test_contains(self): | ||
308 | self.assertTrue(bb.utils.contains("SOMEFLAG", "a", True, False, self.d)) | ||
309 | self.assertTrue(bb.utils.contains("SOMEFLAG", "b", True, False, self.d)) | ||
310 | self.assertTrue(bb.utils.contains("SOMEFLAG", "c", True, False, self.d)) | ||
311 | |||
312 | self.assertTrue(bb.utils.contains("SOMEFLAG", "a b", True, False, self.d)) | ||
313 | self.assertTrue(bb.utils.contains("SOMEFLAG", "b c", True, False, self.d)) | ||
314 | self.assertTrue(bb.utils.contains("SOMEFLAG", "c a", True, False, self.d)) | ||
315 | |||
316 | self.assertTrue(bb.utils.contains("SOMEFLAG", "a b c", True, False, self.d)) | ||
317 | self.assertTrue(bb.utils.contains("SOMEFLAG", "c b a", True, False, self.d)) | ||
318 | |||
319 | self.assertFalse(bb.utils.contains("SOMEFLAG", "x", True, False, self.d)) | ||
320 | self.assertFalse(bb.utils.contains("SOMEFLAG", "a x", True, False, self.d)) | ||
321 | self.assertFalse(bb.utils.contains("SOMEFLAG", "x c b", True, False, self.d)) | ||
322 | self.assertFalse(bb.utils.contains("SOMEFLAG", "x c b a", True, False, self.d)) | ||
323 | |||
324 | def test_contains_any(self): | ||
325 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "a", True, False, self.d)) | ||
326 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "b", True, False, self.d)) | ||
327 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "c", True, False, self.d)) | ||
328 | |||
329 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "a b", True, False, self.d)) | ||
330 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "b c", True, False, self.d)) | ||
331 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "c a", True, False, self.d)) | ||
332 | |||
333 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "a x", True, False, self.d)) | ||
334 | self.assertTrue(bb.utils.contains_any("SOMEFLAG", "x c", True, False, self.d)) | ||
335 | |||
336 | self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x", True, False, self.d)) | ||
337 | self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) | ||