summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-12-13 20:07:11 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-14 12:25:07 +0000
commit7229250411e7517cdf9e464d7f6033b155811bd8 (patch)
tree1234c51773084be06bcce6ff567a24ec636fd43e /bitbake/lib/bb/tests
parent797a8ee040e5f5eca1973478daddb3c18fef8c5e (diff)
downloadpoky-7229250411e7517cdf9e464d7f6033b155811bd8.tar.gz
bitbake: data_smart: support serialisation
The COW object used within VariableHistory can't be serialised itself, but we can convert it to a dict when serializing and then back when deserialising. This finally allows DataSmart objects to be serialized. NOTE: "serialisation" here means pickling, not over XMLRPC or any other transport. (Bitbake rev: bbbb2a53d5decf3b613a92c4ff77c84bfc5d4903) 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')
-rw-r--r--bitbake/lib/bb/tests/data.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index a17245f90a..ba30d12806 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -446,6 +446,29 @@ class Contains(unittest.TestCase):
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 447
448 448
449class Serialize(unittest.TestCase):
450
451 def test_serialize(self):
452 import tempfile
453 import pickle
454 d = bb.data.init()
455 d.enableTracking()
456 d.setVar('HELLO', 'world')
457 d.setVarFlag('HELLO', 'other', 'planet')
458 with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
459 tmpfilename = tmpfile.name
460 pickle.dump(d, tmpfile)
461
462 with open(tmpfilename, 'rb') as f:
463 newd = pickle.load(f)
464
465 os.remove(tmpfilename)
466
467 self.assertEqual(d, newd)
468 self.assertEqual(newd.getVar('HELLO', True), 'world')
469 self.assertEqual(newd.getVarFlag('HELLO', 'other'), 'planet')
470
471
449class Remote(unittest.TestCase): 472class Remote(unittest.TestCase):
450 def test_remote(self): 473 def test_remote(self):
451 class TestConnector: 474 class TestConnector: