git: 5ff2a3cb9e93 - stable/12 - libc: tests: hook CPUSET(9) test up to the build

Kyle Evans kevans at FreeBSD.org
Sun Jan 24 03:54:16 UTC 2021


The branch stable/12 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=5ff2a3cb9e93fe07d39973772926b86ec5ee73d5

commit 5ff2a3cb9e93fe07d39973772926b86ec5ee73d5
Author:     Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2020-12-31 18:26:01 +0000
Commit:     Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2021-01-24 03:54:00 +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
    
    (cherry picked from commit 9e1281eabafa4aaf84828e70488c1802717b59af)
---
 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 <stdio.h>
 #include <sched.h>
 
+#ifdef __FreeBSD__
+#include <sys/cpuset.h>
+
+#include <stdlib.h>
+
+#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 74a245779d1b..aa6a6a1179f1 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)
 
@@ -46,6 +46,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


More information about the dev-commits-src-all mailing list