From owner-dev-commits-src-branches@freebsd.org Wed Mar 17 10:27:46 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DF0D65A8FE1; Wed, 17 Mar 2021 10:27:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F0mZ96zkkz3FF9; Wed, 17 Mar 2021 10:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B21645234; Wed, 17 Mar 2021 10:27:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12HARfbr095995; Wed, 17 Mar 2021 10:27:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12HARfwk095994; Wed, 17 Mar 2021 10:27:41 GMT (envelope-from git) Date: Wed, 17 Mar 2021 10:27:41 GMT Message-Id: <202103171027.12HARfwk095994@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alex Richardson Subject: git: aa1e3a13cd26 - stable/13 - tests/sys/audit: fix timeout calculation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: aa1e3a13cd26549f16efa92eace0a423d4474a4d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2021 10:27:47 -0000 The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=aa1e3a13cd26549f16efa92eace0a423d4474a4d commit aa1e3a13cd26549f16efa92eace0a423d4474a4d Author: Alex Richardson AuthorDate: 2021-01-28 17:23:27 +0000 Commit: Alex Richardson CommitDate: 2021-03-17 09:54:34 +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 (cherry picked from commit 869cc06480b75b4caea0d049e0cf7f82bb5aeed1) --- 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 */