From f721bcda15d9e094c0e9ea986597fc95def431f5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 17 Oct 2006 06:07:54 +0000 Subject: r19366: don't fail async echo tests due to rounding errors (This used to be commit 9389ca13a38b9a3ba6f3533293ab0d0c8c06a30a) --- source4/torture/rpc/echo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c index fef9eb8c2b..0568629e47 100644 --- a/source4/torture/rpc/echo.c +++ b/source4/torture/rpc/echo.c @@ -258,23 +258,26 @@ static bool test_sleep(struct torture_context *tctx, "Event context loop failed"); for (i=0;istate == RPC_REQUEST_DONE) { + int rounded_tdiff; total_done++; done[i] = True; rcv[i] = timeval_current(); diff[i] = timeval_until(&snd[i], &rcv[i]); + rounded_tdiff = (int)(0.5 + diff[i].tv_sec + (1.0e-6*diff[i].tv_usec)); status = dcerpc_ndr_request_recv(req[i]); + printf("rounded_tdiff=%d\n", rounded_tdiff); torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "TestSleep(%d) failed", i)); torture_assert(tctx, r[i].out.result == r[i].in.seconds, talloc_asprintf(tctx, "Failed - Asked to sleep for %u seconds (server replied with %u seconds and the reply takes only %u seconds)", r[i].out.result, r[i].in.seconds, (uint_t)diff[i].tv_sec)); - torture_assert(tctx, r[i].out.result <= diff[i].tv_sec, + torture_assert(tctx, r[i].out.result <= rounded_tdiff, talloc_asprintf(tctx, "Failed - Slept for %u seconds (but reply takes only %u.%06u seconds)", r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec)); - if (r[i].out.result+1 == diff[i].tv_sec) { + if (r[i].out.result+1 == rounded_tdiff) { torture_comment(tctx, "Slept for %u seconds (but reply takes %u.%06u seconds - busy server?)\n", r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); - } else if (r[i].out.result == diff[i].tv_sec) { + } else if (r[i].out.result == rounded_tdiff) { torture_comment(tctx, "Slept for %u seconds (reply takes %u.%06u seconds - ok)\n", r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); } else { -- cgit