Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-dtfabric for openSUSE:Factory checked in at 2021-07-30 23:22:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-dtfabric (Old) and /work/SRC/openSUSE:Factory/.python-dtfabric.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-dtfabric" Fri Jul 30 23:22:20 2021 rev:3 rq:909384 version:20200621 Changes: -------- --- /work/SRC/openSUSE:Factory/python-dtfabric/python-dtfabric.changes 2021-04-12 17:10:29.886573852 +0200 +++ /work/SRC/openSUSE:Factory/.python-dtfabric.new.1899/python-dtfabric.changes 2021-07-30 23:22:48.219595084 +0200 @@ -1,0 +2,5 @@ +Fri Jul 30 10:02:51 UTC 2021 - Matej Cepl <mc...@suse.com> + +- Add tests-improved.patch gh#libyal/dtfabric#25 + +------------------------------------------------------------------- New: ---- tests-improved.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-dtfabric.spec ++++++ --- /var/tmp/diff_new_pack.ht9YoR/_old 2021-07-30 23:22:48.615594649 +0200 +++ /var/tmp/diff_new_pack.ht9YoR/_new 2021-07-30 23:22:48.615594649 +0200 @@ -27,6 +27,9 @@ Group: Development/Languages/Python URL: https://github.com/libyal/dtfabric Source: https://files.pythonhosted.org/packages/source/d/%{modname}/%{modname}-%{version}.tar.gz +# PATCH-FIX-UPSTREAM tests-improved.patch gh#libyal/dtfabric#25 mc...@suse.com +# tests improved and hope more BigEndian safe +Patch0: tests-improved.patch BuildRequires: %{python_module PyYAML} BuildRequires: %{python_module setuptools} BuildRequires: fdupes @@ -40,7 +43,7 @@ dtFabric, or data type fabric, is a project to manage data types and structures, as used in the libyal projects. %prep -%setup -q -n %{modname}-%{version} +%autosetup -p1 -n %{modname}-%{version} %build %python_build ++++++ tests-improved.patch ++++++ >From 40b51143a0b956b0f28fc49b6c3f3e48b379e4bf Mon Sep 17 00:00:00 2001 From: Joachim Metz <joachim.m...@gmail.com> Date: Fri, 30 Jul 2021 11:05:03 +0200 Subject: [PATCH] Worked on tests --- test_data/structure.yaml | 2 test_data/structure_with_condition.yaml | 2 test_data/structure_with_padding.yaml | 5 ++ test_data/structure_with_sequence.yaml | 2 test_data/structure_with_stream.yaml | 2 test_data/structure_with_string.yaml | 2 test_data/structure_with_values.yaml | 2 tests/runtime/byte_operations.py | 4 - tests/runtime/data_maps.py | 69 +++++++++++++------------------- 9 files changed, 48 insertions(+), 42 deletions(-) --- a/test_data/structure.yaml +++ b/test_data/structure.yaml @@ -43,6 +43,8 @@ members: --- name: sphere3d type: structure +attributes: + byte_order: little-endian description: Sphere in 3 dimensional space. members: - name: number_of_triangles --- a/test_data/structure_with_condition.yaml +++ b/test_data/structure_with_condition.yaml @@ -14,6 +14,8 @@ attributes: --- name: structure_with_condition type: structure +attributes: + byte_order: little-endian members: - name: flags data_type: uint16 --- a/test_data/structure_with_padding.yaml +++ b/test_data/structure_with_padding.yaml @@ -14,6 +14,8 @@ attributes: --- name: structure_with_padding type: structure +attributes: + byte_order: little-endian members: - name: data_size data_type: uint16 @@ -23,6 +25,9 @@ members: --- name: structure_with_padding_and_stream type: structure +attributes: + byte_order: little-endian +members: members: - name: data_size data_type: uint16 --- a/test_data/structure_with_sequence.yaml +++ b/test_data/structure_with_sequence.yaml @@ -14,6 +14,8 @@ attributes: --- name: extension_block type: structure +attributes: + byte_order: little-endian members: - name: size data_type: uint32 --- a/test_data/structure_with_stream.yaml +++ b/test_data/structure_with_stream.yaml @@ -14,6 +14,8 @@ attributes: --- name: extension_block type: structure +attributes: + byte_order: little-endian members: - name: size data_type: uint32 --- a/test_data/structure_with_string.yaml +++ b/test_data/structure_with_string.yaml @@ -14,6 +14,8 @@ attributes: --- name: utf16_string type: structure +attributes: + byte_order: little-endian members: - name: size data_type: uint16 --- a/test_data/structure_with_values.yaml +++ b/test_data/structure_with_values.yaml @@ -29,6 +29,8 @@ members: --- name: structure_with_values type: structure +attributes: + byte_order: little-endian members: - name: format_version data_type: uint32 --- a/tests/runtime/byte_operations.py +++ b/tests/runtime/byte_operations.py @@ -27,7 +27,7 @@ class StructOperationTest(test_lib.BaseT def testReadFrom(self): """Tests the ReadFrom function.""" - byte_stream_operation = byte_operations.StructOperation('i') + byte_stream_operation = byte_operations.StructOperation('<i') value = byte_stream_operation.ReadFrom(b'\x12\x34\x56\x78') self.assertEqual(value, tuple([0x78563412])) @@ -40,7 +40,7 @@ class StructOperationTest(test_lib.BaseT def testWriteTo(self): """Tests the WriteTo function.""" - byte_stream_operation = byte_operations.StructOperation('i') + byte_stream_operation = byte_operations.StructOperation('<i') byte_stream = byte_stream_operation.WriteTo(tuple([0x78563412])) self.assertEqual(byte_stream, b'\x12\x34\x56\x78') --- a/tests/runtime/data_maps.py +++ b/tests/runtime/data_maps.py @@ -761,12 +761,10 @@ class SequenceMapTest(test_lib.BaseTestC data_type_map = data_maps.SequenceMap(data_type_definition) - byte_values = [] - for value in range(1, 13): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + byte_values = [ + value.to_bytes(4, byteorder='little') for value in range(1, 13)] - byte_stream = bytes(bytearray(byte_values)) + byte_stream = b''.join(byte_values) sequence_value = data_type_map._CompositeMapByteStream(byte_stream) self.assertEqual( @@ -1157,14 +1155,13 @@ class StructureMapTest(test_lib.BaseTest data_type_definition = definitions_registry.GetDefinitionByName('point3d') data_type_map = data_maps.StructureMap(data_type_definition) - byte_values = [] - for value in range(1, 4): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + expected_byte_values = [ + value.to_bytes(4, byteorder='little') for value in range(1, 4)] + + expected_byte_stream = b''.join(expected_byte_values) point3d = data_type_map.CreateStructureValues(x=1, y=2, z=3) - expected_byte_stream = bytes(bytearray(byte_values)) byte_stream = data_type_map._LinearFoldByteStream(point3d) self.assertEqual(byte_stream, expected_byte_stream) @@ -1178,12 +1175,10 @@ class StructureMapTest(test_lib.BaseTest data_type_definition = definitions_registry.GetDefinitionByName('point3d') data_type_map = data_maps.StructureMap(data_type_definition) - byte_values = [] - for value in range(1, 4): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + byte_values = [ + value.to_bytes(4, byteorder='little') for value in range(1, 4)] - byte_stream = bytes(bytearray(byte_values)) + byte_stream = b''.join(byte_values) point3d = data_type_map._LinearMapByteStream(byte_stream) self.assertEqual(point3d.x, 1) @@ -1240,12 +1235,10 @@ class StructureMapTest(test_lib.BaseTest data_type_definition = definitions_registry.GetDefinitionByName('point3d') data_type_map = data_maps.StructureMap(data_type_definition) - byte_values = [] - for value in range(1, 4): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + byte_values = [ + value.to_bytes(4, byteorder='little') for value in range(1, 4)] - byte_stream = bytes(bytearray(byte_values)) + byte_stream = b''.join(byte_values) point3d = data_type_map.MapByteStream(byte_stream) self.assertEqual(point3d.x, 1) @@ -1271,12 +1264,10 @@ class StructureMapTest(test_lib.BaseTest data_type_definition = definitions_registry.GetDefinitionByName('box3d') data_type_map = data_maps.StructureMap(data_type_definition) - byte_values = [] - for value in range(1, 433): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + byte_values = [ + value.to_bytes(4, byteorder='little') for value in range(1, 433)] - byte_stream = bytes(bytearray(byte_values)) + byte_stream = b''.join(byte_values) box = data_type_map.MapByteStream(byte_stream) self.assertEqual(box.triangles[0].a.x, 1) @@ -1294,12 +1285,11 @@ class StructureMapTest(test_lib.BaseTest 'structure_with_condition') data_type_map = data_maps.StructureMap(data_type_definition) - byte_values = [0x01, 0x80] - for value in range(1, 6): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + byte_values = [0x8001.to_bytes(2, byteorder='little')] + byte_values.extend([ + value.to_bytes(4, byteorder='little') for value in range(1, 6)]) - byte_stream = bytes(bytearray(byte_values)) + byte_stream = b''.join(byte_values) structure_with_condition = data_type_map.MapByteStream(byte_stream) self.assertEqual(structure_with_condition.flags, 0x8001) @@ -1310,12 +1300,11 @@ class StructureMapTest(test_lib.BaseTest self.assertEqual(structure_with_condition.conditional_data2, 4) self.assertEqual(structure_with_condition.data3, 5) - byte_values = [0x01, 0x00] - for value in range(1, 6): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + byte_values = [0x0001.to_bytes(2, byteorder='little')] + byte_values.extend([ + value.to_bytes(4, byteorder='little') for value in range(1, 6)]) - byte_stream = bytes(bytearray(byte_values)) + byte_stream = b''.join(byte_values) structure_with_condition = data_type_map.MapByteStream(byte_stream) self.assertEqual(structure_with_condition.flags, 0x0001) @@ -1378,12 +1367,12 @@ class StructureMapTest(test_lib.BaseTest data_type_definition = definitions_registry.GetDefinitionByName('sphere3d') data_type_map = data_maps.StructureMap(data_type_definition) - byte_values = [3, 0, 0, 0] - for value in range(1, 113): - byte_value_upper, byte_value_lower = divmod(value, 256) - byte_values.extend([byte_value_lower, byte_value_upper, 0, 0]) + # Note that 3.to_bytes() is not supported as syntax. + byte_values = [0x3.to_bytes(4, byteorder='little')] + byte_values.extend([ + value.to_bytes(4, byteorder='little') for value in range(1, 113)]) - byte_stream = bytes(bytearray(byte_values)) + byte_stream = b''.join(byte_values) sphere = data_type_map.MapByteStream(byte_stream) self.assertEqual(sphere.number_of_triangles, 3)