diff options
Diffstat (limited to 'bitbake/lib/bb/tests/utils.py')
| -rw-r--r-- | bitbake/lib/bb/tests/utils.py | 39 | 
1 files changed, 38 insertions, 1 deletions
diff --git a/bitbake/lib/bb/tests/utils.py b/bitbake/lib/bb/tests/utils.py index a7ff33db52..52b7bf85bf 100644 --- a/bitbake/lib/bb/tests/utils.py +++ b/bitbake/lib/bb/tests/utils.py  | |||
| @@ -130,6 +130,14 @@ class Checksum(unittest.TestCase): | |||
| 130 | checksum = bb.utils.sha256_file(f.name) | 130 | checksum = bb.utils.sha256_file(f.name) | 
| 131 | self.assertEqual(checksum, "fcfbae8bf6b721dbb9d2dc6a9334a58f2031a9a9b302999243f99da4d7f12d0f") | 131 | self.assertEqual(checksum, "fcfbae8bf6b721dbb9d2dc6a9334a58f2031a9a9b302999243f99da4d7f12d0f") | 
| 132 | 132 | ||
| 133 | def test_goh1(self): | ||
| 134 | import hashlib | ||
| 135 | with tempfile.NamedTemporaryFile() as f: | ||
| 136 | f.write(self.filler) | ||
| 137 | f.flush() | ||
| 138 | checksum = bb.utils.goh1_file(f.name) | ||
| 139 | self.assertEqual(checksum, "81191f04d4abf413e5badd234814e4202d9efa73e6f9437e9ddd6b8165b569ef") | ||
| 140 | |||
| 133 | class EditMetadataFile(unittest.TestCase): | 141 | class EditMetadataFile(unittest.TestCase): | 
| 134 | _origfile = """ | 142 | _origfile = """ | 
| 135 | # A comment | 143 | # A comment | 
| @@ -418,7 +426,7 @@ MULTILINE = " stuff \\ | |||
| 418 | ['MULTILINE'], | 426 | ['MULTILINE'], | 
| 419 | handle_var) | 427 | handle_var) | 
| 420 | 428 | ||
| 421 | testvalue = re.sub('\s+', ' ', value_in_callback.strip()) | 429 | testvalue = re.sub(r'\s+', ' ', value_in_callback.strip()) | 
| 422 | self.assertEqual(expected_value, testvalue) | 430 | self.assertEqual(expected_value, testvalue) | 
| 423 | 431 | ||
| 424 | class EditBbLayersConf(unittest.TestCase): | 432 | class EditBbLayersConf(unittest.TestCase): | 
| @@ -666,3 +674,32 @@ class GetReferencedVars(unittest.TestCase): | |||
| 666 | 674 | ||
| 667 | layers = [{"SRC_URI"}, {"QT_GIT", "QT_MODULE", "QT_MODULE_BRANCH_PARAM", "QT_GIT_PROTOCOL"}, {"QT_GIT_PROJECT", "QT_MODULE_BRANCH", "BPN"}, {"PN", "SPECIAL_PKGSUFFIX"}] | 675 | layers = [{"SRC_URI"}, {"QT_GIT", "QT_MODULE", "QT_MODULE_BRANCH_PARAM", "QT_GIT_PROTOCOL"}, {"QT_GIT_PROJECT", "QT_MODULE_BRANCH", "BPN"}, {"PN", "SPECIAL_PKGSUFFIX"}] | 
| 668 | self.check_referenced("${SRC_URI}", layers) | 676 | self.check_referenced("${SRC_URI}", layers) | 
| 677 | |||
| 678 | |||
| 679 | class EnvironmentTests(unittest.TestCase): | ||
| 680 | def test_environment(self): | ||
| 681 | os.environ["A"] = "this is A" | ||
| 682 | self.assertIn("A", os.environ) | ||
| 683 | self.assertEqual(os.environ["A"], "this is A") | ||
| 684 | self.assertNotIn("B", os.environ) | ||
| 685 | |||
| 686 | with bb.utils.environment(B="this is B"): | ||
| 687 | self.assertIn("A", os.environ) | ||
| 688 | self.assertEqual(os.environ["A"], "this is A") | ||
| 689 | self.assertIn("B", os.environ) | ||
| 690 | self.assertEqual(os.environ["B"], "this is B") | ||
| 691 | |||
| 692 | self.assertIn("A", os.environ) | ||
| 693 | self.assertEqual(os.environ["A"], "this is A") | ||
| 694 | self.assertNotIn("B", os.environ) | ||
| 695 | |||
| 696 | class FilemodeTests(unittest.TestCase): | ||
| 697 | def test_filemode_convert(self): | ||
| 698 | self.assertEqual(0o775, bb.utils.to_filemode("0o775")) | ||
| 699 | self.assertEqual(0o775, bb.utils.to_filemode(0o775)) | ||
| 700 | self.assertEqual(0o775, bb.utils.to_filemode("775")) | ||
| 701 | with self.assertRaises(ValueError): | ||
| 702 | bb.utils.to_filemode("xyz") | ||
| 703 | with self.assertRaises(ValueError): | ||
| 704 | bb.utils.to_filemode("999") | ||
| 705 | |||
