diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-10 16:56:44 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-10 16:56:44 -0500 |
commit | 41470d29f5888baf7ec78e170cc0d6d981dcf63e (patch) | |
tree | fa9777e5efcaddd21d8c0127dcd617ef7e2fac0a /tests/unittests | |
parent | 0865e5179f2a803f727e83b5e36681613e63fe8a (diff) | |
parent | be38478cd8e11b0e29c70bb881a676628e9f74d5 (diff) | |
download | vyos-cloud-init-41470d29f5888baf7ec78e170cc0d6d981dcf63e.tar.gz vyos-cloud-init-41470d29f5888baf7ec78e170cc0d6d981dcf63e.zip |
dmi data: fix failure of reading dmi data for unset dmi values
it is not uncommon to find dmi data in /sys full of 'ff'. utf-8
decoding of those would fail, causing warning and stacktrace.
Return '.' instead of \xff. This is what dmidecode would return.
$ dmidecode --string system-product-name
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/test_util.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 95990165..0a986fec 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -385,6 +385,16 @@ class TestReadDMIData(helpers.FilesystemMockingTestCase): self.patch_mapping({}) self.assertEqual(None, util.read_dmi_data('expect-fail')) + def test_dots_returned_instead_of_foxfox(self): + # uninitialized dmi values show as \xff, return those as . + my_len = 32 + dmi_value = b'\xff' * my_len + b'\n' + expected = '.' * my_len + dmi_key = 'system-product-name' + sysfs_key = 'product_name' + self._create_sysfs_file(sysfs_key, dmi_value) + self.assertEqual(expected, util.read_dmi_data(dmi_key)) + class TestMultiLog(helpers.FilesystemMockingTestCase): |