From nobody Sat Feb 24 01:54:07 2024 X-Original-To: dev-commits-src-main@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 4ThVKq5sc6z5Bjrn; Sat, 24 Feb 2024 01:54:07 +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 4ThVKq3lk5z4Zxk; Sat, 24 Feb 2024 01:54:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708739647; 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=HG1V0Z8BBBaURFqZ8LnoUOEA4//THKns1xju0AKZr4U=; b=ConizeJX2k9vFwX5l/Sr3ZOZWdMQ/aunqtvQxVpMb22TLy1fm9o/8HH8A4G7Jr5IaAvhVH LBZBtYKsw3Fc6iolh8gcR6cfSdPZfj/buQyJ5275mgXzESPPNWqrYjdNSbDvRVLG6hvszB 1x3qGpI5Xm4U7A5skw5vbMHfOCnrjZRo6x+ueF4/a8KK4veU2A1Lg9YEKhdg5FtV6bXEYB j3d6hmh2JP+T5VZYGLwcmCq5BTcPJ9fDEo6tNgNvHinWZ4e+bYb2UAga5L9ggCYloo+cdP JRavqUp00FeZX/lNAB8g6YcjldlTtlD2syFWolMrC3c1k5opCcd+oMUVLgQSnQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708739647; a=rsa-sha256; cv=none; b=cdKZEvQ1ZkLJd9ZgrC321hDkvxgsMfpOieGapF4UnPMZyLHDEjJG8ZmjLaC4LAKeV3l80B 2rc7d5Q2YMbdwMEE9n7haJjobrHyPSCanMGNtKU/MmLFKF8HNvZJO/0sPGbiHCgge17X6+ WDSmm88mRZQatY3VpwdDG/XHgXlkOrasR56x41hgPOVX4mIqzMPGkkZsZvnWZ09oIPw7os 2296nGOFidsug581N0pw+yGo54sHI99ynV3BuXe2kV8C3n2EUI+aqZAOYKQRBA9hyJw/rz jgy6841o1QR8PA6H2XJCNYKJPJEbFXHKhPqdckScpbNMDEqIpSJI5inx/F4xsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708739647; 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=HG1V0Z8BBBaURFqZ8LnoUOEA4//THKns1xju0AKZr4U=; b=ws+Ep/132RM48ZQFm6nvuh6Q12K4w8taoZd4ULN9gyW9skzrxJsvGapwGtWubwhqxRqbub JPabpxBFcJwVuKJe5PoikK8wVKE0/svmoSRsG5JnO2V3pFFlGca9M1QvYeY2BaiiY4ThA7 fbmeAuX6KzETdkJ3aPzZDDROvAXivhlJil9nw9lo5iBPlmbzgPbkKZBC085EvT0u7mn2Lw zPjgYwrJSvdz5fhwisdWv03iy5Nq7N+uSBXJDCT3BkYD91dfJpD05rPcTo0J/cQ1UC3vwC 4a+TY8LNjDthC3sk7UKC1fZZ/WsKiQoUO0yy+E/1UumH+OH31c+ABva7Yk5/Nw== 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 4ThVKq2rzjzh1D; Sat, 24 Feb 2024 01:54:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41O1s7A7030842; Sat, 24 Feb 2024 01:54:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41O1s7dT030839; Sat, 24 Feb 2024 01:54:07 GMT (envelope-from git) Date: Sat, 24 Feb 2024 01:54:07 GMT Message-Id: <202402240154.41O1s7dT030839@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 4c6ceca9cc44 - main - tests/fdgrowtable: perform the threaded test in a child process List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4c6ceca9cc44fc9b02dc39e80713f2ad3ab8eeb6 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=4c6ceca9cc44fc9b02dc39e80713f2ad3ab8eeb6 commit 4c6ceca9cc44fc9b02dc39e80713f2ad3ab8eeb6 Author: Gleb Smirnoff AuthorDate: 2024-02-24 01:49:53 +0000 Commit: Gleb Smirnoff CommitDate: 2024-02-24 01:49:53 +0000 tests/fdgrowtable: perform the threaded test in a child process The test needs to be performed in a new process that was forked with RFCFDG flag. The will guarantee that the table will start to grow from 20 file descriptors, no matter what kyua(1) or a bare shell was doing before executing this test. This should fix repetitive test runs from a shell as well as failures with kyua(1) in some environments. --- tests/sys/kern/fdgrowtable_test.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/sys/kern/fdgrowtable_test.c b/tests/sys/kern/fdgrowtable_test.c index 826599ecf836..ecab72ff09aa 100644 --- a/tests/sys/kern/fdgrowtable_test.c +++ b/tests/sys/kern/fdgrowtable_test.c @@ -167,21 +167,43 @@ ATF_TC_HEAD(oldtables_shared_via_threads, tc) ATF_TC_BODY(oldtables_shared_via_threads, tc) { + pid_t child; kvm_t *kd; struct kinfo_proc *kp; pthread_t thread; - ATF_REQUIRE((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL)) != NULL); - ATF_REQUIRE(pthread_create(&thread, NULL, exec_thread, NULL) == 0); + if ((child = rfork(RFPROC | RFCFDG)) > 0) { + pid_t wpid; + int status; + + wpid = waitpid(child, &status, 0); + ATF_REQUIRE(wpid == child); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == EXIT_SUCCESS); + return; + } + +#define REQUIRE(expression) do { \ + if (!(expression)) \ + exit(EXIT_FAILURE); \ + } while (0) + + REQUIRE(child == 0); + + REQUIRE((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL)) != NULL); + REQUIRE(pthread_create(&thread, NULL, exec_thread, NULL) == 0); openfiles(128); kp = read_kinfo(kd); - ATF_CHECK(kp->ki_numthreads > 1); - ATF_CHECK(old_tables(kd,kp) > 1); + REQUIRE(kp->ki_numthreads > 1); + REQUIRE(old_tables(kd,kp) > 1); + + REQUIRE(pthread_cancel(thread) == 0); + REQUIRE(pthread_join(thread, NULL) == 0); +#undef REQUIRE - ATF_REQUIRE(pthread_cancel(thread) == 0); - ATF_REQUIRE(pthread_join(thread, NULL) == 0); + exit(EXIT_SUCCESS); } /*