depot/third_party/nixpkgs/pkgs/os-specific/solo5/test_sleep.patch
Default email 02cf88bb76 Project import generated by Copybara.
GitOrigin-RevId: c4a0efdd5a728e20791b8d8d2f26f90ac228ee8d
2022-08-12 15:06:08 +03:00

22 lines
1.1 KiB
Diff

diff --git a/tests/test_time/test_time.c b/tests/test_time/test_time.c
index 931500b..cde64ad 100644
--- a/tests/test_time/test_time.c
+++ b/tests/test_time/test_time.c
@@ -110,7 +110,8 @@ int solo5_app_main(const struct solo5_start_info *si __attribute__((unused)))
/*
* Verify that we did not sleep less than requested (see above).
*/
- if (delta < NSEC_PER_SEC) {
+ const solo5_time_t slack = 100000000ULL;
+ if (delta < NSEC_PER_SEC - slack) {
printf("[%d] ERROR: slept too little (expected at least %llu ns)\n",
iters, (unsigned long long)NSEC_PER_SEC);
failed = true;
@@ -120,7 +121,6 @@ int solo5_app_main(const struct solo5_start_info *si __attribute__((unused)))
* Verify that we did not sleep more than requested, within reason
* (scheduling delays, general inaccuracy of the current timing code).
*/
- const solo5_time_t slack = 100000000ULL;
if (delta > (NSEC_PER_SEC + slack)) {
printf("[%d] ERROR: slept too much (expected at most %llu ns)\n",
iters, (unsigned long long)slack);