From 98793fb9be400af720fa5eeccf2c7047d920f104 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Fri, 5 Apr 2024 15:34:11 +0200 Subject: [PATCH] Add test for osi3trace offset reading robustness Signed-off-by: Pierre R. Mai --- tests/test_osi_trace.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_osi_trace.py b/tests/test_osi_trace.py index 8a9a430ec..428cecbb5 100644 --- a/tests/test_osi_trace.py +++ b/tests/test_osi_trace.py @@ -22,6 +22,20 @@ def test_osi_trace(self): self.assertTrue(os.path.exists(path_output)) + def test_osi_trace_offsets_robustness(self): + with tempfile.TemporaryDirectory() as tmpdirname: + path_input = os.path.join(tmpdirname, "input.osi") + create_sample(path_input) + + trace = OSITrace(path_input) + # Test whether the function can handle be run multiple times safely + offsets = trace.retrieve_offsets(None) + offsets2 = trace.retrieve_offsets(None) + trace.close() + + self.assertEqual(len(offsets), 10) + self.assertEqual(offsets, offsets2) + def create_sample(path): f = open(path, "ab")