laforge has submitted this change. (
https://gerrit.osmocom.org/c/pysim/+/41676?usp=email )
Change subject: unittests/test_files: Pass to-be-encoded length to encoder
functions
......................................................................
unittests/test_files: Pass to-be-encoded length to encoder functions
Some of the encoders can only generate valid output if they are told
the expected output size. This is due to variable-length fields that
depend on the size of the total record (or file). Let's always pass
the expected length to the encoder methods.
Change-Id: I88f957e49b0c88a121a266d3582e79822fa0e214
---
M tests/unittests/test_files.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
laforge: Looks good to me, approved
dexter: Looks good to me, but someone else must approve
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/tests/unittests/test_files.py b/tests/unittests/test_files.py
index ab70771..5bbbddd 100755
--- a/tests/unittests/test_files.py
+++ b/tests/unittests/test_files.py
@@ -96,7 +96,7 @@
inst = c()
encoded, rec_num, decoded = self._parse_t(t)
logging.debug("Testing encode of %s", name)
- re_enc = inst.encode_record_hex(decoded, rec_num)
+ re_enc = inst.encode_record_hex(decoded, rec_num,
len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
def test_de_encode_record(self):
@@ -122,7 +122,7 @@
self.assertEqual(decoded, re_dec)
# re-encode the decoded data
logging.debug("Testing re-encode of %s", name)
- re_enc = inst.encode_record_hex(re_dec, rec_num)
+ re_enc = inst.encode_record_hex(re_dec, rec_num,
len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
if hasattr(c, '_test_no_pad') and c._test_no_pad:
continue
@@ -196,7 +196,7 @@
self.assertEqual(decoded, re_dec)
# re-encode the decoded data
logging.debug("Testing re-encode of %s", name)
- re_enc = inst.encode_record_hex(re_dec)
+ re_enc = inst.encode_record_hex(re_dec,
len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
# there's no point in testing padded input, as TransRecEF
have a fixed record
# size and we cannot ever receive more input data than
that size.
@@ -256,7 +256,7 @@
encoded = t[0]
decoded = t[1]
logging.debug("Testing encode of %s", name)
- re_enc = inst.encode_hex(decoded)
+ re_enc = inst.encode_hex(decoded, len(encoded)//2)
self.assertEqual(encoded, re_enc)
def test_de_encode_file(self):
@@ -280,7 +280,7 @@
self.assertEqual(decoded, re_dec)
logging.debug("Testing re-encode of %s", name)
re_dec = inst.decode_hex(encoded)
- re_enc = inst.encode_hex(re_dec)
+ re_enc = inst.encode_hex(re_dec, len(encoded)//2)
self.assertEqual(encoded.upper(), re_enc.upper())
if hasattr(c, '_test_no_pad') and c._test_no_pad:
continue
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41676?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I88f957e49b0c88a121a266d3582e79822fa0e214
Gerrit-Change-Number: 41676
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>