From owner-svn-src-head@freebsd.org Mon Jul 30 14:21:50 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BCB71057E84; Mon, 30 Jul 2018 14:21:50 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1297873A80; Mon, 30 Jul 2018 14:21:50 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E8FED256FC; Mon, 30 Jul 2018 14:21:49 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6UELnYC076213; Mon, 30 Jul 2018 14:21:49 GMT (envelope-from dab@FreeBSD.org) Received: (from dab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6UELnWf076212; Mon, 30 Jul 2018 14:21:49 GMT (envelope-from dab@FreeBSD.org) Message-Id: <201807301421.w6UELnWf076212@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dab set sender to dab@FreeBSD.org using -f From: David Bright Date: Mon, 30 Jul 2018 14:21:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336905 - head/tests/sys/kqueue/libkqueue X-SVN-Group: head X-SVN-Commit-Author: dab X-SVN-Commit-Paths: head/tests/sys/kqueue/libkqueue X-SVN-Commit-Revision: 336905 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jul 2018 14:21:50 -0000 Author: dab Date: Mon Jul 30 14:21:49 2018 New Revision: 336905 URL: https://svnweb.freebsd.org/changeset/base/336905 Log: Correct possible misleading error message in kqtest. ian@ pointed out that in the test_abstime() function time(NULL) is used twice; once in an "if" test and again in the enclosed error message. If the true branch was taken and the process got preempted before the second time(NULL) call, by the time the error message was generated enough time could have elapsed that the message could claim that the event came "too early" but print an event time that was after the expected timeout. Correct by making the time(NULL) call only once and using that returned time in both the "if" test and the error message. Reported by: ian@ MFC after: 4 days X-MFC-with: r336761, r336781, r336802 Sponsored by: Dell EMC Modified: head/tests/sys/kqueue/libkqueue/timer.c Modified: head/tests/sys/kqueue/libkqueue/timer.c ============================================================================== --- head/tests/sys/kqueue/libkqueue/timer.c Mon Jul 30 12:58:33 2018 (r336904) +++ head/tests/sys/kqueue/libkqueue/timer.c Mon Jul 30 14:21:49 2018 (r336905) @@ -220,16 +220,17 @@ test_abstime(void) { const char *test_id = "kevent(EVFILT_TIMER, EV_ONESHOT, NOTE_ABSTIME)"; struct kevent kev; - time_t when; + time_t start; + time_t stop; const int timeout = 3; test_begin(test_id); test_no_kevents(); - when = time(NULL); + start = time(NULL); EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT, - NOTE_ABSTIME | NOTE_SECONDS, when + timeout, NULL); + NOTE_ABSTIME | NOTE_SECONDS, start + timeout, NULL); if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0) err(1, "%s", test_id); @@ -238,8 +239,9 @@ test_abstime(void) kev.data = 1; kev.fflags = 0; kevent_cmp(&kev, kevent_get(kqfd)); - if (time(NULL) < when + timeout) - err(1, "too early %jd %jd", (intmax_t)time(NULL), (intmax_t)(when + timeout)); + stop = time(NULL); + if (stop < start + timeout) + err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)(start + timeout)); /* Check if the event occurs again */ sleep(3);