diff options
author | Clayton Smith <argilo@gmail.com> | 2023-12-04 16:38:06 -0500 |
---|---|---|
committer | Jeff Long <willcode4@gmail.com> | 2023-12-11 12:05:06 -0500 |
commit | b332ec902181d22d2dd9aadffb784e680fa81b14 (patch) | |
tree | df4bb003ee0ef21babe85c069f150d06ea28faf2 | |
parent | blocks: msq_pair_to_var QA: wait up to 1 s. (diff) | |
download | gnuradio-b332ec902181d22d2dd9aadffb784e680fa81b14.tar.xz gnuradio-b332ec902181d22d2dd9aadffb784e680fa81b14.zip |
blocks: Fix flaky chunk throttling test
The current test often fails in CI because of a tight tolerance.
Signed-off-by: Clayton Smith <argilo@gmail.com>
(cherry picked from commit 0521a78566610d7fdafa9201cf42bc86f1194131)
Signed-off-by: Jeff Long <willcode4@gmail.com>
-rw-r--r-- | gr-blocks/python/blocks/qa_throttle.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/gr-blocks/python/blocks/qa_throttle.py b/gr-blocks/python/blocks/qa_throttle.py index 280c361fb..ef7624488 100644 --- a/gr-blocks/python/blocks/qa_throttle.py +++ b/gr-blocks/python/blocks/qa_throttle.py @@ -63,7 +63,7 @@ class test_throttle(gr_unittest.TestCase): def test_limited_chunk_throttling(self): src_data = [1, 2, 3] - rate = 50 + rate = 10 chunksize = 10 src = blocks.vector_source_c(src_data, repeat=True) @@ -75,15 +75,22 @@ class test_throttle(gr_unittest.TestCase): dst = blocks.vector_sink_c() self.tb.connect(src, thr, dst) - total_time = 0.5 # seconds + total_time = 2.0 # seconds + start_time = time.perf_counter() + previous_len = 0 + self.tb.start() - time.sleep(total_time) + + while time.perf_counter() < start_time + total_time: + time.sleep(0.1) + current_len = len(dst.data()) + print(current_len) + self.assertLessEqual(current_len, previous_len + chunksize) + previous_len = current_len + self.tb.stop() - dst_data = dst.data() - num = len(dst_data) - # be at most one chunksize - self.assertLess(abs(total_time * rate - num) + 1, chunksize) + self.assertGreaterEqual(current_len, chunksize) if __name__ == '__main__': |