summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2019-11-07 23:57:32 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-11-21 23:09:03 +0000
commit1d8a0f4f00e4dda80b9e1c6dc05ac5d99c5a653c (patch)
tree847a59cba4abf0bd0b095b9f6c8ccc8ad7b4e674 /bitbake/lib
parent790fb802b1cb45626bf3c6d89abbabf3241052bd (diff)
downloadpoky-1d8a0f4f00e4dda80b9e1c6dc05ac5d99c5a653c.tar.gz
bitbake: tests: add test for the hashing functions
Add a basic test for bb.utils.md5_file() etc. (Bitbake rev: e944d02fe678f7c6b05c62419f8bceb0709f3037) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/tests/utils.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/utils.py b/bitbake/lib/bb/tests/utils.py
index f4adf1d44b..5c910b4b8e 100644
--- a/bitbake/lib/bb/tests/utils.py
+++ b/bitbake/lib/bb/tests/utils.py
@@ -103,6 +103,32 @@ class Path(unittest.TestCase):
103 result = bb.utils._check_unsafe_delete_path(arg1) 103 result = bb.utils._check_unsafe_delete_path(arg1)
104 self.assertEqual(result, correctresult, '_check_unsafe_delete_path("%s") != %s' % (arg1, correctresult)) 104 self.assertEqual(result, correctresult, '_check_unsafe_delete_path("%s") != %s' % (arg1, correctresult))
105 105
106class Checksum(unittest.TestCase):
107 filler = b"Shiver me timbers square-rigged spike Gold Road galleon bilge water boatswain wherry jack pirate. Mizzenmast rum lad Privateer jack salmagundi hang the jib piracy Pieces of Eight Corsair. Parrel marooned black spot yawl provost quarterdeck cable no prey, no pay spirits lateen sail."
108
109 def test_md5(self):
110 import hashlib
111 with tempfile.NamedTemporaryFile() as f:
112 f.write(self.filler)
113 f.flush()
114 checksum = bb.utils.md5_file(f.name)
115 self.assertEqual(checksum, "bd572cd5de30a785f4efcb6eaf5089e3")
116
117 def test_sha1(self):
118 import hashlib
119 with tempfile.NamedTemporaryFile() as f:
120 f.write(self.filler)
121 f.flush()
122 checksum = bb.utils.sha1_file(f.name)
123 self.assertEqual(checksum, "249eb8fd654732ea836d5e702d7aa567898eca71")
124
125 def test_sha256(self):
126 import hashlib
127 with tempfile.NamedTemporaryFile() as f:
128 f.write(self.filler)
129 f.flush()
130 checksum = bb.utils.sha256_file(f.name)
131 self.assertEqual(checksum, "fcfbae8bf6b721dbb9d2dc6a9334a58f2031a9a9b302999243f99da4d7f12d0f")
106 132
107class EditMetadataFile(unittest.TestCase): 133class EditMetadataFile(unittest.TestCase):
108 _origfile = """ 134 _origfile = """