diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-12-13 20:07:04 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-14 12:25:07 +0000 |
commit | d325d94f3f8b6a475aebe3ae7d8a140ac6fec779 (patch) | |
tree | 0aed87e5ae71454350b631cc30e4dd6a2247b78b /bitbake/lib/bb/tests/data.py | |
parent | 727f332829a29cf71972573e68b53bb570e30ffd (diff) | |
download | poky-d325d94f3f8b6a475aebe3ae7d8a140ac6fec779.tar.gz |
bitbake: data_smart: implement remote datastore functionality
This allows you to maintain a local reference to a remote datastore. The
actual implementation of the remote connection is delegated to a
connector object that the caller must define and supply. There is
support for getting variable values and expanding python references
(i.e. ${@...} remotely, however setting variables remotely is not
supported - any variable setting is done locally as if the datastore
were a copy (which it kind of is).
Loosely based on an earlier prototype implementation by Qing He.
(Bitbake rev: a3edc3eefa2d03c4ad5d12187b32fa4dc495082a)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/data.py')
-rw-r--r-- | bitbake/lib/bb/tests/data.py | 39 |
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 | |||
449 | class 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') | ||