summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/lib')
-rw-r--r--contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c17
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/db/t_db.sh8
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c90
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c1
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_glob.c18
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_sleep.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/hash/h_hash.c20
-rw-r--r--contrib/netbsd-tests/lib/libc/hash/t_hmac.c127
-rw-r--r--contrib/netbsd-tests/lib/libc/hash/t_sha2.c14
-rw-r--r--contrib/netbsd-tests/lib/libc/locale/t_io.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c1
-rw-r--r--contrib/netbsd-tests/lib/libc/regex/debug.c7
-rw-r--r--contrib/netbsd-tests/lib/libc/regex/t_exhaust.c24
-rw-r--r--contrib/netbsd-tests/lib/libc/regex/t_regex_att.c23
-rw-r--r--contrib/netbsd-tests/lib/libc/rpc/t_rpc.c9
-rw-r--r--contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_memset.c8
-rw-r--r--contrib/netbsd-tests/lib/libc/ssp/h_read.c21
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c21
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_strlen.c10
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c15
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_connect.c11
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_dup.c9
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_getcontext.c23
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_getrusage.c8
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_kevent.c29
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_link.c9
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_listen.c9
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mincore.c10
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mlock.c2
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mmap.c13
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_msgctl.c9
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c9
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c9
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_msync.c29
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c8
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_pipe.c8
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_pipe2.c17
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_revoke.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_select.c18
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_sigaction.c16
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c36
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_socketpair.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_stat.c13
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_timer_create.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_truncate.c15
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_umask.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_unlink.c11
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait.c11
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c3
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_write.c16
-rw-r--r--contrib/netbsd-tests/lib/libm/t_ilogb.c12
-rw-r--r--contrib/netbsd-tests/lib/libm/t_pow.c22
-rw-r--r--contrib/netbsd-tests/lib/libm/t_precision.c5
-rw-r--r--contrib/netbsd-tests/lib/libm/t_scalbn.c10
-rw-r--r--contrib/netbsd-tests/lib/libposix/t_rename.c6
-rw-r--r--contrib/netbsd-tests/lib/libpthread/h_common.h8
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_condwait.c14
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_detach.c21
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_fork.c12
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_fpu.c27
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_join.c4
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_mutex.c10
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_once.c7
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_sem.c9
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_swapcontext.c16
-rw-r--r--contrib/netbsd-tests/lib/libpthread_dbg/h_common.h128
-rw-r--r--contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c131
-rw-r--r--contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c719
-rw-r--r--contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c418
-rw-r--r--contrib/netbsd-tests/lib/librt/t_sem.c24
-rw-r--r--contrib/netbsd-tests/lib/librumpclient/t_fd.c4
-rw-r--r--contrib/netbsd-tests/lib/semaphore/sem.c4
80 files changed, 1866 insertions, 598 deletions
diff --git a/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c b/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c
index 5c496c8..4f91afd 100644
--- a/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c
+++ b/contrib/netbsd-tests/lib/libc/c063/t_mkfifoat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $ */
+/* $NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $");
+__RCSID("$NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $");
#include <atf-c.h>
#include <errno.h>
@@ -55,13 +55,11 @@ ATF_TC_HEAD(mkfifoat_fd, tc)
ATF_TC_BODY(mkfifoat_fd, tc)
{
int dfd;
- int fd;
mode_t mode = 0600;
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
ATF_REQUIRE((dfd = open(DIR, O_RDONLY, 0)) != -1);
- ATF_REQUIRE((fd = mkfifoat(dfd, BASEFIFO, mode)) != -1);
- ATF_REQUIRE(close(fd) == 0);
+ ATF_REQUIRE(mkfifoat(dfd, BASEFIFO, mode) != -1);
ATF_REQUIRE(access(FIFO, F_OK) == 0);
(void)close(dfd);
}
@@ -74,12 +72,10 @@ ATF_TC_HEAD(mkfifoat_fdcwd, tc)
}
ATF_TC_BODY(mkfifoat_fdcwd, tc)
{
- int fd;
mode_t mode = 0600;
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
- ATF_REQUIRE((fd = mkfifoat(AT_FDCWD, FIFO, mode)) != -1);
- ATF_REQUIRE(close(fd) == 0);
+ ATF_REQUIRE(mkfifoat(AT_FDCWD, FIFO, mode) != -1);
ATF_REQUIRE(access(FIFO, F_OK) == 0);
}
@@ -91,10 +87,9 @@ ATF_TC_HEAD(mkfifoat_fdcwderr, tc)
}
ATF_TC_BODY(mkfifoat_fdcwderr, tc)
{
- int fd;
mode_t mode = 0600;
- ATF_REQUIRE((fd = mkfifoat(AT_FDCWD, FIFOERR, mode)) == -1);
+ ATF_REQUIRE(mkfifoat(AT_FDCWD, FIFOERR, mode) == -1);
}
ATF_TC(mkfifoat_fderr);
@@ -110,7 +105,7 @@ ATF_TC_BODY(mkfifoat_fderr, tc)
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
ATF_REQUIRE((fd = open(FIFO, O_CREAT|O_RDWR, 0644)) != -1);
ATF_REQUIRE(close(fd) == 0);
- ATF_REQUIRE((fd = mkfifoat(-1, FIFO, mode)) == -1);
+ ATF_REQUIRE(mkfifoat(-1, FIFO, mode) == -1);
}
ATF_TP_ADD_TCS(tp)
diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh
index 6858e36..93a7b1e 100755
--- a/contrib/netbsd-tests/lib/libc/db/t_db.sh
+++ b/contrib/netbsd-tests/lib/libc/db/t_db.sh
@@ -42,18 +42,10 @@ dict()
elif [ -f /usr/dict/words ]; then
echo /usr/dict/words
else
- echo ""
atf_fail "no dictionary found"
fi
}
-# Begin FreeBSD
-dict()
-{
- echo /usr/share/dict/words
-}
-# End FreeBSD
-
SEVEN_SEVEN="abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg"
atf_test_case small_btree
diff --git a/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c b/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c
new file mode 100644
index 0000000..4c85e4b
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/gen/exect/t_exect.c
@@ -0,0 +1,90 @@
+/* $NetBSD: t_exect.c,v 1.6 2016/12/12 10:34:55 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <atf-c.h>
+
+#include <errno.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+ATF_TC(t_exect_null);
+
+ATF_TC_HEAD(t_exect_null, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Tests an empty exect(2) executing");
+}
+
+static volatile sig_atomic_t caught = 0;
+
+static void
+sigtrap_handler(int sig, siginfo_t *info, void *ctx)
+{
+ ATF_REQUIRE_EQ(sig, SIGTRAP);
+ ATF_REQUIRE_EQ(info->si_code, TRAP_TRACE);
+
+ ++caught;
+}
+
+ATF_TC_BODY(t_exect_null, tc)
+{
+ struct sigaction act;
+
+ /*
+ * Currently exect(3) is misdesigned -- see PR port-amd64/51700 and it
+ * needs to be redone from scratch.
+ *
+ * This test affects amd64 releng machines causing tests to hang or
+ * fail. As there is little point to test interface that is still not,
+ * designed and implemented and is breaking tests - skip it
+ * unconditionally for all ports.
+ */
+ /* Prevent static analysis from requiring t_exec_null to be __dead. */
+ if (!caught)
+ atf_tc_skip("exect(3) misdesigned and hangs - PR port-amd64/51700");
+
+ ATF_REQUIRE(sigemptyset(&act.sa_mask) == 0);
+ act.sa_sigaction = sigtrap_handler;
+ act.sa_flags = SA_SIGINFO;
+
+ ATF_REQUIRE(sigaction(SIGTRAP, &act, 0) == 0);
+
+ ATF_REQUIRE_ERRNO(EFAULT, exect(NULL, NULL, NULL) == -1);
+
+ ATF_REQUIRE_EQ_MSG(caught, 1, "expected caught (1) != received (%d)",
+ (int)caught);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, t_exect_null);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c
index 2085b9e..8e4d30d 100644
--- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c
+++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c
@@ -30,7 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h>
#include <atf-c.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_glob.c b/contrib/netbsd-tests/lib/libc/gen/t_glob.c
index 0572a42..c53e183 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_glob.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_glob.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $ */
+/* $NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $");
+__RCSID("$NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $");
#include <atf-c.h>
@@ -46,13 +46,7 @@ __RCSID("$NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $");
#include <string.h>
#include <errno.h>
-#ifdef __FreeBSD__
#include "h_macros.h"
-#define __gl_stat_t struct stat
-#define _S_IFDIR S_IFDIR
-#else
-#include "../../../h_macros.h"
-#endif
#ifdef DEBUG
@@ -91,7 +85,7 @@ static struct gl_dir d[] = {
{ "a/b", b, __arraycount(b), 0 },
};
-#ifndef __FreeBSD__
+#ifdef GLOB_STAR
static const char *glob_star[] = {
"a/1", "a/3", "a/4", "a/b", "a/b/w", "a/b/x", "a/b/y", "a/b/z",
};
@@ -158,7 +152,7 @@ gl_stat(const char *name , __gl_stat_t *st)
memset(st, 0, sizeof(*st));
if (strcmp(buf, "a") == 0 || strcmp(buf, "a/b") == 0) {
- st->st_mode |= _S_IFDIR;
+ st->st_mode |= S_IFDIR;
return 0;
}
@@ -225,7 +219,7 @@ run(const char *p, int flags, const char **res, size_t len)
}
-#ifndef __FreeBSD__
+#ifdef GLOB_STAR
ATF_TC(glob_star);
ATF_TC_HEAD(glob_star, tc)
{
@@ -274,7 +268,7 @@ ATF_TC_BODY(glob_nocheck, tc)
ATF_TP_ADD_TCS(tp)
{
-#ifndef __FreeBSD__
+#ifdef GLOB_STAR
ATF_TP_ADD_TC(tp, glob_star);
#endif
ATF_TP_ADD_TC(tp, glob_star_not);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c
index 17eac87..54d798f 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c
@@ -34,11 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifdef __FreeBSD__
-#include <libutil.h>
-#else
#include <util.h>
-#endif
const struct hnopts {
size_t ho_len;
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
index e85867a..d4bd271 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
@@ -26,10 +26,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef __FreeBSD__
-/* kqueue(2) on FreeBSD requires sys/types.h for uintptr_t; NetBSD doesn't. */
-#include <sys/types.h>
-#endif
#include <sys/cdefs.h>
#include <sys/event.h>
#include <sys/signal.h>
diff --git a/contrib/netbsd-tests/lib/libc/hash/h_hash.c b/contrib/netbsd-tests/lib/libc/hash/h_hash.c
index 6e20a48..33b9f9a 100644
--- a/contrib/netbsd-tests/lib/libc/hash/h_hash.c
+++ b/contrib/netbsd-tests/lib/libc/hash/h_hash.c
@@ -35,13 +35,8 @@
#include <unistd.h>
#include <string.h>
#include <md5.h>
-#ifdef __NetBSD__
#include <sha1.h>
-#endif
-#ifdef __FreeBSD__
-#include <sha.h>
-#endif
int mflag, rflag, sflag, tflag;
@@ -107,32 +102,17 @@ regress(void)
MD5Final(out, &ctx);
outlen = 16;
} else {
-#ifdef __FreeBSD__
- SHA_CTX ctx;
-
- SHA1_Init(&ctx);
- SHA1_Update(&ctx, buf, len);
-#else
SHA1_CTX ctx;
SHA1Init(&ctx);
SHA1Update(&ctx, buf, len);
-#endif
while (!last &&
fgets((char *)buf, sizeof(buf), stdin) != NULL) {
len = strlen((char *)buf);
CHOMP(buf, len, last);
-#ifdef __FreeBSD__
- SHA1_Update(&ctx, buf, len);
-#else
SHA1Update(&ctx, buf, len);
-#endif
}
-#ifdef __FreeBSD__
- SHA1_Final(out, &ctx);
-#else
SHA1Final(out, &ctx);
-#endif
outlen = 20;
}
hexdump(out, outlen);
diff --git a/contrib/netbsd-tests/lib/libc/hash/t_hmac.c b/contrib/netbsd-tests/lib/libc/hash/t_hmac.c
new file mode 100644
index 0000000..3dcbea9
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/hash/t_hmac.c
@@ -0,0 +1,127 @@
+/* $NetBSD: t_hmac.c,v 1.1 2016/07/02 14:52:09 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_hmac.c,v 1.1 2016/07/02 14:52:09 christos Exp $");
+
+#include <atf-c.h>
+#include <string.h>
+#include <stdlib.h>
+#include <openssl/evp.h>
+#include <openssl/hmac.h>
+
+static void
+test(void)
+{
+ uint8_t tmp1[EVP_MAX_MD_SIZE];
+ uint8_t tmp2[EVP_MAX_MD_SIZE];
+ uint8_t key[256];
+ uint8_t data[4096];
+ unsigned int tmp1len;
+ size_t tmp2len;
+ int stop;
+ void *e1;
+ const void *evps[] = {
+ EVP_md2(),
+ EVP_md4(),
+ EVP_md5(),
+ EVP_ripemd160(),
+ EVP_sha1(),
+ EVP_sha224(),
+ EVP_sha256(),
+ EVP_sha384(),
+ EVP_sha512(),
+ };
+ const char *names[] = {
+ "md2",
+ "md4",
+ "md5",
+ "rmd160",
+ "sha1",
+ "sha224",
+ "sha256",
+ "sha384",
+ "sha512",
+ };
+
+ for (size_t k = 0; k < sizeof(key); k++)
+ key[k] = k;
+ for (size_t d = 0; d < sizeof(data); d++)
+ data[d] = d % 256;
+
+ for (size_t t = 0; t < __arraycount(names); t++)
+ for (size_t i = 1; i < sizeof(key); i += 9)
+ for (size_t j = 3; j < sizeof(data); j += 111) {
+ stop = 0;
+#ifdef DEBUG
+ printf("%s: keysize = %zu datasize = %zu\n", names[t],
+ i, j);
+#endif
+ memset(tmp1, 0, sizeof(tmp1));
+ memset(tmp2, 0, sizeof(tmp2));
+ e1 = HMAC(evps[t], key, i, data, j, tmp1, &tmp1len);
+ ATF_REQUIRE(e1 != NULL);
+ tmp2len = hmac(names[t], key, i, data, j, tmp2,
+ sizeof(tmp2));
+ ATF_REQUIRE_MSG(tmp1len == tmp2len, "hash %s len %u "
+ "!= %zu", names[t], tmp1len, tmp2len);
+ for (size_t k = 0; k < tmp2len; k++)
+ if (tmp1[k] != tmp2[k]) {
+#ifdef DEBUG
+ printf("%zu %.2x %.2x\n",
+ k, tmp1[k], tmp2[k]);
+#endif
+ stop = 1;
+ break;
+ }
+ ATF_REQUIRE_MSG(!stop, "hash %s failed for "
+ "keylen=%zu, datalen=%zu", names[t], i, j);
+ }
+}
+
+ATF_TC(t_hmac);
+
+ATF_TC_HEAD(t_hmac, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test hmac functions for consistent results");
+}
+
+ATF_TC_BODY(t_hmac, tc)
+{
+ test();
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, t_hmac);
+ return atf_no_error();
+}
+
diff --git a/contrib/netbsd-tests/lib/libc/hash/t_sha2.c b/contrib/netbsd-tests/lib/libc/hash/t_sha2.c
index ce2c80d..a45e82a 100644
--- a/contrib/netbsd-tests/lib/libc/hash/t_sha2.c
+++ b/contrib/netbsd-tests/lib/libc/hash/t_sha2.c
@@ -36,23 +36,9 @@ __RCSID("$NetBSD: t_sha2.c,v 1.3 2012/09/26 22:23:30 joerg Exp $");
#include <atf-c.h>
#include <sys/types.h>
-#ifdef __NetBSD__
#include <sha2.h>
-#endif
#include <string.h>
-#ifdef __FreeBSD__
-#include <openssl/sha.h>
-typedef SHA512_CTX SHA384_CTX;
-/* From /usr/src/crypto/openssh/openbsd-compat/sha2.h */
-#define SHA256_DIGEST_LENGTH 32
-#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
-#define SHA384_DIGEST_LENGTH 48
-#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
-#define SHA512_DIGEST_LENGTH 64
-#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
-#endif
-
ATF_TC(t_sha256);
ATF_TC(t_sha384);
ATF_TC(t_sha512);
diff --git a/contrib/netbsd-tests/lib/libc/locale/t_io.c b/contrib/netbsd-tests/lib/libc/locale/t_io.c
index 86029e9..8c7f371 100644
--- a/contrib/netbsd-tests/lib/libc/locale/t_io.c
+++ b/contrib/netbsd-tests/lib/libc/locale/t_io.c
@@ -57,11 +57,9 @@ ATF_TC_BODY(bad_big5_wprintf, tc)
atf_tc_skip("does not fail as expected (may be implementation "
"specific issue with the test)");
#endif
-
/* XXX implementation detail knowledge (wchar_t encoding) */
wchar_t ibuf[] = { 0xcf10, 0 };
setlocale(LC_CTYPE, "zh_TW.Big5");
-
ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L"%ls\n", ibuf) < 0);
ATF_REQUIRE(ferror(stdout));
}
@@ -78,12 +76,10 @@ ATF_TC_BODY(bad_big5_swprintf, tc)
atf_tc_skip("does not fail as expected (may be implementation "
"specific issue with the test)");
#endif
-
/* XXX implementation detail knowledge (wchar_t encoding) */
wchar_t ibuf[] = { 0xcf10, 0 };
wchar_t obuf[20];
setlocale(LC_CTYPE, "zh_TW.Big5");
-
ATF_REQUIRE_ERRNO(EILSEQ,
swprintf(obuf, sizeof(obuf), L"%ls\n", ibuf) < 0);
}
diff --git a/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c b/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c
index 2e57786..e366344 100644
--- a/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c
+++ b/contrib/netbsd-tests/lib/libc/locale/t_mbtowc.c
@@ -137,7 +137,6 @@ ATF_TC_BODY(mbtowc, tc)
h_mbtowc("ja_JP.ISO2022-JP", "\033$B", "\033$B$\"\033(B");
h_mbtowc("ja_JP.SJIS", "\202", "\202\240");
h_mbtowc("ja_JP.eucJP", "\244", "\244\242");
- /* Moved last as it fails */
h_mbtowc("zh_CN.GB18030", "\241", "\241\241");
h_mbtowc("zh_TW.Big5", "\241", "\241@");
h_mbtowc("zh_TW.eucTW", "\241", "\241\241");
diff --git a/contrib/netbsd-tests/lib/libc/regex/debug.c b/contrib/netbsd-tests/lib/libc/regex/debug.c
index 22f0b90..18ab6ea 100644
--- a/contrib/netbsd-tests/lib/libc/regex/debug.c
+++ b/contrib/netbsd-tests/lib/libc/regex/debug.c
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.2 2011/10/10 04:32:41 christos Exp $ */
+/* $NetBSD: debug.c,v 1.3 2017/01/14 00:50:56 christos Exp $ */
/*-
* Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -26,18 +26,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/types.h>
#include <ctype.h>
#include <limits.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-#include <sys/types.h>
-#ifdef __FreeBSD__
#include <wchar.h>
#include <wctype.h>
-#endif
/* Don't sort these! */
#include "utils.h"
diff --git a/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c b/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c
index 0670e51..f9bd276 100644
--- a/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c
+++ b/contrib/netbsd-tests/lib/libc/regex/t_exhaust.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $ */
+/* $NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,17 +37,15 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_exhaust.c,v 1.7 2011/11/16 18:37:31 christos Exp $");
+__RCSID("$NetBSD: t_exhaust.c,v 1.8 2017/01/14 00:50:56 christos Exp $");
-#include <stdio.h>
+#include <sys/resource.h>
+#include <atf-c.h>
+#include <err.h>
#include <regex.h>
-#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <err.h>
-#include <atf-c.h>
-#ifdef __FreeBSD__
-#include <sys/resource.h>
-#endif
+#include <string.h>
#ifndef REGEX_MAXSIZE
#define REGEX_MAXSIZE 9999
@@ -179,25 +177,17 @@ ATF_TC_HEAD(regcomp_too_big, tc)
" crash, but return a proper error code");
// libtre needs it.
atf_tc_set_md_var(tc, "timeout", "600");
-#ifdef __FreeBSD__
atf_tc_set_md_var(tc, "require.memory", "64M");
-#else
- atf_tc_set_md_var(tc, "require.memory", "120M");
-#endif
}
ATF_TC_BODY(regcomp_too_big, tc)
{
regex_t re;
-#ifdef __FreeBSD__
struct rlimit limit;
-#endif
int e;
-#ifdef __FreeBSD__
limit.rlim_cur = limit.rlim_max = 64 * 1024 * 1024;
ATF_REQUIRE(setrlimit(RLIMIT_VMEM, &limit) != -1);
-#endif
for (size_t i = 0; i < __arraycount(tests); i++) {
char *d = (*tests[i].pattern)(REGEX_MAXSIZE);
e = regcomp(&re, d, tests[i].type);
diff --git a/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c b/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c
index 0ca44b4..dd5b818 100644
--- a/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c
+++ b/contrib/netbsd-tests/lib/libc/regex/t_regex_att.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $ */
+/* $NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,20 +37,18 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_regex_att.c,v 1.1 2012/08/24 20:24:40 jmmv Exp $");
+__RCSID("$NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $");
#include <sys/param.h>
-#include <stdio.h>
+#include <atf-c.h>
+#include <ctype.h>
#include <regex.h>
-#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <util.h>
#include <vis.h>
-#include <ctype.h>
-#include <atf-c.h>
-#ifdef __FreeBSD__
-#include <libutil.h>
-#endif
static const char sep[] = "\r\n\t";
static const char delim[3] = "\\\\\0";
@@ -377,11 +375,7 @@ checkmatches(const char *matches, size_t nm, const regmatch_t *pm,
" cur=%d, max=%zu", res, l, len - off);
off += l;
}
-#ifdef __FreeBSD__
ATF_CHECK_STREQ_MSG(res, matches, " at line %zu", lineno);
-#else
- ATF_REQUIRE_STREQ_MSG(res, matches, " at line %zu", lineno);
-#endif
free(res);
}
@@ -580,9 +574,6 @@ ATF_TC_BODY(leftassoc, tc)
* any explation. Mark as broken here, but I don't know why. */
atf_tc_expect_fail("Reason for breakage unknown");
#endif
-#ifdef __FreeBSD__
- atf_tc_expect_fail("The expected and matched groups are mismatched on FreeBSD");
-#endif
att_test(tc, "leftassoc");
}
diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
index bce3633..e5d4321 100644
--- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
+++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
@@ -24,13 +24,6 @@ __RCSID("$NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $");
return ev; \
} while(/*CONSTCOND*/0)
-#ifdef __FreeBSD__
-#define SKIPXI(ev, msg, ...) do { \
- atf_tc_skip(msg, __VA_ARGS__); \
- return ev; \
-} while(/*CONSTCOND*/0)
-#endif
-
#else
#define ERRX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__)
#define SKIPX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__)
@@ -196,7 +189,7 @@ regtest(const char *hostname, const char *transp, const char *arg, int p)
#endif
if (!svc_create(server, PROGNUM, VERSNUM, transp))
{
- SKIPXI(EXIT_FAILURE, "Cannot create server %d", num);
+ SKIPX(EXIT_FAILURE, "Cannot create server %d", num);
}
switch ((pid = fork())) {
diff --git a/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c b/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c
index 34fd5cc..1f0f1ed 100644
--- a/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c
+++ b/contrib/netbsd-tests/lib/libc/setjmp/t_setjmp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $ */
+/* $NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $");
+__RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $");
#include <sys/types.h>
diff --git a/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c b/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c
index 2014470..44d7555 100644
--- a/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c
+++ b/contrib/netbsd-tests/lib/libc/setjmp/t_threadjmp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $ */
+/* $NetBSD: t_threadjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $");
+__RCSID("$NetBSD: t_threadjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $");
#include <sys/types.h>
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_memset.c b/contrib/netbsd-tests/lib/libc/ssp/h_memset.c
index c5ab607..f1acbbd 100644
--- a/contrib/netbsd-tests/lib/libc/ssp/h_memset.c
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_memset.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+/* $NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_memset.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+__RCSID("$NetBSD: h_memset.c,v 1.2 2017/01/16 16:34:24 christos Exp $");
#include <stdio.h>
#include <string.h>
@@ -41,9 +41,5 @@ main(int argc, char *argv[])
char b[10];
size_t len = atoi(argv[1]);
(void)memset(b, 0, len);
-#ifdef __FreeBSD__
return b[0]; /* keeps optimizer from zapping the call to memset() */
-#else
- return 0;
-#endif
}
diff --git a/contrib/netbsd-tests/lib/libc/ssp/h_read.c b/contrib/netbsd-tests/lib/libc/ssp/h_read.c
index c25cfeb..046ac62 100644
--- a/contrib/netbsd-tests/lib/libc/ssp/h_read.c
+++ b/contrib/netbsd-tests/lib/libc/ssp/h_read.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $ */
+/* $NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,17 +29,15 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_read.c,v 1.1 2010/12/27 02:04:19 pgoyette Exp $");
+__RCSID("$NetBSD: h_read.c,v 1.2 2017/01/16 16:35:57 christos Exp $");
#include <sys/param.h>
+#include <fcntl.h>
+#include <paths.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
-#ifdef __FreeBSD__
-#include <fcntl.h>
-#include <paths.h>
-
int
main(int argc, char *argv[])
{
@@ -54,14 +52,3 @@ main(int argc, char *argv[])
(void)printf("%s\n", b);
return (0);
}
-#else
-int
-main(int argc, char *argv[])
-{
- char b[MAXPATHLEN];
- size_t len = atoi(argv[1]);
-
- (void)printf("%s\n", b);
- return 0;
-}
-#endif
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c b/contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c
index ec2b9bb..d53d2d9 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/h_getopt.c
@@ -35,6 +35,10 @@
#include <unistd.h>
#include <err.h>
#ifdef __FreeBSD__
+/*
+ * Needed to avoid libutil.h pollution in stdio.h, which causes grief with
+ * with hexdump(3) in lib/libc/db/h_hash.c
+ */
#include <libutil.h>
#endif
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c b/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c
index 2293e2c..c7cd83e 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/h_getopt_long.c
@@ -37,6 +37,10 @@
#include <stdlib.h>
#include <unistd.h>
#ifdef __FreeBSD__
+/*
+ * Needed to avoid libutil.h pollution in stdio.h, which causes grief with
+ * with hexdump(3) in lib/libc/db/h_hash.c
+ */
#include <libutil.h>
#endif
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c b/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c
index a0e77d3..5a13250 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c
@@ -75,7 +75,6 @@ __RCSID("$NetBSD: t_hsearch.c,v 1.4 2014/07/20 20:17:21 christos Exp $");
#define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno))
-#ifdef __NetBSD__
ATF_TC(hsearch_basic);
ATF_TC_HEAD(hsearch_basic, tc)
{
@@ -122,9 +121,12 @@ ATF_TC_BODY(hsearch_basic, tc)
ATF_REQUIRE_EQ((intptr_t)ep->data, i);
}
+#ifdef __NetBSD__
hdestroy1(free, NULL);
-}
+#else
+ hdestroy();
#endif
+}
ATF_TC(hsearch_duplicate);
ATF_TC_HEAD(hsearch_duplicate, tc)
@@ -232,7 +234,6 @@ ATF_TC_BODY(hsearch_two, tc)
}
#if defined(__FreeBSD__) && 1100027 <= __FreeBSD_version
-#ifdef __NetBSD__
ATF_TC(hsearch_r_basic);
ATF_TC_HEAD(hsearch_r_basic, tc)
{
@@ -278,10 +279,15 @@ ATF_TC_BODY(hsearch_r_basic, tc)
ATF_REQUIRE_EQ((intptr_t)ep->data, i);
}
+#ifdef __NetBSD__
hdestroy1_r(&t, free, NULL);
+#else
+ hdestroy_r(&t);
+#endif
}
#endif
+#if defined(__FreeBSD__) && 1100027 <= __FreeBSD_version
ATF_TC(hsearch_r_duplicate);
ATF_TC_HEAD(hsearch_r_duplicate, tc)
{
@@ -332,6 +338,9 @@ ATF_TC_BODY(hsearch_r_nonexistent, tc)
REQUIRE_ERRNO(hcreate_r(16, &t));
+#ifdef __FreeBSD__
+ atf_tc_expect_fail("behavior doesn't match docs; see bug # 216872");
+#endif
e.key = __UNCONST("A");
ATF_REQUIRE(hsearch_r(e, FIND, &ep, &t) == 1);
ATF_REQUIRE_EQ(ep, NULL);
@@ -391,17 +400,13 @@ ATF_TC_BODY(hsearch_r_two, tc)
ATF_TP_ADD_TCS(tp)
{
-#ifdef __NetBSD__
ATF_TP_ADD_TC(tp, hsearch_basic);
-#endif
ATF_TP_ADD_TC(tp, hsearch_duplicate);
ATF_TP_ADD_TC(tp, hsearch_nonexistent);
ATF_TP_ADD_TC(tp, hsearch_two);
-
+
#if defined(__FreeBSD__) && 1100027 <= __FreeBSD_version
-#ifdef __NetBSD__
ATF_TP_ADD_TC(tp, hsearch_r_basic);
-#endif
ATF_TP_ADD_TC(tp, hsearch_r_duplicate);
ATF_TP_ADD_TC(tp, hsearch_r_nonexistent);
ATF_TP_ADD_TC(tp, hsearch_r_two);
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c
index 06f2de0..4835e5d 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c
@@ -218,9 +218,7 @@ ATF_TC_BODY(strtold_nan, tc)
volatile long double ld = strtold(nan_string, &end);
ATF_REQUIRE(isnan(ld) != 0);
-#ifdef __FreeBSD__
- ATF_REQUIRE(strcmp(end, "y") == 0);
-#else
+#ifndef __FreeBSD__
ATF_REQUIRE(__isnanl(ld) != 0);
#endif
ATF_REQUIRE(strcmp(end, "y") == 0);
diff --git a/contrib/netbsd-tests/lib/libc/string/t_strlen.c b/contrib/netbsd-tests/lib/libc/string/t_strlen.c
index 7483dc6..9899e6d 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_strlen.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_strlen.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strlen.c,v 1.5 2011/07/14 07:33:20 jruoho Exp $ */
+/* $NetBSD: t_strlen.c,v 1.6 2017/01/14 20:49:24 christos Exp $ */
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
@@ -40,9 +40,7 @@ ATF_TC_HEAD(strlen_basic, tc)
ATF_TC_BODY(strlen_basic, tc)
{
-#ifdef __FreeBSD__
void *dl_handle;
-#endif
/* try to trick the compiler */
size_t (*strlen_fn)(const char *);
@@ -110,12 +108,8 @@ ATF_TC_BODY(strlen_basic, tc)
* During testing it is useful have the rest of the program
* use a known good version!
*/
-#ifdef __FreeBSD__
dl_handle = dlopen(NULL, RTLD_LAZY);
strlen_fn = dlsym(dl_handle, "test_strlen");
-#else
- strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen");
-#endif
if (!strlen_fn)
strlen_fn = strlen;
@@ -142,9 +136,7 @@ ATF_TC_BODY(strlen_basic, tc)
}
}
}
-#ifdef __FreeBSD__
(void)dlclose(dl_handle);
-#endif
}
ATF_TC(strlen_huge);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c b/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c
index 229c343..a319b09 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_clock_gettime.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_clock_gettime.c,v 1.1 2011/10/15 06:42:16 jruoho Exp $ */
+/* $NetBSD: t_clock_gettime.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,30 +58,23 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_clock_gettime.c,v 1.1 2011/10/15 06:42:16 jruoho Exp $");
+__RCSID("$NetBSD: t_clock_gettime.c,v 1.3 2017/01/13 21:30:41 christos Exp $");
#include <sys/param.h>
#include <sys/sysctl.h>
-#ifdef __NetBSD__
-#include <machine/int_limits.h>
-#endif
#include <atf-c.h>
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
-#ifdef __NetBSD__
-#include "../../../h_macros.h"
-#else
-#include <limits.h>
-#include <stdint.h>
#include "h_macros.h"
-#endif
#define MINPOSDIFF 15000000 /* 15 ms for now */
#define TIMEOUT 5
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_connect.c b/contrib/netbsd-tests/lib/libc/sys/t_connect.c
index 672a022..a920d3d 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_connect.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_connect.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_connect.c,v 1.2 2015/04/05 23:17:41 rtr Exp $ */
+/* $NetBSD: t_connect.c,v 1.3 2017/01/13 20:09:48 christos Exp $ */
/*
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -26,6 +26,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/socket.h>
#include <err.h>
#include <errno.h>
#include <string.h>
@@ -36,10 +37,6 @@
#include <atf-c.h>
-#ifdef __FreeBSD__
-#include <sys/socket.h>
-#endif
-
ATF_TC(connect_low_port);
ATF_TC_HEAD(connect_low_port, tc)
{
@@ -56,10 +53,8 @@ ATF_TC_BODY(connect_low_port, tc)
slist = socket(AF_INET, SOCK_STREAM, 0);
sd = socket(AF_INET, SOCK_STREAM, 0);
-#ifdef __FreeBSD__
ATF_REQUIRE(sd > 0);
ATF_REQUIRE(slist > 0);
-#endif
/* bind listening socket */
memset(&sinlist, 0, sizeof(sinlist));
@@ -97,9 +92,7 @@ ATF_TC_BODY(connect_low_port, tc)
ATF_REQUIRE(ntohs(sin.sin_port) <= IPPORT_RESERVEDMAX);
close(sd);
-#ifdef __FreeBSD__
close(slist);
-#endif
}
ATF_TC(connect_foreign_family);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_dup.c b/contrib/netbsd-tests/lib/libc/sys/t_dup.c
index d8125ab..b1924e4 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_dup.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_dup.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dup.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $ */
+/* $NetBSD: t_dup.c,v 1.9 2017/01/13 20:31:53 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_dup.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $");
+__RCSID("$NetBSD: t_dup.c,v 1.9 2017/01/13 20:31:53 christos Exp $");
#include <sys/resource.h>
#include <sys/stat.h>
@@ -39,16 +39,13 @@ __RCSID("$NetBSD: t_dup.c,v 1.8 2012/03/18 07:00:51 jruoho Exp $");
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sysexits.h>
-#ifdef __FreeBSD__
-#include <stdbool.h>
-#endif
-
static char path[] = "dup";
#ifdef __NetBSD__
static void check_mode(bool, bool, bool);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c b/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c
index 20a9e42..102c79f 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c
@@ -51,10 +51,16 @@ run(int n, ...)
ATF_REQUIRE_EQ(n, DEPTH - calls - 1);
va_start(va, n);
-#if defined(__FreeBSD__) && defined(__amd64__)
+#ifdef __FreeBSD__
+#if defined(__amd64__)
for (i = 0; i < 5; i++) {
-#elif defined(__FreeBSD__) && defined(__aarch64__)
+#elif defined(__aarch64__)
for (i = 0; i < 7; i++) {
+#elif defined(__mips__)
+ for (i = 0; i < 5; i++) {
+#else
+ for (i = 0; i < 9; i++) {
+#endif
#else
for (i = 0; i < 9; i++) {
#endif
@@ -114,14 +120,23 @@ ATF_TC_BODY(setcontext_link, tc)
uc[i].uc_stack.ss_size = STACKSZ;
uc[i].uc_link = (i > 0) ? &uc[i - 1] : &save;
-#if defined(__FreeBSD__) && defined(__amd64__)
+#ifdef __FreeBSD__
+#if defined(__amd64__)
/* FreeBSD/amd64 only permits up to 6 arguments. */
makecontext(&uc[i], (void *)run, 6, i,
0, 1, 2, 3, 4);
-#elif defined(__FreeBSD__) && defined(__aarch64__)
+#elif defined(__aarch64__)
/* FreeBSD/arm64 only permits up to 8 arguments. */
makecontext(&uc[i], (void *)run, 8, i,
0, 1, 2, 3, 4, 5, 6);
+#elif defined(__mips__)
+ /* FreeBSD/mips only permits up to 6 arguments. */
+ makecontext(&uc[i], (void *)run, 6, i,
+ 0, 1, 2, 3, 4);
+#else
+ makecontext(&uc[i], (void *)run, 10, i,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8);
+#endif
#else
makecontext(&uc[i], (void *)run, 10, i,
0, 1, 2, 3, 4, 5, 6, 7, 8);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
index f4ee96b..273fd83 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.4 2016/08/05 15:01:39 scole Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.5 2017/01/13 20:31:06 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_getrusage.c,v 1.4 2016/08/05 15:01:39 scole Exp $");
+__RCSID("$NetBSD: t_getrusage.c,v 1.5 2017/01/13 20:31:06 christos Exp $");
#include <sys/resource.h>
#include <sys/time.h>
@@ -47,11 +47,7 @@ static void sighandler(int);
static const size_t maxiter = 2000;
static void
-#ifdef __FreeBSD__
sighandler(int signo __unused)
-#else
-sighandler(int signo)
-#endif
{
/* Nothing. */
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_kevent.c b/contrib/netbsd-tests/lib/libc/sys/t_kevent.c
index 8a20d63..5bddea5 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_kevent.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_kevent.c
@@ -45,16 +45,14 @@ __RCSID("$NetBSD: t_kevent.c,v 1.7 2015/02/05 13:55:37 isaki Exp $");
#include <err.h>
#ifdef __NetBSD__
#include <sys/drvctlio.h>
+#else
+#define DRVCTLDEV "/nonexistent"
#endif
#include <sys/event.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/wait.h>
-#ifdef __FreeBSD__
-#define DRVCTLDEV "/nonexistent"
-#endif
-
ATF_TC(kevent_zerotimer);
ATF_TC_HEAD(kevent_zerotimer, tc)
{
@@ -117,15 +115,9 @@ ATF_TC_BODY(kqueue_desc_passing, tc)
if (recvmsg(s[1], &m, 0) == -1)
err(1, "child: could not recvmsg");
-#ifdef __FreeBSD__
- bcopy(CMSG_DATA(msg), &kq, sizeof(kq));
- printf("child (pid %d): received kq fd %d\n", getpid(), kq);
- _exit(0);
-#else
kq = *(int *)CMSG_DATA(msg);
printf("child (pid %d): received kq fd %d\n", getpid(), kq);
exit(0);
-#endif
}
close(s[1]);
@@ -133,17 +125,14 @@ ATF_TC_BODY(kqueue_desc_passing, tc)
iov.iov_base = &storage;
iov.iov_len = sizeof(int);
+#ifdef __FreeBSD__
+ msg = CMSG_FIRSTHDR(&m);
+#endif
msg->cmsg_level = SOL_SOCKET;
msg->cmsg_type = SCM_RIGHTS;
msg->cmsg_len = CMSG_LEN(sizeof(int));
-#ifdef __FreeBSD__
- /*
- * What is should have been
- * bcopy(&s[0], CMSG_DATA(msg), sizeof(kq));
- */
- bcopy(&kq, CMSG_DATA(msg), sizeof(kq));
-#else
+#ifdef __NetBSD__
*(int *)CMSG_DATA(msg) = kq;
#endif
@@ -152,14 +141,8 @@ ATF_TC_BODY(kqueue_desc_passing, tc)
printf("parent (pid %d): sending kq fd %d\n", getpid(), kq);
if (sendmsg(s[0], &m, 0) == -1) {
-#ifdef __NetBSD__
ATF_REQUIRE_EQ_MSG(errno, EBADF, "errno is %d", errno);
atf_tc_skip("PR kern/46523");
-#endif
-#ifdef __FreeBSD__
- ATF_REQUIRE_EQ_MSG(errno, EOPNOTSUPP, "errno is %d", errno);
- close(s[0]);
-#endif
}
close(kq);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_link.c b/contrib/netbsd-tests/lib/libc/sys/t_link.c
index b8dcacc..a6d894c 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_link.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_link.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_link.c,v 1.2 2014/04/21 14:39:36 martin Exp $ */
+/* $NetBSD: t_link.c,v 1.3 2017/01/13 20:42:36 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_link.c,v 1.2 2014/04/21 14:39:36 martin Exp $");
+__RCSID("$NetBSD: t_link.c,v 1.3 2017/01/13 20:42:36 christos Exp $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -37,14 +37,11 @@ __RCSID("$NetBSD: t_link.c,v 1.2 2014/04/21 14:39:36 martin Exp $");
#include <atf-c.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <limits.h>
-#endif
-
static const char *getpath(void);
static char path[] = "link";
static const char *pathl;
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_listen.c b/contrib/netbsd-tests/lib/libc/sys/t_listen.c
index a9ee733..9f3f9b8 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_listen.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_listen.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_listen.c,v 1.4 2012/03/18 07:00:52 jruoho Exp $ */
+/* $NetBSD: t_listen.c,v 1.5 2017/01/13 20:41:50 christos Exp $ */
/*
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -26,6 +26,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/socket.h>
#include <atf-c.h>
#include <err.h>
#include <errno.h>
@@ -36,10 +37,6 @@
#include <arpa/inet.h>
#include <netinet/in.h>
-#ifdef __FreeBSD__
-#include <sys/socket.h>
-#endif
-
static const char *path = "listen";
ATF_TC_WITH_CLEANUP(listen_err);
@@ -110,9 +107,7 @@ ATF_TC_BODY(listen_low_port, tc)
int sd, val;
sd = socket(AF_INET, SOCK_STREAM, 0);
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(sd != -1, "socket failed: %s", strerror(errno));
-#endif
val = IP_PORTRANGE_LOW;
if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, &val,
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c
index ab8c33f..da6cafe 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $ */
+/* $NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $");
+__RCSID("$NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $");
#include <sys/mman.h>
#include <sys/stat.h>
@@ -141,9 +141,7 @@ ATF_TC_WITH_CLEANUP(mincore_resid);
ATF_TC_HEAD(mincore_resid, tc)
{
atf_tc_set_md_var(tc, "descr", "Test page residency with mincore(2)");
-#ifdef __FreeBSD__
atf_tc_set_md_var(tc, "require.user", "root");
-#endif
}
ATF_TC_BODY(mincore_resid, tc)
@@ -155,13 +153,11 @@ ATF_TC_BODY(mincore_resid, tc)
struct rlimit rlim;
ATF_REQUIRE(getrlimit(RLIMIT_MEMLOCK, &rlim) == 0);
-#ifdef __FreeBSD__
/*
* Bump the mlock limit to unlimited so the rest of the testcase
* passes instead of failing on the mlock call.
*/
rlim.rlim_max = RLIM_INFINITY;
-#endif
rlim.rlim_cur = rlim.rlim_max;
ATF_REQUIRE(setrlimit(RLIMIT_MEMLOCK, &rlim) == 0);
@@ -276,9 +272,7 @@ ATF_TC_BODY(mincore_resid, tc)
(void)munmap(addr2, npgs * page);
(void)munmap(addr3, npgs * page);
(void)unlink(path);
-#ifdef __FreeBSD__
free(buf);
-#endif
}
ATF_TC_CLEANUP(mincore_resid, tc)
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
index 75048b3..cd9ad55 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
@@ -32,7 +32,7 @@
__RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $");
#ifdef __FreeBSD__
-#include <sys/types.h>
+#include <sys/param.h> /* NetBSD requires sys/param.h for sysctl(3), unlike FreeBSD */
#endif
#include <sys/mman.h>
#include <sys/resource.h>
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
index b35b2ae..8839aea 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $ */
+/* $NetBSD: t_mmap.c,v 1.12 2017/01/16 16:31:05 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,9 +55,10 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $");
+__RCSID("$NetBSD: t_mmap.c,v 1.12 2017/01/16 16:31:05 christos Exp $");
#include <sys/param.h>
+#include <sys/disklabel.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -73,12 +74,7 @@ __RCSID("$NetBSD: t_mmap.c,v 1.10 2017/01/10 22:36:29 christos Exp $");
#include <string.h>
#include <unistd.h>
#include <paths.h>
-#ifdef __NetBSD__
-#include <machine/disklabel.h>
-#endif
-
#ifdef __FreeBSD__
-#include <sys/disklabel.h>
#include <stdint.h>
#endif
@@ -453,6 +449,7 @@ ATF_TC_BODY(mmap_truncate, tc)
ATF_REQUIRE(ftruncate(fd, page / 12) == 0);
ATF_REQUIRE(ftruncate(fd, page / 64) == 0);
+ (void)munmap(map, page);
ATF_REQUIRE(close(fd) == 0);
}
@@ -509,6 +506,8 @@ ATF_TC_BODY(mmap_truncate_signal, tc)
prevent the access to be optimized out */
ATF_REQUIRE(i == 0);
ATF_REQUIRE(sta == 0);
+ (void)munmap(map, page);
+ (void)close(fd);
return;
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c b/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c
index b9b3067..9f99980 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_msgctl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_msgctl.c,v 1.4 2014/02/27 00:59:50 joerg Exp $ */
+/* $NetBSD: t_msgctl.c,v 1.5 2017/01/13 20:44:45 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_msgctl.c,v 1.4 2014/02/27 00:59:50 joerg Exp $");
+__RCSID("$NetBSD: t_msgctl.c,v 1.5 2017/01/13 20:44:45 christos Exp $");
#include <sys/msg.h>
#include <sys/stat.h>
@@ -38,6 +38,7 @@ __RCSID("$NetBSD: t_msgctl.c,v 1.4 2014/02/27 00:59:50 joerg Exp $");
#include <atf-c.h>
#include <errno.h>
+#include <limits.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,10 +47,6 @@ __RCSID("$NetBSD: t_msgctl.c,v 1.4 2014/02/27 00:59:50 joerg Exp $");
#include <time.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <limits.h>
-#endif
-
#define MSG_KEY 12345689
#define MSG_MTYPE_1 0x41
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c b/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c
index 70f8906..522ceb8 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_msgrcv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $ */
+/* $NetBSD: t_msgrcv.c,v 1.4 2017/01/13 20:44:45 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $");
+__RCSID("$NetBSD: t_msgrcv.c,v 1.4 2017/01/13 20:44:45 christos Exp $");
#include <sys/msg.h>
#include <sys/stat.h>
@@ -38,6 +38,7 @@ __RCSID("$NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $");
#include <atf-c.h>
#include <errno.h>
+#include <limits.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
@@ -47,10 +48,6 @@ __RCSID("$NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $");
#include <time.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <limits.h>
-#endif
-
#define MSG_KEY 1234
#define MSG_MTYPE_1 0x41
#define MSG_MTYPE_2 0x42
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c b/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c
index d30cb7b..5988821 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_msgsnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_msgsnd.c,v 1.2 2011/11/05 08:47:54 jruoho Exp $ */
+/* $NetBSD: t_msgsnd.c,v 1.3 2017/01/13 20:44:45 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_msgsnd.c,v 1.2 2011/11/05 08:47:54 jruoho Exp $");
+__RCSID("$NetBSD: t_msgsnd.c,v 1.3 2017/01/13 20:44:45 christos Exp $");
#include <sys/msg.h>
#include <sys/stat.h>
@@ -38,6 +38,7 @@ __RCSID("$NetBSD: t_msgsnd.c,v 1.2 2011/11/05 08:47:54 jruoho Exp $");
#include <atf-c.h>
#include <errno.h>
+#include <limits.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
@@ -47,10 +48,6 @@ __RCSID("$NetBSD: t_msgsnd.c,v 1.2 2011/11/05 08:47:54 jruoho Exp $");
#include <time.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <limits.h>
-#endif
-
#define MSG_KEY 1234
#define MSG_MTYPE_1 0x41
#define MSG_MTYPE_2 0x42
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_msync.c b/contrib/netbsd-tests/lib/libc/sys/t_msync.c
index 70d0ccf..d1fdbe0 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_msync.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_msync.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $ */
+/* $NetBSD: t_msync.c,v 1.3 2017/01/14 20:52:42 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $");
+__RCSID("$NetBSD: t_msync.c,v 1.3 2017/01/14 20:52:42 christos Exp $");
#include <sys/mman.h>
@@ -52,8 +52,7 @@ msync_sync(const char *garbage, int flags)
{
char *buf, *map = MAP_FAILED;
const char *str = NULL;
- size_t i, len;
- ssize_t tot;
+ size_t len;
int fd, rv;
/*
@@ -65,29 +64,17 @@ msync_sync(const char *garbage, int flags)
if (buf == NULL)
return NULL;
- for (i = 0; i < (size_t)page; i++)
- buf[i] = 'x';
+ memset(buf, 'x', page);
fd = open(path, O_RDWR | O_CREAT, 0700);
if (fd < 0) {
- str = "failed to open";
- goto out;
+ free(buf);
+ return "failed to open";
}
- tot = 0;
-
- while (tot < page) {
-
- rv = write(fd, buf, sizeof(buf));
-
- if (rv < 0) {
- str = "failed to write";
- goto out;
- }
-
- tot += rv;
- }
+ ATF_REQUIRE_MSG(write(fd, buf, page) != -1, "write(2) failed: %s",
+ strerror(errno));
map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE|MAP_PRIVATE,
fd, 0);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c b/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c
index b4d9f8a..1ad6661 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_nanosleep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_nanosleep.c,v 1.3 2013/03/31 16:47:16 christos Exp $ */
+/* $NetBSD: t_nanosleep.c,v 1.4 2017/01/13 21:15:14 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_nanosleep.c,v 1.3 2013/03/31 16:47:16 christos Exp $");
+__RCSID("$NetBSD: t_nanosleep.c,v 1.4 2017/01/13 21:15:14 christos Exp $");
#include <sys/time.h>
#include <sys/wait.h>
@@ -45,11 +45,7 @@ __RCSID("$NetBSD: t_nanosleep.c,v 1.3 2013/03/31 16:47:16 christos Exp $");
#include <unistd.h>
static void
-#ifdef __FreeBSD__
handler(int signo __unused)
-#else
-handler(int signo)
-#endif
{
/* Nothing. */
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_pipe.c b/contrib/netbsd-tests/lib/libc/sys/t_pipe.c
index 32beecc..df8f1ed 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_pipe.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_pipe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_pipe.c,v 1.3 2011/10/31 15:41:31 christos Exp $ */
+/* $NetBSD: t_pipe.c,v 1.5 2017/01/13 21:30:41 christos Exp $ */
/*-
* Copyright (c) 2001, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_pipe.c,v 1.3 2011/10/31 15:41:31 christos Exp $");
+__RCSID("$NetBSD: t_pipe.c,v 1.5 2017/01/13 21:30:41 christos Exp $");
#include <sys/types.h>
#include <sys/wait.h>
@@ -45,7 +45,7 @@ __RCSID("$NetBSD: t_pipe.c,v 1.3 2011/10/31 15:41:31 christos Exp $");
#include <atf-c.h>
-#include "../../../h_macros.h"
+#include "h_macros.h"
static pid_t pid;
static int nsiginfo = 0;
@@ -153,9 +153,7 @@ ATF_TC_BODY(pipe_restart, tc)
ATF_REQUIRE_EQ(WEXITSTATUS(st), 0);
}
-#ifdef __FreeBSD__
free(f);
-#endif
}
ATF_TP_ADD_TCS(tp)
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c b/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c
index 8208cf7..48f9734 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_pipe2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_pipe2.c,v 1.8 2012/05/16 13:54:28 jruoho Exp $ */
+/* $NetBSD: t_pipe2.c,v 1.9 2017/01/13 21:19:45 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_pipe2.c,v 1.8 2012/05/16 13:54:28 jruoho Exp $");
+__RCSID("$NetBSD: t_pipe2.c,v 1.9 2017/01/13 21:19:45 christos Exp $");
#include <atf-c.h>
#include <fcntl.h>
@@ -56,7 +56,8 @@ run(int flags)
#ifdef __FreeBSD__
closefrom(3);
#else
- ATF_REQUIRE(fcntl(3, F_CLOSEM) != -1);
+ ATF_REQUIRE_MSG(closefrom(3) != -1, "closefrom failed: %s",
+ strerror(errno));
#endif
ATF_REQUIRE(pipe2(fd, flags) == 0);
@@ -116,13 +117,13 @@ ATF_TC_BODY(pipe2_consume, tc)
{
struct rlimit rl;
int err, filedes[2];
-#ifdef __FreeBSD__
int old;
+#ifdef __FreeBSD__
closefrom(4);
#else
- err = fcntl(4, F_CLOSEM);
- ATF_REQUIRE(err == 0);
+ ATF_REQUIRE_MSG(closefrom(4) != -1, "closefrom failed: %s",
+ strerror(errno));
#endif
err = getrlimit(RLIMIT_NOFILE, &rl);
@@ -132,19 +133,15 @@ ATF_TC_BODY(pipe2_consume, tc)
* file descriptor limit in the middle of a pipe2() call - i.e.
* before the call only a single descriptor may be openend.
*/
-#ifdef __FreeBSD__
old = rl.rlim_cur;
-#endif
rl.rlim_cur = 4;
err = setrlimit(RLIMIT_NOFILE, &rl);
ATF_REQUIRE(err == 0);
err = pipe2(filedes, O_CLOEXEC);
ATF_REQUIRE(err == -1);
-#ifdef __FreeBSD__
rl.rlim_cur = old;
err = setrlimit(RLIMIT_NOFILE, &rl);
-#endif
}
ATF_TC(pipe2_nonblock);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c b/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c
index da4e746..813bfb8 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_posix_fadvise.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_posix_fadvise.c,v 1.1 2011/10/15 06:10:26 jruoho Exp $ */
+/* $NetBSD: t_posix_fadvise.c,v 1.2 2017/01/13 21:30:41 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_posix_fadvise.c,v 1.1 2011/10/15 06:10:26 jruoho Exp $");
+__RCSID("$NetBSD: t_posix_fadvise.c,v 1.2 2017/01/13 21:30:41 christos Exp $");
#include <sys/fcntl.h>
@@ -68,7 +68,7 @@ __RCSID("$NetBSD: t_posix_fadvise.c,v 1.1 2011/10/15 06:10:26 jruoho Exp $");
#include <atf-c.h>
-#include "../../../h_macros.h"
+#include "h_macros.h"
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_revoke.c b/contrib/netbsd-tests/lib/libc/sys/t_revoke.c
index 8e4c2a3..ec225b9 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_revoke.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_revoke.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_revoke.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $ */
+/* $NetBSD: t_revoke.c,v 1.2 2017/01/13 21:15:57 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_revoke.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $");
+__RCSID("$NetBSD: t_revoke.c,v 1.2 2017/01/13 21:15:57 christos Exp $");
#include <sys/resource.h>
#include <sys/wait.h>
@@ -176,9 +176,7 @@ ATF_TC_BODY(revoke_perm, tc)
if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS)
atf_tc_fail("revoke(2) did not obey permissions");
-#ifdef __FreeBSD__
(void)close(fd);
-#endif
ATF_REQUIRE(unlink(path) == 0);
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_select.c b/contrib/netbsd-tests/lib/libc/sys/t_select.c
index 437b67b..04a684a 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_select.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_select.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_select.c,v 1.3 2012/03/18 07:00:52 jruoho Exp $ */
+/* $NetBSD: t_select.c,v 1.4 2017/01/13 21:18:33 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -47,21 +47,13 @@
static sig_atomic_t keep_going = 1;
static void
-#ifdef __FreeBSD__
sig_handler(int signum __unused)
-#else
-sig_handler(int signum)
-#endif
{
keep_going = 0;
}
static void
-#ifdef __FreeBSD__
sigchld(int signum __unused)
-#else
-sigchld(int signum)
-#endif
{
}
@@ -90,7 +82,7 @@ prmask(const sigset_t *m, char *buf, size_t len)
return buf;
}
-static void
+static __dead void
child(const struct timespec *ts)
{
struct sigaction sa;
@@ -135,9 +127,7 @@ child(const struct timespec *ts)
"after timeout %s != %s",
prmask(&nset, nbuf, sizeof(nbuf)),
prmask(&oset, obuf, sizeof(obuf)));
-#ifdef __FreeBSD__
_exit(0);
-#endif
}
ATF_TC(pselect_sigmask);
@@ -157,9 +147,7 @@ ATF_TC_BODY(pselect_sigmask, tc)
switch (pid = fork()) {
case 0:
child(NULL);
-#ifdef __FreeBSD__
- break;
-#endif
+ /*NOTREACHED*/
case -1:
err(1, "fork");
default:
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c b/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c
index f1100bf..7bef590 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $ */
+/* $NetBSD: t_setrlimit.c,v 1.6 2017/01/13 21:16:38 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $");
+__RCSID("$NetBSD: t_setrlimit.c,v 1.6 2017/01/13 21:16:38 christos Exp $");
#include <sys/resource.h>
#include <sys/mman.h>
@@ -124,9 +124,7 @@ out:
if (lim != 0)
atf_tc_fail("failed to set limit (%d)", lim);
-#ifdef __FreeBSD__
free(buf);
-#endif
}
ATF_TC(setrlimit_current);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c b/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c
index 23ca36a..4bbf421 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sigaction.c,v 1.3 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_sigaction.c,v 1.5 2017/01/13 21:30:41 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2010\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sigaction.c,v 1.3 2014/11/04 00:20:19 justin Exp $");
+__RCSID("$NetBSD: t_sigaction.c,v 1.5 2017/01/13 21:30:41 christos Exp $");
#include <sys/wait.h>
@@ -41,20 +41,12 @@ __RCSID("$NetBSD: t_sigaction.c,v 1.3 2014/11/04 00:20:19 justin Exp $");
#include <atf-c.h>
-#ifdef __NetBSD__
-#include "../../../h_macros.h"
-#else
#include "h_macros.h"
-#endif
static bool handler_called = false;
static void
-#ifdef __FreeBSD__
handler(int signo __unused)
-#else
-handler(int signo)
-#endif
{
handler_called = true;
}
@@ -87,11 +79,7 @@ wait_and_check_child(const pid_t pid, const char *fail_message)
}
static void
-#ifdef __FreeBSD__
catch(int sig __unused)
-#else
-catch(int sig)
-#endif
{
return;
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c b/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c
index e911d42..af560f8 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sigqueue.c,v 1.6 2016/08/04 06:43:43 christos Exp $ */
+/* $NetBSD: t_sigqueue.c,v 1.7 2017/01/13 20:44:10 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,31 +30,24 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_sigqueue.c,v 1.6 2016/08/04 06:43:43 christos Exp $");
+__RCSID("$NetBSD: t_sigqueue.c,v 1.7 2017/01/13 20:44:10 christos Exp $");
#include <atf-c.h>
+#include <err.h>
#include <errno.h>
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <err.h>
-#include <stdio.h>
-#endif
-
static void handler(int, siginfo_t *, void *);
#define VALUE (int)0xc001dad1
static int value;
static void
-#ifdef __FreeBSD__
-handler(int signo __unused, siginfo_t *info __unused, void *data __unused)
-#else
-handler(int signo, siginfo_t *info, void *data)
-#endif
+handler(int signo __unused, siginfo_t *info, void *data __unused)
{
value = info->si_value.sival_int;
kill(0, SIGINFO);
@@ -123,12 +116,10 @@ static sig_atomic_t count = 0;
static int delivered[CNT];
static void
-myhandler(int signo, siginfo_t *info, void *context)
+myhandler(int signo, siginfo_t *info, void *context __unused)
{
delivered[count++] = signo;
-#ifdef __FreeBSD__
printf("Signal #%zu: signo: %d\n", (size_t)count, signo);
-#endif
}
static int
@@ -213,12 +204,8 @@ ATF_TC_BODY(sigqueue_rt, tc)
sigset_t mask, orig;
sigemptyset(&mask);
for (size_t i = 0; i < CNT; i++)
-#ifdef __FreeBSD__
if (sigaddset(&mask, signals[i]) == -1)
warn("sigaddset");
-#else
- sigaddset(&mask, signals[i]);
-#endif
ATF_REQUIRE(sigprocmask(SIG_BLOCK, &mask, &orig) != -1);
@@ -227,23 +214,16 @@ ATF_TC_BODY(sigqueue_rt, tc)
ATF_REQUIRE(sigprocmask(SIG_UNBLOCK, &mask, &orig) != -1);
sleep(1);
-#ifdef __FreeBSD__
ATF_CHECK_MSG((size_t)count == ndelivered,
"count %zu != ndelivered %zu", (size_t)count, ndelivered);
-#else
- ATF_REQUIRE_MSG((size_t)count == ndelivered,
- "count %zu != ndelivered %zu", (size_t)count, ndelivered);
-#endif
for (size_t i = 0; i < ndelivered; i++)
ATF_REQUIRE_MSG(ordered[i] == delivered[i],
"%zu: ordered %d != delivered %d",
i, ordered[i], delivered[i]);
-#ifdef __FreeBSD__
- if (count > ndelivered)
- for (size_t i = ndelivered; i < count; i++)
+ if ((size_t)count > ndelivered)
+ for (size_t i = ndelivered; i < (size_t)count; i++)
printf("Undelivered signal #%zu: %d\n", i, ordered[i]);
-#endif
for (size_t i = 0; i < ndelivered; i++)
ATF_REQUIRE(sigaction(signals[i], &oact[i], NULL) != -1);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c b/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c
index 9da7861..7a0cc20 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_socketpair.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_socketpair.c,v 1.1 2011/11/05 18:19:02 jruoho Exp $ */
+/* $NetBSD: t_socketpair.c,v 1.2 2017/01/13 20:04:52 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_socketpair.c,v 1.1 2011/11/05 18:19:02 jruoho Exp $");
+__RCSID("$NetBSD: t_socketpair.c,v 1.2 2017/01/13 20:04:52 christos Exp $");
#include <atf-c.h>
#include <fcntl.h>
@@ -66,7 +66,7 @@ run(int flags)
#ifdef __FreeBSD__
closefrom(3);
#else
- ATF_REQUIRE(fcntl(3, F_CLOSEM) != -1);
+ ATF_REQUIRE(closefrom(3) != -1);
#endif
ATF_REQUIRE(socketpair(AF_UNIX, SOCK_DGRAM | flags, 0, fd) == 0);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_stat.c b/contrib/netbsd-tests/lib/libc/sys/t_stat.c
index 300c6e8..adb32bb 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_stat.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_stat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_stat.c,v 1.4 2012/03/17 08:37:08 jruoho Exp $ */
+/* $NetBSD: t_stat.c,v 1.5 2017/01/13 20:06:50 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,13 +29,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_stat.c,v 1.4 2012/03/17 08:37:08 jruoho Exp $");
+__RCSID("$NetBSD: t_stat.c,v 1.5 2017/01/13 20:06:50 christos Exp $");
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
+#include <netinet/in.h>
#include <atf-c.h>
#include <errno.h>
@@ -47,10 +48,6 @@ __RCSID("$NetBSD: t_stat.c,v 1.4 2012/03/17 08:37:08 jruoho Exp $");
#include <stdio.h>
-#ifdef __FreeBSD__
-#include <netinet/in.h>
-#endif
-
static const char *path = "stat";
ATF_TC_WITH_CLEANUP(stat_chflags);
@@ -396,11 +393,9 @@ ATF_TC_BODY(stat_symlink, tc)
if (sa.st_mode == sb.st_mode)
atf_tc_fail("inconsistencies between stat(2) and lstat(2)");
+ (void)close(fd);
ATF_REQUIRE(unlink(path) == 0);
ATF_REQUIRE(unlink(pathlink) == 0);
-#ifdef __FreeBSD__
- (void)close(fd);
-#endif
}
ATF_TC_CLEANUP(stat_symlink, tc)
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c b/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c
index cc85307..e8a6acd 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_timer_create.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_timer_create.c,v 1.4 2012/03/18 07:00:52 jruoho Exp $ */
+/* $NetBSD: t_timer_create.c,v 1.5 2017/01/16 16:32:13 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,11 +38,7 @@ static timer_t t;
static bool fail = true;
static void
-#ifdef __FreeBSD__
timer_signal_handler(int signo, siginfo_t *si, void *osi __unused)
-#else
-timer_signal_handler(int signo, siginfo_t *si, void *osi)
-#endif
{
timer_t *tp;
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_truncate.c b/contrib/netbsd-tests/lib/libc/sys/t_truncate.c
index 59193a9..5b96a20 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_truncate.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_truncate.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_truncate.c,v 1.2 2011/08/18 19:48:03 dholland Exp $ */
+/* $NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,21 +29,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_truncate.c,v 1.2 2011/08/18 19:48:03 dholland Exp $");
+__RCSID("$NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $");
#include <sys/stat.h>
#include <atf-c.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <limits.h>
-#endif
-
static const char path[] = "truncate";
static const size_t sizes[] = { 8, 16, 512, 1024, 2048, 4094, 3000, 30 };
@@ -153,9 +150,7 @@ ATF_TC_HEAD(truncate_err, tc)
ATF_TC_BODY(truncate_err, tc)
{
-#ifndef __NetBSD__
char buf[PATH_MAX];
-#endif
errno = 0;
ATF_REQUIRE_ERRNO(EFAULT, truncate((void *)-1, 999) == -1);
@@ -167,13 +162,9 @@ ATF_TC_BODY(truncate_err, tc)
ATF_REQUIRE_ERRNO(ENOENT, truncate("/a/b/c/d/e/f/g", 999) == -1);
errno = 0;
-#ifdef __NetBSD__
- ATF_REQUIRE_ERRNO(EACCES, truncate("/usr/bin/fpr", 999) == -1);
-#else
snprintf(buf, sizeof(buf), "%s/truncate_test.root_owned",
atf_tc_get_config_var(tc, "srcdir"));
ATF_REQUIRE_ERRNO(EACCES, truncate(buf, 999) == -1);
-#endif
}
ATF_TP_ADD_TCS(tp)
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_umask.c b/contrib/netbsd-tests/lib/libc/sys/t_umask.c
index 7a65574..fb3e405b 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_umask.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_umask.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_umask.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $ */
+/* $NetBSD: t_umask.c,v 1.2 2017/01/13 19:34:19 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_umask.c,v 1.1 2011/07/07 06:57:54 jruoho Exp $");
+__RCSID("$NetBSD: t_umask.c,v 1.2 2017/01/13 19:34:19 christos Exp $");
#include <sys/stat.h>
#include <sys/wait.h>
@@ -129,9 +129,7 @@ ATF_TC_BODY(umask_open, tc)
if (fd < 0)
continue;
-#ifdef __FreeBSD__
(void)close(fd);
-#endif
(void)memset(&st, 0, sizeof(struct stat));
if (stat(path, &st) != 0) {
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_unlink.c b/contrib/netbsd-tests/lib/libc/sys/t_unlink.c
index b504bb0..cda9c16 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_unlink.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_unlink.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_unlink.c,v 1.2 2014/04/21 18:05:17 martin Exp $ */
+/* $NetBSD: t_unlink.c,v 1.4 2017/01/14 20:55:26 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_unlink.c,v 1.2 2014/04/21 18:05:17 martin Exp $");
+__RCSID("$NetBSD: t_unlink.c,v 1.4 2017/01/14 20:55:26 christos Exp $");
#include <sys/stat.h>
@@ -111,15 +111,8 @@ ATF_TC_HEAD(unlink_fifo, tc)
ATF_TC_BODY(unlink_fifo, tc)
{
-#ifdef __FreeBSD__
- int fd;
- ATF_REQUIRE_MSG((fd = mkfifo(path, 0666)) == 0,
- "mkfifo failed: %s", strerror(errno));
- (void)close(fd);
-#else
ATF_REQUIRE(mkfifo(path, 0666) == 0);
-#endif
ATF_REQUIRE(unlink(path) == 0);
errno = 0;
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait.c b/contrib/netbsd-tests/lib/libc/sys/t_wait.c
index 8653265..91bbaf1f 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_wait.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $ */
+/* $NetBSD: t_wait.c,v 1.8 2017/01/13 19:28:55 christos Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -29,25 +29,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_wait.c,v 1.7 2016/11/06 15:04:14 kamil Exp $");
+__RCSID("$NetBSD: t_wait.c,v 1.8 2017/01/13 19:28:55 christos Exp $");
#include <sys/wait.h>
#include <sys/resource.h>
-#include <stdio.h>
#include <errno.h>
+#include <inttypes.h>
#include <limits.h>
#include <pwd.h>
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <atf-c.h>
-#ifdef __FreeBSD__
-#define wrusage __wrusage
-#endif
-
ATF_TC(wait6_invalid);
ATF_TC_HEAD(wait6_invalid, tc)
{
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c
index e5ddcbd..c529f17 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c
@@ -29,9 +29,6 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $");
-#ifdef __FreeBSD__
-#include <sys/param.h> /* For NBBY -- it's in sys/types.h on NetBSD */
-#endif
#include <sys/wait.h>
#include <sys/resource.h>
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_write.c b/contrib/netbsd-tests/lib/libc/sys/t_write.c
index a3783cb..576ce7e 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_write.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_write.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_write.c,v 1.2 2011/10/19 16:19:30 jruoho Exp $ */
+/* $NetBSD: t_write.c,v 1.3 2017/01/13 19:27:23 christos Exp $ */
/*-
* Copyright (c) 2001, 2008 The NetBSD Foundation, Inc.
@@ -29,37 +29,27 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_write.c,v 1.2 2011/10/19 16:19:30 jruoho Exp $");
+__RCSID("$NetBSD: t_write.c,v 1.3 2017/01/13 19:27:23 christos Exp $");
#include <sys/uio.h>
-#ifdef __NetBSD__
-#include <sys/syslimits.h>
-#endif
#include <atf-c.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
+#include <limits.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <limits.h>
-#endif
-
static void sighandler(int);
static bool fail = false;
static const char *path = "write";
static void
-#ifdef __FreeBSD__
sighandler(int signo __unused)
-#else
-sighandler(int signo)
-#endif
{
fail = false;
}
diff --git a/contrib/netbsd-tests/lib/libm/t_ilogb.c b/contrib/netbsd-tests/lib/libm/t_ilogb.c
index b3c2126..1d35cb6 100644
--- a/contrib/netbsd-tests/lib/libm/t_ilogb.c
+++ b/contrib/netbsd-tests/lib/libm/t_ilogb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */
+/* $NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -28,18 +28,18 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_ilogb.c,v 1.7 2017/01/13 19:23:40 christos Exp $");
-#ifdef __FreeBSD__
-#include <limits.h>
-#endif
#include <atf-c.h>
#include <fenv.h>
+#include <limits.h>
#include <math.h>
#ifndef __HAVE_FENV
-# define ATF_CHECK_RAISED_INVALID
-# define ATF_CHECK_RAISED_NOTHING
+# define ATF_CHECK_RAISED_INVALID
+# define ATF_CHECK_RAISED_NOTHING
#else
# define ATF_CHECK_RAISED_INVALID do { \
diff --git a/contrib/netbsd-tests/lib/libm/t_pow.c b/contrib/netbsd-tests/lib/libm/t_pow.c
index fbdb984..7afee9f 100644
--- a/contrib/netbsd-tests/lib/libm/t_pow.c
+++ b/contrib/netbsd-tests/lib/libm/t_pow.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $ */
+/* $NetBSD: t_pow.c,v 1.5 2017/01/20 21:15:56 maya Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,15 +29,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_pow.c,v 1.4 2015/09/08 05:24:27 dholland Exp $");
+__RCSID("$NetBSD: t_pow.c,v 1.5 2017/01/20 21:15:56 maya Exp $");
#include <atf-c.h>
#include <math.h>
-#ifdef __FreeBSD__
-#define isinff isinf
-#endif
-
/*
* pow(3)
*/
@@ -383,12 +379,12 @@ ATF_TC_BODY(powf_inf_neg_x, tc)
*/
z = powf(x, 3.0);
- if (isinff(z) == 0 || signbit(z) == 0)
+ if (isinf(z) == 0 || signbit(z) == 0)
atf_tc_fail_nonfatal("powf(-Inf, 3.0) != -Inf");
z = powf(x, 4.0);
- if (isinff(z) == 0 || signbit(z) != 0)
+ if (isinf(z) == 0 || signbit(z) != 0)
atf_tc_fail_nonfatal("powf(-Inf, 4.0) != +Inf");
/*
@@ -425,7 +421,7 @@ ATF_TC_BODY(powf_inf_neg_y, tc)
*/
z = powf(0.1, y);
- if (isinff(z) == 0 || signbit(z) != 0)
+ if (isinf(z) == 0 || signbit(z) != 0)
atf_tc_fail_nonfatal("powf(0.1, -Inf) != +Inf");
z = powf(1.1, y);
@@ -456,7 +452,7 @@ ATF_TC_BODY(powf_inf_pos_x, tc)
z = powf(x, 2.0);
- if (isinff(z) == 0 || signbit(z) != 0)
+ if (isinf(z) == 0 || signbit(z) != 0)
atf_tc_fail_nonfatal("powf(+Inf, 2.0) != +Inf");
}
@@ -482,7 +478,7 @@ ATF_TC_BODY(powf_inf_pos_y, tc)
z = powf(1.1, y);
- if (isinff(z) == 0 || signbit(z) != 0)
+ if (isinf(z) == 0 || signbit(z) != 0)
atf_tc_fail_nonfatal("powf(1.1, +Inf) != +Inf");
}
@@ -500,8 +496,8 @@ ATF_TC_BODY(powf_one_neg_x, tc)
/*
* If x is -1.0, and y is +-Inf, 1.0 shall be returned.
*/
- ATF_REQUIRE(isinff(infp) != 0);
- ATF_REQUIRE(isinff(infn) != 0);
+ ATF_REQUIRE(isinf(infp) != 0);
+ ATF_REQUIRE(isinf(infn) != 0);
if (powf(-1.0, infp) != 1.0) {
atf_tc_expect_fail("PR lib/45372");
diff --git a/contrib/netbsd-tests/lib/libm/t_precision.c b/contrib/netbsd-tests/lib/libm/t_precision.c
index df2d8a3..eb8e295 100644
--- a/contrib/netbsd-tests/lib/libm/t_precision.c
+++ b/contrib/netbsd-tests/lib/libm/t_precision.c
@@ -51,6 +51,11 @@ volatile long double y = 1;
ATF_TC_BODY(t_precision, tc)
{
+#ifdef __FreeBSD__
+#ifdef __i386__
+ atf_tc_expect_fail("the __HAVE_LONG_DOUBLE checks fail on i386");
+#endif
+#endif
x += DBL_EPSILON;
ATF_CHECK(x != 1.0);
x -= 1;
diff --git a/contrib/netbsd-tests/lib/libm/t_scalbn.c b/contrib/netbsd-tests/lib/libm/t_scalbn.c
index fe70b3c..4bf00c3 100644
--- a/contrib/netbsd-tests/lib/libm/t_scalbn.c
+++ b/contrib/netbsd-tests/lib/libm/t_scalbn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_scalbn.c,v 1.11 2014/03/03 10:39:08 martin Exp $ */
+/* $NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_scalbn.c,v 1.11 2014/03/03 10:39:08 martin Exp $");
+__RCSID("$NetBSD: t_scalbn.c,v 1.14 2017/01/13 21:09:12 agc Exp $");
#include <math.h>
#include <limits.h>
@@ -81,9 +81,7 @@ ATF_TC_BODY(scalbn_val, tc)
double rv;
for (i = 0; i < tcnt; i++) {
-#ifdef __FreeBSD__
errno = 0;
-#endif
rv = scalbn(tests[i].inval, tests[i].exp);
ATF_CHECK_EQ_MSG(errno, tests[i].error,
"test %zu: errno %d instead of %d", i, errno,
@@ -225,9 +223,7 @@ ATF_TC_BODY(scalbnf_val, tc)
double rv;
for (i = 0; i < tcnt; i++) {
-#ifdef __FreeBSD__
errno = 0;
-#endif
rv = scalbnf(tests[i].inval, tests[i].exp);
ATF_CHECK_EQ_MSG(errno, tests[i].error,
"test %zu: errno %d instead of %d", i, errno,
@@ -372,9 +368,7 @@ ATF_TC_BODY(scalbnl_val, tc)
long double rv;
for (i = 0; i < tcnt; i++) {
-#ifdef __FreeBSD__
errno = 0;
-#endif
rv = scalbnl(tests[i].inval, tests[i].exp);
ATF_CHECK_EQ_MSG(errno, tests[i].error,
"test %zu: errno %d instead of %d", i, errno,
diff --git a/contrib/netbsd-tests/lib/libposix/t_rename.c b/contrib/netbsd-tests/lib/libposix/t_rename.c
index 85b2b95..8c18ec5 100644
--- a/contrib/netbsd-tests/lib/libposix/t_rename.c
+++ b/contrib/netbsd-tests/lib/libposix/t_rename.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_rename.c,v 1.2 2011/05/16 00:03:36 christos Exp $ */
+/* $NetBSD: t_rename.c,v 1.3 2017/01/13 21:30:41 christos Exp $ */
/*
* Copyright (c) 2001, 2008, 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_rename.c,v 1.2 2011/05/16 00:03:36 christos Exp $");
+__RCSID("$NetBSD: t_rename.c,v 1.3 2017/01/13 21:30:41 christos Exp $");
#include <sys/types.h>
#include <sys/stat.h>
@@ -43,7 +43,7 @@ __RCSID("$NetBSD: t_rename.c,v 1.2 2011/05/16 00:03:36 christos Exp $");
#include <atf-c.h>
-#include "../../h_macros.h"
+#include "h_macros.h"
ATF_TC(rename);
ATF_TC_HEAD(rename, tc)
diff --git a/contrib/netbsd-tests/lib/libpthread/h_common.h b/contrib/netbsd-tests/lib/libpthread/h_common.h
index 2e8b0a1..261b07f 100644
--- a/contrib/netbsd-tests/lib/libpthread/h_common.h
+++ b/contrib/netbsd-tests/lib/libpthread/h_common.h
@@ -5,14 +5,14 @@
#define PTHREAD_REQUIRE(x) \
do { \
- int ret = (x); \
- ATF_REQUIRE_MSG(ret == 0, "%s: %s", #x, strerror(ret)); \
+ int _ret = (x); \
+ ATF_REQUIRE_MSG(_ret == 0, "%s: %s", #x, strerror(_ret)); \
} while (0)
#define PTHREAD_REQUIRE_STATUS(x, v) \
do { \
- int ret = (x); \
- ATF_REQUIRE_MSG(ret == (v), "%s: %s", #x, strerror(ret)); \
+ int _ret = (x); \
+ ATF_REQUIRE_MSG(_ret == (v), "%s: %s", #x, strerror(_ret)); \
} while (0)
#endif // H_COMMON_H
diff --git a/contrib/netbsd-tests/lib/libpthread/t_condwait.c b/contrib/netbsd-tests/lib/libpthread/t_condwait.c
index 99793d0..58b4a8b 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_condwait.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_condwait.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $ */
+/* $NetBSD: t_condwait.c,v 1.5 2017/01/16 16:29:19 christos Exp $ */
/*
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -26,8 +26,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $");
+__RCSID("$NetBSD: t_condwait.c,v 1.5 2017/01/16 16:29:19 christos Exp $");
+#include <sys/time.h>
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
@@ -40,11 +41,7 @@ __RCSID("$NetBSD: t_condwait.c,v 1.4 2013/04/12 17:18:11 christos Exp $");
#include "isqemu.h"
-#ifdef __FreeBSD__
-#include <sys/time.h>
-
#include "h_common.h"
-#endif
#define WAITTIME 2 /* Timeout wait secound */
@@ -62,13 +59,8 @@ run(void *param)
clck = *(clockid_t *)param;
-#ifdef __FreeBSD__
PTHREAD_REQUIRE(pthread_condattr_init(&attr));
PTHREAD_REQUIRE(pthread_condattr_setclock(&attr, clck));
-#else
- pthread_condattr_init(&attr);
- pthread_condattr_setclock(&attr, clck); /* MONOTONIC or MONOTONIC */
-#endif
pthread_cond_init(&cond, &attr);
ATF_REQUIRE_EQ((ret = pthread_mutex_lock(&m)), 0);
diff --git a/contrib/netbsd-tests/lib/libpthread/t_detach.c b/contrib/netbsd-tests/lib/libpthread/t_detach.c
index b3357bc..b30cb02 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_detach.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_detach.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $ */
+/* $NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,27 +29,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_detach.c,v 1.1 2011/03/24 13:52:04 jruoho Exp $");
+__RCSID("$NetBSD: t_detach.c,v 1.2 2017/01/16 16:29:54 christos Exp $");
-#include <pthread.h>
#include <errno.h>
+#include <pthread.h>
+#include <time.h>
#include <atf-c.h>
#include "h_common.h"
-#ifdef __FreeBSD__
-#include <time.h>
-#endif
-
static void *func(void *);
static void *
func(void *arg)
{
-#ifdef __FreeBSD__
sleep(2);
-#endif
return NULL;
}
@@ -79,25 +74,17 @@ ATF_TC_BODY(pthread_detach, tc)
*/
PTHREAD_REQUIRE(pthread_detach(t));
-#ifdef __FreeBSD__
sleep(1);
-#endif
rv = pthread_join(t, NULL);
ATF_REQUIRE(rv == EINVAL);
-#ifdef __FreeBSD__
sleep(3);
-#endif
/*
* As usual, ESRCH should follow if
* we try to detach an invalid thread.
*/
-#ifdef __NetBSD__
- rv = pthread_cancel(NULL);
-#else
rv = pthread_cancel(t);
-#endif
ATF_REQUIRE(rv == ESRCH);
}
diff --git a/contrib/netbsd-tests/lib/libpthread/t_fork.c b/contrib/netbsd-tests/lib/libpthread/t_fork.c
index a58c1a6..936c7de 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_fork.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_fork.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fork.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */
+/* $NetBSD: t_fork.c,v 1.2 2017/01/16 16:28:27 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_fork.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $");
+__RCSID("$NetBSD: t_fork.c,v 1.2 2017/01/16 16:28:27 christos Exp $");
/*
* Written by Love Hörnquist Åstrand <lha@NetBSD.org>, March 2003.
@@ -61,11 +61,7 @@ print_pid(void *arg)
thread_survived = 1;
if (parent != getpid()) {
-#ifdef __FreeBSD__
_exit(1);
-#else
- exit(1);
-#endif
}
return NULL;
}
@@ -99,11 +95,7 @@ ATF_TC_BODY(fork, tc)
ATF_REQUIRE_EQ_MSG(WEXITSTATUS(status), 0, "thread survived in child");
} else {
sleep(5);
-#ifdef __FreeBSD__
_exit(thread_survived ? 1 : 0);
-#else
- exit(thread_survived ? 1 : 0);
-#endif
}
}
diff --git a/contrib/netbsd-tests/lib/libpthread/t_fpu.c b/contrib/netbsd-tests/lib/libpthread/t_fpu.c
index 6a385d9..dd47fb8 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_fpu.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_fpu.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $ */
+/* $NetBSD: t_fpu.c,v 1.3 2017/01/16 16:27:43 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $");
+__RCSID("$NetBSD: t_fpu.c,v 1.3 2017/01/16 16:27:43 christos Exp $");
/*
* This is adapted from part of csw/cstest of the MPD implementation by
@@ -49,20 +49,17 @@ __RCSID("$NetBSD: t_fpu.c,v 1.2 2013/01/27 14:47:37 mbalmer Exp $");
* <is@netbsd.org>.
*/
+#include <errno.h>
#include <math.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <atf-c.h>
-#ifdef __FreeBSD__
-#include <errno.h>
-#include <string.h>
-#endif
-
#include "h_common.h"
#define N_RECURSE 10
@@ -82,24 +79,16 @@ stir(void *p)
for (;;) {
x = sin ((y = cos (x + y + .4)) - (z = cos (x + z + .6)));
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(sched_yield() == 0,
"sched_yield failed: %s", strerror(errno));
-#else
- PTHREAD_REQUIRE(sched_yield());
-#endif
}
}
static double
mul3(double x, double y, double z)
{
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(sched_yield() == 0,
"sched_yield failed: %s", strerror(errno));
-#else
- PTHREAD_REQUIRE(sched_yield());
-#endif
return x * y * z;
}
@@ -129,11 +118,7 @@ bar(void *p)
static void
recurse(void) {
pthread_t s2;
-#ifdef __FreeBSD__
PTHREAD_REQUIRE(pthread_create(&s2, 0, bar, 0));
-#else
- pthread_create(&s2, 0, bar, 0);
-#endif
sleep(20); /* XXX must be long enough for our slowest machine */
}
@@ -153,11 +138,7 @@ ATF_TC_BODY(fpu, tc)
PTHREAD_REQUIRE(pthread_mutex_init(&recursion_depth_lock, 0));
-#ifdef __FreeBSD__
PTHREAD_REQUIRE(pthread_create(&s5, 0, stir, stirseed));
-#else
- pthread_create(&s5, 0, stir, stirseed);
-#endif
recurse();
atf_tc_fail("exiting from main");
diff --git a/contrib/netbsd-tests/lib/libpthread/t_join.c b/contrib/netbsd-tests/lib/libpthread/t_join.c
index 71b6775..1c57910 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_join.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_join.c
@@ -37,10 +37,6 @@ __RCSID("$NetBSD: t_join.c,v 1.8 2012/03/12 20:17:16 joerg Exp $");
#include <atf-c.h>
-#ifdef __FreeBSD__
-#include <pthread_np.h>
-#endif
-
#include "h_common.h"
#ifdef CHECK_STACK_ALIGNMENT
diff --git a/contrib/netbsd-tests/lib/libpthread/t_mutex.c b/contrib/netbsd-tests/lib/libpthread/t_mutex.c
index b8d60e6..bcb8540 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_mutex.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_mutex.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $ */
+/* $NetBSD: t_mutex.c,v 1.15 2017/01/16 16:23:41 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,12 +29,10 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $");
+__RCSID("$NetBSD: t_mutex.c,v 1.15 2017/01/16 16:23:41 christos Exp $");
-#ifdef __FreeBSD__
#include <sys/time.h> /* For timespecadd */
#include <inttypes.h> /* For UINT16_MAX */
-#endif
#include <pthread.h>
#include <stdio.h>
#include <string.h>
@@ -594,20 +592,16 @@ ATF_TC_BODY(mutexattr2, tc)
int min_prio = sched_get_priority_min(SCHED_FIFO);
for (int i = min_prio; i <= max_prio; i++) {
int prioceiling;
-#ifdef __FreeBSD__
int protocol;
PTHREAD_REQUIRE(pthread_mutexattr_getprotocol(&mattr,
&protocol));
printf("priority: %d\nprotocol: %d\n", i, protocol);
-#endif
PTHREAD_REQUIRE(pthread_mutexattr_setprioceiling(&mattr, i));
PTHREAD_REQUIRE(pthread_mutexattr_getprioceiling(&mattr,
&prioceiling));
-#ifdef __FreeBSD__
printf("prioceiling: %d\n", prioceiling);
-#endif
ATF_REQUIRE_EQ(i, prioceiling);
}
}
diff --git a/contrib/netbsd-tests/lib/libpthread/t_once.c b/contrib/netbsd-tests/lib/libpthread/t_once.c
index e879077..e2f209b 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_once.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_once.c
@@ -31,6 +31,9 @@ __COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_once.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $");
+#ifdef __FreeBSD__
+#include <sys/time.h> /* For itimer*, etc. */
+#endif
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
@@ -46,10 +49,6 @@ static int x;
#define NTHREADS 25
-#ifdef __FreeBSD__
-#include <sys/time.h>
-#endif
-
static void
ofunc(void)
{
diff --git a/contrib/netbsd-tests/lib/libpthread/t_sem.c b/contrib/netbsd-tests/lib/libpthread/t_sem.c
index 5bb7ae7..3d15edd 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_sem.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_sem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_sem.c,v 1.9 2017/01/16 16:22:22 christos Exp $ */
/*
* Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -86,8 +86,9 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $");
+__RCSID("$NetBSD: t_sem.c,v 1.9 2017/01/16 16:22:22 christos Exp $");
+#include <sys/time.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
@@ -111,10 +112,6 @@ __RCSID("$NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $");
static sem_t sem;
-#ifdef __FreeBSD__
-#include <sys/time.h>
-#endif
-
ATF_TC(named);
ATF_TC_HEAD(named, tc)
{
diff --git a/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c b/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
index a18ac2f..677c51f 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_swapcontext.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_swapcontext.c,v 1.2 2014/08/25 16:31:15 bouyer Exp $ */
+/* $NetBSD: t_swapcontext.c,v 1.3 2017/01/16 16:27:06 christos Exp $ */
/*
* Copyright (c) 2012 Emmanuel Dreyfus. All rights reserved.
@@ -28,15 +28,13 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD");
-#ifdef __FreeBSD__
#include <sys/types.h>
#include <errno.h>
-#include <string.h>
-#endif
#include <pthread.h>
-#include <ucontext.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ucontext.h>
#include <atf-c.h>
@@ -82,12 +80,8 @@ threadfunc(void *arg)
oself = (void *)pthread_self();
printf("before swapcontext self = %p\n", oself);
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(swapcontext(&octx, &nctx) != -1, "swapcontext failed: %s",
strerror(errno));
-#else
- PTHREAD_REQUIRE(swapcontext(&octx, &nctx));
-#endif
/* NOTREACHED */
return NULL;
@@ -109,12 +103,8 @@ ATF_TC_BODY(swapcontext1, tc)
printf("Testing if swapcontext() alters pthread_self()\n");
-#ifdef __FreeBSD__
ATF_REQUIRE_MSG(getcontext(&nctx) != -1, "getcontext failed: %s",
strerror(errno));
-#else
- PTHREAD_REQUIRE(getcontext(&nctx));
-#endif
PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc, NULL));
PTHREAD_REQUIRE(pthread_join(thread, NULL));
}
diff --git a/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h b/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h
new file mode 100644
index 0000000..0a02b96
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libpthread_dbg/h_common.h
@@ -0,0 +1,128 @@
+/* $NetBSD: h_common.h,v 1.2 2016/11/19 02:30:54 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef H_COMMON_H
+#define H_COMMON_H
+
+#include <sys/cdefs.h>
+#include <dlfcn.h>
+#include <pthread_dbg.h>
+#include <string.h>
+
+#include <atf-c.h>
+
+#define PTHREAD_REQUIRE(x) \
+ do { \
+ int ret = (x); \
+ ATF_REQUIRE_MSG(ret == 0, "%s: %s", #x, strerror(ret)); \
+ } while (0)
+
+#define PTHREAD_REQUIRE_STATUS(x, v) \
+ do { \
+ int ret = (x); \
+ ATF_REQUIRE_MSG(ret == (v), "%s: %s", #x, strerror(ret)); \
+ } while (0)
+
+static int __used
+dummy_proc_read(void *arg, caddr_t addr, void *buf, size_t size)
+{
+ return TD_ERR_ERR;
+}
+
+static int __used
+dummy_proc_write(void *arg, caddr_t addr, void *buf, size_t size)
+{
+ return TD_ERR_ERR;
+}
+
+static int __used
+dummy_proc_lookup(void *arg, const char *sym, caddr_t *addr)
+{
+ return TD_ERR_ERR;
+}
+
+static int __used
+dummy_proc_regsize(void *arg, int regset, size_t *size)
+{
+ return TD_ERR_ERR;
+}
+
+static int __used
+dummy_proc_getregs(void *arg, int regset, int lwp, void *buf)
+{
+ return TD_ERR_ERR;
+}
+
+static int __used
+dummy_proc_setregs(void *arg, int regset, int lwp, void *buf)
+{
+ return TD_ERR_ERR;
+}
+
+/* Minimalistic basic implementation */
+
+static int __used
+basic_proc_read(void *arg, caddr_t addr, void *buf, size_t size)
+{
+ memcpy(buf, addr, size);
+
+ return TD_ERR_OK;
+}
+
+static int __used
+basic_proc_write(void *arg, caddr_t addr, void *buf, size_t size)
+{
+ memcpy(addr, buf, size);
+
+ return TD_ERR_OK;
+}
+
+static int __used
+basic_proc_lookup(void *arg, const char *sym, caddr_t *addr)
+{
+ void *handle;
+ void *symbol;
+
+ ATF_REQUIRE_MSG((handle = dlopen(NULL, RTLD_LOCAL | RTLD_LAZY))
+ != NULL, "dlopen(3) failed: %s", dlerror());
+
+ symbol = dlsym(handle, sym);
+
+ ATF_REQUIRE_MSG(dlclose(handle) == 0, "dlclose(3) failed: %s",
+ dlerror());
+
+ if (!symbol)
+ return TD_ERR_NOSYM;
+
+ *addr = (caddr_t)(uintptr_t)symbol;
+
+ return TD_ERR_OK;
+}
+
+#endif // H_COMMON_H
diff --git a/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c b/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c
new file mode 100644
index 0000000..367443c
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libpthread_dbg/t_dummy.c
@@ -0,0 +1,131 @@
+/* $NetBSD: t_dummy.c,v 1.6 2016/11/19 15:13:46 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_dummy.c,v 1.6 2016/11/19 15:13:46 kamil Exp $");
+
+#include "h_common.h"
+#include <pthread_dbg.h>
+#include <stdio.h>
+
+#include <atf-c.h>
+
+
+ATF_TC(dummy1);
+ATF_TC_HEAD(dummy1, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that dummy lookup functions stop td_open() with failure");
+}
+
+ATF_TC_BODY(dummy1, tc)
+{
+
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+
+ dummy_callbacks.proc_read = dummy_proc_read;
+ dummy_callbacks.proc_write = dummy_proc_write;
+ dummy_callbacks.proc_lookup = dummy_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_ERR);
+}
+
+ATF_TC(dummy2);
+ATF_TC_HEAD(dummy2, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that td_open() for basic proc_{read,write,lookup} works");
+}
+
+ATF_TC_BODY(dummy2, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+}
+
+ATF_TC(dummy3);
+ATF_TC_HEAD(dummy3, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that calling twice td_open() for the same process fails");
+}
+
+ATF_TC_BODY(dummy3, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta1;
+ td_proc_t *main_ta2;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ printf("Calling td_open(3) for the first time - expecting success\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta1) == TD_ERR_OK);
+
+ printf("Calling td_open(3) for the first time - expecting in-use\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta2) ==
+ TD_ERR_INUSE);
+
+ printf("Calling td_close(3) for the first successful call\n");
+ ATF_REQUIRE(td_close(main_ta1) == TD_ERR_OK);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, dummy1);
+ ATF_TP_ADD_TC(tp, dummy2);
+ ATF_TP_ADD_TC(tp, dummy3);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c b/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c
new file mode 100644
index 0000000..f22bbc9
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libpthread_dbg/t_threads.c
@@ -0,0 +1,719 @@
+/* $NetBSD: t_threads.c,v 1.9 2017/01/13 05:18:22 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_threads.c,v 1.9 2017/01/13 05:18:22 christos Exp $");
+
+#include <dlfcn.h>
+#include <pthread.h>
+#include <pthread_dbg.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "h_common.h"
+
+#define MAX_THREADS (size_t)10
+
+ATF_TC(threads1);
+ATF_TC_HEAD(threads1, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that td_thr_iter() call without extra logic works");
+}
+
+static volatile int exiting1;
+
+static void *
+busyFunction1(void *arg)
+{
+
+ while (exiting1 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads1(td_thread_t *thread, void *arg)
+{
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads1, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction1, NULL));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads1, NULL) == TD_ERR_OK);
+
+ exiting1 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+}
+
+ATF_TC(threads2);
+ATF_TC_HEAD(threads2, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that td_thr_iter() call is executed for each thread once");
+}
+
+static volatile int exiting2;
+
+static void *
+busyFunction2(void *arg)
+{
+
+ while (exiting2 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads2(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads2, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction2, NULL));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads2, &count) == TD_ERR_OK);
+
+ exiting2 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TC(threads3);
+ATF_TC_HEAD(threads3, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that for each td_thr_iter() call td_thr_info() is valid");
+}
+
+static volatile int exiting3;
+
+static void *
+busyFunction3(void *arg)
+{
+
+ while (exiting3 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads3(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+ td_thread_info_t info;
+
+ ATF_REQUIRE(td_thr_info(thread, &info) == TD_ERR_OK);
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads3, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction3, NULL));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads3, &count) == TD_ERR_OK);
+
+ exiting3 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TC(threads4);
+ATF_TC_HEAD(threads4, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that for each td_thr_iter() call td_thr_getname() is "
+ "valid");
+}
+
+static volatile int exiting4;
+
+static void *
+busyFunction4(void *arg)
+{
+
+ while (exiting4 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads4(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+ char name[PTHREAD_MAX_NAMELEN_NP];
+
+ ATF_REQUIRE(td_thr_getname(thread, name, sizeof(name)) == TD_ERR_OK);
+
+ printf("Thread name: %s\n", name);
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads4, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction4, NULL));
+ }
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ PTHREAD_REQUIRE
+ (pthread_setname_np(threads[i], "test_%d", (void*)i));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads4, &count) == TD_ERR_OK);
+
+ exiting4 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TC(threads5);
+ATF_TC_HEAD(threads5, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that td_thr_getname() handles shorter buffer parameter "
+ "and the result is properly truncated");
+}
+
+static volatile int exiting5;
+
+static void *
+busyFunction5(void *arg)
+{
+
+ while (exiting5 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads5(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+ /* Arbitrarily short string buffer */
+ char name[3];
+
+ ATF_REQUIRE(td_thr_getname(thread, name, sizeof(name)) == TD_ERR_OK);
+
+ printf("Thread name: %s\n", name);
+
+ /* strlen(3) does not count including a '\0' character */
+ ATF_REQUIRE(strlen(name) < sizeof(name));
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads5, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction5, NULL));
+ }
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ PTHREAD_REQUIRE
+ (pthread_setname_np(threads[i], "test_%d", (void*)i));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads5, &count) == TD_ERR_OK);
+
+ exiting5 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TC(threads6);
+ATF_TC_HEAD(threads6, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that pthread_t can be translated with td_map_pth2thr() "
+ "to td_thread_t -- and assert earlier that td_thr_iter() call is "
+ "valid");
+}
+
+static volatile int exiting6;
+
+static void *
+busyFunction6(void *arg)
+{
+
+ while (exiting6 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads6(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads6, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction6, NULL));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads6, &count) == TD_ERR_OK);
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ td_thread_t *td_thread;
+ ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread)
+ == TD_ERR_OK);
+ }
+
+ exiting6 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TC(threads7);
+ATF_TC_HEAD(threads7, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that pthread_t can be translated with td_map_pth2thr() "
+ "to td_thread_t -- and assert later that td_thr_iter() call is "
+ "valid");
+}
+
+static volatile int exiting7;
+
+static void *
+busyFunction7(void *arg)
+{
+
+ while (exiting7 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads7(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads7, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction7, NULL));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ td_thread_t *td_thread;
+ ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread)
+ == TD_ERR_OK);
+ }
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads7, &count) == TD_ERR_OK);
+
+ exiting7 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TC(threads8);
+ATF_TC_HEAD(threads8, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that pthread_t can be translated with td_map_pth2thr() "
+ "to td_thread_t -- compare thread's name of pthread_t and "
+ "td_thread_t");
+}
+
+static volatile int exiting8;
+
+static void *
+busyFunction8(void *arg)
+{
+
+ while (exiting8 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads8(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads8, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction8, NULL));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads8, &count) == TD_ERR_OK);
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ td_thread_t *td_thread;
+ char td_threadname[PTHREAD_MAX_NAMELEN_NP];
+ char pth_threadname[PTHREAD_MAX_NAMELEN_NP];
+ ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread)
+ == TD_ERR_OK);
+ ATF_REQUIRE(td_thr_getname(td_thread, td_threadname,
+ sizeof(td_threadname)) == TD_ERR_OK);
+ PTHREAD_REQUIRE(pthread_getname_np(threads[i], pth_threadname,
+ sizeof(pth_threadname)));
+ ATF_REQUIRE(strcmp(td_threadname, pth_threadname) == 0);
+ }
+
+ exiting8 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TC(threads9);
+ATF_TC_HEAD(threads9, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Asserts that pthread_t can be translated with td_map_pth2thr() "
+ "to td_thread_t -- assert that thread is in the TD_STATE_RUNNING "
+ "state");
+}
+
+static volatile int exiting9;
+
+static void *
+busyFunction9(void *arg)
+{
+
+ while (exiting9 == 0)
+ usleep(50000);
+
+ return NULL;
+}
+
+static int
+iterateThreads9(td_thread_t *thread, void *arg)
+{
+ int *counter = (int *)arg;
+
+ ++(*counter);
+
+ return TD_ERR_OK;
+}
+
+ATF_TC_BODY(threads9, tc)
+{
+ struct td_proc_callbacks_t dummy_callbacks;
+ td_proc_t *main_ta;
+ size_t i;
+ pthread_t threads[MAX_THREADS];
+ int count = 0;
+
+ dummy_callbacks.proc_read = basic_proc_read;
+ dummy_callbacks.proc_write = basic_proc_write;
+ dummy_callbacks.proc_lookup = basic_proc_lookup;
+ dummy_callbacks.proc_regsize = dummy_proc_regsize;
+ dummy_callbacks.proc_getregs = dummy_proc_getregs;
+ dummy_callbacks.proc_setregs = dummy_proc_setregs;
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ printf("Creating thread %zu\n", i);
+ PTHREAD_REQUIRE
+ (pthread_create(&threads[i], NULL, busyFunction9, NULL));
+ }
+
+ printf("Calling td_open(3)\n");
+ ATF_REQUIRE(td_open(&dummy_callbacks, NULL, &main_ta) == TD_ERR_OK);
+
+ for (i = 0; i < MAX_THREADS; i++) {
+ td_thread_t *td_thread;
+ td_thread_info_t info;
+ ATF_REQUIRE(td_map_pth2thr(main_ta, threads[i], &td_thread)
+ == TD_ERR_OK);
+ ATF_REQUIRE(td_thr_info(td_thread, &info) == TD_ERR_OK);
+ ATF_REQUIRE_EQ(info.thread_state, TD_STATE_RUNNING);
+ }
+
+ ATF_REQUIRE(td_thr_iter(main_ta, iterateThreads9, &count) == TD_ERR_OK);
+
+ exiting9 = 1;
+
+ printf("Calling td_close(3)\n");
+ ATF_REQUIRE(td_close(main_ta) == TD_ERR_OK);
+
+ ATF_REQUIRE_EQ_MSG(count, MAX_THREADS + 1,
+ "counted threads (%d) != expected threads (%zu)",
+ count, MAX_THREADS + 1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, threads1);
+ ATF_TP_ADD_TC(tp, threads2);
+ ATF_TP_ADD_TC(tp, threads3);
+ ATF_TP_ADD_TC(tp, threads4);
+ ATF_TP_ADD_TC(tp, threads5);
+ ATF_TP_ADD_TC(tp, threads6);
+ ATF_TP_ADD_TC(tp, threads7);
+ ATF_TP_ADD_TC(tp, threads8);
+ ATF_TP_ADD_TC(tp, threads9);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c b/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c
new file mode 100644
index 0000000..23c2803
--- /dev/null
+++ b/contrib/netbsd-tests/lib/librefuse/t_refuse_opt.c
@@ -0,0 +1,418 @@
+/* $NetBSD: t_refuse_opt.c,v 1.8 2017/01/13 21:30:41 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_refuse_opt.c,v 1.8 2017/01/13 21:30:41 christos Exp $");
+
+#define _KERNTYPES
+#include <sys/types.h>
+
+#include <atf-c.h>
+
+#include <fuse.h>
+
+#include "h_macros.h"
+
+ATF_TC(t_fuse_opt_add_arg);
+ATF_TC_HEAD(t_fuse_opt_add_arg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_arg(3) works");
+}
+
+ATF_TC_BODY(t_fuse_opt_add_arg, tc)
+{
+ struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+
+ RZ(fuse_opt_add_arg(&args, "foo"));
+ RZ(fuse_opt_add_arg(&args, "bar"));
+
+ ATF_REQUIRE_EQ(args.argc, 2);
+ ATF_CHECK_STREQ(args.argv[0], "foo");
+ ATF_CHECK_STREQ(args.argv[1], "bar");
+ ATF_CHECK(args.allocated != 0);
+}
+
+ATF_TC(t_fuse_opt_insert_arg);
+ATF_TC_HEAD(t_fuse_opt_insert_arg, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_insert_arg(3) works");
+}
+
+ATF_TC_BODY(t_fuse_opt_insert_arg, tc)
+{
+ struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+
+ RZ(fuse_opt_insert_arg(&args, 0, "foo"));
+ RZ(fuse_opt_insert_arg(&args, 0, "bar"));
+
+ ATF_REQUIRE_EQ(args.argc, 2);
+ ATF_CHECK_STREQ(args.argv[0], "bar");
+ ATF_CHECK_STREQ(args.argv[1], "foo");
+ ATF_CHECK(args.allocated != 0);
+}
+
+ATF_TC(t_fuse_opt_add_opt);
+ATF_TC_HEAD(t_fuse_opt_add_opt, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_opt(3) works");
+}
+
+ATF_TC_BODY(t_fuse_opt_add_opt, tc)
+{
+ char* opt = NULL;
+
+ RZ(fuse_opt_add_opt(&opt, "fo\\o"));
+ ATF_CHECK_STREQ(opt, "fo\\o");
+
+ RZ(fuse_opt_add_opt(&opt, "ba,r"));
+ ATF_CHECK_STREQ(opt, "fo\\o,ba,r");
+}
+
+ATF_TC(t_fuse_opt_add_opt_escaped);
+ATF_TC_HEAD(t_fuse_opt_add_opt_escaped, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_add_opt_escaped(3) works");
+}
+
+ATF_TC_BODY(t_fuse_opt_add_opt_escaped, tc)
+{
+ char* opt = NULL;
+
+ RZ(fuse_opt_add_opt_escaped(&opt, "fo\\o"));
+ ATF_CHECK_STREQ(opt, "fo\\\\o");
+
+ RZ(fuse_opt_add_opt_escaped(&opt, "ba,r"));
+ ATF_CHECK_STREQ(opt, "fo\\\\o,ba\\,r");
+}
+
+ATF_TC(t_fuse_opt_match);
+ATF_TC_HEAD(t_fuse_opt_match, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_match(3) works"
+ " for every form of templates");
+}
+
+ATF_TC_BODY(t_fuse_opt_match, tc)
+{
+ struct fuse_opt o1[] = { FUSE_OPT_KEY("-x" , 0), FUSE_OPT_END };
+ struct fuse_opt o2[] = { FUSE_OPT_KEY("foo" , 0), FUSE_OPT_END };
+ struct fuse_opt o3[] = { FUSE_OPT_KEY("foo=" , 0), FUSE_OPT_END };
+ struct fuse_opt o4[] = { FUSE_OPT_KEY("foo=%s", 0), FUSE_OPT_END };
+ struct fuse_opt o5[] = { FUSE_OPT_KEY("-x " , 0), FUSE_OPT_END };
+ struct fuse_opt o6[] = { FUSE_OPT_KEY("-x %s" , 0), FUSE_OPT_END };
+
+ ATF_CHECK(fuse_opt_match(o1, "-x") == 1);
+ ATF_CHECK(fuse_opt_match(o1, "x") == 0);
+
+ ATF_CHECK(fuse_opt_match(o2, "foo") == 1);
+ ATF_CHECK(fuse_opt_match(o2, "-foo") == 0);
+
+ ATF_CHECK(fuse_opt_match(o3, "foo=bar") == 1);
+ ATF_CHECK(fuse_opt_match(o3, "foo" ) == 0);
+
+ ATF_CHECK(fuse_opt_match(o4, "foo=bar") == 1);
+ ATF_CHECK(fuse_opt_match(o4, "foo" ) == 0);
+
+ ATF_CHECK(fuse_opt_match(o5, "-xbar" ) == 1);
+ ATF_CHECK(fuse_opt_match(o5, "-x" ) == 1);
+ ATF_CHECK(fuse_opt_match(o5, "-x=bar") == 1);
+ ATF_CHECK(fuse_opt_match(o5, "bar" ) == 0);
+
+ ATF_CHECK(fuse_opt_match(o6, "-xbar" ) == 1);
+ ATF_CHECK(fuse_opt_match(o6, "-x" ) == 1);
+ ATF_CHECK(fuse_opt_match(o6, "-x=bar") == 1);
+ ATF_CHECK(fuse_opt_match(o6, "bar" ) == 0);
+}
+
+struct foofs_config {
+ int number;
+ char *string;
+ char* nonopt;
+};
+
+#define FOOFS_OPT(t, p, v) { t, offsetof(struct foofs_config, p), v }
+
+static struct fuse_opt foofs_opts[] = {
+ FOOFS_OPT("number=%i" , number, 0),
+ FOOFS_OPT("-n %i" , number, 0),
+ FOOFS_OPT("string=%s" , string, 0),
+ FOOFS_OPT("number1" , number, 1),
+ FOOFS_OPT("number2" , number, 2),
+ FOOFS_OPT("--number=three", number, 3),
+ FOOFS_OPT("--number=four" , number, 4),
+ FUSE_OPT_END
+};
+
+static int foo_opt_proc(void *data, const char *arg, int key, struct fuse_args *outargs) {
+ struct foofs_config *config = data;
+
+ if (key == FUSE_OPT_KEY_NONOPT && config->nonopt == NULL) {
+ config->nonopt = strdup(arg);
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
+ATF_TC(t_fuse_opt_parse_null_args);
+ATF_TC_HEAD(t_fuse_opt_parse_null_args, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "NULL args means an empty arguments vector");
+}
+
+ATF_TC_BODY(t_fuse_opt_parse_null_args, tc)
+{
+ struct foofs_config config;
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(NULL, &config, NULL, NULL) == 0);
+ ATF_CHECK_EQ(config.number, 0);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_EQ(config.nonopt, NULL);
+}
+
+ATF_TC(t_fuse_opt_parse_null_opts);
+ATF_TC_HEAD(t_fuse_opt_parse_null_opts, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "NULL opts means an opts array which only has FUSE_OPT_END");
+}
+
+ATF_TC_BODY(t_fuse_opt_parse_null_opts, tc)
+{
+ struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+ struct foofs_config config;
+
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "-o"));
+ RZ(fuse_opt_add_arg(&args, "number=1,string=foo"));
+ RZ(fuse_opt_add_arg(&args, "bar"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, NULL, NULL) == 0);
+ ATF_CHECK_EQ(config.number, 0);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_EQ(config.nonopt, NULL);
+ ATF_CHECK_EQ(args.argc, 4);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+ ATF_CHECK_STREQ(args.argv[1], "-o");
+ ATF_CHECK_STREQ(args.argv[2], "number=1,string=foo");
+ ATF_CHECK_STREQ(args.argv[3], "bar");
+}
+
+ATF_TC(t_fuse_opt_parse_null_proc);
+ATF_TC_HEAD(t_fuse_opt_parse_null_proc, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "NULL proc means a processor function always returning 1,"
+ " i.e. keep the argument");
+}
+
+ATF_TC_BODY(t_fuse_opt_parse_null_proc, tc)
+{
+ struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+ struct foofs_config config;
+
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "-o"));
+ RZ(fuse_opt_add_arg(&args, "number=1,string=foo"));
+ RZ(fuse_opt_add_arg(&args, "bar"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, NULL) == 0);
+ ATF_CHECK_EQ(config.number, 1);
+ ATF_CHECK_STREQ(config.string, "foo");
+ ATF_CHECK_EQ(config.nonopt, NULL);
+ ATF_CHECK_EQ(args.argc, 2);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+ ATF_CHECK_STREQ(args.argv[1], "bar");
+}
+
+ATF_TC(t_fuse_opt_parse);
+ATF_TC_HEAD(t_fuse_opt_parse, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that fuse_opt_parse(3) fully works");
+}
+
+ATF_TC_BODY(t_fuse_opt_parse, tc)
+{
+ struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+ struct foofs_config config;
+
+ /* Standard form */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "-o"));
+ RZ(fuse_opt_add_arg(&args, "number=1,string=foo"));
+ RZ(fuse_opt_add_arg(&args, "bar"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 1);
+ ATF_CHECK_STREQ(config.string, "foo");
+ ATF_CHECK_STREQ(config.nonopt, "bar");
+ ATF_CHECK_EQ(args.argc, 1);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+
+ /* Concatenated -o */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "-onumber=1,unknown,string=foo"));
+ RZ(fuse_opt_add_arg(&args, "bar"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 1);
+ ATF_CHECK_STREQ(config.string, "foo");
+ ATF_CHECK_STREQ(config.nonopt, "bar");
+ ATF_CHECK_EQ(args.argc, 3);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+ ATF_CHECK_STREQ(args.argv[1], "-o");
+ ATF_CHECK_STREQ(args.argv[2], "unknown");
+
+ /* Sparse -o */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "bar"));
+ RZ(fuse_opt_add_arg(&args, "baz"));
+ RZ(fuse_opt_add_arg(&args, "-o"));
+ RZ(fuse_opt_add_arg(&args, "number=1"));
+ RZ(fuse_opt_add_arg(&args, "-o"));
+ RZ(fuse_opt_add_arg(&args, "unknown"));
+ RZ(fuse_opt_add_arg(&args, "-o"));
+ RZ(fuse_opt_add_arg(&args, "string=foo"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 1);
+ ATF_CHECK_STREQ(config.string, "foo");
+ ATF_CHECK_STREQ(config.nonopt, "bar");
+ ATF_CHECK_EQ(args.argc, 4);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+ ATF_CHECK_STREQ(args.argv[1], "-o");
+ ATF_CHECK_STREQ(args.argv[2], "unknown");
+ ATF_CHECK_STREQ(args.argv[3], "baz");
+
+ /* Separate -n %i */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "-n"));
+ RZ(fuse_opt_add_arg(&args, "3"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 3);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_EQ(config.nonopt, NULL);
+ ATF_CHECK_EQ(args.argc, 1);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+
+ /* Concatenated -n %i */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "-n3"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 3);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_EQ(config.nonopt, NULL);
+ ATF_CHECK_EQ(args.argc, 1);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+
+ /* -o constant */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "-o"));
+ RZ(fuse_opt_add_arg(&args, "number2"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 2);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_EQ(config.nonopt, NULL);
+ ATF_CHECK_EQ(args.argc, 1);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+
+ /* -x constant */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "--number=four"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 4);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_EQ(config.nonopt, NULL);
+ ATF_CHECK_EQ(args.argc, 1);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+
+ /* end-of-options "--" marker */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "--"));
+ RZ(fuse_opt_add_arg(&args, "-onumber=1"));
+ RZ(fuse_opt_add_arg(&args, "-ostring=foo"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 0);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_STREQ(config.nonopt, "-onumber=1");
+ ATF_CHECK_EQ(args.argc, 3);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+ ATF_CHECK_STREQ(args.argv[1], "--");
+ ATF_CHECK_STREQ(args.argv[2], "-ostring=foo");
+
+ /* The "--" marker at the last of outargs should be removed */
+ fuse_opt_free_args(&args);
+ RZ(fuse_opt_add_arg(&args, "foofs"));
+ RZ(fuse_opt_add_arg(&args, "--"));
+ RZ(fuse_opt_add_arg(&args, "-onumber=1"));
+
+ memset(&config, 0, sizeof(config));
+ ATF_CHECK(fuse_opt_parse(&args, &config, foofs_opts, foo_opt_proc) == 0);
+ ATF_CHECK_EQ(config.number, 0);
+ ATF_CHECK_EQ(config.string, NULL);
+ ATF_CHECK_STREQ(config.nonopt, "-onumber=1");
+ ATF_CHECK_EQ(args.argc, 1);
+ ATF_CHECK_STREQ(args.argv[0], "foofs");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, t_fuse_opt_add_arg);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_insert_arg);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_add_opt);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_add_opt_escaped);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_match);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_parse_null_args);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_parse_null_opts);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_parse_null_proc);
+ ATF_TP_ADD_TC(tp, t_fuse_opt_parse);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/librt/t_sem.c b/contrib/netbsd-tests/lib/librt/t_sem.c
index e76cd52..0541ae5 100644
--- a/contrib/netbsd-tests/lib/librt/t_sem.c
+++ b/contrib/netbsd-tests/lib/librt/t_sem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $ */
+/* $NetBSD: t_sem.c,v 1.3 2017/01/14 20:58:20 christos Exp $ */
/*
* Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $");
+__RCSID("$NetBSD: t_sem.c,v 1.3 2017/01/14 20:58:20 christos Exp $");
#include <sys/wait.h>
@@ -72,7 +72,7 @@ __RCSID("$NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $");
#define NCHILDREN 10
-ATF_TC(basic);
+ATF_TC_WITH_CLEANUP(basic);
ATF_TC_HEAD(basic, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks basic functionality of POSIX "
@@ -86,9 +86,6 @@ ATF_TC_BODY(basic, tc)
if (sysconf(_SC_SEMAPHORES) == -1)
atf_tc_skip("POSIX semaphores not supported");
-#ifdef __FreeBSD__
- sem_unlink("/sem_b");
-#endif
sem_b = sem_open("/sem_b", O_CREAT | O_EXCL, 0644, 0);
ATF_REQUIRE(sem_b != SEM_FAILED);
@@ -111,8 +108,12 @@ ATF_TC_BODY(basic, tc)
ATF_REQUIRE_EQ(sem_close(sem_b), 0);
ATF_REQUIRE_EQ(sem_unlink("/sem_b"), 0);
}
+ATF_TC_CLEANUP(basic, tc)
+{
+ (void)sem_unlink("/sem_b");
+}
-ATF_TC(child);
+ATF_TC_WITH_CLEANUP(child);
ATF_TC_HEAD(child, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks using semaphores to synchronize "
@@ -127,12 +128,9 @@ ATF_TC_BODY(child, tc)
pid_t pid;
- if (sysconf(_SC_SEMAPHORES) == -1)
+ if (sysconf(_SC_SEMAPHORES) == -1)
atf_tc_skip("POSIX semaphores not supported");
-#ifdef __FreeBSD__
- sem_unlink("/sem_a");
-#endif
sem_a = sem_open("/sem_a", O_CREAT | O_EXCL, 0644, 0);
ATF_REQUIRE(sem_a != SEM_FAILED);
@@ -170,6 +168,10 @@ ATF_TC_BODY(child, tc)
ATF_REQUIRE_EQ(sem_close(sem_a), 0);
ATF_REQUIRE_EQ(sem_unlink("/sem_a"), 0);
}
+ATF_TC_CLEANUP(child, tc)
+{
+ (void)sem_unlink("/sem_a");
+}
ATF_TP_ADD_TCS(tp)
{
diff --git a/contrib/netbsd-tests/lib/librumpclient/t_fd.c b/contrib/netbsd-tests/lib/librumpclient/t_fd.c
index 6e6d947..70182ab 100644
--- a/contrib/netbsd-tests/lib/librumpclient/t_fd.c
+++ b/contrib/netbsd-tests/lib/librumpclient/t_fd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fd.c,v 1.5 2016/08/10 21:10:18 kre Exp $ */
+/* $NetBSD: t_fd.c,v 1.6 2017/01/13 21:30:41 christos Exp $ */
/*
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
#include <rump/rumpclient.h>
#include <rump/rump_syscalls.h>
-#include "../../h_macros.h"
+#include "h_macros.h"
ATF_TC_WITH_CLEANUP(bigenough);
ATF_TC_HEAD(bigenough, tc)
diff --git a/contrib/netbsd-tests/lib/semaphore/sem.c b/contrib/netbsd-tests/lib/semaphore/sem.c
index 5967b88..6af9b0d 100644
--- a/contrib/netbsd-tests/lib/semaphore/sem.c
+++ b/contrib/netbsd-tests/lib/semaphore/sem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.10 2012/03/09 14:25:34 joerg Exp $ */
+/* $NetBSD: sem.c,v 1.11 2017/01/13 21:30:42 christos Exp $ */
/*
* Common code for semaphore tests. This can be included both into
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <unistd.h>
-#include "../../h_macros.h"
+#include "h_macros.h"
ATF_TC(postwait);
ATF_TC_HEAD(postwait, tc)
OpenPOWER on IntegriCloud