summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/data.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/tests/data.py')
-rw-r--r--bitbake/lib/bb/tests/data.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index 1a5a28af06..2bd481b5d7 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -444,3 +444,42 @@ class Contains(unittest.TestCase):
444 444
445 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x", True, False, self.d)) 445 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x", True, False, self.d))
446 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) 446 self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d))
447
448
449class Remote(unittest.TestCase):
450 def test_remote(self):
451 class TestConnector:
452 d = None
453 def __init__(self, d):
454 self.d = d
455 def getVar(self, name):
456 return self.d._findVar(name)
457 def getKeys(self):
458 return self.d.localkeys()
459 def getVarHistory(self, name):
460 return self.d.varhistory.variable(name)
461 def expandPythonRef(self, varname, expr):
462 varparse = bb.data_smart.VariableParse(varname, self.d)
463 return varparse.python_sub(expr)
464 def setVar(self, name, value):
465 self.d.setVar(name, value)
466
467 d1 = bb.data.init()
468 d1.enableTracking()
469 d2 = bb.data.init()
470 d2.enableTracking()
471 connector = TestConnector(d1)
472
473 d2.setVar('_remote_data', connector)
474
475 d1.setVar('HELLO', 'world')
476 d1.setVarFlag('OTHER', 'flagname', 'flagvalue')
477 self.assertEqual(d2.getVar('HELLO'), 'world')
478 self.assertEqual(d2.expand('${HELLO}'), 'world')
479 self.assertEqual(d2.expand('${@d.getVar("HELLO")}'), 'world')
480 self.assertIn('flagname', d2.getVarFlags('OTHER'))
481 self.assertEqual(d2.getVarFlag('OTHER', 'flagname'), 'flagvalue')
482 self.assertEqual(d1.varhistory.variable('HELLO'), d2.varhistory.variable('HELLO'))
483 # Test setVar on client side affects server
484 d2.setVar('HELLO', 'other-world')
485 self.assertEqual(d1.getVar('HELLO'), 'other-world')