From nobody Wed Mar 02 21:57:23 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DD80119E0A98; Wed, 2 Mar 2022 21:57:27 +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 4K87JN4QQBz3KH1; Wed, 2 Mar 2022 21:57:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646258244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ah9RiJGjmBZyY5da3fooO/8XUQ+V/faMqW0Vf/ACurU=; b=cQYu/pFjyj0nFeUm7CMH+pufUctssnYdHtYzWJHGguZXG5pexO6HEJSjISImh8LMmBEgMc 9jownVJ3Njm4rDW+XA/QLRHb2AZ2ezJqmgjX/gw5I3EWknvua74G3N2x97OLKw55H7EoZm NanvBuq4NOXHPm3MQU/LClzCBy81/qqhoWajgodyH0erUW5gQQ7RZnO+yL0zK8ExTwbIWY Dl1lAZ9YeseAOZBv99MZlPyXa0imL0ty7ZYhnKlMbwoXIUb7+K4/ppKrSOPBZ+zYSS+Uwl gSuycIBiRVfR5R8J04SZiqqSdPT0DtKCWRE5VEHloTRRgEKG6zPE4qwUAdLlDQ== 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 CDB453746; Wed, 2 Mar 2022 21:57:23 +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 222LvNTq065168; Wed, 2 Mar 2022 21:57:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 222LvNrN065167; Wed, 2 Mar 2022 21:57:23 GMT (envelope-from git) Date: Wed, 2 Mar 2022 21:57:23 GMT Message-Id: <202203022157.222LvNrN065167@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eric van Gyzen Subject: git: 190a6b5aeaa0 - stable/13 - sem test: move sem_clockwait_np tests into individual cases List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 190a6b5aeaa041bdeadd2f2534493356f5c8c71d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646258244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ah9RiJGjmBZyY5da3fooO/8XUQ+V/faMqW0Vf/ACurU=; b=ngntSriGzgXZgB+QGWzufrbSPkFDbt80Xw3r/t+BdNAWSGxLSsgfcTa6ZxFK/LI77oQgVQ AQgm9Bf65LsIE73jP/iPr2UhtJcpgRhxYkofLB4Y7HpH7/+5qP+GdwkUde0fz4wx5ZbT40 PMRPQtOX811MMIAt/RHYamkWCo/yQt24ONj0uQgNoLNCmltL598jbHbizSaAtYnbDA+BLk PNz50de7TtPHjW6jSWyRA9SpaHgdvIQRp5fUKGZMssEIyYjSzhbsdJbJlo1Q4RcbwqCEUo pvWMrq6Sgr7PuM8CEZYo5gBxYNxXY0h1d4AsIeLAfg1yNkJDgnyHa/KaZpRq6Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646258244; a=rsa-sha256; cv=none; b=ERixsCjvG2ySGDy8w7pIh7dIJafXhnK26WZYruWfXRh54NkRrMAwwP0Csdj44EZuf78FnU if6zyGyfac3JDvPr0u2gpR53tG7XcMnYqU9rYkltk1PTmvmO8bFRzwLLObnkglyyPPBriD VdlZWCDPEwwJ5ZhBtVEWHg0PZs299dCbEiPtUuNlKbtBZ8bmB2UtsJrn/N6d9Q6dlNerAT s7gmGTk4UlinqHCz+zA8XOYibEh0+QSfm5Jxkq0eQDR3MhAakxG9osjL9aCMpllLhO8bDE C7Fl5l8z0PxF066KCueKMxkOSTfPi15ub2/oRlwIHbJxrc9SSVwGkEZ7LoKXgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=190a6b5aeaa041bdeadd2f2534493356f5c8c71d commit 190a6b5aeaa041bdeadd2f2534493356f5c8c71d Author: Eric van Gyzen AuthorDate: 2021-10-01 11:24:27 +0000 Commit: Eric van Gyzen CommitDate: 2022-03-02 21:56:30 +0000 sem test: move sem_clockwait_np tests into individual cases Move these tests into individual test cases for all the usual reasons. No functional change intended. MFC after: 1 week Sponsored by: Dell EMC Isilon (cherry picked from commit 2334abfd01ba92dfa6a7ab6f2c4cc45fa64ffd3c) --- contrib/netbsd-tests/lib/librt/t_sem.c | 126 ++++++++++++++++++++++++++------- 1 file changed, 102 insertions(+), 24 deletions(-) diff --git a/contrib/netbsd-tests/lib/librt/t_sem.c b/contrib/netbsd-tests/lib/librt/t_sem.c index 55a416083846..3156b11e9bf3 100644 --- a/contrib/netbsd-tests/lib/librt/t_sem.c +++ b/contrib/netbsd-tests/lib/librt/t_sem.c @@ -221,14 +221,27 @@ sigalrm_handler(int sig __unused) got_sigalrm = 1; } +#ifdef __FreeBSD__ +/* This is refactored from the timedwait test case. */ +static void +setup_signals(void) +{ + struct sigaction act = { + .sa_handler = sigalrm_handler, + .sa_flags = 0 /* not SA_RESTART */ + }; + + ATF_REQUIRE_MSG(sigemptyset(&act.sa_mask) == 0, + "%s", strerror(errno)); + ATF_REQUIRE_MSG(sigaction(SIGALRM, &act, NULL) == 0, + "%s", strerror(errno)); +} +#endif + ATF_TC(timedwait); ATF_TC_HEAD(timedwait, tc) { - atf_tc_set_md_var(tc, "descr", "Tests sem_timedwait(3)" -#ifdef __FreeBSD__ - " and sem_clockwait_np(3)" -#endif - ); + atf_tc_set_md_var(tc, "descr", "Tests sem_timedwait(3)"); atf_tc_set_md_var(tc, "timeout", "20"); } ATF_TC_BODY(timedwait, tc) @@ -263,14 +276,10 @@ ATF_TC_BODY(timedwait, tc) ATF_REQUIRE_ERRNO(EINVAL, sem_timedwait(&sem, &ts)); /* EINTR */ - struct sigaction act = { - .sa_handler = sigalrm_handler, - .sa_flags = 0 /* not SA_RESTART */ - }; - ATF_REQUIRE_MSG(sigemptyset(&act.sa_mask) == 0, - "%s", strerror(errno)); - ATF_REQUIRE_MSG(sigaction(SIGALRM, &act, NULL) == 0, - "%s", strerror(errno)); +#ifdef __FreeBSD__ + /* This is refactored into a function. */ + setup_signals(); +#endif struct itimerval it = { .it_value.tv_usec = 50*1000 }; @@ -281,9 +290,24 @@ ATF_TC_BODY(timedwait, tc) timespec_add_ms(&ts, 100); ATF_REQUIRE_ERRNO(EINTR, sem_timedwait(&sem, &ts)); ATF_REQUIRE_MSG(got_sigalrm, "did not get SIGALRM"); +} #ifdef __FreeBSD__ - /* CLOCK_MONOTONIC, absolute */ + +ATF_TC(clockwait_monotonic_absolute); +ATF_TC_HEAD(clockwait_monotonic_absolute, tc) +{ + atf_tc_set_md_var(tc, "descr", + "sem_clockwait_np(3) with monotonic clock and absolute time"); + atf_tc_set_md_var(tc, "timeout", "20"); +} +ATF_TC_BODY(clockwait_monotonic_absolute, tc) +{ + struct timespec ts; + sem_t sem; + + SEM_REQUIRE(sem_init(&sem, 0, 0)); + SEM_REQUIRE(sem_post(&sem)); ATF_REQUIRE_MSG(clock_gettime(CLOCK_MONOTONIC, &ts) == 0, "%s", strerror(errno)); @@ -292,8 +316,22 @@ ATF_TC_BODY(timedwait, tc) &ts, NULL)); ATF_REQUIRE_ERRNO(ETIMEDOUT, sem_clockwait_np(&sem, CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL)); +} + +ATF_TC(clockwait_monotonic_relative); +ATF_TC_HEAD(clockwait_monotonic_relative, tc) +{ + atf_tc_set_md_var(tc, "descr", + "sem_clockwait_np(3) with monotonic clock and relative time"); + atf_tc_set_md_var(tc, "timeout", "20"); +} +ATF_TC_BODY(clockwait_monotonic_relative, tc) +{ + struct timespec ts; + sem_t sem; + + SEM_REQUIRE(sem_init(&sem, 0, 0)); - /* CLOCK_MONOTONIC, relative */ SEM_REQUIRE(sem_post(&sem)); ts.tv_sec = 0; ts.tv_nsec = 100*1000*1000; @@ -301,11 +339,28 @@ ATF_TC_BODY(timedwait, tc) &ts, NULL)); ATF_REQUIRE_ERRNO(ETIMEDOUT, sem_clockwait_np(&sem, CLOCK_MONOTONIC, 0, &ts, NULL)); +} + +ATF_TC(clockwait_absolute_intr_remaining); +ATF_TC_HEAD(clockwait_absolute_intr_remaining, tc) +{ + atf_tc_set_md_var(tc, "descr", + "sem_clockwait_np(3) with absolute time does not update " + "remaining time on EINTR"); + atf_tc_set_md_var(tc, "timeout", "20"); +} +ATF_TC_BODY(clockwait_absolute_intr_remaining, tc) +{ + struct timespec ts; + sem_t sem; + + SEM_REQUIRE(sem_init(&sem, 0, 0)); + setup_signals(); - /* absolute does not update remaining time on EINTR */ struct timespec remain = {42, 1000*1000*1000}; - got_sigalrm = 0; - it.it_value.tv_usec = 50*1000; + struct itimerval it = { + .it_value.tv_usec = 50*1000 + }; ATF_REQUIRE_MSG(setitimer(ITIMER_REAL, &it, NULL) == 0, "%s", strerror(errno)); ATF_REQUIRE_MSG(clock_gettime(CLOCK_MONOTONIC, &ts) == 0, @@ -316,12 +371,28 @@ ATF_TC_BODY(timedwait, tc) ATF_REQUIRE_MSG(got_sigalrm, "did not get SIGALRM"); ATF_REQUIRE_MSG(remain.tv_sec == 42 && remain.tv_nsec == 1000*1000*1000, "an absolute clockwait modified the remaining time on EINTR"); +} + +ATF_TC(clockwait_relative_intr_remaining); +ATF_TC_HEAD(clockwait_relative_intr_remaining, tc) +{ + atf_tc_set_md_var(tc, "descr", + "sem_clockwait_np(3) with relative time updates " + "remaining time on EINTR"); + atf_tc_set_md_var(tc, "timeout", "20"); +} +ATF_TC_BODY(clockwait_relative_intr_remaining, tc) +{ + struct timespec ts; + sem_t sem; - /* relative updates remaining time on EINTR */ - remain.tv_sec = 42; - remain.tv_nsec = 1000*1000*1000; - got_sigalrm = 0; - it.it_value.tv_usec = 50*1000; + SEM_REQUIRE(sem_init(&sem, 0, 0)); + setup_signals(); + + struct timespec remain = {42, 1000*1000*1000}; + struct itimerval it = { + .it_value.tv_usec = 50*1000 + }; ATF_REQUIRE_MSG(setitimer(ITIMER_REAL, &it, NULL) == 0, "%s", strerror(errno)); ts.tv_sec = 0; @@ -334,15 +405,22 @@ ATF_TC_BODY(timedwait, tc) remain.tv_nsec <= 75*1000*1000, "the remaining time was not as expected when a relative clockwait" " got EINTR: %ld.%09ld", remain.tv_sec, remain.tv_nsec); -#endif } +#endif /* __FreeBSD__ */ + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, basic); ATF_TP_ADD_TC(tp, child); ATF_TP_ADD_TC(tp, timedwait); +#ifdef __FreeBSD__ + ATF_TP_ADD_TC(tp, clockwait_monotonic_absolute); + ATF_TP_ADD_TC(tp, clockwait_monotonic_relative); + ATF_TP_ADD_TC(tp, clockwait_absolute_intr_remaining); + ATF_TP_ADD_TC(tp, clockwait_relative_intr_remaining); +#endif return atf_no_error(); }