From owner-dev-commits-src-all@freebsd.org Thu Dec 31 18:32:20 2020 Return-Path: Delivered-To: dev-commits-src-all@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 40C564CAB0B; Thu, 31 Dec 2020 18:32:20 +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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D6GwN1QPHz3PfB; Thu, 31 Dec 2020 18:32:20 +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 2317315496; Thu, 31 Dec 2020 18:32:20 +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 0BVIWKxD088843; Thu, 31 Dec 2020 18:32:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 0BVIWK8E088842; Thu, 31 Dec 2020 18:32:20 GMT (envelope-from git) Date: Thu, 31 Dec 2020 18:32:20 GMT Message-Id: <202012311832.0BVIWK8E088842@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 9e1281eabafa - main - libc: tests: hook CPUSET(9) test up to the build MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e1281eabafa4aaf84828e70488c1802717b59af Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Dec 2020 18:32:20 -0000 The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=9e1281eabafa4aaf84828e70488c1802717b59af commit 9e1281eabafa4aaf84828e70488c1802717b59af Author: Kyle Evans AuthorDate: 2020-12-31 18:26:01 +0000 Commit: Kyle Evans CommitDate: 2020-12-31 18:26:01 +0000 libc: tests: hook CPUSET(9) test up to the build Add shims to map NetBSD's API to CPUSET(9). Obviously the invalid input parts of these tests are relatively useless since we're just testing the shims that aren't used elsewhere, there's still some amount of value in the parts testing valid inputs. Differential Revision: https://reviews.freebsd.org/D27307 --- contrib/netbsd-tests/lib/libc/gen/t_cpuset.c | 40 ++++++++++++++++++++++++++++ lib/libc/tests/gen/Makefile | 3 ++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c b/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c index 9eca03bae2b0..56ab7364af2a 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_cpuset.c @@ -36,6 +36,46 @@ __RCSID("$NetBSD: t_cpuset.c,v 1.1 2011/11/08 05:47:00 jruoho Exp $"); #include #include +#ifdef __FreeBSD__ +#include + +#include + +#define cpuset_create() calloc(1, sizeof(cpuset_t)) +#define cpuset_destroy(cs) free(cs) + +static inline int +cpuset_set(size_t i, cpuset_t *cs) +{ + + if (i > CPU_SETSIZE) + return (-1); + CPU_SET(i, cs); + return (0); +} + +static inline int +cpuset_clr(size_t i, cpuset_t *cs) +{ + + if (i > CPU_SETSIZE) + return (-1); + CPU_CLR(i, cs); + return (0); +} + +static inline int +cpuset_isset(size_t i, cpuset_t *cs) +{ + + if (i > CPU_SETSIZE) + return (-1); + return (CPU_ISSET(i, cs)); +} + +#define cpuset_size(cs) sizeof(*cs) +#endif + ATF_TC(cpuset_err); ATF_TC_HEAD(cpuset_err, tc) { diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index 2096f2066e52..a808f6617ec7 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -20,7 +20,7 @@ ATF_TESTS_C+= realpath2_test ATF_TESTS_C+= sigsetops_test ATF_TESTS_C+= wordexp_test -# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, +# TODO: t_closefrom, t_fmtcheck, t_randomid, # TODO: t_siginfo (fixes require further inspection) # TODO: t_sethostname_test (consistently screws up the hostname) @@ -47,6 +47,7 @@ CFLAGS+= -D__HAVE_LONG_DOUBLE NETBSD_ATF_TESTS_C= alarm_test NETBSD_ATF_TESTS_C+= assert_test NETBSD_ATF_TESTS_C+= basedirname_test +NETBSD_ATF_TESTS_C+= cpuset_test NETBSD_ATF_TESTS_C+= dir_test NETBSD_ATF_TESTS_C+= floatunditf_test NETBSD_ATF_TESTS_C+= fnmatch_test