summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-17 14:41:48 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-18 10:59:27 +0100
commit4ef016683d986cc5291e494789ff5a49b28030eb (patch)
treef24f29d31f36642f7facf3f4b857bba4faebe078 /bitbake/lib
parent7e9212712817a7c10b9aae7a26de3de3a4f18611 (diff)
downloadpoky-4ef016683d986cc5291e494789ff5a49b28030eb.tar.gz
bitbake: test/data: Add new tests for task checksum changing/not changing
This adds some basic tests for task checksums to ensure that the checksums: * change when variables change * change when active _remove operators are present * don't change when the _remove operators are not active * change when an active contains() expression is present * dont' change a contains() expression isn't active There is a lot of other functionality which should be added to this test but its a start. (Bitbake rev: 5463c16e3619d324aed137f47f93f0997a227d29) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/tests/data.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index 8279115e03..9ac78e3683 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -455,6 +455,54 @@ class Contains(unittest.TestCase):
455 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) 455 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d))
456 456
457 457
458class TaskHash(unittest.TestCase):
459 def test_taskhashes(self):
460 def gettask_bashhash(taskname, d):
461 tasklist, gendeps, lookupcache = bb.data.generate_dependencies(d)
462 taskdeps, basehash = bb.data.generate_dependency_hash(tasklist, gendeps, lookupcache, set(), "somefile")
463 bb.warn(str(lookupcache))
464 return basehash["somefile." + taskname]
465
466 d = bb.data.init()
467 d.setVar("__BBTASKS", ["mytask"])
468 d.setVar("__exportlist", [])
469 d.setVar("mytask", "${MYCOMMAND}")
470 d.setVar("MYCOMMAND", "${VAR}; foo; bar; exit 0")
471 d.setVar("VAR", "val")
472 orighash = gettask_bashhash("mytask", d)
473
474 # Changing a variable should change the hash
475 d.setVar("VAR", "val2")
476 nexthash = gettask_bashhash("mytask", d)
477 self.assertNotEqual(orighash, nexthash)
478
479 d.setVar("VAR", "val")
480 # Adding an inactive removal shouldn't change the hash
481 d.setVar("BAR", "notbar")
482 d.setVar("MYCOMMAND_remove", "${BAR}")
483 nexthash = gettask_bashhash("mytask", d)
484 self.assertEqual(orighash, nexthash)
485
486 # Adding an active removal should change the hash
487 d.setVar("BAR", "bar;")
488 nexthash = gettask_bashhash("mytask", d)
489 self.assertNotEqual(orighash, nexthash)
490
491 # Setup an inactive contains()
492 d.setVar("VAR", "${@bb.utils.contains('VAR2', 'A', 'val', '', d)}")
493 orighash = gettask_bashhash("mytask", d)
494
495 # Activate the contains() and the hash should change
496 d.setVar("VAR2", "A")
497 nexthash = gettask_bashhash("mytask", d)
498 self.assertNotEqual(orighash, nexthash)
499
500 # The contains should be inactive but even though VAR2 has a
501 # different value the hash should match the original
502 d.setVar("VAR2", "B")
503 nexthash = gettask_bashhash("mytask", d)
504 self.assertEqual(orighash, nexthash)
505
458class Serialize(unittest.TestCase): 506class Serialize(unittest.TestCase):
459 507
460 def test_serialize(self): 508 def test_serialize(self):