diff options
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r-- | bitbake/lib/bb/tests/data.py | 128 |
1 files changed, 110 insertions, 18 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index da3f4e66f8..fe947f5ba7 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
@@ -460,26 +460,43 @@ class Serialize(unittest.TestCase): | |||
460 | self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet') | 460 | self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet') |
461 | 461 | ||
462 | 462 | ||
463 | # Remote datastore tests | ||
464 | # These really only test the interface, since in actual usage we have a | ||
465 | # tinfoil connector that does everything over RPC, and this doesn't test | ||
466 | # that. | ||
467 | |||
468 | class TestConnector: | ||
469 | d = None | ||
470 | def __init__(self, d): | ||
471 | self.d = d | ||
472 | def getVar(self, name): | ||
473 | return self.d._findVar(name) | ||
474 | def getKeys(self): | ||
475 | return set(self.d.keys()) | ||
476 | def getVarHistory(self, name): | ||
477 | return self.d.varhistory.variable(name) | ||
478 | def expandPythonRef(self, varname, expr, d): | ||
479 | localdata = self.d.createCopy() | ||
480 | for key in d.localkeys(): | ||
481 | localdata.setVar(d.getVar(key)) | ||
482 | varparse = bb.data_smart.VariableParse(varname, localdata) | ||
483 | return varparse.python_sub(expr) | ||
484 | def setVar(self, name, value): | ||
485 | self.d.setVar(name, value) | ||
486 | def setVarFlag(self, name, flag, value): | ||
487 | self.d.setVarFlag(name, flag, value) | ||
488 | def delVar(self, name): | ||
489 | self.d.delVar(name) | ||
490 | return False | ||
491 | def delVarFlag(self, name, flag): | ||
492 | self.d.delVarFlag(name, flag) | ||
493 | return False | ||
494 | def renameVar(self, name, newname): | ||
495 | self.d.renameVar(name, newname) | ||
496 | return False | ||
497 | |||
463 | class Remote(unittest.TestCase): | 498 | class Remote(unittest.TestCase): |
464 | def test_remote(self): | 499 | def test_remote(self): |
465 | class TestConnector: | ||
466 | d = None | ||
467 | def __init__(self, d): | ||
468 | self.d = d | ||
469 | def getVar(self, name): | ||
470 | return self.d._findVar(name) | ||
471 | def getKeys(self): | ||
472 | return self.d.localkeys() | ||
473 | def getVarHistory(self, name): | ||
474 | return self.d.varhistory.variable(name) | ||
475 | def expandPythonRef(self, varname, expr, d): | ||
476 | localdata = self.d.createCopy() | ||
477 | for key in d.localkeys(): | ||
478 | localdata.setVar(d.getVar(key)) | ||
479 | varparse = bb.data_smart.VariableParse(varname, localdata) | ||
480 | return varparse.python_sub(expr) | ||
481 | def setVar(self, name, value): | ||
482 | self.d.setVar(name, value) | ||
483 | 500 | ||
484 | d1 = bb.data.init() | 501 | d1 = bb.data.init() |
485 | d1.enableTracking() | 502 | d1.enableTracking() |
@@ -500,6 +517,9 @@ class Remote(unittest.TestCase): | |||
500 | # Test setVar on client side affects server | 517 | # Test setVar on client side affects server |
501 | d2.setVar('HELLO', 'other-world') | 518 | d2.setVar('HELLO', 'other-world') |
502 | self.assertEqual(d1.getVar('HELLO'), 'other-world') | 519 | self.assertEqual(d1.getVar('HELLO'), 'other-world') |
520 | # Test setVarFlag on client side affects server | ||
521 | d2.setVarFlag('HELLO', 'flagname', 'flagvalue') | ||
522 | self.assertEqual(d1.getVarFlag('HELLO', 'flagname'), 'flagvalue') | ||
503 | # Test client side data is incorporated in python expansion (which is done on server) | 523 | # Test client side data is incorporated in python expansion (which is done on server) |
504 | d2.setVar('FOO', 'bar') | 524 | d2.setVar('FOO', 'bar') |
505 | self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar') | 525 | self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar') |
@@ -507,3 +527,75 @@ class Remote(unittest.TestCase): | |||
507 | d1.setVar('FOO_test', 'baz') | 527 | d1.setVar('FOO_test', 'baz') |
508 | d1.appendVar('OVERRIDES', ':test') | 528 | d1.appendVar('OVERRIDES', ':test') |
509 | self.assertEqual(d2.getVar('FOO'), 'baz') | 529 | self.assertEqual(d2.getVar('FOO'), 'baz') |
530 | |||
531 | |||
532 | # Remote equivalents of local test classes | ||
533 | # Note that these aren't perfect since we only test in one direction | ||
534 | |||
535 | class RemoteDataExpansions(DataExpansions): | ||
536 | def setUp(self): | ||
537 | self.d1 = bb.data.init() | ||
538 | self.d = bb.data.init() | ||
539 | self.d1["foo"] = "value_of_foo" | ||
540 | self.d1["bar"] = "value_of_bar" | ||
541 | self.d1["value_of_foo"] = "value_of_'value_of_foo'" | ||
542 | connector = TestConnector(self.d1) | ||
543 | self.d.setVar('_remote_data', connector) | ||
544 | |||
545 | class TestRemoteNestedExpansions(TestNestedExpansions): | ||
546 | def setUp(self): | ||
547 | self.d1 = bb.data.init() | ||
548 | self.d = bb.data.init() | ||
549 | self.d1["foo"] = "foo" | ||
550 | self.d1["bar"] = "bar" | ||
551 | self.d1["value_of_foobar"] = "187" | ||
552 | connector = TestConnector(self.d1) | ||
553 | self.d.setVar('_remote_data', connector) | ||
554 | |||
555 | class TestRemoteConcat(TestConcat): | ||
556 | def setUp(self): | ||
557 | self.d1 = bb.data.init() | ||
558 | self.d = bb.data.init() | ||
559 | self.d1.setVar("FOO", "foo") | ||
560 | self.d1.setVar("VAL", "val") | ||
561 | self.d1.setVar("BAR", "bar") | ||
562 | connector = TestConnector(self.d1) | ||
563 | self.d.setVar('_remote_data', connector) | ||
564 | |||
565 | class TestRemoteConcatOverride(TestConcatOverride): | ||
566 | def setUp(self): | ||
567 | self.d1 = bb.data.init() | ||
568 | self.d = bb.data.init() | ||
569 | self.d1.setVar("FOO", "foo") | ||
570 | self.d1.setVar("VAL", "val") | ||
571 | self.d1.setVar("BAR", "bar") | ||
572 | connector = TestConnector(self.d1) | ||
573 | self.d.setVar('_remote_data', connector) | ||
574 | |||
575 | class TestRemoteOverrides(TestOverrides): | ||
576 | def setUp(self): | ||
577 | self.d1 = bb.data.init() | ||
578 | self.d = bb.data.init() | ||
579 | self.d1.setVar("OVERRIDES", "foo:bar:local") | ||
580 | self.d1.setVar("TEST", "testvalue") | ||
581 | connector = TestConnector(self.d1) | ||
582 | self.d.setVar('_remote_data', connector) | ||
583 | |||
584 | class TestRemoteKeyExpansion(TestKeyExpansion): | ||
585 | def setUp(self): | ||
586 | self.d1 = bb.data.init() | ||
587 | self.d = bb.data.init() | ||
588 | self.d1.setVar("FOO", "foo") | ||
589 | self.d1.setVar("BAR", "foo") | ||
590 | connector = TestConnector(self.d1) | ||
591 | self.d.setVar('_remote_data', connector) | ||
592 | |||
593 | class TestRemoteFlags(TestFlags): | ||
594 | def setUp(self): | ||
595 | self.d1 = bb.data.init() | ||
596 | self.d = bb.data.init() | ||
597 | self.d1.setVar("foo", "value of foo") | ||
598 | self.d1.setVarFlag("foo", "flag1", "value of flag1") | ||
599 | self.d1.setVarFlag("foo", "flag2", "value of flag2") | ||
600 | connector = TestConnector(self.d1) | ||
601 | self.d.setVar('_remote_data', connector) | ||