[riot-notifications] [RIOT-OS/RIOT] tests/thread_float: improve and add script (#16901)

Martine Lenders notifications at github.com
Tue Sep 28 21:59:54 CEST 2021


@miri64 commented on this pull request.



> +
+    child.expect(r"t(\d): (\d{3}\.\d+)")
+    first_thread = int(child.match.group(1))
+    first_result = float(child.match.group(2))
+    assert (first_result > 141.4) and (first_result < 141.5), f"result of t{first_thread} wrong"
+    child.expect(r"t(\d): (\d{3}\.\d+)")
+    second_thread = int(child.match.group(1))
+    second_result = float(child.match.group(2))
+    assert (second_result > 141.4) and (second_result < 141.5), f"result of t{second_thread} wrong"
+    assert (first_thread == 1) or (first_thread == 3), "only thread t1 and t3 should print"
+    assert (second_thread == 1) or (second_thread == 3), "only thread t1 and t3 should print"
+    assert first_thread != second_thread, "t1 and t3 should print in turns"
+    for _ in range(3):
+        child.expect(r"t(\d): (\d{3}\.\d+)")
+        assert first_thread == int(child.match.group(1)), "t1 and t3 should print in turns"
+        assert first_result == float(child.match.group(2)), "same calculation but different result"

Still not sure if `==` comparison with floats is a good idea in tests… But let's fix things when they actually become a problem.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16901#pullrequestreview-765899861
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210928/e0a417d5/attachment-0001.htm>


More information about the notifications mailing list