diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-28 17:13:18 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-12 22:50:46 +0100 |
| commit | a730981b75ebb528e447eb3e41c83440dbc133bd (patch) | |
| tree | 6aa6f52e3724d786fe946a2452f372efab69b1d6 | |
| parent | 4c386e1dd5df8e1bfb675f1a7f47c1162ec76d07 (diff) | |
| download | poky-a730981b75ebb528e447eb3e41c83440dbc133bd.tar.gz | |
bitbake: tests/data: Add new data tests
Add a variety of tests which were found to be useful when working
on the data store recently.
(Bitbake rev: 5c5f8da509f6bbc1fad263462142519ef3d54a35)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | bitbake/lib/bb/tests/data.py | 47 | ||||
| -rw-r--r-- | bitbake/lib/bb/tests/parse.py | 46 |
2 files changed, 93 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index 2c2e7ae48b..e9aab577f6 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
| @@ -270,6 +270,13 @@ class TestConcatOverride(unittest.TestCase): | |||
| 270 | bb.data.update_data(self.d) | 270 | bb.data.update_data(self.d) |
| 271 | self.assertEqual(self.d.getVar("TEST", True), "foo:val:val2:bar") | 271 | self.assertEqual(self.d.getVar("TEST", True), "foo:val:val2:bar") |
| 272 | 272 | ||
| 273 | def test_append_unset(self): | ||
| 274 | self.d.setVar("TEST_prepend", "${FOO}:") | ||
| 275 | self.d.setVar("TEST_append", ":val2") | ||
| 276 | self.d.setVar("TEST_append", ":${BAR}") | ||
| 277 | bb.data.update_data(self.d) | ||
| 278 | self.assertEqual(self.d.getVar("TEST", True), "foo::val2:bar") | ||
| 279 | |||
| 273 | def test_remove(self): | 280 | def test_remove(self): |
| 274 | self.d.setVar("TEST", "${VAL} ${BAR}") | 281 | self.d.setVar("TEST", "${VAL} ${BAR}") |
| 275 | self.d.setVar("TEST_remove", "val") | 282 | self.d.setVar("TEST_remove", "val") |
| @@ -318,12 +325,52 @@ class TestOverrides(unittest.TestCase): | |||
| 318 | bb.data.update_data(self.d) | 325 | bb.data.update_data(self.d) |
| 319 | self.assertEqual(self.d.getVar("TEST", True), "testvalue2") | 326 | self.assertEqual(self.d.getVar("TEST", True), "testvalue2") |
| 320 | 327 | ||
| 328 | def test_one_override_unset(self): | ||
| 329 | self.d.setVar("TEST2_bar", "testvalue2") | ||
| 330 | bb.data.update_data(self.d) | ||
| 331 | self.assertEqual(self.d.getVar("TEST2", True), "testvalue2") | ||
| 332 | self.assertItemsEqual(self.d.keys(), ['TEST', 'TEST2', 'OVERRIDES', 'TEST2_bar']) | ||
| 333 | |||
| 321 | def test_multiple_override(self): | 334 | def test_multiple_override(self): |
| 322 | self.d.setVar("TEST_bar", "testvalue2") | 335 | self.d.setVar("TEST_bar", "testvalue2") |
| 323 | self.d.setVar("TEST_local", "testvalue3") | 336 | self.d.setVar("TEST_local", "testvalue3") |
| 324 | self.d.setVar("TEST_foo", "testvalue4") | 337 | self.d.setVar("TEST_foo", "testvalue4") |
| 325 | bb.data.update_data(self.d) | 338 | bb.data.update_data(self.d) |
| 326 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | 339 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") |
| 340 | self.assertItemsEqual(self.d.keys(), ['TEST', 'TEST_foo', 'OVERRIDES', 'TEST_bar', 'TEST_local']) | ||
| 341 | |||
| 342 | def test_multiple_combined_overrides(self): | ||
| 343 | self.d.setVar("TEST_local_foo_bar", "testvalue3") | ||
| 344 | bb.data.update_data(self.d) | ||
| 345 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | ||
| 346 | |||
| 347 | def test_multiple_overrides_unset(self): | ||
| 348 | self.d.setVar("TEST2_local_foo_bar", "testvalue3") | ||
| 349 | bb.data.update_data(self.d) | ||
| 350 | self.assertEqual(self.d.getVar("TEST2", True), "testvalue3") | ||
| 351 | |||
| 352 | def test_keyexpansion_override(self): | ||
| 353 | self.d.setVar("LOCAL", "local") | ||
| 354 | self.d.setVar("TEST_bar", "testvalue2") | ||
| 355 | self.d.setVar("TEST_${LOCAL}", "testvalue3") | ||
| 356 | self.d.setVar("TEST_foo", "testvalue4") | ||
| 357 | bb.data.update_data(self.d) | ||
| 358 | bb.data.expandKeys(self.d) | ||
| 359 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | ||
| 360 | |||
| 361 | def test_rename_override(self): | ||
| 362 | self.d.setVar("ALTERNATIVE_ncurses-tools_class-target", "a") | ||
| 363 | self.d.setVar("OVERRIDES", "class-target") | ||
| 364 | bb.data.update_data(self.d) | ||
| 365 | self.d.renameVar("ALTERNATIVE_ncurses-tools", "ALTERNATIVE_lib32-ncurses-tools") | ||
| 366 | self.assertEqual(self.d.getVar("ALTERNATIVE_lib32-ncurses-tools", True), "a") | ||
| 367 | |||
| 368 | def test_underscore_override(self): | ||
| 369 | self.d.setVar("TEST_bar", "testvalue2") | ||
| 370 | self.d.setVar("TEST_some_val", "testvalue3") | ||
| 371 | self.d.setVar("TEST_foo", "testvalue4") | ||
| 372 | self.d.setVar("OVERRIDES", "foo:bar:some_val") | ||
| 373 | self.assertEqual(self.d.getVar("TEST", True), "testvalue3") | ||
| 327 | 374 | ||
| 328 | class TestKeyExpansion(unittest.TestCase): | 375 | class TestKeyExpansion(unittest.TestCase): |
| 329 | def setUp(self): | 376 | def setUp(self): |
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py index fa40327339..21fd78a736 100644 --- a/bitbake/lib/bb/tests/parse.py +++ b/bitbake/lib/bb/tests/parse.py | |||
| @@ -67,3 +67,49 @@ C = "3" | |||
| 67 | f = self.parsehelper(testfileB) | 67 | f = self.parsehelper(testfileB) |
| 68 | with self.assertRaises(bb.parse.ParseError): | 68 | with self.assertRaises(bb.parse.ParseError): |
| 69 | d = bb.parse.handle(f.name, self.d)[''] | 69 | d = bb.parse.handle(f.name, self.d)[''] |
| 70 | |||
| 71 | overridetest = """ | ||
| 72 | RRECOMMENDS_${PN} = "a" | ||
| 73 | RRECOMMENDS_${PN}_libc = "b" | ||
| 74 | OVERRIDES = "libc:${PN}" | ||
| 75 | PN = "gtk+" | ||
| 76 | """ | ||
| 77 | |||
| 78 | def test_parse_overrides(self): | ||
| 79 | f = self.parsehelper(self.overridetest) | ||
| 80 | d = bb.parse.handle(f.name, self.d)[''] | ||
| 81 | self.assertEqual(d.getVar("RRECOMMENDS", True), "b") | ||
| 82 | bb.data.expandKeys(d) | ||
| 83 | self.assertEqual(d.getVar("RRECOMMENDS", True), "b") | ||
| 84 | d.setVar("RRECOMMENDS_gtk+", "c") | ||
| 85 | self.assertEqual(d.getVar("RRECOMMENDS", True), "c") | ||
| 86 | |||
| 87 | overridetest2 = """ | ||
| 88 | EXTRA_OECONF = "" | ||
| 89 | EXTRA_OECONF_class-target = "b" | ||
| 90 | EXTRA_OECONF_append = " c" | ||
| 91 | """ | ||
| 92 | |||
| 93 | def test_parse_overrides(self): | ||
| 94 | f = self.parsehelper(self.overridetest2) | ||
| 95 | d = bb.parse.handle(f.name, self.d)[''] | ||
| 96 | d.appendVar("EXTRA_OECONF", " d") | ||
| 97 | d.setVar("OVERRIDES", "class-target") | ||
| 98 | self.assertEqual(d.getVar("EXTRA_OECONF", True), "b c d") | ||
| 99 | |||
| 100 | overridetest3 = """ | ||
| 101 | DESCRIPTION = "A" | ||
| 102 | DESCRIPTION_${PN}-dev = "${DESCRIPTION} B" | ||
| 103 | PN = "bc" | ||
| 104 | """ | ||
| 105 | |||
| 106 | def test_parse_combinations(self): | ||
| 107 | f = self.parsehelper(self.overridetest3) | ||
| 108 | d = bb.parse.handle(f.name, self.d)[''] | ||
| 109 | bb.data.expandKeys(d) | ||
| 110 | self.assertEqual(d.getVar("DESCRIPTION_bc-dev", True), "A B") | ||
| 111 | d.setVar("DESCRIPTION", "E") | ||
| 112 | d.setVar("DESCRIPTION_bc-dev", "C D") | ||
| 113 | d.setVar("OVERRIDES", "bc-dev") | ||
| 114 | self.assertEqual(d.getVar("DESCRIPTION", True), "C D") | ||
| 115 | |||
