Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jan 2021 17:39:44 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 869cc06480b7 - main - tests/sys/audit: fix timeout calculation
Message-ID:  <202101281739.10SHdiL1056818@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=869cc06480b75b4caea0d049e0cf7f82bb5aeed1

commit 869cc06480b75b4caea0d049e0cf7f82bb5aeed1
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-01-28 17:23:27 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-01-28 17:24:24 +0000

    tests/sys/audit: fix timeout calculation
    
    This changes the behaviour to a 30s total timeout (needed when running
    on slow emulated uniprocessor systems) and timing out after 10s without
    any input. This also uses timespecsub() instead of ignoring the
    nanoseconds field.
    
    After this change the tests runs more reliably on QEMU and time out less
    frequently.
    
    Reviewed By:    asomers
    Differential Revision: https://reviews.freebsd.org/D28391
---
 tests/sys/audit/utils.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tests/sys/audit/utils.c b/tests/sys/audit/utils.c
index 531c99ea77da..d7a1e6792b1c 100644
--- a/tests/sys/audit/utils.c
+++ b/tests/sys/audit/utils.c
@@ -146,13 +146,18 @@ check_auditpipe(struct pollfd fd[], const char *auditregex, FILE *pipestream)
 
 	/* Set the expire time for poll(2) while waiting for syscall audit */
 	ATF_REQUIRE_EQ(0, clock_gettime(CLOCK_MONOTONIC, &endtime));
-	endtime.tv_sec += 10;
-	timeout.tv_nsec = endtime.tv_nsec;
+	/* Set limit to 30 seconds total and ~10s without an event. */
+	endtime.tv_sec += 30;
 
 	for (;;) {
 		/* Update the time left for auditpipe to return any event */
 		ATF_REQUIRE_EQ(0, clock_gettime(CLOCK_MONOTONIC, &currtime));
-		timeout.tv_sec = endtime.tv_sec - currtime.tv_sec;
+		timespecsub(&endtime, &currtime, &timeout);
+		timeout.tv_sec = MIN(timeout.tv_sec, 9);
+		if (timeout.tv_sec < 0) {
+			atf_tc_fail("%s not found in auditpipe within the "
+			    "time limit", auditregex);
+		}
 
 		switch (ppoll(fd, 1, &timeout, NULL)) {
 		/* ppoll(2) returns, check if it's what we want */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101281739.10SHdiL1056818>