Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)

- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
2013-12-06 12:04:52 +01:00
parent ff10274392
commit 84d9c625bf
4655 changed files with 379317 additions and 151059 deletions

View File

@@ -2,5 +2,8 @@
WARNS ?= 4
CWARNFLAGS+= -Wno-missing-noreturn
.if defined(__MINIX)
LDSTATIC= -dynamic
NOGCCERROR=yes
NOCLANGERROR=yes
.endif # defined(__MINIX)

View File

@@ -4,7 +4,6 @@
TESTSDIR= ${TESTSBASE}/bin
# LSC FIXME df test is ignored
TESTS_SUBDIRS= cat cp dd expr pax ps sh sleep tar
TESTS_SUBDIRS= cat cp dd df expr pax ps sh sleep tar
.include <bsd.test.mk>

View File

@@ -1,4 +1,4 @@
# $NetBSD: t_expand.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
# $NetBSD: t_expand.sh,v 1.2 2013/10/06 21:05:50 ast Exp $
#
# Copyright (c) 2007, 2009 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -37,7 +37,7 @@ delim_argv() {
else
str="${str} >$1<"
fi
shift
shift
done
echo ${str}
}
@@ -119,10 +119,24 @@ arithmetic_body() {
atf_check_equal '9223372036854775807' '$(((1 << 63) - 1))'
}
atf_test_case iteration_on_null_parameter
iteration_on_null_parameter_head() {
atf_set "descr" "Check iteration of \$@ in for loop when set to null;" \
"the error \"sh: @: parameter not set\" is incorrect." \
"PR bin/48202."
}
iteration_on_null_parameter_body() {
s1=`/bin/sh -uc 'N=; set -- ${N}; for X; do echo "[$X]"; done' 2>&1`
s2=`/bin/sh -uc 'N=; set -- ${N:-}; for X; do echo "[$X]"; done' 2>&1`
atf_check_equal '' '$s1'
atf_check_equal '[]' '$s2'
}
atf_init_test_cases() {
atf_add_test_case dollar_at
atf_add_test_case dollar_at_with_text
atf_add_test_case strip
atf_add_test_case varpattern_backslashes
atf_add_test_case arithmetic
atf_add_test_case iteration_on_null_parameter
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: fstest_puffs.c,v 1.10 2011/02/10 16:35:01 njoly Exp $ */
/* $NetBSD: fstest_puffs.c,v 1.11 2013/09/09 19:47:38 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -386,12 +386,6 @@ puffs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags)
if (fd == -1)
return fd;
#if 0
pa->pa_fd = fd;
#else
assert(fd == 0); /* XXX: FIXME */
#endif
if (rump_sys_mkdir(path, 0777) == -1)
return -1;

View File

@@ -1,4 +1,4 @@
# $NetBSD: ffs_common.sh,v 1.1 2012/01/18 20:51:23 bouyer Exp $
# $NetBSD: ffs_common.sh,v 1.2 2013/07/29 13:15:24 skrll Exp $
create_ffs()
{
@@ -72,7 +72,7 @@ test_case_root()
eval "${name}_head() { \
atf_set "descr" "${descr}"
atf_set "require.user" "root"
atf_set "timeout" "60"
atf_set "timeout" "360"
}"
eval "${name}_body() { \
RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \

View File

@@ -1,4 +1,4 @@
/* $NetBSD: mountd.c,v 1.7 2012/01/22 18:36:17 christos Exp $ */
/* $NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
#if 0
static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: mountd.c,v 1.7 2012/01/22 18:36:17 christos Exp $");
__RCSID("$NetBSD: mountd.c,v 1.8 2013/10/19 17:45:00 christos Exp $");
#endif
#endif /* not lint */
@@ -497,7 +497,6 @@ mntsrv(rqstp, transp)
struct fhreturn fhr;
struct stat stb;
struct statvfs fsb;
struct addrinfo *ai;
char host[NI_MAXHOST], numerichost[NI_MAXHOST];
int lookup_failed = 1;
struct sockaddr *saddr;
@@ -532,7 +531,6 @@ mntsrv(rqstp, transp)
if (getnameinfo(saddr, saddr->sa_len, numerichost,
sizeof numerichost, NULL, 0, ninumeric) != 0)
strlcpy(numerichost, "?", sizeof(numerichost));
ai = NULL;
ret = 0;
switch (rqstp->rq_proc) {
case NULLPROC:

View File

@@ -1,4 +1,4 @@
/* $NetBSD: nfsd.c,v 1.3 2010/07/28 15:12:17 pooka Exp $ */
/* $NetBSD: nfsd.c,v 1.4 2013/10/19 17:45:00 christos Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\
#if 0
static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95";
#else
__RCSID("$NetBSD: nfsd.c,v 1.3 2010/07/28 15:12:17 pooka Exp $");
__RCSID("$NetBSD: nfsd.c,v 1.4 2013/10/19 17:45:00 christos Exp $");
#endif
#endif /* not lint */
@@ -149,18 +149,17 @@ nfsd_main(argc, argv)
struct sockaddr_in inetpeer;
struct pollfd set[4];
socklen_t len;
int ch, cltpflag, connect_type_cnt, i, maxsock, msgsock;
int ch, connect_type_cnt, i, msgsock;
int nfsdcnt, on = 1, reregister, sock, tcpflag, tcpsock;
int tcp6sock, ip6flag;
int tp4cnt, tp4flag, tpipcnt, tpipflag, udpflag, ecode, s;
int tp4cnt, tp4flag, tpipcnt, udpflag, ecode, s;
int error = 0;
#define DEFNFSDCNT 4
nfsdcnt = DEFNFSDCNT;
cltpflag = reregister = tcpflag = tp4cnt = tp4flag = tpipcnt = 0;
tpipflag = udpflag = ip6flag = 0;
reregister = tcpflag = tp4cnt = tp4flag = tpipcnt = 0;
udpflag = ip6flag = 0;
nconf_udp = nconf_tcp = nconf_udp6 = nconf_tcp6 = NULL;
maxsock = 0;
tcpsock = tcp6sock = -1;
#define GETOPT "6n:rtu"
#define USAGE "[-rtu] [-n num_servers]"

View File

@@ -1,4 +1,4 @@
/* $NetBSD: pmap_svc.c,v 1.1 2010/07/26 15:53:00 pooka Exp $ */
/* $NetBSD: pmap_svc.c,v 1.2 2013/10/19 17:45:00 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -170,7 +170,6 @@ pmapproc_change(struct svc_req *rqstp, SVCXPRT *xprt, unsigned long op)
struct pmap reg;
RPCB rpcbreg;
long ans;
struct sockaddr_in *who;
struct sockcred *sc;
char uidbuf[32];
@@ -191,7 +190,7 @@ pmapproc_change(struct svc_req *rqstp, SVCXPRT *xprt, unsigned long op)
return FALSE;
}
who = svc_getcaller(xprt);
(void)svc_getcaller(xprt);
sc = __svc_getcallercreds(xprt);
/*

View File

@@ -1,4 +1,4 @@
/* $NetBSD: rpcbind.c,v 1.3 2011/09/16 16:13:18 plunky Exp $ */
/* $NetBSD: rpcbind.c,v 1.4 2013/10/19 17:45:00 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -233,9 +233,7 @@ init_transport(struct netconfig *nconf)
struct addrinfo hints, *res = NULL;
struct __rpc_sockinfo si;
SVCXPRT *my_xprt;
int status; /* bound checking ? */
int aicode;
int addrlen;
int aicode, status, addrlen;
struct sockaddr *sa;
struct sockaddr_un sun;
const int one = 1;
@@ -480,6 +478,8 @@ init_transport(struct netconfig *nconf)
nconf->nc_netid);
}
}
#else
__USE(status);
#endif
/*
* rmtcall only supported on CLTS transports for now.

View File

@@ -1,4 +1,4 @@
/* $NetBSD: dtfs_subr.c,v 1.3 2011/03/01 15:19:49 pooka Exp $ */
/* $NetBSD: dtfs_subr.c,v 1.4 2013/10/19 17:45:00 christos Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@@ -81,7 +81,7 @@ struct puffs_node *
dtfs_genfile(struct puffs_node *dir, const struct puffs_cn *pcn,
enum vtype type)
{
struct dtfs_file *df_dir, *dff;
struct dtfs_file *dff;
struct dtfs_dirent *dfd;
struct dtfs_mount *dtm;
struct puffs_node *newpn;
@@ -107,7 +107,6 @@ dtfs_genfile(struct puffs_node *dir, const struct puffs_cn *pcn,
errx(1, "getnewpnode");
dtfs_baseattrs(&newpn->pn_va, type, dtm->dtm_nextfileid++);
df_dir = dir->pn_data;
dfd = emalloc(sizeof(struct dtfs_dirent));
dfd->dfd_node = newpn;
dfd->dfd_name = estrndup(pcn->pcn_name, pcn->pcn_namelen);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: dtfs_vnops.c,v 1.9 2012/01/31 18:56:07 njoly Exp $ */
/* $NetBSD: dtfs_vnops.c,v 1.10 2013/10/19 17:45:00 christos Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@@ -430,7 +430,6 @@ dtfs_node_mknod(struct puffs_usermount *pu, void *opc,
{
struct puffs_node *pn_parent = opc;
struct puffs_node *pn_new;
struct dtfs_file *df;
if (!(va->va_type == VBLK || va->va_type == VCHR
|| va->va_type == VFIFO))
@@ -439,7 +438,6 @@ dtfs_node_mknod(struct puffs_usermount *pu, void *opc,
pn_new = dtfs_genfile(pn_parent, pcn, va->va_type);
puffs_setvattr(&pn_new->pn_va, va);
df = DTFS_PTOF(pn_new);
puffs_newinfo_setcookie(pni, pn_new);
return 0;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_basic.c,v 1.11 2011/04/04 15:42:42 plunky Exp $ */
/* $NetBSD: t_basic.c,v 1.12 2013/10/19 17:45:00 christos Exp $ */
#include <sys/types.h>
#include <sys/mount.h>
@@ -115,13 +115,11 @@ ATF_TC_HEAD(root_lnk, tc)
ATF_TC_BODY(root_lnk, tc)
{
MAKEOPTS("-r", "lnk " LINKSTR);
struct puffstestargs *pargs;
void *args;
char buf[PATH_MAX];
ssize_t len;
FSTEST_CONSTRUCTOR_FSPRIV(tc, puffs, args, theopts);
pargs = args;
if ((len = rump_sys_readlink(FSTEST_MNTNAME, buf, sizeof(buf)-1)) == -1)
atf_tc_fail_errno("readlink");

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_io.c,v 1.11 2013/06/12 12:08:08 pooka Exp $ */
/* $NetBSD: t_io.c,v 1.12 2013/08/04 11:02:02 pooka Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -168,6 +168,60 @@ shrinkfile(const atf_tc_t *tc, const char *mp)
FSTEST_EXIT();
}
#define TBSIZE 9000
static void
read_after_unlink(const atf_tc_t *tc, const char *mp)
{
char buf[TBSIZE], buf2[TBSIZE];
int fd;
FSTEST_ENTER();
/* create file and put some content into it */
RL(fd = rump_sys_open("file", O_RDWR|O_CREAT, 0666));
memset(buf, 'D', TBSIZE);
ATF_REQUIRE_EQ(rump_sys_write(fd, buf, TBSIZE), TBSIZE);
rump_sys_close(fd);
/* flush buffers from UBC to file system */
ATF_REQUIRE_ERRNO(EBUSY, rump_sys_unmount(mp, 0) == -1);
RL(fd = rump_sys_open("file", O_RDWR));
RL(rump_sys_unlink("file"));
ATF_REQUIRE_EQ(rump_sys_read(fd, buf2, TBSIZE), TBSIZE);
ATF_REQUIRE_EQ(memcmp(buf, buf2, TBSIZE), 0);
rump_sys_close(fd);
FSTEST_EXIT();
}
static void
wrrd_after_unlink(const atf_tc_t *tc, const char *mp)
{
int value = 0x11;
int v2;
int fd;
FSTEST_ENTER();
RL(fd = rump_sys_open("file", O_RDWR|O_CREAT, 0666));
RL(rump_sys_unlink("file"));
RL(rump_sys_pwrite(fd, &value, sizeof(value), 654321));
/*
* We can't easily invalidate the buffer since we hold a
* reference, but try to get them to flush anyway.
*/
RL(rump_sys_fsync(fd));
RL(rump_sys_pread(fd, &v2, sizeof(v2), 654321));
rump_sys_close(fd);
ATF_REQUIRE_EQ(value, v2);
FSTEST_EXIT();
}
ATF_TC_FSAPPLY(holywrite, "create a sparse file and fill hole");
ATF_TC_FSAPPLY(extendfile, "check that extending a file works");
ATF_TC_FSAPPLY(extendfile_append, "check that extending a file works "
@@ -176,6 +230,8 @@ ATF_TC_FSAPPLY(overwrite512, "write a 512 byte file twice");
ATF_TC_FSAPPLY(overwrite64k, "write a 64k byte file twice");
ATF_TC_FSAPPLY(overwrite_trunc, "write 64k + truncate + rewrite");
ATF_TC_FSAPPLY(shrinkfile, "shrink file");
ATF_TC_FSAPPLY(read_after_unlink, "contents can be read off disk after unlink");
ATF_TC_FSAPPLY(wrrd_after_unlink, "file can be written and read after unlink");
ATF_TP_ADD_TCS(tp)
{
@@ -187,6 +243,8 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_FSAPPLY(overwrite64k);
ATF_TP_FSAPPLY(overwrite_trunc);
ATF_TP_FSAPPLY(shrinkfile);
ATF_TP_FSAPPLY(read_after_unlink);
ATF_TP_FSAPPLY(wrrd_after_unlink);
return atf_no_error();
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_vnops.c,v 1.36 2013/07/10 18:55:00 reinoud Exp $ */
/* $NetBSD: t_vnops.c,v 1.38 2013/10/19 17:45:00 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -333,7 +333,7 @@ rename_reg_nodir(const atf_tc_t *tc, const char *mp)
{
bool haslinks;
struct stat sb;
ino_t f1ino, f2ino;
ino_t f1ino;
if (FSTYPE_RUMPFS(tc))
atf_tc_skip("rename not supported by file system");
@@ -366,7 +366,6 @@ rename_reg_nodir(const atf_tc_t *tc, const char *mp)
if (rump_sys_stat("file2", &sb) == -1)
atf_tc_fail_errno("stat");
f2ino = sb.st_ino;
if (rump_sys_rename("file1", "file3") == -1)
atf_tc_fail_errno("rename 1");
@@ -400,6 +399,9 @@ rename_reg_nodir(const atf_tc_t *tc, const char *mp)
ATF_REQUIRE_EQ(sb.st_nlink, 1);
}
ATF_CHECK_ERRNO(EFAULT, rump_sys_rename("file2", NULL) == -1);
ATF_CHECK_ERRNO(EFAULT, rump_sys_rename(NULL, "file2") == -1);
rump_sys_chdir("/");
}

View File

@@ -6,8 +6,7 @@ NOMAN= # defined
TESTSDIR= ${TESTSBASE}/include/sys
#LSC: Unsupported on Minix t_bitops
TESTS_C= t_bootblock t_cdefs t_tree t_types
TESTS_C= t_bitops t_bootblock t_cdefs t_tree t_types
LDADD.t_bitops+= -lm

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_cdefs.c,v 1.2 2012/03/23 23:12:28 matt Exp $ */
/* $NetBSD: t_cdefs.c,v 1.3 2013/09/05 09:01:27 gsutre Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_cdefs.c,v 1.2 2012/03/23 23:12:28 matt Exp $");
__RCSID("$NetBSD: t_cdefs.c,v 1.3 2013/09/05 09:01:27 gsutre Exp $");
#include <atf-c.h>
#include <sys/types.h>
@@ -206,8 +206,8 @@ ATF_TC_BODY(stypefit, tc)
CHECK(signed long long, -1, 0);
CHECK(signed long long, 1, 0);
CHECK(signed long long, 0x7fffffffffffffffLL, 0);
CHECK(signed long long, 0x8000000000000000LL, 0);
CHECK(signed long long, 0xffffffffffffffffLL, 0);
CHECK(signed long long, 0x8000000000000000LL, 1);
CHECK(signed long long, 0xffffffffffffffffLL, 1);
#undef CHECK
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_socket.c,v 1.1 2011/07/07 05:50:27 jruoho Exp $ */
/* $NetBSD: t_socket.c,v 1.3 2013/10/19 17:45:00 christos Exp $ */
#include <sys/types.h>
#include <sys/mount.h>
@@ -83,7 +83,7 @@ ATF_TC_BODY(cmsg_sendfd, tc)
struct cmsghdr *cmp;
struct msghdr msg;
struct sockaddr_un sun;
struct lwp *l1, *l2;
struct lwp *l1;
struct iovec iov;
socklen_t sl;
int s1, s2, sgot;
@@ -109,7 +109,7 @@ ATF_TC_BODY(cmsg_sendfd, tc)
/* create second process for test */
RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
l2 = rump_pub_lwproc_curlwp();
(void)rump_pub_lwproc_curlwp();
/* connect to unix domain socket */
memset(&sun, 0, sizeof(sun));
@@ -179,10 +179,27 @@ ATF_TC_BODY(cmsg_sendfd, tc)
atf_tc_fail("expected \"%s\", got \"%s\"", MAGICSTRING, buf);
}
ATF_TC(sock_cloexec);
ATF_TC_HEAD(sock_cloexec, tc)
{
atf_tc_set_md_var(tc, "descr", "SOCK_CLOEXEC kernel invariant failure");
}
ATF_TC_BODY(sock_cloexec, tc)
{
rump_init();
rump_pub_lwproc_rfork(RUMP_RFFDG);
if (rump_sys_socket(-1, SOCK_CLOEXEC, 0) != -1)
atf_tc_fail("invalid socket parameters unexpectedly worked");
rump_pub_lwproc_releaselwp();
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, cmsg_sendfd);
ATF_TP_ADD_TC(tp, cmsg_sendfd_bounds);
ATF_TP_ADD_TC(tp, sock_cloexec);
return atf_no_error();
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_inttypes.c,v 1.2 2010/07/18 12:16:19 jmmv Exp $ */
/* $NetBSD: t_inttypes.c,v 1.3 2013/10/19 17:44:37 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,34 +37,34 @@ ATF_TC_BODY(int_fmtio, tc)
{
char buf[64];
int8_t i8;
int16_t i16;
int32_t i32;
int64_t i64;
int_least8_t il8;
int_least16_t il16;
int_least32_t il32;
int_least64_t il64;
int_fast8_t if8;
int_fast16_t if16;
int_fast32_t if32;
int_fast64_t if64;
intmax_t im;
intptr_t ip;
uint8_t ui8;
uint16_t ui16;
uint32_t ui32;
uint64_t ui64;
uint_least8_t uil8;
uint_least16_t uil16;
uint_least32_t uil32;
uint_least64_t uil64;
uint_fast8_t uif8;
uint_fast16_t uif16;
uint_fast32_t uif32;
uint_fast64_t uif64;
uintmax_t uim;
uintptr_t uip;
int8_t i8 = 0;
int16_t i16 = 0;
int32_t i32 = 0;
int64_t i64 = 0;
int_least8_t il8 = 0;
int_least16_t il16 = 0;
int_least32_t il32 = 0;
int_least64_t il64 = 0;
int_fast8_t if8 = 0;
int_fast16_t if16 = 0;
int_fast32_t if32 = 0;
int_fast64_t if64 = 0;
intmax_t im = 0;
intptr_t ip = 0;
uint8_t ui8 = 0;
uint16_t ui16 = 0;
uint32_t ui32 = 0;
uint64_t ui64 = 0;
uint_least8_t uil8 = 0;
uint_least16_t uil16 = 0;
uint_least32_t uil32 = 0;
uint_least64_t uil64 = 0;
uint_fast8_t uif8 = 0;
uint_fast16_t uif16 = 0;
uint_fast32_t uif32 = 0;
uint_fast64_t uif64 = 0;
uintmax_t uim = 0;
uintptr_t uip = 0;
#define PRINT(fmt, var) \
snprintf(buf, sizeof(buf), "%" fmt, var)

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_lockf.c,v 1.8 2013/02/20 02:22:48 pgoyette Exp $ */
/* $NetBSD: t_lockf.c,v 1.9 2013/10/19 17:45:00 christos Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ random_uint32(void)
static void
trylocks(int id)
{
int i, ret, fd;
int i, fd;
srand48(getpid());
@@ -99,7 +99,7 @@ trylocks(int id)
}
fl.l_whence = SEEK_SET;
ret = fcntl(fd, F_SETLKW, &fl);
(void)fcntl(fd, F_SETLKW, &fl);
if (usleep(sleeptime) < 0)
err(1, "usleep");

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_sysv.c,v 1.2 2012/11/06 18:31:53 pgoyette Exp $ */
/* $NetBSD: t_sysv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $ */
/*-
* Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -252,11 +252,11 @@ ATF_TC_BODY(msg, tc)
*/
m.mtype = MTYPE_1;
strcpy(m.mtext, m1_str);
ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, sizeof(m), 0) != -1,
"sender: msgsnd 1: %d", errno);
ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN,
0) != -1, "sender: msgsnd 1: %d", errno);
ATF_REQUIRE_MSG(msgrcv(sender_msqid, &m, sizeof(m),
MTYPE_1_ACK, 0) == sizeof(m),
ATF_REQUIRE_MSG(msgrcv(sender_msqid, &m, MESSAGE_TEXT_LEN,
MTYPE_1_ACK, 0) == MESSAGE_TEXT_LEN,
"sender: msgrcv 1 ack: %d", errno);
print_msqid_ds(&m_ds, 0600);
@@ -266,11 +266,11 @@ ATF_TC_BODY(msg, tc)
*/
m.mtype = MTYPE_2;
strcpy(m.mtext, m2_str);
ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, sizeof(m), 0) != -1,
ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN, 0) != -1,
"sender: msgsnd 2: %d", errno);
ATF_REQUIRE_MSG(msgrcv(sender_msqid, &m, sizeof(m),
MTYPE_2_ACK, 0) == sizeof(m),
ATF_REQUIRE_MSG(msgrcv(sender_msqid, &m, MESSAGE_TEXT_LEN,
MTYPE_2_ACK, 0) == MESSAGE_TEXT_LEN,
"sender: msgrcv 2 ack: %d", errno);
}
@@ -361,7 +361,7 @@ receiver()
/*
* Receive the first message, print it, and send an ACK.
*/
if (msgrcv(msqid, &m, sizeof(m), MTYPE_1, 0) != sizeof(m))
if (msgrcv(msqid, &m, MESSAGE_TEXT_LEN, MTYPE_1, 0) != MESSAGE_TEXT_LEN)
err(1, "receiver: msgrcv 1");
printf("%s\n", m.mtext);
@@ -370,14 +370,14 @@ receiver()
m.mtype = MTYPE_1_ACK;
if (msgsnd(msqid, &m, sizeof(m), 0) == -1)
if (msgsnd(msqid, &m, MESSAGE_TEXT_LEN, 0) == -1)
err(1, "receiver: msgsnd ack 1");
/*
* Receive the second message, print it, and send an ACK.
*/
if (msgrcv(msqid, &m, sizeof(m), MTYPE_2, 0) != sizeof(m))
if (msgrcv(msqid, &m, MESSAGE_TEXT_LEN, MTYPE_2, 0) != MESSAGE_TEXT_LEN)
err(1, "receiver: msgrcv 2");
printf("%s\n", m.mtext);
@@ -386,7 +386,7 @@ receiver()
m.mtype = MTYPE_2_ACK;
if (msgsnd(msqid, &m, sizeof(m), 0) == -1)
if (msgsnd(msqid, &m, MESSAGE_TEXT_LEN, 0) == -1)
err(1, "receiver: msgsnd ack 2");
}

View File

@@ -3,7 +3,7 @@
.include <bsd.own.mk>
# LSC: Only relevant libraries
TESTS_SUBDIRS= csu libc libcrypt libcurses \
TESTS_SUBDIRS= csu libc libcrypt libcurses libexecinfo \
libm libprop \
libutil

View File

@@ -0,0 +1,12 @@
/* $NetBSD: h_initfini_align.S,v 1.1 2013/11/15 11:48:30 skrll Exp $ */
#include <machine/asm.h>
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/11/15 11:48:30 skrll Exp $")
LEAF_ENTRY(check_stack_alignment)
extru %sp,31,6,%ret0
comiclr,<> 0, %ret0, %ret0
ldi 1,%ret0
bv,n %r0(%r2)
EXIT(check_stack_alignment)

View File

@@ -0,0 +1,11 @@
/* $NetBSD: h_initfini_align.S,v 1.1 2013/11/15 20:00:20 martin Exp $ */
#include <machine/asm.h>
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/11/15 20:00:20 martin Exp $")
_ENTRY(check_stack_alignment)
add %sp, BIAS, %o1
and %o1, 15, %o2
retl
not %o2, %o0

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,10 @@ SUBDIR+= tls_dso .WAIT
# LSC: Unsupported on MINIX
# c063 gen rpc setjmp
# sys tls ttyio
TESTS_SUBDIRS+= db hash inet locale net regex stdlib
# LSC: db hangs, so compiled, installed, but not added to the testsuite by
# default
SUBDIR+= db
TESTS_SUBDIRS+= hash inet locale net regex stdlib
TESTS_SUBDIRS+= stdio string termios time
.if !defined(__MINIX)

View File

@@ -1,4 +1,4 @@
# $NetBSD: t_db.sh,v 1.3 2011/12/10 17:50:19 skrll Exp $
# $NetBSD: t_db.sh,v 1.4 2013/07/29 10:43:15 skrll Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -801,7 +801,7 @@ ffactor=$ffactor,nelem=25000,cachesize=65536" hash in
atf_test_case bsize_ffactor
bsize_ffactor_head()
{
atf_set "timeout" "360"
atf_set "timeout" "480"
atf_set "descr" "Checks hash database with various" \
"bucketsizes and fill factors"
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_dir.c,v 1.5 2012/03/18 07:14:08 jruoho Exp $ */
/* $NetBSD: t_dir.c,v 1.6 2013/10/19 17:45:00 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -122,7 +122,6 @@ ATF_TC_HEAD(telldir_leak, tc)
ATF_TC_BODY(telldir_leak, tc)
{
DIR *dp;
long loc;
char *memused;
int i;
int oktouse = 4096;
@@ -131,7 +130,7 @@ ATF_TC_BODY(telldir_leak, tc)
if (dp == NULL)
atf_tc_fail("Could not open current directory");
loc = telldir(dp);
(void)telldir(dp);
memused = sbrk(0);
closedir(dp);
@@ -140,7 +139,7 @@ ATF_TC_BODY(telldir_leak, tc)
if (dp == NULL)
atf_tc_fail("Could not open current directory");
loc = telldir(dp);
(void)telldir(dp);
closedir(dp);
if ((char *)sbrk(0) - memused > oktouse) {

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_isnan.c,v 1.1 2011/09/19 05:25:50 jruoho Exp $ */
/* $NetBSD: t_isnan.c,v 1.3 2013/09/16 15:33:24 martin Exp $ */
/*
* This file is in the Public Domain.
@@ -21,9 +21,13 @@ ATF_TC_HEAD(isnan_basic, tc)
ATF_TC_BODY(isnan_basic, tc)
{
#ifdef NAN
/* NAN is meant to be a (float)NaN. */
ATF_CHECK(isnan(NAN) != 0);
ATF_CHECK(isnan((double)NAN) != 0);
#else
atf_tc_skip("Test not applicable");
#endif
}
ATF_TC(isinf_basic);
@@ -51,7 +55,7 @@ ATF_TP_ADD_TCS(tp)
arch = atf_config_get("atf_arch");
if (strcmp("vax", arch) == 0 || strcmp("m68000", arch) == 0)
if (strcmp("m68000", arch) == 0)
atf_tc_skip("Test not applicable on %s", arch);
else {
ATF_TP_ADD_TC(tp, isnan_basic);

View File

@@ -6,8 +6,7 @@ TESTSDIR= ${TESTSBASE}/lib/libc/locale
TESTS_C+= t_mbrtowc
TESTS_C+= t_mbstowcs
# LSC: Unsupported on MINIX
#TESTS_C+= t_mbsnrtowcs
TESTS_C+= t_mbsnrtowcs
TESTS_C+= t_mbtowc
TESTS_C+= t_wcscspn
TESTS_C+= t_wcspbrk

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.7 2012/09/15 16:22:58 plunky Exp $
# $NetBSD: Makefile,v 1.8 2013/08/16 15:29:45 christos Exp $
.include <bsd.own.mk>
@@ -6,6 +6,7 @@ MKMAN= no
#LSC: Unsupported on MINIX
#TESTS_SUBDIRS+= getaddrinfo
FILES+=hosts
TESTSDIR= ${TESTSBASE}/lib/libc/net
@@ -21,6 +22,7 @@ aton_ether_subr.c: gen_ether_subr ${NETBSDSRCDIR}/sys/net/if_ethersubr.c
TESTS_SH+= t_nsdispatch
TESTS_SH+= t_protoent
TESTS_SH+= t_servent
TESTS_SH+= t_hostent
BINDIR= ${TESTSDIR}
@@ -28,6 +30,13 @@ BINDIR= ${TESTSDIR}
#PROGS+= h_nsd_recurse
PROGS+= h_protoent
PROGS+= h_servent
PROGS+= h_hostent
CPPFLAGS.h_hostent.c += -I${NETBSDSRCDIR}/lib/libc/net
# For easy debugging, without installing libc
#.PATH.c:${NETBSDSRCDIR}/lib/libc/net
#SRCS.h_hostent = h_hostent.c gethnamaddr.c
#DBG=-g3
LDADD.h_nsd_recurse+= -lpthread

View File

@@ -0,0 +1,190 @@
/* $NetBSD: h_hostent.c,v 1.1 2013/08/16 15:29:45 christos Exp $ */
/*-
* Copyright (c) 2013 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: h_hostent.c,v 1.1 2013/08/16 15:29:45 christos Exp $");
#include <stdio.h>
#include <string.h>
#include <nsswitch.h>
#include <netdb.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <err.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include "hostent.h"
static void
phostent(const struct hostent *h)
{
size_t i;
char buf[1024];
const int af = h->h_length == NS_INADDRSZ ? AF_INET : AF_INET6;
printf("name=%s, length=%d, addrtype=%d, aliases=[",
h->h_name, h->h_length, h->h_addrtype);
for (i = 0; h->h_aliases[i]; i++)
printf("%s%s", i == 0 ? "" : " ", h->h_aliases[i]);
printf("] addr_list=[");
for (i = 0; h->h_addr_list[i]; i++)
printf("%s%s", i == 0 ? "" : " ", inet_ntop(af,
h->h_addr_list[i], buf, (socklen_t)sizeof(buf)));
printf("]\n");
}
static void
usage(void)
{
(void)fprintf(stderr, "Usage: %s [-f <hostsfile>] "
"[-t <any|dns|nis|files>] "
"[-46a] <name|address>\n", getprogname());
exit(EXIT_FAILURE);
}
static void
getby(int (*f)(void *, void *, va_list), struct getnamaddr *info, ...)
{
va_list ap;
int e;
va_start(ap, info);
e = (*f)(info, NULL, ap);
va_end(ap);
switch (e) {
case NS_SUCCESS:
phostent(info->hp);
break;
default:
printf("error %d\n", e);
break;
}
}
static void
geta(struct hostent *hp) {
if (hp == NULL)
printf("error %d\n", h_errno);
else
phostent(hp);
}
int
main(int argc, char *argv[])
{
int (*f)(void *, void *, va_list) = NULL;
const char *type = "any";
int c, af, e, byaddr, len;
struct hostent hent;
struct getnamaddr info;
char buf[4096];
af = AF_INET;
byaddr = 0;
len = 0;
info.hp = &hent;
info.buf = buf;
info.buflen = sizeof(buf);
info.he = &e;
while ((c = getopt(argc, argv, "46af:t:")) != -1) {
switch (c) {
case '4':
af = AF_INET;
break;
case '6':
af = AF_INET6;
break;
case 'a':
byaddr++;
break;
case 't':
type = optarg;
break;
case 'f':
_hf_sethostsfile(optarg);
break;
default:
usage();
}
}
argc -= optind;
argv += optind;
if (argc != 1)
usage();
switch (*type) {
case 'a':
break;
case 'd':
f = byaddr ? _dns_gethtbyaddr : _dns_gethtbyname;
break;
#ifdef YP
case 'n':
f = byaddr ? _yp_gethtbyaddr : _yp_gethtbyname;
break;
#endif
case 'f':
f = byaddr ? _hf_gethtbyaddr : _hf_gethtbyname;
break;
default:
errx(EXIT_FAILURE, "Unknown db type `%s'", type);
}
if (byaddr) {
struct in6_addr addr;
af = strchr(*argv, ':') ? AF_INET6 : AF_INET;
len = af == AF_INET ? NS_INADDRSZ : NS_IN6ADDRSZ;
if (inet_pton(af, *argv, &addr) == -1)
err(EXIT_FAILURE, "Can't parse `%s'", *argv);
if (*type == 'a')
geta(gethostbyaddr((const char *)&addr, len, af));
else
getby(f, &info, &addr, len, af);
} else {
if (*type == 'a')
geta(gethostbyname2(*argv, af));
else
getby(f, &info, *argv, len, af);
}
return 0;
}

11
tests/lib/libc/net/hosts Normal file
View File

@@ -0,0 +1,11 @@
# $NetBSD: hosts,v 1.1 2013/08/16 15:29:45 christos Exp $
#
# Host Database
# This file should contain the addresses and aliases
# for local hosts that share this file.
# It is used only for "ifconfig" and other operations
# before the nameserver is started.
#
#
::1 localhost localhost. localhost.localdomain.
127.0.0.1 localhost localhost. localhost.localdomain.

View File

@@ -0,0 +1,188 @@
# $NetBSD: t_hostent.sh,v 1.2 2013/10/20 17:22:49 christos Exp $
#
# Copyright (c) 2008 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.
#
n6="sixthavenue.astron.com"
a6="2620:106:3003:1f00:2e0:81ff:fe2f:e5d7"
ans6="name=$n6, length=16, addrtype=24, aliases=[] addr_list=[$a6]\n"
n4="sixthavenue.astron.com"
a4="38.117.134.6"
ans4="name=$n4, length=4, addrtype=2, aliases=[] addr_list=[$a4]\n"
l6="localhost"
al6="::1"
loc6="name=$l6, length=16, addrtype=24, aliases=[localhost. localhost.localdomain.] addr_list=[$al6]\n"
l4="localhost"
al4="127.0.0.1"
loc4="name=$l4, length=4, addrtype=2, aliases=[localhost. localhost.localdomain.] addr_list=[$al4]\n"
atf_test_case gethostbyname4
gethostbyname4_head()
{
atf_set "descr" "Checks gethostbyname2(3) for AF_INET (auto, as determined by nsswitch.conf(5)"
}
gethostbyname4_body()
{
atf_check -o inline:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -4 $n4"
}
atf_test_case gethostbyname6
gethostbyname6_head()
{
atf_set "descr" "Checks gethostbyname2(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)"
}
gethostbyname6_body()
{
atf_check -o inline:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -6 $n6"
}
atf_test_case gethostbyaddr4
gethostbyaddr4_head()
{
atf_set "descr" "Checks gethostbyaddr(3) for AF_INET (auto, as determined by nsswitch.conf(5)"
}
gethostbyaddr4_body()
{
atf_check -o inline:"$ans4" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a4"
}
atf_test_case gethostbyaddr6
gethostbyaddr6_head()
{
atf_set "descr" "Checks gethostbyaddr(3) for AF_INET6 (auto, as determined by nsswitch.conf(5)"
}
gethostbyaddr6_body()
{
atf_check -o inline:"$ans6" -x "$(atf_get_srcdir)/h_hostent -t auto -a $a6"
}
atf_test_case hostsbynamelookup4
hostsbynamelookup4_head()
{
atf_set "descr" "Checks /etc/hosts name lookup for AF_INET"
}
hostsbynamelookup4_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$loc4" -x "$dir/h_hostent -f $dir/hosts -t file -4 $l4"
}
atf_test_case hostsbynamelookup6
hostsbynamelookup6_head()
{
atf_set "descr" "Checks /etc/hosts name lookup for AF_INET6"
}
hostsbynamelookup6_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$loc6" -x "$dir/h_hostent -f $dir/hosts -t file -6 $l6"
}
atf_test_case hostsbyaddrlookup4
hostsbyaddrlookup4_head()
{
atf_set "descr" "Checks /etc/hosts address lookup for AF_INET"
}
hostsbyaddrlookup4_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$loc4" -x "$dir/h_hostent -f $dir/hosts -t file -4 -a $al4"
}
atf_test_case hostsbyaddrlookup6
hostsbyaddrlookup6_head()
{
atf_set "descr" "Checks /etc/hosts address lookup for AF_INET6"
}
hostsbyaddrlookup6_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$loc6" -x "$dir/h_hostent -f $dir/hosts -t file -6 -a $al6"
}
atf_test_case dnsbynamelookup4
dnsbynamelookup4_head()
{
atf_set "descr" "Checks DNS name lookup for AF_INET"
}
dnsbynamelookup4_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$ans4" -x "$dir/h_hostent -t dns -4 $n4"
}
atf_test_case dnsbynamelookup6
dnsbynamelookup6_head()
{
atf_set "descr" "Checks DNS name lookup for AF_INET6"
}
dnsbynamelookup6_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$ans6" -x "$dir/h_hostent -t dns -6 $n6"
}
atf_test_case dnsbyaddrlookup4
dnsbyaddrlookup4_head()
{
atf_set "descr" "Checks DNS address lookup for AF_INET"
}
dnsbyaddrlookup4_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$ans4" -x "$dir/h_hostent -t dns -4 -a $a4"
}
atf_test_case dnsbyaddrlookup6
dnsbyaddrlookup6_head()
{
atf_set "descr" "Checks dns address lookup for AF_INET6"
}
dnsbyaddrlookup6_body()
{
local dir=$(atf_get_srcdir)
atf_check -o inline:"$ans6" -x "$dir/h_hostent -t dns -6 -a $a6"
}
atf_init_test_cases()
{
atf_add_test_case gethostbyname4
atf_add_test_case gethostbyname6
atf_add_test_case gethostbyaddr4
atf_add_test_case gethostbyaddr6
atf_add_test_case hostsbynamelookup4
atf_add_test_case hostsbynamelookup6
atf_add_test_case hostsbyaddrlookup4
atf_add_test_case hostsbyaddrlookup6
atf_add_test_case dnsbynamelookup4
atf_add_test_case dnsbynamelookup6
atf_add_test_case dnsbyaddrlookup4
atf_add_test_case dnsbyaddrlookup6
}

View File

@@ -14,7 +14,17 @@ CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION}
TESTS_SH?= t_regex
TESTS_C= t_regex_att
.if !defined(__MINIX)
TESTS_C+= t_exhaust
.else
# this test fails in a way which breaks the test run
# Thre following is normaly done in bsd.test.mk
PROGS+= t_exhaust
BINDIR.t_exhaust= ${TESTSDIR}
LDADD.t_exhaust+= -latf-c
DPADD.t_exhaust+= ${LIBATF_C}
MAN.t_exhaust= # empty
.endif # !defined(__MINIX)
FILESDIR= ${TESTSDIR}/data
FILES+= README

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_fmemopen.c,v 1.3 2011/08/22 00:33:16 dholland Exp $ */
/* $NetBSD: t_fmemopen.c,v 1.4 2013/10/19 17:45:00 christos Exp $ */
/*-
* Copyright (c)2010 Takehiko NOZAKI,
@@ -463,13 +463,12 @@ ATF_TC_HEAD(test10, tc)
ATF_TC_BODY(test10, tc)
{
struct testcase *t;
off_t len, i;
off_t i;
const char **p;
char buf[BUFSIZ];
FILE *fp;
for (t = &testcases[0]; t->s != NULL; ++t) {
len = (off_t)strnlen(t->s, t->n);
for (p = &mode_rw[0]; *p != NULL; ++p) {
memcpy(&buf[0], t->s, t->n);
@@ -630,15 +629,13 @@ ATF_TC_HEAD(test13, tc)
ATF_TC_BODY(test13, tc)
{
struct testcase *t;
off_t len, rest, i;
off_t i;
const char **p;
char buf[BUFSIZ];
FILE *fp;
/* test fmemopen_seek(SEEK_END) */
for (t = &testcases[0]; t->s != NULL; ++t) {
len = (off_t)strnlen(t->s, t->n);
rest = t->n - len;
for (p = &mode_w[0]; *p != NULL; ++p) {
memcpy(buf, t->s, t->n);
@@ -938,14 +935,12 @@ ATF_TC_HEAD(test19, tc)
ATF_TC_BODY(test19, tc)
{
struct testcase *t;
size_t len;
int i;
const char **p;
char buf[BUFSIZ];
FILE *fp;
for (t = &testcases[0]; t->s != NULL; ++t) {
len = strnlen(t->s, t->n);
for (p = &mode_rw2[0]; *p != NULL; ++p) {
memcpy(&buf[0], t->s, t->n);
@@ -998,13 +993,11 @@ ATF_TC_HEAD(test20, tc)
ATF_TC_BODY(test20, tc)
{
struct testcase *t;
size_t len;
const char **p;
char buf[BUFSIZ];
FILE *fp;
for (t = &testcases[0]; t->s != NULL; ++t) {
len = strnlen(t->s, t->n);
for (p = &mode_rw2[0]; *p != NULL; ++p) {
memcpy(&buf[0], t->s, t->n);

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.32 2013/03/08 17:01:54 martin Exp $
# $NetBSD: Makefile,v 1.34 2013/07/24 11:45:48 skrll Exp $
MKMAN= no

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_msgrcv.c,v 1.2 2011/11/11 05:06:01 jruoho Exp $ */
/* $NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll 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.2 2011/11/11 05:06:01 jruoho Exp $");
__RCSID("$NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $");
#include <sys/msg.h>
#include <sys/stat.h>
@@ -51,10 +51,11 @@ __RCSID("$NetBSD: t_msgrcv.c,v 1.2 2011/11/11 05:06:01 jruoho Exp $");
#define MSG_MTYPE_1 0x41
#define MSG_MTYPE_2 0x42
#define MSG_MTYPE_3 0x43
#define MSG_LEN 3
struct msg {
long mtype;
char buf[3];
char buf[MSG_LEN];
};
static void clean(void);
@@ -83,8 +84,8 @@ ATF_TC_BODY(msgrcv_basic, tc)
id = msgget(MSG_KEY, IPC_CREAT | 0600);
ATF_REQUIRE(id != -1);
(void)msgsnd(id, &msg1, sizeof(struct msg), IPC_NOWAIT);
(void)msgrcv(id, &msg2, sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT);
(void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
(void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT);
ATF_CHECK(msg1.buf[0] == msg2.buf[0]);
ATF_CHECK(msg1.buf[1] == msg2.buf[1]);
@@ -118,7 +119,7 @@ ATF_TC_BODY(msgrcv_block, tc)
if (pid == 0) {
if (msgrcv(id, &msg, sizeof(struct msg), MSG_MTYPE_1, 0) < 0)
if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1, 0) < 0)
_exit(EXIT_FAILURE);
_exit(EXIT_SUCCESS);
@@ -129,7 +130,7 @@ ATF_TC_BODY(msgrcv_block, tc)
* and hence kill(2) should fail with ESRCH.
*/
(void)sleep(1);
(void)msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT);
(void)msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT);
(void)sleep(1);
(void)kill(pid, SIGKILL);
(void)wait(&sta);
@@ -162,31 +163,31 @@ ATF_TC_BODY(msgrcv_err, tc)
errno = 0;
ATF_REQUIRE_ERRNO(ENOMSG, msgrcv(id, &msg,
sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT) == -1);
MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
ATF_REQUIRE(msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT) == 0);
ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
errno = 0;
ATF_REQUIRE_ERRNO(EFAULT, msgrcv(id, (void *)-1,
sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT) == -1);
MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
errno = 0;
ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg,
sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT) == -1);
MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
errno = 0;
ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg,
SSIZE_MAX, MSG_MTYPE_1, IPC_NOWAIT) == -1);
ATF_REQUIRE(msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT) == 0);
ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
errno = 0;
ATF_REQUIRE_ERRNO(E2BIG, msgrcv(id, &r,
sizeof(int), MSG_MTYPE_1, IPC_NOWAIT) == -1);
MSG_LEN - 1, MSG_MTYPE_1, IPC_NOWAIT) == -1);
ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
}
@@ -212,14 +213,14 @@ ATF_TC_BODY(msgrcv_mtype, tc)
id = msgget(MSG_KEY, IPC_CREAT | 0600);
ATF_REQUIRE(id != -1);
(void)msgsnd(id, &msg1, sizeof(struct msg), IPC_NOWAIT);
(void)msgrcv(id, &msg2, sizeof(struct msg), MSG_MTYPE_2, IPC_NOWAIT);
(void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
(void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_2, IPC_NOWAIT);
ATF_CHECK(msg1.buf[0] != msg2.buf[0]); /* Different mtype. */
ATF_CHECK(msg1.buf[1] != msg2.buf[1]);
ATF_CHECK(msg1.buf[2] != msg2.buf[2]);
(void)msgrcv(id, &msg2, sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT);
(void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT);
ATF_CHECK(msg1.buf[0] == msg2.buf[0]); /* Same mtype. */
ATF_CHECK(msg1.buf[1] == msg2.buf[1]);
@@ -253,8 +254,7 @@ ATF_TC_BODY(msgrcv_nonblock, tc)
for (i = 0; i < n; i++) {
ATF_REQUIRE(msgsnd(id, &msg,
sizeof(struct msg), IPC_NOWAIT) == 0);
ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
}
pid = fork();
@@ -264,8 +264,8 @@ ATF_TC_BODY(msgrcv_nonblock, tc)
while (i != 0) {
if (msgrcv(id, &msg, sizeof(struct msg),
MSG_MTYPE_1, IPC_NOWAIT) == -1)
if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1,
IPC_NOWAIT) == -1)
_exit(EXIT_FAILURE);
i--;
@@ -300,9 +300,10 @@ ATF_TC_HEAD(msgrcv_truncate, tc)
ATF_TC_BODY(msgrcv_truncate, tc)
{
#define MSG_SMALLLEN 2
struct msgsmall {
long mtype;
char buf[2];
char buf[MSG_SMALLLEN];
};
struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
@@ -312,8 +313,8 @@ ATF_TC_BODY(msgrcv_truncate, tc)
id = msgget(MSG_KEY, IPC_CREAT | 0600);
ATF_REQUIRE(id != -1);
(void)msgsnd(id, &msg1, sizeof(struct msg), IPC_NOWAIT);
(void)msgrcv(id, &msg2, sizeof(struct msgsmall),
(void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
(void)msgrcv(id, &msg2, MSG_SMALLLEN,
MSG_MTYPE_1, IPC_NOWAIT | MSG_NOERROR);
ATF_CHECK(msg1.buf[0] == msg2.buf[0]);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: h_tls_dlopen.c,v 1.4 2012/01/17 20:34:57 joerg Exp $ */
/* $NetBSD: h_tls_dlopen.c,v 1.5 2013/10/21 19:14:16 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: h_tls_dlopen.c,v 1.4 2012/01/17 20:34:57 joerg Exp $");
__RCSID("$NetBSD: h_tls_dlopen.c,v 1.5 2013/10/21 19:14:16 joerg Exp $");
#include <atf-c.h>
#include <unistd.h>
@@ -45,6 +45,7 @@ __RCSID("$NetBSD: h_tls_dlopen.c,v 1.4 2012/01/17 20:34:57 joerg Exp $");
extern __thread int var1;
extern __thread int var2;
extern __thread int *var3;
__thread int var5 = 1;
static __thread pid_t (*local_var)(void) = getpid;
void testf_dso_helper(int x, int y);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: h_tls_dynamic.c,v 1.3 2012/01/17 20:34:57 joerg Exp $ */
/* $NetBSD: h_tls_dynamic.c,v 1.5 2013/10/21 19:11:17 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: h_tls_dynamic.c,v 1.3 2012/01/17 20:34:57 joerg Exp $");
__RCSID("$NetBSD: h_tls_dynamic.c,v 1.5 2013/10/21 19:11:17 joerg Exp $");
#include <unistd.h>
#include <sys/tls.h>

View File

@@ -26,5 +26,10 @@ realall: ${TERMINFO_DB}.cdb
${TERMINFO_DB}.cdb: ${TOOL_TIC} ${TEST_TERMINFO}
${TOOL_TIC} -o ${.TARGET} ${.CURDIR}/${TEST_TERMINFO}
.if defined(__MINIX) && ${USETOOLS:Uno} != "yes"
tic:
true
.endif # defined(__MINIX) && ${USETOOLS:Uno} == "no"
.include <bsd.test.mk>
#.include <bsd.subdir.mk>

View File

@@ -1 +1 @@
revabcdesgr0
revabcdehomesgr0

View File

@@ -1,5 +1,5 @@
%{
/* $NetBSD: testlang_conf.l,v 1.6 2011/10/07 13:39:33 joerg Exp $ */
/* $NetBSD: testlang_conf.l,v 1.7 2013/11/21 11:06:04 blymn Exp $ */
/*-
* Copyright 2009 Brett Lymn <blymn@NetBSD.org>
@@ -103,6 +103,12 @@ dequote(const char *s, size_t *len)
p++;
break;
case 'r':
/* carriage return */
*q++ = '\r';
p++;
break;
case 't':
/* tab */
*q++ = '\t';

View File

@@ -193,6 +193,7 @@ are:
\e escape
\n new line
\r carriage return
\t tab
\\ \ character
\nnn Where nnn is three octal digits, the character

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.3 2013/07/04 23:53:13 joerg Exp $
# $NetBSD: Makefile,v 1.4 2013/07/21 15:29:04 tron Exp $
.include <bsd.own.mk>
@@ -9,4 +9,6 @@ TESTS_C+= t_backtrace
LDADD+= -lexecinfo -lelf
DPADD+= ${LIBEXECINFO} ${LIBELF}
COPTS.t_backtrace.c= -Wno-stack-protector
.include <bsd.test.mk>

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_backtrace.c,v 1.8 2013/07/05 09:55:39 joerg Exp $ */
/* $NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_backtrace.c,v 1.8 2013/07/05 09:55:39 joerg Exp $");
__RCSID("$NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $");
#include <atf-c.h>
#include <atf-c/config.h>
@@ -42,9 +42,14 @@ __RCSID("$NetBSD: t_backtrace.c,v 1.8 2013/07/05 09:55:39 joerg Exp $");
#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
#endif
void myfunc3(size_t ncalls);
void myfunc2(size_t ncalls);
void myfunc1(size_t origcalls, volatile size_t ncalls);
void myfunc(size_t ncalls);
volatile int prevent_inline;
static void
void
myfunc3(size_t ncalls)
{
static const char *top[] = { "myfunc", "atfu_backtrace_fmt_basic_body",
@@ -90,7 +95,7 @@ myfunc3(size_t ncalls)
vfork();
}
static void
void
myfunc2(size_t ncalls)
{
myfunc3(ncalls);
@@ -99,7 +104,7 @@ myfunc2(size_t ncalls)
vfork();
}
static void
void
myfunc1(size_t origcalls, volatile size_t ncalls)
{
if (ncalls > 1)
@@ -111,7 +116,7 @@ myfunc1(size_t origcalls, volatile size_t ncalls)
vfork();
}
static void
void
myfunc(size_t ncalls)
{
myfunc1(ncalls, ncalls);
@@ -128,13 +133,10 @@ ATF_TC_HEAD(backtrace_fmt_basic, tc)
ATF_TC_BODY(backtrace_fmt_basic, tc)
{
const char *arch = atf_config_get("atf_arch");
if (strcmp(arch, "x86_64") != 0)
atf_tc_skip("PR toolchain/46490: libexecinfo only"
" works on amd64 currently");
myfunc(12);
if (prevent_inline)
vfork();
}
ATF_TP_ADD_TCS(tp)

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.18 2012/04/13 12:31:19 njoly Exp $
# $NetBSD: Makefile,v 1.20 2013/11/12 16:48:39 joerg Exp $
.include <bsd.own.mk>
@@ -13,14 +13,14 @@ TESTS_C+= t_cos
TESTS_C+= t_cosh
TESTS_C+= t_erf
TESTS_C+= t_exp
TESTS_C+= t_fmod
TESTS_C+= t_infinity
TESTS_C+= t_ldexp
TESTS_C+= t_log
TESTS_C+= t_pow
TESTS_C+= t_precision
TESTS_C+= t_round
.if !defined(__MINIX)
TESTS_C+= t_scalbn
.endif # !defined(__MINIX)
TESTS_C+= t_sin
TESTS_C+= t_sinh
TESTS_C+= t_sqrt

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_cbrt.c,v 1.1 2011/10/16 08:25:40 jruoho Exp $ */
/* $NetBSD: t_cbrt.c,v 1.2 2013/11/19 19:24:33 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_cbrt.c,v 1.1 2011/10/16 08:25:40 jruoho Exp $");
__RCSID("$NetBSD: t_cbrt.c,v 1.2 2013/11/19 19:24:33 joerg Exp $");
#include <atf-c.h>
#include <math.h>
@@ -261,6 +261,119 @@ ATF_TC_BODY(cbrtf_zero_pos, tc)
#endif
}
/*
* cbrtl(3)
*/
ATF_TC(cbrtl_nan);
ATF_TC_HEAD(cbrtl_nan, tc)
{
atf_tc_set_md_var(tc, "descr", "Test cbrtl(NaN) == NaN");
}
ATF_TC_BODY(cbrtl_nan, tc)
{
#ifndef __vax__
const long double x = 0.0L / 0.0L;
ATF_CHECK(isnan(x) != 0);
ATF_CHECK(isnan(cbrtl(x)) != 0);
#endif
}
ATF_TC(cbrtl_powl);
ATF_TC_HEAD(cbrtl_powl, tc)
{
atf_tc_set_md_var(tc, "descr", "Test cbrtl(3) vs. powl(3)");
}
ATF_TC_BODY(cbrtl_powl, tc)
{
#ifndef __vax__
const long double x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, 9999.0 };
const long double eps = 1.0e-15;
long double y, z;
size_t i;
for (i = 0; i < __arraycount(x); i++) {
y = cbrtl(x[i]);
z = powl(x[i], 1.0 / 3.0);
if (fabsl(y - z) > eps * fabsl(1 + x[i]))
atf_tc_fail_nonfatal("cbrtl(%0.03Lf) != "
"powl(%0.03Lf, 1/3)\n", x[i], x[i]);
}
#endif
}
ATF_TC(cbrtl_inf_neg);
ATF_TC_HEAD(cbrtl_inf_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test cbrtl(-Inf) == -Inf");
}
ATF_TC_BODY(cbrtl_inf_neg, tc)
{
#ifndef __vax__
const long double x = -1.0L / 0.0L;
long double y = cbrtl(x);
ATF_CHECK(isinf(y) != 0);
ATF_CHECK(signbit(y) != 0);
#endif
}
ATF_TC(cbrtl_inf_pos);
ATF_TC_HEAD(cbrtl_inf_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test cbrtl(+Inf) == +Inf");
}
ATF_TC_BODY(cbrtl_inf_pos, tc)
{
#ifndef __vax__
const long double x = 1.0L / 0.0L;
long double y = cbrtl(x);
ATF_CHECK(isinf(y) != 0);
ATF_CHECK(signbit(y) == 0);
#endif
}
ATF_TC(cbrtl_zero_neg);
ATF_TC_HEAD(cbrtl_zero_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test cbrtl(-0.0) == -0.0");
}
ATF_TC_BODY(cbrtl_zero_neg, tc)
{
#ifndef __vax__
const long double x = -0.0L;
long double y = cbrtl(x);
if (fabsl(y) > 0.0 || signbit(y) == 0)
atf_tc_fail_nonfatal("cbrtl(-0.0) != -0.0");
#endif
}
ATF_TC(cbrtl_zero_pos);
ATF_TC_HEAD(cbrtl_zero_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test cbrtl(+0.0) == +0.0");
}
ATF_TC_BODY(cbrtl_zero_pos, tc)
{
#ifndef __vax__
const long double x = 0.0L;
long double y = cbrtl(x);
if (fabsl(y) > 0.0 || signbit(y) != 0)
atf_tc_fail_nonfatal("cbrtl(+0.0) != +0.0");
#endif
}
ATF_TP_ADD_TCS(tp)
{
@@ -278,5 +391,12 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, cbrtf_zero_neg);
ATF_TP_ADD_TC(tp, cbrtf_zero_pos);
ATF_TP_ADD_TC(tp, cbrtl_nan);
ATF_TP_ADD_TC(tp, cbrtl_powl);
ATF_TP_ADD_TC(tp, cbrtl_inf_neg);
ATF_TP_ADD_TC(tp, cbrtl_inf_pos);
ATF_TP_ADD_TC(tp, cbrtl_zero_neg);
ATF_TP_ADD_TC(tp, cbrtl_zero_pos);
return atf_no_error();
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_ceil.c,v 1.7 2011/09/17 12:12:19 jruoho Exp $ */
/* $NetBSD: t_ceil.c,v 1.9 2013/11/13 12:58:11 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_ceil.c,v 1.7 2011/09/17 12:12:19 jruoho Exp $");
__RCSID("$NetBSD: t_ceil.c,v 1.9 2013/11/13 12:58:11 joerg Exp $");
#include <atf-c.h>
#include <math.h>
@@ -244,6 +244,107 @@ ATF_TC_BODY(ceilf_zero_pos, tc)
#endif
}
/*
* ceill(3)
*/
ATF_TC(ceill_basic);
ATF_TC_HEAD(ceill_basic, tc)
{
atf_tc_set_md_var(tc, "descr", "A basic test of ceill(3)");
}
ATF_TC_BODY(ceill_basic, tc)
{
const long double x = 0.9999999;
const long double y = 0.0000001;
ATF_CHECK(fabsl(ceill(x) - 1) < SMALL_NUM);
ATF_CHECK(fabsl(ceill(y) - 1) < SMALL_NUM);
}
ATF_TC(ceill_nan);
ATF_TC_HEAD(ceill_nan, tc)
{
atf_tc_set_md_var(tc, "descr", "Test ceill(NaN) == NaN");
}
ATF_TC_BODY(ceill_nan, tc)
{
#ifndef __vax__
const long double x = 0.0L / 0.0L;
ATF_CHECK(isnan(ceill(x)) != 0);
#endif
}
ATF_TC(ceill_inf_neg);
ATF_TC_HEAD(ceill_inf_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test ceill(-Inf) == -Inf");
}
ATF_TC_BODY(ceill_inf_neg, tc)
{
#ifndef __vax__
const long double x = -1.0L / 0.0L;
long double y = ceill(x);
if (isinf(y) == 0 || signbit(y) == 0)
atf_tc_fail_nonfatal("ceill(-Inf) != -Inf");
#endif
}
ATF_TC(ceill_inf_pos);
ATF_TC_HEAD(ceill_inf_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test ceill(+Inf) == +Inf");
}
ATF_TC_BODY(ceill_inf_pos, tc)
{
#ifndef __vax__
const long double x = 1.0L / 0.0L;
long double y = ceill(x);
if (isinf(y) == 0 || signbit(y) != 0)
atf_tc_fail_nonfatal("ceill(+Inf) != +Inf");
#endif
}
ATF_TC(ceill_zero_neg);
ATF_TC_HEAD(ceill_zero_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test ceill(-0.0) == -0.0");
}
ATF_TC_BODY(ceill_zero_neg, tc)
{
#ifndef __vax__
const long double x = -0.0L;
long double y = ceill(x);
if (fabsl(y) > 0.0 || signbit(y) == 0)
atf_tc_fail_nonfatal("ceill(-0.0) != -0.0");
#endif
}
ATF_TC(ceill_zero_pos);
ATF_TC_HEAD(ceill_zero_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test ceill(+0.0) == +0.0");
}
ATF_TC_BODY(ceill_zero_pos, tc)
{
#ifndef __vax__
const long double x = 0.0L;
long double y = ceill(x);
if (fabsl(y) > 0.0 || signbit(y) != 0)
atf_tc_fail_nonfatal("ceill(+0.0) != +0.0");
#endif
}
/*
* floor(3)
*/
@@ -446,6 +547,410 @@ ATF_TC_BODY(floorf_zero_pos, tc)
#endif
}
/*
* floorl(3)
*/
ATF_TC(floorl_basic);
ATF_TC_HEAD(floorl_basic, tc)
{
atf_tc_set_md_var(tc, "descr", "A basic test of floorl(3)");
}
ATF_TC_BODY(floorl_basic, tc)
{
const long double x = 0.9999999;
const long double y = 0.0000001;
ATF_CHECK(floorl(x) < SMALL_NUM);
ATF_CHECK(floorl(y) < SMALL_NUM);
}
ATF_TC(floorl_nan);
ATF_TC_HEAD(floorl_nan, tc)
{
atf_tc_set_md_var(tc, "descr", "Test floorl(NaN) == NaN");
}
ATF_TC_BODY(floorl_nan, tc)
{
#ifndef __vax__
const long double x = 0.0L / 0.0L;
ATF_CHECK(isnan(floorl(x)) != 0);
#endif
}
ATF_TC(floorl_inf_neg);
ATF_TC_HEAD(floorl_inf_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test floorl(-Inf) == -Inf");
}
ATF_TC_BODY(floorl_inf_neg, tc)
{
#ifndef __vax__
const long double x = -1.0L / 0.0L;
long double y = floorl(x);
if (isinf(y) == 0 || signbit(y) == 0)
atf_tc_fail_nonfatal("floorl(-Inf) != -Inf");
#endif
}
ATF_TC(floorl_inf_pos);
ATF_TC_HEAD(floorl_inf_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test floorl(+Inf) == +Inf");
}
ATF_TC_BODY(floorl_inf_pos, tc)
{
#ifndef __vax__
const long double x = 1.0L / 0.0L;
long double y = floorl(x);
if (isinf(y) == 0 || signbit(y) != 0)
atf_tc_fail_nonfatal("floorl(+Inf) != +Inf");
#endif
}
ATF_TC(floorl_zero_neg);
ATF_TC_HEAD(floorl_zero_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test floorl(-0.0) == -0.0");
}
ATF_TC_BODY(floorl_zero_neg, tc)
{
#ifndef __vax__
const long double x = -0.0L;
long double y = floorl(x);
if (fabsl(y) > 0.0 || signbit(y) == 0)
atf_tc_fail_nonfatal("floorl(-0.0) != -0.0");
#endif
}
ATF_TC(floorl_zero_pos);
ATF_TC_HEAD(floorl_zero_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test floorl(+0.0) == +0.0");
}
ATF_TC_BODY(floorl_zero_pos, tc)
{
#ifndef __vax__
const long double x = 0.0L;
long double y = floorl(x);
if (fabsl(y) > 0.0 || signbit(y) != 0)
atf_tc_fail_nonfatal("floorl(+0.0) != +0.0");
#endif
}
/*
* trunc(3)
*/
ATF_TC(trunc_basic);
ATF_TC_HEAD(trunc_basic, tc)
{
atf_tc_set_md_var(tc, "descr", "A basic test of trunc(3)");
}
ATF_TC_BODY(trunc_basic, tc)
{
const double x = 0.999999999999999;
const double y = 0.000000000000001;
ATF_CHECK(trunc(x) < SMALL_NUM);
ATF_CHECK(trunc(y) < SMALL_NUM);
}
ATF_TC(trunc_nan);
ATF_TC_HEAD(trunc_nan, tc)
{
atf_tc_set_md_var(tc, "descr", "Test trunc(NaN) == NaN");
}
ATF_TC_BODY(trunc_nan, tc)
{
#ifndef __vax__
const double x = 0.0L / 0.0L;
ATF_CHECK(isnan(trunc(x)) != 0);
#endif
}
ATF_TC(trunc_inf_neg);
ATF_TC_HEAD(trunc_inf_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test trunc(-Inf) == -Inf");
}
ATF_TC_BODY(trunc_inf_neg, tc)
{
#ifndef __vax__
const double x = -1.0L / 0.0L;
double y = trunc(x);
if (isinf(y) == 0 || signbit(y) == 0)
atf_tc_fail_nonfatal("trunc(-Inf) != -Inf");
#endif
}
ATF_TC(trunc_inf_pos);
ATF_TC_HEAD(trunc_inf_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test trunc(+Inf) == +Inf");
}
ATF_TC_BODY(trunc_inf_pos, tc)
{
#ifndef __vax__
const double x = 1.0L / 0.0L;
double y = trunc(x);
if (isinf(y) == 0 || signbit(y) != 0)
atf_tc_fail_nonfatal("trunc(+Inf) != +Inf");
#endif
}
ATF_TC(trunc_zero_neg);
ATF_TC_HEAD(trunc_zero_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test trunc(-0.0) == -0.0");
}
ATF_TC_BODY(trunc_zero_neg, tc)
{
#ifndef __vax__
const double x = -0.0L;
double y = trunc(x);
if (fabs(y) > 0.0 || signbit(y) == 0)
atf_tc_fail_nonfatal("trunc(-0.0) != -0.0");
#endif
}
ATF_TC(trunc_zero_pos);
ATF_TC_HEAD(trunc_zero_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test trunc(+0.0) == +0.0");
}
ATF_TC_BODY(trunc_zero_pos, tc)
{
#ifndef __vax__
const double x = 0.0L;
double y = trunc(x);
if (fabs(y) > 0.0 || signbit(y) != 0)
atf_tc_fail_nonfatal("trunc(+0.0) != +0.0");
#endif
}
/*
* truncf(3)
*/
ATF_TC(truncf_basic);
ATF_TC_HEAD(truncf_basic, tc)
{
atf_tc_set_md_var(tc, "descr", "A basic test of truncf(3)");
}
ATF_TC_BODY(truncf_basic, tc)
{
const float x = 0.9999999;
const float y = 0.0000001;
ATF_CHECK(truncf(x) < SMALL_NUM);
ATF_CHECK(truncf(y) < SMALL_NUM);
}
ATF_TC(truncf_nan);
ATF_TC_HEAD(truncf_nan, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncf(NaN) == NaN");
}
ATF_TC_BODY(truncf_nan, tc)
{
#ifndef __vax__
const float x = 0.0L / 0.0L;
ATF_CHECK(isnan(truncf(x)) != 0);
#endif
}
ATF_TC(truncf_inf_neg);
ATF_TC_HEAD(truncf_inf_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncf(-Inf) == -Inf");
}
ATF_TC_BODY(truncf_inf_neg, tc)
{
#ifndef __vax__
const float x = -1.0L / 0.0L;
float y = truncf(x);
if (isinf(y) == 0 || signbit(y) == 0)
atf_tc_fail_nonfatal("truncf(-Inf) != -Inf");
#endif
}
ATF_TC(truncf_inf_pos);
ATF_TC_HEAD(truncf_inf_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncf(+Inf) == +Inf");
}
ATF_TC_BODY(truncf_inf_pos, tc)
{
#ifndef __vax__
const float x = 1.0L / 0.0L;
float y = truncf(x);
if (isinf(y) == 0 || signbit(y) != 0)
atf_tc_fail_nonfatal("truncf(+Inf) != +Inf");
#endif
}
ATF_TC(truncf_zero_neg);
ATF_TC_HEAD(truncf_zero_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncf(-0.0) == -0.0");
}
ATF_TC_BODY(truncf_zero_neg, tc)
{
#ifndef __vax__
const float x = -0.0L;
float y = truncf(x);
if (fabsf(y) > 0.0 || signbit(y) == 0)
atf_tc_fail_nonfatal("truncf(-0.0) != -0.0");
#endif
}
ATF_TC(truncf_zero_pos);
ATF_TC_HEAD(truncf_zero_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncf(+0.0) == +0.0");
}
ATF_TC_BODY(truncf_zero_pos, tc)
{
#ifndef __vax__
const float x = 0.0L;
float y = truncf(x);
if (fabsf(y) > 0.0 || signbit(y) != 0)
atf_tc_fail_nonfatal("truncf(+0.0) != +0.0");
#endif
}
/*
* truncl(3)
*/
ATF_TC(truncl_basic);
ATF_TC_HEAD(truncl_basic, tc)
{
atf_tc_set_md_var(tc, "descr", "A basic test of truncl(3)");
}
ATF_TC_BODY(truncl_basic, tc)
{
const long double x = 0.9999999;
const long double y = 0.0000001;
ATF_CHECK(truncl(x) < SMALL_NUM);
ATF_CHECK(truncl(y) < SMALL_NUM);
}
ATF_TC(truncl_nan);
ATF_TC_HEAD(truncl_nan, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncl(NaN) == NaN");
}
ATF_TC_BODY(truncl_nan, tc)
{
#ifndef __vax__
const long double x = 0.0L / 0.0L;
ATF_CHECK(isnan(truncl(x)) != 0);
#endif
}
ATF_TC(truncl_inf_neg);
ATF_TC_HEAD(truncl_inf_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncl(-Inf) == -Inf");
}
ATF_TC_BODY(truncl_inf_neg, tc)
{
#ifndef __vax__
const long double x = -1.0L / 0.0L;
long double y = truncl(x);
if (isinf(y) == 0 || signbit(y) == 0)
atf_tc_fail_nonfatal("truncl(-Inf) != -Inf");
#endif
}
ATF_TC(truncl_inf_pos);
ATF_TC_HEAD(truncl_inf_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncl(+Inf) == +Inf");
}
ATF_TC_BODY(truncl_inf_pos, tc)
{
#ifndef __vax__
const long double x = 1.0L / 0.0L;
long double y = truncl(x);
if (isinf(y) == 0 || signbit(y) != 0)
atf_tc_fail_nonfatal("truncl(+Inf) != +Inf");
#endif
}
ATF_TC(truncl_zero_neg);
ATF_TC_HEAD(truncl_zero_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncl(-0.0) == -0.0");
}
ATF_TC_BODY(truncl_zero_neg, tc)
{
#ifndef __vax__
const long double x = -0.0L;
long double y = truncl(x);
if (fabsl(y) > 0.0 || signbit(y) == 0)
atf_tc_fail_nonfatal("truncl(-0.0) != -0.0");
#endif
}
ATF_TC(truncl_zero_pos);
ATF_TC_HEAD(truncl_zero_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test truncl(+0.0) == +0.0");
}
ATF_TC_BODY(truncl_zero_pos, tc)
{
#ifndef __vax__
const long double x = 0.0L;
long double y = truncl(x);
if (fabsl(y) > 0.0 || signbit(y) != 0)
atf_tc_fail_nonfatal("truncl(+0.0) != +0.0");
#endif
}
ATF_TP_ADD_TCS(tp)
{
@@ -463,6 +968,13 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, ceilf_zero_neg);
ATF_TP_ADD_TC(tp, ceilf_zero_pos);
ATF_TP_ADD_TC(tp, ceill_basic);
ATF_TP_ADD_TC(tp, ceill_nan);
ATF_TP_ADD_TC(tp, ceill_inf_neg);
ATF_TP_ADD_TC(tp, ceill_inf_pos);
ATF_TP_ADD_TC(tp, ceill_zero_neg);
ATF_TP_ADD_TC(tp, ceill_zero_pos);
ATF_TP_ADD_TC(tp, floor_basic);
ATF_TP_ADD_TC(tp, floor_nan);
ATF_TP_ADD_TC(tp, floor_inf_neg);
@@ -477,5 +989,33 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, floorf_zero_neg);
ATF_TP_ADD_TC(tp, floorf_zero_pos);
ATF_TP_ADD_TC(tp, floorl_basic);
ATF_TP_ADD_TC(tp, floorl_nan);
ATF_TP_ADD_TC(tp, floorl_inf_neg);
ATF_TP_ADD_TC(tp, floorl_inf_pos);
ATF_TP_ADD_TC(tp, floorl_zero_neg);
ATF_TP_ADD_TC(tp, floorl_zero_pos);
ATF_TP_ADD_TC(tp, trunc_basic);
ATF_TP_ADD_TC(tp, trunc_nan);
ATF_TP_ADD_TC(tp, trunc_inf_neg);
ATF_TP_ADD_TC(tp, trunc_inf_pos);
ATF_TP_ADD_TC(tp, trunc_zero_neg);
ATF_TP_ADD_TC(tp, trunc_zero_pos);
ATF_TP_ADD_TC(tp, truncf_basic);
ATF_TP_ADD_TC(tp, truncf_nan);
ATF_TP_ADD_TC(tp, truncf_inf_neg);
ATF_TP_ADD_TC(tp, truncf_inf_pos);
ATF_TP_ADD_TC(tp, truncf_zero_neg);
ATF_TP_ADD_TC(tp, truncf_zero_pos);
ATF_TP_ADD_TC(tp, truncl_basic);
ATF_TP_ADD_TC(tp, truncl_nan);
ATF_TP_ADD_TC(tp, truncl_inf_neg);
ATF_TP_ADD_TC(tp, truncl_inf_pos);
ATF_TP_ADD_TC(tp, truncl_zero_neg);
ATF_TP_ADD_TC(tp, truncl_zero_pos);
return atf_no_error();
}

63
tests/lib/libm/t_fmod.c Normal file
View File

@@ -0,0 +1,63 @@
/* $NetBSD: t_fmod.c,v 1.1 2013/11/12 16:48:39 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Joerg Sonnenberger.
*
* 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 <float.h>
#include <math.h>
ATF_TC(fmod);
ATF_TC_HEAD(fmod, tc)
{
atf_tc_set_md_var(tc, "descr","Check fmod family");
}
ATF_TC_BODY(fmod, tc)
{
ATF_CHECK(fmodf(2.0, 1.0) == 0);
ATF_CHECK(fmod(2.0, 1.0) == 0);
ATF_CHECK(fmodl(2.0, 1.0) == 0);
ATF_CHECK(fmodf(2.0, 0.5) == 0);
ATF_CHECK(fmod(2.0, 0.5) == 0);
ATF_CHECK(fmodl(2.0, 0.5) == 0);
ATF_CHECK(fabsf(fmodf(1.0, 0.1) - 0.1) <= 55 * FLT_EPSILON);
ATF_CHECK(fabs(fmod(1.0, 0.1) - 0.1) <= 55 * DBL_EPSILON);
ATF_CHECK(fabsl(fmodl(1.0, 0.1L) - 0.1L) <= 55 * LDBL_EPSILON);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, fmod);
return atf_no_error();
}

View File

@@ -0,0 +1,76 @@
/* $NetBSD: t_precision.c,v 1.1 2013/11/11 11:10:45 joerg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Joerg Sonnenberger.
*
* 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_precision.c,v 1.1 2013/11/11 11:10:45 joerg Exp $");
#include <atf-c.h>
#include <atf-c/config.h>
#include <float.h>
#include <stdlib.h>
ATF_TC(t_precision);
ATF_TC_HEAD(t_precision, tc)
{
atf_tc_set_md_var(tc, "descr",
"Basic precision test for double and long double");
}
volatile double x = 1;
volatile long double y = 1;
ATF_TC_BODY(t_precision, tc)
{
x += DBL_EPSILON;
ATF_CHECK(x != 1.0);
x -= 1;
ATF_CHECK(x == DBL_EPSILON);
x = 2;
x += DBL_EPSILON;
ATF_CHECK(x == 2.0);
y += LDBL_EPSILON;
ATF_CHECK(y != 1.0L);
y -= 1;
ATF_CHECK(y == LDBL_EPSILON);
y = 2;
y += LDBL_EPSILON;
ATF_CHECK(y == 2.0L);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, t_precision);
return atf_no_error();
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_round.c,v 1.3 2011/09/13 08:58:41 jruoho Exp $ */
/* $NetBSD: t_round.c,v 1.4 2013/11/11 23:57:34 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -27,6 +27,7 @@
*/
#include <atf-c.h>
#include <float.h>
#include <math.h>
/*
@@ -38,6 +39,7 @@
/* 0.5 - EPSILON */
#define VAL 0x0.7ffffffffffffcp0
#define VALF 0x0.7fffff8p0
#define VALL (0.5 - LDBL_EPSILON)
#ifdef __vax__
#define SMALL_NUM 1.0e-38
@@ -55,18 +57,23 @@ ATF_TC_BODY(round_dir, tc)
{
double a = VAL, b, c;
float af = VALF, bf, cf;
long double al = VALL, bl, cl;
b = round(a);
bf = roundf(af);
bl = roundl(al);
ATF_CHECK(fabs(b) < SMALL_NUM);
ATF_CHECK(fabsf(bf) < SMALL_NUM);
ATF_CHECK(fabsl(bl) < SMALL_NUM);
c = round(-a);
cf = roundf(-af);
cl = roundl(-al);
ATF_CHECK(fabs(c) < SMALL_NUM);
ATF_CHECK(fabsf(cf) < SMALL_NUM);
ATF_CHECK(fabsl(cl) < SMALL_NUM);
}
ATF_TP_ADD_TCS(tp)

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_sqrt.c,v 1.3 2012/02/13 05:09:01 jruoho Exp $ */
/* $NetBSD: t_sqrt.c,v 1.5 2013/11/22 17:19:14 martin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,10 +29,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_sqrt.c,v 1.3 2012/02/13 05:09:01 jruoho Exp $");
__RCSID("$NetBSD: t_sqrt.c,v 1.5 2013/11/22 17:19:14 martin Exp $");
#include <atf-c.h>
#include <math.h>
#include <float.h>
#include <stdio.h>
/*
@@ -259,6 +260,118 @@ ATF_TC_BODY(sqrtf_zero_pos, tc)
#endif
}
/*
* sqrtl(3)
*/
ATF_TC(sqrtl_nan);
ATF_TC_HEAD(sqrtl_nan, tc)
{
atf_tc_set_md_var(tc, "descr", "Test sqrtl(NaN) == NaN");
}
ATF_TC_BODY(sqrtl_nan, tc)
{
#ifndef __vax__
const long double x = 0.0L / 0.0L;
ATF_CHECK(isnan(x) != 0);
ATF_CHECK(isnan(sqrtl(x)) != 0);
#endif
}
ATF_TC(sqrtl_powl);
ATF_TC_HEAD(sqrtl_powl, tc)
{
atf_tc_set_md_var(tc, "descr", "Test sqrtl(3) vs. powl(3)");
}
ATF_TC_BODY(sqrtl_powl, tc)
{
#ifndef __vax__
const long double x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, 9999.9999 };
const long double eps = 5.0*DBL_EPSILON; /* XXX powl == pow for now */
volatile long double y, z;
size_t i;
for (i = 0; i < __arraycount(x); i++) {
y = sqrtl(x[i]);
z = powl(x[i], 1.0 / 2.0);
if (fabsl(y - z) > eps)
atf_tc_fail_nonfatal("sqrtl(%0.03Lf) != "
"powl(%0.03Lf, 1/2)\n", x[i], x[i]);
}
#endif
}
ATF_TC(sqrtl_inf_neg);
ATF_TC_HEAD(sqrtl_inf_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test sqrtl(-Inf) == NaN");
}
ATF_TC_BODY(sqrtl_inf_neg, tc)
{
#ifndef __vax__
const long double x = -1.0L / 0.0L;
long double y = sqrtl(x);
ATF_CHECK(isnan(y) != 0);
#endif
}
ATF_TC(sqrtl_inf_pos);
ATF_TC_HEAD(sqrtl_inf_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test sqrtl(+Inf) == +Inf");
}
ATF_TC_BODY(sqrtl_inf_pos, tc)
{
#ifndef __vax__
const long double x = 1.0L / 0.0L;
long double y = sqrtl(x);
ATF_CHECK(isinf(y) != 0);
ATF_CHECK(signbit(y) == 0);
#endif
}
ATF_TC(sqrtl_zero_neg);
ATF_TC_HEAD(sqrtl_zero_neg, tc)
{
atf_tc_set_md_var(tc, "descr", "Test sqrtl(-0.0) == -0.0");
}
ATF_TC_BODY(sqrtl_zero_neg, tc)
{
#ifndef __vax__
const long double x = -0.0L;
long double y = sqrtl(x);
if (fabsl(y) > 0.0 || signbit(y) == 0)
atf_tc_fail_nonfatal("sqrtl(-0.0) != -0.0");
#endif
}
ATF_TC(sqrtl_zero_pos);
ATF_TC_HEAD(sqrtl_zero_pos, tc)
{
atf_tc_set_md_var(tc, "descr", "Test sqrtl(+0.0) == +0.0");
}
ATF_TC_BODY(sqrtl_zero_pos, tc)
{
#ifndef __vax__
const long double x = 0.0L;
long double y = sqrtl(x);
if (fabsl(y) > 0.0 || signbit(y) != 0)
atf_tc_fail_nonfatal("sqrtl(+0.0) != +0.0");
#endif
}
ATF_TP_ADD_TCS(tp)
{
@@ -276,5 +389,12 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, sqrtf_zero_neg);
ATF_TP_ADD_TC(tp, sqrtf_zero_pos);
ATF_TP_ADD_TC(tp, sqrtl_nan);
ATF_TP_ADD_TC(tp, sqrtl_powl);
ATF_TP_ADD_TC(tp, sqrtl_inf_neg);
ATF_TP_ADD_TC(tp, sqrtl_inf_pos);
ATF_TP_ADD_TC(tp, sqrtl_zero_neg);
ATF_TP_ADD_TC(tp, sqrtl_zero_pos);
return atf_no_error();
}

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_threads.m,v 1.1 2010/07/18 12:41:51 jmmv Exp $ */
/* $NetBSD: t_threads.m,v 1.2 2013/10/31 21:02:11 christos Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -35,8 +35,11 @@
#include <atf-c.h>
#include <objc/objc.h>
#include <objc/objc-api.h>
#include <objc/thr.h>
#include <objc/Object.h>
#if __GNUC_PREREQ__(4,8)
#include <objc/runtime.h>
#endif
static int IsMultithreaded = 0;
static objc_mutex_t Mutex;
@@ -46,6 +49,12 @@ static objc_condition_t Condition;
{
}
-(void)start;
#if __GNUC_PREREQ__(4,8)
-init;
+new;
+alloc;
-free;
#endif
@end
@implementation MyClass
@@ -55,6 +64,27 @@ static objc_condition_t Condition;
objc_condition_signal(Condition);
}
#if __GNUC_PREREQ__(4,8)
-init
{
return self;
}
+new
{
return [[self alloc] init];
}
+alloc
{
return class_createInstance(self, 0);
}
-free
{
return object_dispose(self);
}
#endif
@end
static void

View File

@@ -1,4 +1,4 @@
# $Id: Makefile,v 1.4 2012/03/17 12:42:31 nakayama Exp $
# $Id: Makefile,v 1.5 2013/10/19 17:28:38 christos Exp $
.include <bsd.own.mk>
@@ -18,6 +18,7 @@ CPPFLAGS+=-I$(.OBJDIR)
.plist.c:
AWK=${TOOL_AWK:Q} ${HOST_SH} ${.CURDIR}/plist_to_c ${.TARGET:S,.c$,,} < ${.IMPSRC} > ${.TARGET}
t_ppath.o: personnel.h
CLEANFILES+=personnel.c personnel.h
#LDADD+=-L$(LIBPPATH)

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_cond.c,v 1.4 2013/03/17 05:13:13 jmmv Exp $ */
/* $NetBSD: t_cond.c,v 1.5 2013/10/19 17:45:01 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_cond.c,v 1.4 2013/03/17 05:13:13 jmmv Exp $");
__RCSID("$NetBSD: t_cond.c,v 1.5 2013/10/19 17:45:01 christos Exp $");
#include <sys/time.h>
@@ -74,7 +74,6 @@ ATF_TC_HEAD(signal_delay_wait, tc)
}
ATF_TC_BODY(signal_delay_wait, tc)
{
int x;
pthread_t new;
void *joinval;
int sharedval;
@@ -84,7 +83,6 @@ ATF_TC_BODY(signal_delay_wait, tc)
PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
PTHREAD_REQUIRE(pthread_cond_init(&cond, NULL));
x = 20;
PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
sharedval = 1;
@@ -137,7 +135,6 @@ ATF_TC_HEAD(signal_before_unlock, tc)
}
ATF_TC_BODY(signal_before_unlock, tc)
{
int x;
pthread_t new;
void *joinval;
int sharedval;
@@ -147,7 +144,6 @@ ATF_TC_BODY(signal_before_unlock, tc)
PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
PTHREAD_REQUIRE(pthread_cond_init(&cond, NULL));
x = 20;
PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
sharedval = 1;
@@ -201,14 +197,12 @@ ATF_TC_HEAD(signal_before_unlock_static_init, tc)
}
ATF_TC_BODY(signal_before_unlock_static_init, tc)
{
int x;
pthread_t new;
void *joinval;
int sharedval;
printf("1: condition variable test 3\n");
x = 20;
PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex));
sharedval = 1;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_sigmask.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
/* $NetBSD: t_sigmask.c,v 1.3 2013/10/19 17:45:01 christos Exp $ */
/*
* Copyright (c) 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_sigmask.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
__RCSID("$NetBSD: t_sigmask.c,v 1.3 2013/10/19 17:45:01 christos Exp $");
/*
* Regression test for pthread_sigmask when SA upcalls aren't started yet.
@@ -107,7 +107,6 @@ ATF_TC_HEAD(before_threads, tc)
ATF_TC_BODY(before_threads, tc)
{
struct sigaction act;
int ret;
act.sa_sigaction = upcalls_not_started_handler1;
sigemptyset(&act.sa_mask);
@@ -119,7 +118,7 @@ ATF_TC_BODY(before_threads, tc)
act.sa_sigaction = upcalls_not_started_handler2;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
ret = sigaction(SIGUSR2, &act, NULL);
(void)sigaction(SIGUSR2, &act, NULL);
kill(getpid(), SIGUSR1);
@@ -179,7 +178,6 @@ ATF_TC_BODY(respected_while_running, tc)
{
struct sigaction act;
pthread_t thread;
int rv;
act.sa_sigaction = respected_while_running_handler1;
sigemptyset(&act.sa_mask);
@@ -191,7 +189,7 @@ ATF_TC_BODY(respected_while_running, tc)
act.sa_sigaction = respected_while_running_handler2;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
rv = sigaction(SIGUSR2, &act, NULL);
(void)sigaction(SIGUSR2, &act, NULL);
PTHREAD_REQUIRE(pthread_create(&thread, NULL,
respected_while_running_threadroutine, NULL));

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_snprintb.c,v 1.1 2010/07/16 13:56:32 jmmv Exp $ */
/* $NetBSD: t_snprintb.c,v 1.3 2013/08/08 05:10:07 pgoyette Exp $ */
/*
* Copyright (c) 2002, 2004, 2008, 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_snprintb.c,v 1.1 2010/07/16 13:56:32 jmmv Exp $");
__RCSID("$NetBSD: t_snprintb.c,v 1.3 2013/08/08 05:10:07 pgoyette Exp $");
#include <string.h>
#include <util.h>
@@ -59,17 +59,58 @@ ATF_TC_HEAD(snprintb, tc)
ATF_TC_BODY(snprintb, tc)
{
h_snprintb("\10\2BITTWO\1BITONE", 3, "03<BITTWO,BITONE>");
h_snprintb("\177\20b\05NOTBOOT\0b\06FPP\0b\013SDVMA\0b\015VIDEO\0"
"b\020LORES\0b\021FPA\0b\022DIAG\0b\016CACHE\0"
"b\017IOCACHE\0b\022LOOPBACK\0b\04DBGCACHE\0",
0xe860, "0xe860<NOTBOOT,FPP,SDVMA,VIDEO,CACHE,IOCACHE>");
}
static void
h_snprintb_m(const char *fmt, uint64_t val, int line_max, const char *res,
int res_len)
{
char buf[1024];
int len;
len = snprintb_m(buf, sizeof(buf), fmt, val, line_max);
ATF_REQUIRE_EQ(len, res_len);
ATF_REQUIRE_EQ(0, memcmp(res, buf, res_len + 1));
}
ATF_TC(snprintb_m);
ATF_TC_HEAD(snprintb_m, tc)
{
atf_tc_set_md_var(tc, "descr", "Checks snprintb_m(3)");
}
ATF_TC_BODY(snprintb_m, tc)
{
h_snprintb_m("\177\020b\0LSB\0b\1_BITONE\0f\4\4NIBBLE2\0"
"f\x10\4BURST\0=\4FOUR\0=\xfSIXTEEN\0"
"b\x1fMSB\0\0",
0x800f0701,
33,
"0x800f0701<LSB,NIBBLE2=0x0>\0"
"0x800f0701<BURST=0xf=SIXTEEN,MSB>\0\0",
62);
h_snprintb_m("\177\020b\0LSB\0b\1_BITONE\0f\4\4NIBBLE2\0"
"f\x10\4BURST\0=\4FOUR\0=\xfSIXTEEN\0"
"b\x1fMSB\0\0",
0x800f0701,
32,
"0x800f0701<LSB,NIBBLE2=0x0>\0"
"0x800f0701<BURST=0xf=SIXTEEN>\0"
"0x800f0701<MSB>\0\0",
74);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, snprintb);
ATF_TP_ADD_TC(tp, snprintb_m);
return atf_no_error();
}

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.14 2013/07/03 14:01:29 nakayama Exp $
# $NetBSD: Makefile,v 1.15 2013/07/19 04:00:40 kefren Exp $
.include <bsd.own.mk>
@@ -6,7 +6,7 @@ TESTSDIR= ${TESTSBASE}/net
TESTS_SUBDIRS= fdpass net route sys
.if (${MKRUMP} != "no")
TESTS_SUBDIRS+= bpf bpfilter carp icmp if if_loop npf
TESTS_SUBDIRS+= bpf bpfilter carp icmp if if_loop mpls npf
.endif
.include <bsd.test.mk>

10
tests/net/mpls/Makefile Normal file
View File

@@ -0,0 +1,10 @@
# $NetBSD: Makefile,v 1.4 2013/11/12 12:22:33 kefren Exp $
#
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/net/mpls
TESTS_SH= t_mpls_fw t_rfc4182 t_ldp_regen
.include <bsd.test.mk>

174
tests/net/mpls/t_ldp_regen.sh Executable file
View File

@@ -0,0 +1,174 @@
# $NetBSD: t_ldp_regen.sh,v 1.2 2013/07/27 14:36:39 kefren Exp $
#
# Copyright (c) 2013 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.
#
# IP/MPLS & LDP label reallocation test
# Create 4 routers connected like this: R1--R2--R3--R4--
# The goal is to push packets from R1 to the R4 shmif1 (the right one) interface
# Enable MPLS forwarding on R2
# Disable IP forwarding and enable MPLS forwarding on R3
# Start ldpd and wait for adjancencies to come up
# Add an alias on shmif1 on R4 for which we already have a route on R3
# Now: * R4 should install label IMPLNULL for that prefix
# * R3 should realloc the target label from IMPLNULL to something else
RUMP_SERVER1=unix://./r1
RUMP_SERVER2=unix://./r2
RUMP_SERVER3=unix://./r3
RUMP_SERVER4=unix://./r4
RUMP_LIBS="-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_shmif"
LDP_FLAGS=""
atf_test_case ldp_regen cleanup
ldp_regen_head() {
atf_set "descr" "IP/MPLS and LDP label regeneration test"
atf_set "require.progs" "rump_server"
atf_set "use.fs" "true"
}
newaddr_and_ping() {
# Add new address on R4
RUMP_SERVER=${RUMP_SERVER4} atf_check -s exit:0 \
rump.ifconfig shmif1 10.0.5.1/24 alias
# Now ldpd on R5 should take notice of the new route and announce it
# to R4's ldpd. ldpd on R4 should verify that the next hop
# corresponds to its routing table and change its tag entry
RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 -o ignore -e ignore \
rump.ping -n -o -w 5 10.0.5.1
}
create_servers() {
# allows us to run as normal user
ulimit -r 400
atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER1}
atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER2}
atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER3}
atf_check -s exit:0 rump_server ${RUMP_LIBS} ${RUMP_SERVER4}
# LDP HIJACK
export RUMPHIJACK=path=/rump,socket=all,sysctl=yes
export LD_PRELOAD=/usr/lib/librumphijack.so
# Setup first server
export RUMP_SERVER=${RUMP_SERVER1}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.1.2
atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.1.2
atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
# Setup second server
export RUMP_SERVER=${RUMP_SERVER2}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
# This one should still do ip forwarding because it announces IMPLNULL
# for the 10.0.1.0/24 subnet
atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.2.2
atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.2.2
atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
# Setup third server
export RUMP_SERVER=${RUMP_SERVER3}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add 10.0.1.0/24 10.0.2.1
atf_check -s exit:0 rump.route -q add 10.0.4.0/24 10.0.3.2
atf_check -s exit:0 rump.route -q add 10.0.5.0/24 10.0.3.2
atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
# Setup fourth server
export RUMP_SERVER=${RUMP_SERVER4}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.route -q add 10.0.1.0/24 10.0.3.1
atf_check -s exit:0 /usr/sbin/ldpd ${LDP_FLAGS}
unset RUMP_SERVER
unset LD_PRELOAD
unset RUMPHIJACK
}
wait_ldp_ok() {
RUMP_SERVER=${RUMP_SERVER1} atf_check -s exit:0 -o ignore -e ignore \
rump.ping -o -w 60 10.0.4.1
}
docleanup() {
RUMP_SERVER=${RUMP_SERVER1} rump.halt
RUMP_SERVER=${RUMP_SERVER2} rump.halt
RUMP_SERVER=${RUMP_SERVER3} rump.halt
RUMP_SERVER=${RUMP_SERVER4} rump.halt
}
ldp_regen_body() {
create_servers
wait_ldp_ok
newaddr_and_ping
}
ldp_regen_cleanup() {
docleanup
}
atf_init_test_cases() {
atf_add_test_case ldp_regen
}

188
tests/net/mpls/t_mpls_fw.sh Normal file
View File

@@ -0,0 +1,188 @@
# $NetBSD: t_mpls_fw.sh,v 1.3 2013/07/23 12:41:01 kefren Exp $
#
# Copyright (c) 2013 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.
#
# TEST MPLS encap/decap and forwarding using INET as encapsulated protocol
# Setup four routers connected like this: R1---R2---R3---R4--
# Goal is to be able to ping from R1 the outermost interface of R4
# Disable net.inet.ip.forwarding, enable net.mpls.forwarding
# Add route on R1 in order to encapsulate into MPLS the IP packets with
# destination equal to R4 right hand side interface
# Add MPLS routes on R2 in order to forward frames belonging to that FEC to R3
# Add MPLS "POP" route on R3 for that FEC, pointing to R4
# Do the same for the reverse direction (R4 to R1)
# ping from R1 to R4 right hand side interface
RUMP_SERVER1=unix://./r1
RUMP_SERVER2=unix://./r2
RUMP_SERVER3=unix://./r3
RUMP_SERVER4=unix://./r4
RUMP_FLAGS=\
"-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_shmif"
atf_test_case mplsfw4 cleanup
mplsfw4_head()
{
atf_set "descr" "IP/MPLS forwarding test using PHP"
atf_set "require.progs" "rump_server"
}
startservers()
{
ulimit -r 300
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER2}
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER3}
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER4}
}
configservers()
{
# Setup the first server
export RUMP_SERVER=${RUMP_SERVER1}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add 10.0.4.0/24 -ifa 10.0.1.1 \
-ifp mpls0 -tag 25 -inet 10.0.1.2
# Setup the second server
export RUMP_SERVER=${RUMP_SERVER2}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30 -inet 10.0.2.2
atf_check -s exit:0 rump.route -q add -mpls 27 -tag ${1} -inet 10.0.1.1
# Setup the third server
export RUMP_SERVER=${RUMP_SERVER3}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add -mpls 30 -tag ${1} -inet 10.0.3.2
atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27 -inet 10.0.2.1
# Setup the fourth server
export RUMP_SERVER=${RUMP_SERVER4}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add 10.0.1.0/24 -ifa 10.0.3.2 \
-ifp mpls0 -tag 26 -inet 10.0.3.1
unset RUMP_SERVER
}
doping()
{
export RUMP_SERVER=${RUMP_SERVER1}
atf_check -s exit:0 -o match:"64 bytes from 10.0.4.1: icmp_seq=" \
rump.ping -n -o -w 5 10.0.4.1
unset RUMP_SERVER
}
docleanup()
{
RUMP_SERVER=${RUMP_SERVER1} rump.halt
RUMP_SERVER=${RUMP_SERVER2} rump.halt
RUMP_SERVER=${RUMP_SERVER3} rump.halt
RUMP_SERVER=${RUMP_SERVER4} rump.halt
}
mplsfw4_body()
{
startservers
configservers 3
doping
}
mplsfw4_cleanup()
{
docleanup
}
atf_test_case mplsfw4_expl cleanup
mplsfw4_expl_head()
{
atf_set "descr" "IP/MPLS forwarding test using explicit NULL labels"
atf_set "require.progs" "rump_server"
}
mplsfw4_expl_body()
{
startservers
configservers 0
doping
}
mplsfw4_expl_cleanup()
{
docleanup
}
atf_init_test_cases()
{
atf_add_test_case mplsfw4
atf_add_test_case mplsfw4_expl
}

165
tests/net/mpls/t_rfc4182.sh Normal file
View File

@@ -0,0 +1,165 @@
# $NetBSD: t_rfc4182.sh,v 1.2 2013/07/23 12:41:01 kefren Exp $
#
# Copyright (c) 2013 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.
#
# TEST RFC 4182
# Setup four routers connected like this: R1---R2---R3---R4--
# Goal is to be able to ping from R1 the outermost interface of R4
# Disable net.inet.ip.forwarding, enable net.mpls.forwarding
# Add route on R1 in order to encapsulate into MPLS the IP packets with
# destination equal to R4 right hand side interface. Use two labels here:
# 25 and IPv6 Explicit NULL
# Add a double tagged MPLS route on R2 in order to forward frames belonging to
# that FEC to R3, with IPv4 NULL being the most outermost one
# Add MPLS "POP" route on R3 for that FEC, pointing to R4
# Do the same for the reverse direction (R4 to R1)
# ping from R1 to R4 right hand side interface
RUMP_SERVER1=unix://./r1
RUMP_SERVER2=unix://./r2
RUMP_SERVER3=unix://./r3
RUMP_SERVER4=unix://./r4
RUMP_FLAGS=\
"-lrumpnet -lrumpnet_net -lrumpnet_netmpls -lrumpnet_netinet -lrumpnet_shmif"
atf_test_case rfc4182 cleanup
rfc4182_head()
{
atf_set "descr" "RFC 4182 conformance test"
atf_set "require.progs" "rump_server"
}
startservers()
{
ulimit -r 300
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER1}
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER2}
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER3}
atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${RUMP_SERVER4}
}
configservers()
{
# Setup the first server
export RUMP_SERVER=${RUMP_SERVER1}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add 10.0.4.0/24 -ifa 10.0.1.1 \
-ifp mpls0 -tag 25,2 -inet 10.0.1.2
# Setup the second server
export RUMP_SERVER=${RUMP_SERVER2}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.1.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom2
atf_check -s exit:0 rump.ifconfig shmif1 10.0.2.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add -mpls 25 -tag 30,0 -inet 10.0.2.2
atf_check -s exit:0 rump.route -q add -mpls 27 -tag 3 -inet 10.0.1.1
# Setup the third server
export RUMP_SERVER=${RUMP_SERVER3}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom2
atf_check -s exit:0 rump.ifconfig shmif0 10.0.2.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom3
atf_check -s exit:0 rump.ifconfig shmif1 10.0.3.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.mpls.forwarding=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add -mpls 30 -tag 3 -inet 10.0.3.2
atf_check -s exit:0 rump.route -q add -mpls 26 -tag 27,0 -inet 10.0.2.1
# Setup the fourth server
export RUMP_SERVER=${RUMP_SERVER4}
atf_check -s exit:0 rump.ifconfig shmif0 create
atf_check -s exit:0 rump.ifconfig shmif0 linkstr ./shdom3
atf_check -s exit:0 rump.ifconfig shmif0 10.0.3.2/24
atf_check -s exit:0 rump.ifconfig shmif1 create
atf_check -s exit:0 rump.ifconfig shmif1 linkstr ./shdom4
atf_check -s exit:0 rump.ifconfig shmif1 10.0.4.1/24
atf_check -s exit:0 rump.ifconfig mpls0 create up
atf_check -s exit:0 rump.sysctl -q -w net.mpls.accept=1
atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=0
atf_check -s exit:0 rump.route -q add 10.0.1.0/24 -ifa 10.0.3.2 \
-ifp mpls0 -tag 26 -inet 10.0.3.1
unset RUMP_SERVER
}
doping()
{
export RUMP_SERVER=${RUMP_SERVER1}
atf_check -s exit:0 -o match:"64 bytes from 10.0.4.1: icmp_seq=" \
rump.ping -n -o -w 5 10.0.4.1
unset RUMP_SERVER
}
docleanup()
{
RUMP_SERVER=${RUMP_SERVER1} rump.halt
RUMP_SERVER=${RUMP_SERVER2} rump.halt
RUMP_SERVER=${RUMP_SERVER3} rump.halt
RUMP_SERVER=${RUMP_SERVER4} rump.halt
}
rfc4182_body()
{
startservers
configservers
doping
}
rfc4182_cleanup()
{
docleanup
}
atf_init_test_cases()
{
atf_add_test_case rfc4182
}

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.6 2013/07/03 14:01:29 nakayama Exp $
# $NetBSD: Makefile,v 1.7 2013/10/12 15:29:16 christos Exp $
#
.include <bsd.own.mk>
@@ -6,6 +6,7 @@
TESTSDIR= ${TESTSBASE}/net/net
TESTS_C= t_unix
TESTS_C+= t_tcp
TESTS_C+= t_udp
TESTS_C+= t_pktinfo
.if (${MKRUMP} != "no")

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_pktinfo.c,v 1.1 2013/06/27 20:01:24 christos Exp $ */
/* $NetBSD: t_pktinfo.c,v 1.2 2013/10/19 17:45:01 christos Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_pktinfo.c,v 1.1 2013/06/27 20:01:24 christos Exp $");
__RCSID("$NetBSD: t_pktinfo.c,v 1.2 2013/10/19 17:45:01 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -141,6 +141,7 @@ receive(int s) {
printf("%s message received on address %s at interface %d\n",
m, inet_ntoa(ipi->ipi_addr), ipi->ipi_ifindex);
#else
__USE(m);
ATF_REQUIRE_MSG(ipi->ipi_addr.s_addr == htonl(INADDR_LOOPBACK),
"address 0x%x != 0x%x", ipi->ipi_addr.s_addr,
htonl(INADDR_LOOPBACK));

220
tests/net/net/t_tcp.c Normal file
View File

@@ -0,0 +1,220 @@
/* $NetBSD: t_tcp.c,v 1.3 2013/10/17 12:53:28 christos Exp $ */
/*-
* Copyright (c) 2013 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 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>
#ifdef __RCSID
__RCSID("$Id: t_tcp.c,v 1.3 2013/10/17 12:53:28 christos Exp $");
#endif
/* Example code. Should block; does with accept not paccept. */
/* Original by: Justin Cormack <justin@specialbusrvrervice.com> */
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <err.h>
#include <stdlib.h>
#include <signal.h>
#ifdef TEST
#define FAIL(msg, ...) err(EXIT_FAILURE, msg, ## __VA_ARGS__)
#else
#include <atf-c.h>
#define FAIL(msg, ...) ATF_CHECK_MSG(0, msg, ## __VA_ARGS__); goto fail
#endif
static void
ding(int al)
{
}
static void
paccept_block(bool pacceptblock, bool fcntlblock)
{
int srvr = -1, clnt = -1, as = -1;
int ok, fl, n;
char buf[10];
struct sockaddr_in sin, ba;
struct sigaction sa;
srvr = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (srvr == -1)
FAIL("socket");
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
#ifdef BSD4_4
sin.sin_len = sizeof(sin);
#endif
sin.sin_port = htons(0);
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
ok = bind(srvr, (const struct sockaddr *)&sin, (socklen_t)sizeof(sin));
if (ok == -1)
FAIL("bind");
socklen_t addrlen = sizeof(struct sockaddr_in);
ok = getsockname(srvr, (struct sockaddr *)&ba, &addrlen);
if (ok == -1)
FAIL("getsockname");
ok = listen(srvr, SOMAXCONN);
if (ok == -1)
FAIL("listen");
clnt = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (clnt == -1)
FAIL("socket");
/* may not connect first time */
ok = connect(clnt, (struct sockaddr *) &ba, addrlen);
as = paccept(srvr, NULL, NULL, NULL, pacceptblock ? 0 : SOCK_NONBLOCK);
ok = connect(clnt, (struct sockaddr *) &ba, addrlen);
if (ok == -1 && errno != EISCONN)
FAIL("both connects failed");
#if 0
fl = fcntl(srvr, F_GETFL, 0);
if (fl == -1)
FAIL("fnctl getfl");
ok = fcntl(srvr, F_SETFL, fl & ~O_NONBLOCK);
if (ok == -1)
FAIL("fnctl setfl");
#endif
if (as == -1) { /* not true under NetBSD */
as = paccept(srvr, NULL, NULL, NULL, pacceptblock ? 0 : SOCK_NONBLOCK);
if (as == -1)
FAIL("paccept");
}
if (fcntlblock) {
fl = fcntl(as, F_GETFL, 0);
if (fl == -1)
FAIL("fnctl");
if (fl != (O_RDWR|O_NONBLOCK))
FAIL("fl 0x%x != 0x%x\n", fl, O_RDWR|O_NONBLOCK);
ok = fcntl(as, F_SETFL, fl & ~O_NONBLOCK);
if (ok == -1)
FAIL("fnctl setfl");
fl = fcntl(as, F_GETFL, 0);
if (fl & O_NONBLOCK)
FAIL("fl non blocking after reset");
}
sa.sa_handler = ding;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(SIGALRM, &sa, NULL);
alarm(1);
n = read(as, buf, 10);
if (pacceptblock || fcntlblock) {
if (n == -1 && errno != EINTR)
FAIL("read");
} else {
if (n != -1 || errno != EWOULDBLOCK)
FAIL("read");
}
return;
fail:
close(srvr);
close(clnt);
close(as);
}
#ifndef TEST
ATF_TC(paccept_reset_nonblock);
ATF_TC_HEAD(paccept_reset_nonblock, tc)
{
atf_tc_set_md_var(tc, "descr", "Check that paccept(2) resets "
"the non-blocking flag on non-blocking sockets");
}
ATF_TC_BODY(paccept_reset_nonblock, tc)
{
paccept_block(true, false);
}
ATF_TC(fcntl_reset_nonblock);
ATF_TC_HEAD(fcntl_reset_nonblock, tc)
{
atf_tc_set_md_var(tc, "descr", "Check that fcntl(2) resets "
"the non-blocking flag on non-blocking sockets");
}
ATF_TC_BODY(fcntl_reset_nonblock, tc)
{
paccept_block(false, true);
}
ATF_TC(paccept_nonblock);
ATF_TC_HEAD(paccept_nonblock, tc)
{
atf_tc_set_md_var(tc, "descr", "Check that fcntl(2) resets "
"the non-blocking flag on non-blocking sockets");
}
ATF_TC_BODY(paccept_nonblock, tc)
{
paccept_block(false, false);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, paccept_reset_nonblock);
ATF_TP_ADD_TC(tp, fcntl_reset_nonblock);
ATF_TP_ADD_TC(tp, paccept_nonblock);
return atf_no_error();
}
#else
int
main(int argc, char *argv[])
{
paccept_block(false);
paccept_block(true);
return 0;
}
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_unix.c,v 1.6 2011/10/04 16:28:26 christos Exp $ */
/* $NetBSD: t_unix.c,v 1.11 2013/11/13 21:41:23 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,8 +37,20 @@
*/
#include <sys/cdefs.h>
__RCSID("$Id: t_unix.c,v 1.6 2011/10/04 16:28:26 christos Exp $");
#ifdef __RCSID
__RCSID("$Id: t_unix.c,v 1.11 2013/11/13 21:41:23 christos Exp $");
#else
#define getprogname() argv[0]
#endif
#ifdef __linux__
#define LX -1
#else
#define LX
#endif
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <err.h>
#include <errno.h>
@@ -46,19 +58,45 @@ __RCSID("$Id: t_unix.c,v 1.6 2011/10/04 16:28:26 christos Exp $");
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdbool.h>
#ifdef TEST
#define FAIL(msg, ...) err(EXIT_FAILURE, msg, ## __VA_ARGS__)
#else
#include <atf-c.h>
#define FAIL(msg, ...) ATF_CHECK_MSG(0, msg, ## __VA_ARGS__)
#define FAIL(msg, ...) \
do { \
ATF_CHECK_MSG(0, msg, ## __VA_ARGS__); \
goto fail; \
} while (/*CONSTCOND*/0)
#endif
static __dead int
#define OF offsetof(struct sockaddr_un, sun_path)
static void
print(const char *msg, struct sockaddr_un *addr, socklen_t len)
{
size_t i;
printf("%s: client socket length: %zu\n", msg, (size_t)len);
printf("%s: client family %d\n", msg, addr->sun_family);
#ifdef BSD4_4
printf("%s: client len %d\n", msg, addr->sun_len);
#endif
printf("%s: socket name: ", msg);
for (i = 0; i < len - OF; i++) {
int ch = addr->sun_path[i];
if (ch < ' ' || '~' < ch)
printf("\\x%02x", ch);
else
printf("%c", ch);
}
printf("\n");
}
static int
acc(int s)
{
char guard1;
@@ -68,32 +106,56 @@ acc(int s)
guard1 = guard2 = 's';
memset(&sun, 0, sizeof(sun));
len = sizeof(sun);
if (accept(s, (struct sockaddr *)&sun, &len) == -1)
if ((s = accept(s, (struct sockaddr *)&sun, &len)) == -1)
FAIL("accept");
if (guard1 != 's')
errx(EXIT_FAILURE, "guard1 = '%c'", guard1);
FAIL("guard1 = '%c'", guard1);
if (guard2 != 's')
errx(EXIT_FAILURE, "guard2 = '%c'", guard2);
close(s);
exit(0);
FAIL("guard2 = '%c'", guard2);
#ifdef DEBUG
print("accept", &sun, len);
#endif
if (len != 2)
FAIL("len %d != 2", len);
if (sun.sun_family != AF_UNIX)
FAIL("sun->sun_family %d != AF_UNIX", sun.sun_family);
#ifdef BSD4_4
if (sun.sun_len != 2)
FAIL("sun->sun_len %d != 2", sun.sun_len);
#endif
for (size_t i = 0; i < sizeof(sun.sun_path); i++)
if (sun.sun_path[i])
FAIL("sun.sun_path[%zu] %d != NULL", i,
sun.sun_path[i]);
return s;
fail:
if (s != -1)
close(s);
return -1;
}
static int
test(size_t len)
test(bool closeit, size_t len)
{
struct sockaddr_un *sun;
int s, s2;
size_t slen;
socklen_t sl;
int srvr = -1, clnt = -1, acpt = -1;
struct sockaddr_un *sock_addr = NULL, *sun = NULL;
socklen_t sock_addrlen;
slen = len + offsetof(struct sockaddr_un, sun_path) + 1;
srvr = socket(AF_UNIX, SOCK_STREAM, 0);
if (srvr == -1)
FAIL("socket(srvrer)");
slen = len + OF + 1;
if ((sun = calloc(1, slen)) == NULL)
FAIL("calloc");
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s == -1)
srvr = socket(AF_UNIX, SOCK_STREAM, 0);
if (srvr == -1)
FAIL("socket");
memset(sun->sun_path, 'a', len);
@@ -101,35 +163,99 @@ test(size_t len)
(void)unlink(sun->sun_path);
sl = SUN_LEN(sun);
#ifdef BSD4_4
sun->sun_len = sl;
#endif
sun->sun_family = AF_UNIX;
if (bind(s, (struct sockaddr *)sun, sl) == -1) {
if (errno == EINVAL && sl >= 256)
if (bind(srvr, (struct sockaddr *)sun, sl) == -1) {
if (errno == EINVAL && sl >= 256) {
close(srvr);
return -1;
}
FAIL("bind");
}
if (listen(s, 5) == -1)
if (listen(srvr, SOMAXCONN) == -1)
FAIL("listen");
switch (fork()) {
case -1:
FAIL("fork");
case 0:
acc(s);
/*NOTREACHED*/
default:
sleep(1);
s2 = socket(AF_UNIX, SOCK_STREAM, 0);
if (s2 == -1)
FAIL("socket");
if (connect(s2, (struct sockaddr *)sun, sl) == -1)
FAIL("connect");
close(s2);
break;
clnt = socket(AF_UNIX, SOCK_STREAM, 0);
if (clnt == -1)
FAIL("socket(client)");
if (connect(clnt, (const struct sockaddr *)sun, sl) == -1)
FAIL("connect");
if (closeit) {
if (close(clnt) == -1)
FAIL("close");
clnt = -1;
}
acpt = acc(srvr);
#if 0
/*
* Both linux and NetBSD return ENOTCONN, why?
*/
if (!closeit) {
socklen_t peer_addrlen;
sockaddr_un peer_addr;
peer_addrlen = sizeof(peer_addr);
memset(&peer_addr, 0, sizeof(peer_addr));
if (getpeername(srvr, (struct sockaddr *)&peer_addr,
&peer_addrlen) == -1)
FAIL("getpeername");
print("peer", &peer_addr, peer_addrlen);
}
#endif
if ((sock_addr = calloc(1, slen)) == NULL)
FAIL("calloc");
sock_addrlen = slen;
if (getsockname(srvr, (struct sockaddr *)sock_addr, &sock_addrlen)
== -1)
FAIL("getsockname");
print("sock", sock_addr, sock_addrlen);
if (sock_addr->sun_family != AF_UNIX)
FAIL("sock_addr->sun_family %d != AF_UNIX",
sock_addr->sun_family);
len += OF;
if (sock_addrlen LX != len)
FAIL("sock_addr_len %zu != %zu", (size_t)sock_addrlen, len);
#ifdef BSD4_4
if (sock_addr->sun_len != sl)
FAIL("sock_addr.sun_len %d != %zu", sock_addr->sun_len,
(size_t)sl);
#endif
for (size_t i = 0; i < slen - OF; i++)
if (sock_addr->sun_path[i] != sun->sun_path[i])
FAIL("sock_addr.sun_path[%zu] %d != "
"sun->sun_path[%zu] %d\n", i,
sock_addr->sun_path[i], i, sun->sun_path[i]);
if (acpt != -1)
(void)close(acpt);
if (srvr != -1)
(void)close(srvr);
if (clnt != -1 && !closeit)
(void)close(clnt);
free(sock_addr);
free(sun);
return 0;
fail:
if (acpt != -1)
(void)close(acpt);
if (srvr != -1)
(void)close(srvr);
if (clnt != -1 && !closeit)
(void)close(clnt);
free(sock_addr);
free(sun);
return -1;
}
#ifndef TEST
@@ -145,7 +271,8 @@ ATF_TC_HEAD(sockaddr_un_len_exceed, tc)
ATF_TC_BODY(sockaddr_un_len_exceed, tc)
{
ATF_REQUIRE_MSG(test(254) == -1, "test(254): %s", strerror(errno));
ATF_REQUIRE_MSG(test(false, 254) == -1, "test(false, 254): %s",
strerror(errno));
}
ATF_TC(sockaddr_un_len_max);
@@ -159,7 +286,22 @@ ATF_TC_HEAD(sockaddr_un_len_max, tc)
ATF_TC_BODY(sockaddr_un_len_max, tc)
{
ATF_REQUIRE_MSG(test(253) == 0, "test(253): %s", strerror(errno));
ATF_REQUIRE_MSG(test(false, 253) == 0, "test(false, 253): %s",
strerror(errno));
}
ATF_TC(sockaddr_un_closed);
ATF_TC_HEAD(sockaddr_un_closed, tc)
{
atf_tc_set_md_var(tc, "descr", "Check that we can use the accepted "
"address of unix domain socket when closed");
}
ATF_TC_BODY(sockaddr_un_closed, tc)
{
ATF_REQUIRE_MSG(test(true, 100) == 0, "test(true, 100): %s",
strerror(errno));
}
ATF_TP_ADD_TCS(tp)
@@ -167,6 +309,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, sockaddr_un_len_exceed);
ATF_TP_ADD_TC(tp, sockaddr_un_len_max);
ATF_TP_ADD_TC(tp, sockaddr_un_closed);
return atf_no_error();
}
#else
@@ -179,6 +322,7 @@ main(int argc, char *argv[])
fprintf(stderr, "Usage: %s <len>\n", getprogname());
return EXIT_FAILURE;
}
test(atoi(argv[1]));
test(false, atoi(argv[1]));
test(true, atoi(argv[1]));
}
#endif

View File

@@ -1,4 +1,4 @@
/* $NetBSD: t_copy.c,v 1.1 2010/11/09 15:25:20 pooka Exp $ */
/* $NetBSD: t_copy.c,v 1.2 2013/07/26 16:09:48 njoly Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -56,14 +56,16 @@ ATF_TC_HEAD(copyoutstr, tc)
atf_tc_set_md_var(tc, "descr", "Tests copyoutstr()");
}
typedef int (copy_fn)(const void *, void *, size_t, size_t *);
typedef int (copystr_fn)(const void *, void *, size_t, size_t *);
typedef int (copy_fn)(const void *, void *, size_t);
extern copy_fn rumpns_copystr, rumpns_copyinstr, rumpns_copyoutstr;
extern copystr_fn rumpns_copystr, rumpns_copyinstr, rumpns_copyoutstr;
extern copy_fn rumpns_copyin, rumpns_copyout;
#define TESTSTR "jippii, lisaa puuroa"
static void
dotest(copy_fn *thefun)
dotest(copystr_fn *thefun)
{
char buf[sizeof(TESTSTR)+1];
size_t len;
@@ -108,12 +110,30 @@ ATF_TC_BODY(copyoutstr, tc)
dotest(rumpns_copyoutstr);
}
ATF_TC(copy_efault);
ATF_TC_HEAD(copy_efault, tc)
{
atf_tc_set_md_var(tc, "descr", "Tests that copy(9) functions can return EFAULT");
}
ATF_TC_BODY(copy_efault, tc)
{
char buf[1024];
ATF_REQUIRE_EQ(rumpns_copyin(NULL, buf, sizeof(buf)), EFAULT);
ATF_REQUIRE_EQ(rumpns_copyout(buf, NULL, sizeof(buf)), EFAULT);
ATF_REQUIRE_EQ(rumpns_copyinstr(NULL, buf, sizeof(buf), NULL), EFAULT);
ATF_REQUIRE_EQ(rumpns_copyoutstr(buf, NULL, sizeof(buf), NULL), EFAULT);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, copystr);
ATF_TP_ADD_TC(tp, copyinstr);
ATF_TP_ADD_TC(tp, copyoutstr);
ATF_TP_ADD_TC(tp, copy_efault);
return atf_no_error();
}

View File

@@ -1,4 +1,4 @@
# $NetBSD: t_shmif.sh,v 1.1 2011/03/10 14:09:46 pooka Exp $
# $NetBSD: t_shmif.sh,v 1.2 2013/09/09 19:27:49 pooka Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -27,9 +27,11 @@
atf_test_case crossping cleanup
NKERN=8
crossping_head()
{
atf_set "descr" "start 16 rump kernels on one shmif bus and crossping"
atf_set "descr" "run $NKERN rump kernels on one shmif bus and crossping"
}
startserver()
@@ -51,11 +53,11 @@ pingothers()
crossping_body()
{
for x in `jot 16` ; do startserver $x ; done
for x in `jot 16`
for x in `jot ${NKERN}` ; do startserver $x ; done
for x in `jot ${NKERN}`
do
export RUMP_SERVER=unix://sock${x}
for y in `jot 16`
for y in `jot ${NKERN}`
do
[ ${y} -eq ${x} ] && continue
atf_check -s exit:0 -o ignore -e ignore \
@@ -67,7 +69,7 @@ crossping_body()
crossping_cleanup()
{
for x in `jot 16` ; do RUMP_SERVER=unix://sock${x} rump.halt ; done
for x in `jot ${NKERN}` ; do RUMP_SERVER=unix://sock${x} rump.halt ;done
:
}

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.17 2012/11/20 08:02:06 agc Exp $
# $NetBSD: Makefile,v 1.18 2013/08/10 22:36:16 dholland Exp $
#
.include <bsd.own.mk>
@@ -8,6 +8,6 @@ TESTSDIR= ${TESTSBASE}/usr.bin
TESTS_SUBDIRS= awk basename bzip2 cc cmp config cut \
diff dirname find grep gzip id infocmp jot m4 make mkdep \
nbperf netpgpverify pr rump_server shmif_dumpbus sdiff \
sed sort tmux unifdef xlint
sed sort tmux tr unifdef xlint
.include <bsd.test.mk>

View File

@@ -22,8 +22,8 @@ shared.2.1
shared.2.1
shared.2.99
shared.2.99
make: Graph cycles through `cycle.2.99'
make: Graph cycles through `cycle.2.98'
make: Graph cycles through `cycle.2.97'
make[1]: Graph cycles through `cycle.2.99'
make[1]: Graph cycles through `cycle.2.98'
make[1]: Graph cycles through `cycle.2.97'
cycle.1.99
cycle.1.99

View File

@@ -0,0 +1,9 @@
# $NetBSD: Makefile,v 1.1 2013/08/10 22:36:16 dholland Exp $
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/usr.bin/tr
TESTS_SH= t_basic
.include <bsd.test.mk>

195
tests/usr.bin/tr/t_basic.sh Normal file
View File

@@ -0,0 +1,195 @@
# $NetBSD: t_basic.sh,v 1.3 2013/08/11 01:50:02 dholland Exp $
#
# Copyright (c) 2013 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by David A. Holland.
#
# 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.
#
#
# tr -d: delete character
#
atf_test_case dopt
dopt_head() {
atf_set "descr" "Tests for tr -d"
}
dopt_body() {
atf_check -o inline:'abcde\n' -x 'echo abcde | tr -d x'
atf_check -o inline:'abde\n' -x 'echo abcde | tr -d c'
atf_check -o inline:'ace\n' -x 'echo abcde | tr -d bd'
atf_check -o inline:'ae\n' -x 'echo abcde | tr -d b-d'
atf_check -o inline:'b\n' -x 'echo abcde | tr -d ac-e'
atf_check -o inline:'d\n' -x 'echo abcde | tr -d a-ce'
atf_check -o inline:'aei\n' -x 'echo abcdefghi | tr -d b-df-h'
atf_check -o inline:'' -x 'echo abcde | tr -c -d x'
atf_check -o inline:'c' -x 'echo abcde | tr -c -d c'
atf_check -o inline:'bd' -x 'echo abcde | tr -c -d bd'
atf_check -o inline:'bcd' -x 'echo abcde | tr -c -d b-d'
atf_check -o inline:'acde' -x 'echo abcde | tr -c -d ac-e'
atf_check -o inline:'abce' -x 'echo abcde | tr -c -d a-ce'
atf_check -o inline:'bcdfgh' -x 'echo abcdefghi | tr -c -d b-df-h'
# see if escape codes work
atf_check -o inline:'splice' -x '(echo spl; echo ice) | tr -d '"'\n'"
atf_check -o inline:'splice' -x '(echo spl; echo ice) | tr -d '"'\012'"
# see if escape codes work when followed by other things
atf_check -o inline:'slice' -x '(echo spl; echo ice) | tr -d '"'\n'p"
atf_check -o inline:'slice' -x '(echo spl; echo ice) | tr -d '"'\012'p"
# see if the [=x=] syntax works
atf_check -o inline:'abde\n' -x 'echo abcde | tr -d '"'[=c=]'"
atf_check -o inline:'bde\n' -x 'echo abcde | tr -d '"'[=c=]'a"
# make sure 0 works
# (ignore stderr as dd blabbers to it)
atf_check -e ignore -o inline:'ab\n' \
-x '(echo -n a; dd if=/dev/zero bs=3 count=1; echo b) | tr -d '"'\0'"
# test posix classes
atf_check -o inline:'.\n' -x 'echo aAzZ.123 | tr -d '"'[:alnum:]'"
atf_check -o inline:'.123\n' -x 'echo aAzZ.123 | tr -d '"'[:alpha:]'"
atf_check -o inline:'az\n' -x 'echo "a z" | tr -d '"'[:blank:]'"
atf_check -o inline:'az' -x '(echo a; echo z) | tr -d '"'[:cntrl:]'"
atf_check -o inline:'aAzZ.\n' -x 'echo aAzZ.123 | tr -d '"'[:digit:]'"
atf_check -o inline:' \n' -x 'echo "a z.123" | tr -d '"'[:graph:]'"
atf_check -o inline:'AZ.123\n' -x 'echo aAzZ.123 | tr -d '"'[:lower:]'"
atf_check -o inline:'\n' -x 'echo aAzZ.123 | tr -d '"'[:print:]'"
atf_check -o inline:'aAzZ12\n' -x 'echo aAzZ.12 | tr -d '"'[:punct:]'"
atf_check -o inline:'az' -x 'echo "a z" | tr -d '"'[:space:]'"
atf_check -o inline:'az.123\n' -x 'echo aAzZ.123 | tr -d '"'[:upper:]'"
atf_check -o inline:'zZ.\n' -x 'echo aAzZ.123 | tr -d '"'[:xdigit:]'"
}
#
# tr -s: squeeze duplicate character runs
#
atf_test_case sopt
sopt_head() {
atf_set "descr" "Tests for tr -s"
}
sopt_body() {
atf_check -o inline:'abcde\n' -x 'echo abcde | tr -s x'
atf_check -o inline:'abcde\n' -x 'echo abcde | tr -s c'
atf_check -o inline:'abcde\n' -x 'echo abccccde | tr -s c'
atf_check -o inline:'abcde\n' -x 'echo abbbcddde | tr -s bd'
atf_check -o inline:'abcde\n' -x 'echo abbbcccddde | tr -s b-d'
atf_check -o inline:'acac\n' -x 'echo acac | tr -s c'
atf_check -o inline:'acac\n' -x 'echo accacc | tr -s c'
atf_check -o inline:'abcde\n' -x 'echo abcde | tr -c -s x'
atf_check -o inline:'abcde\n' -x 'echo abcde | tr -c -s c'
atf_check -o inline:'abcccde\n' -x 'echo abcccde | tr -c -s c'
atf_check -o inline:'abbbcddde\n' -x 'echo abbbcddde | tr -c -s bd'
atf_check -o inline:'abbbccddde\n' -x 'echo abbbccddde | tr -c -s b-d'
atf_check -o inline:'abcccde\n' -x 'echo aaabcccde | tr -c -s b-d'
}
#
# tr -ds: both -d and -s at once
#
atf_test_case dsopt
dsopt_head() {
atf_set "descr" "Tests for tr -ds"
}
dsopt_body() {
atf_check -o inline:'abcde\n' -x 'echo abcde | tr -ds x y'
atf_check -o inline:'abde\n' -x 'echo abcde | tr -ds c x'
atf_check -o inline:'abcde\n' -x 'echo abcde | tr -ds x c'
atf_check -o inline:'abde\n' -x 'echo abcde | tr -ds c c'
atf_check -o inline:'abde\n' -x 'echo abcccde | tr -ds c x'
atf_check -o inline:'abcde\n' -x 'echo abcccde | tr -ds x c'
atf_check -o inline:'abde\n' -x 'echo abcccde | tr -ds c c'
# -c complements only the first string
atf_check -o inline:'' -x 'echo abcde | tr -c -ds x y'
atf_check -o inline:'c' -x 'echo abcde | tr -c -ds c x'
atf_check -o inline:'' -x 'echo abcde | tr -c -ds x c'
atf_check -o inline:'c' -x 'echo abcde | tr -c -ds c c'
atf_check -o inline:'ccc' -x 'echo abcccde | tr -c -ds c x'
atf_check -o inline:'' -x 'echo abcccde | tr -c -ds x c'
atf_check -o inline:'c' -x 'echo abcccde | tr -c -ds c c'
}
#
# test substitution
#
atf_test_case subst
subst_head() {
atf_set "descr" "Tests for tr substitution"
}
subst_body() {
atf_check -o inline:'abcde\n' -x 'echo abcde | tr a-c a-c'
atf_check -o inline:'cbade\n' -x 'echo abcde | tr a-c cba'
atf_check -o inline:'abcde\n' -x 'echo abcde | tr a-z a-z'
atf_check -o inline:'bcdef\n' -x 'echo abcde | tr a-z b-za'
atf_check -o inline:'zabcd\n' -x 'echo abcde | tr b-za a-z'
atf_check -o inline:'bbbbb\n' -x 'echo ababa | tr a b'
atf_check -o inline:'furrfu\n' -x 'echo sheesh | tr a-z n-za-m'
atf_check -o inline:'furrfu\n' -x 'echo sheesh | tr n-za-m a-z'
atf_check -o inline:'ABCDE\n' -x 'echo abcde | tr a-z A-Z'
atf_check -o inline:'ABC\n' \
-x 'echo abc | tr '"'[:lower:]' '[:upper:]'"
# If you don't give enough substitution chars the last is repeated.
atf_check -o inline:'bozoo\n' -x 'echo abcde | tr a-z bozo'
atf_check -o inline:'qaaaa\n' -x 'echo abcde | tr a-z qa'
# You can use -s with substitution.
atf_check -o inline:'cbade\n' -x 'echo abcde | tr -s a-c cba'
atf_check -o inline:'cbaddee\n' -x 'echo aabbccddee | tr -s a-c cba'
}
#
# test substitution with -c (does not currently work)
#
atf_test_case csubst
csubst_head() {
atf_set "descr" "Tests for tr substitution with -c"
}
csubst_body() {
atf_check -o inline:'abcde\n' -x \
'echo abcde | tr -c '"'\0-ac-\377' b"
atf_check -o inline:'abcde\n' -x \
'echo abcde | tr -c '"'\0-ad-\377' bc"
atf_check -o inline:'QUACK\n' -x \
'echo ABCDE | tr -c '"'\0-@' QUACK"
}
atf_init_test_cases() {
atf_add_test_case dopt
atf_add_test_case sopt
atf_add_test_case dsopt
atf_add_test_case subst
atf_add_test_case csubst
}

View File

@@ -6,13 +6,13 @@
# .
/set type=file nlink=1
. type=dir nlink=4
a.symlink.1 type=link size=8 link=a.file.1
a.symlink.1 type=link link=a.file.1
top.dangling \
type=link size=11 link=nonexistent
type=link link=nonexistent
top.file.1 size=18 \
sha256=74c53aaf0cd9543b7efad969de1058ee38859134ba467500b849811fc3513195
top.symlink.b \
type=link size=1 link=b
type=link link=b
# ./a
a type=dir nlink=4

View File

@@ -29,6 +29,9 @@
# are expected to differ from one run to another.
#
# mtree is not in the default user PATH on MINIX
export PATH=$PATH:/usr/sbin
h_postprocess()
{
sed -e '