diff options
authorVadim Yanitskiy <>2020-05-22 18:13:51 +0700
committerVadim Yanitskiy <>2020-05-22 18:22:32 +0700
commit0a6e083e8a26b04f8fefa092ca4c5e4632899472 (patch)
parent4f677e6ba8434dab376495cd996d140548fa6e93 (diff)
trx_toolkit/ fix return value of parse_msg()
Jenkins build #2516 has uncovered a problem in DATADumpFile.parse_msg(): ====================================================================== FAIL: test_parse_empty (test_data_dump.DATADump_Test) ---------------------------------------------------------------------- Traceback (most recent call last): File "/build/src/target/trx_toolkit/", line 138, in test_parse_empty self.assertEqual(msg, False) AssertionError: None != False I did a quick investigation, and figured out that this failure happens when trying to call parse_msg() with idx == 0, because DATADumpFile._seek2msg() basically does nothing in this case and thus always returns True. The None itself comes from DATADumpFile._parse_msg(). Let's ensure that DATADumpFile.parse_msg() always returns None, even if DATADumpFile._seek2msg() fails. Also, update the unit test, so we always test a wide range of 'idx' values. Change-Id: Ifcfa9c5208636a0f9309f5ba8e47d282dc6a03f4
2 files changed, 6 insertions, 6 deletions
diff --git a/src/target/trx_toolkit/ b/src/target/trx_toolkit/
index 7c5452bf..41af6950 100644
--- a/src/target/trx_toolkit/
+++ b/src/target/trx_toolkit/
@@ -158,14 +158,14 @@ class DATADumpFile(DATADump):
# Parses a particular message defined by index idx
# Return value:
# a parsed message in case of success,
- # or None in case of EOF or header parsing error,
- # or False in case of message parsing error or out of range.
+ # or None in case of EOF, out of range, or header parsing error,
+ # or False in case of message parsing error.
def parse_msg(self, idx):
# Move descriptor to the beginning of requested message
rc = self._seek2msg(idx)
if not rc:
log.error("Couldn't find requested message")
- return False
+ return None
# Attempt to parse a message
return self._parse_msg()
diff --git a/src/target/trx_toolkit/ b/src/target/trx_toolkit/
index 2f7e25a0..51291967 100644
--- a/src/target/trx_toolkit/
+++ b/src/target/trx_toolkit/
@@ -133,9 +133,9 @@ class DATADump_Test(unittest.TestCase):
def test_parse_empty(self):
with self.assertLogs(level = 'ERROR'):
- idx = random.randrange(100)
- msg = self._ddf.parse_msg(idx)
- self.assertEqual(msg, False)
+ for idx in range(100):
+ msg = self._ddf.parse_msg(idx)
+ self.assertEqual(msg, None)
def test_parse_all_empty(self):
msg_list = self._ddf.parse_all()