From 8864cde3495dbfd6b476c1b77a8bde035e1cf000 Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 10 Feb 2017 01:13:12 +0000 Subject: MFC r305358,r305449,r305451,r306367,r306397,r309474: This also contains a merge of ^/projects/netbsd-tests-update-12@r304035 . This change never hit ^/head because bin/cat's behavior was changed (on ^/head) to match NetBSD. PR: 210607 r305358: Update contrib/netbsd-tests with new content from NetBSD This updates the snapshot from 09/30/2014 to 08/11/2016 This brings in a number of new testcases from upstream, most notably: - bin/cat - lib/libc - lib/msun - lib/libthr - usr.bin/sort lib/libc/tests/stdio/open_memstream_test.c was moved to lib/libc/tests/stdio/open_memstream2_test.c to accomodate the new open_memstream test from NetBSD. Tested on: amd64 (VMware fusion VM; various bare metal platforms); i386 (VMware fusion VM); make tinderbox r305449: Install h_db to unbreak some of the lib/libc/db testcases after r305358 r305451: Fix lib/libc/rpc test assumptions added in r305358 - Require root in the tcp/udp subtests (it's needed on FreeBSD when registering services). - Skip the tests if service registration fails. r306367 (by br): Allow up to 6 arguments only on MIPS. r306397 (by br): Use right piece of code for FreeBSD. r309474: Don't build :strvis_locale if VIS_NOLOCALE is undefined The copy of contrib/libc-vis on ^/stable/10 doesn't contain all of the features in the ^/stable/11 // ^/head version, including VIS_NOLOCALE. The risk is lower in conditionally running the test instead of backporting the newer version of libc-vis --- contrib/netbsd-tests/lib/libc/rpc/t_rpc.c | 279 ++++++++++++++++++++++++++++-- 1 file changed, 266 insertions(+), 13 deletions(-) (limited to 'contrib/netbsd-tests/lib/libc/rpc') diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c index a9715cf..28a8763 100644 --- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c +++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c @@ -1,18 +1,19 @@ -/* $NetBSD: t_rpc.c,v 1.3 2013/02/28 15:56:53 christos Exp $ */ +/* $NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $ */ #include -__RCSID("$NetBSD: t_rpc.c,v 1.3 2013/02/28 15:56:53 christos Exp $"); +__RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); #include #include #include #include +#include #include #include #include +#include #include - #ifndef TEST #include @@ -23,11 +24,24 @@ __RCSID("$NetBSD: t_rpc.c,v 1.3 2013/02/28 15:56:53 christos Exp $"); return; \ } while(/*CONSTCOND*/0) +#ifdef __FreeBSD__ +#define SKIPXI(ev, msg, ...) do { \ + atf_tc_skip(msg, __VA_ARGS__); \ + return ev; \ +} while(/*CONSTCOND*/0) +#endif + #else #define ERRX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) #define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) #endif +#ifdef DEBUG +#define DPRINTF(...) printf(__VA_ARGS__) +#else +#define DPRINTF(...) +#endif + #define RPCBPROC_NULL 0 @@ -51,7 +65,7 @@ reply(caddr_t replyp, struct netbuf * raddrp, struct netconfig * nconf) #define __rpc_control rpc_control #endif -extern bool __rpc_control(int, void *); +extern bool_t __rpc_control(int, void *); static void onehost(const char *host, const char *transp) @@ -86,9 +100,146 @@ onehost(const char *host, const char *transp) reply(NULL, &addr, NULL); } +#define PROGNUM 0x81 +#define VERSNUM 0x01 +#define PLUSONE 1 +#define DESTROY 2 + +static struct timeval tout = {1, 0}; + +static void +server(struct svc_req *rqstp, SVCXPRT *transp) +{ + int num; + + DPRINTF("Starting server\n"); + + switch (rqstp->rq_proc) { + case NULLPROC: + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); + return; + case PLUSONE: + break; + case DESTROY: + if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) + ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); + svc_destroy(transp); + exit(0); + default: + svcerr_noproc(transp); + return; + } + + if (!svc_getargs(transp, (xdrproc_t)xdr_int, (void *)&num)) { + svcerr_decode(transp); + return; + } + DPRINTF("About to increment\n"); + num++; + if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num)) + ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1); + DPRINTF("Leaving server procedure.\n"); +} + +static int +rawtest(const char *arg) +{ + CLIENT *clnt; + SVCXPRT *svc; + int num, resp; + enum clnt_stat rv; + + if (arg) + num = atoi(arg); + else + num = 0; + + svc = svc_raw_create(); + if (svc == NULL) + ERRX(EXIT_FAILURE, "Cannot create server %d", num); + if (!svc_reg(svc, PROGNUM, VERSNUM, server, NULL)) + ERRX(EXIT_FAILURE, "Cannot register server %d", num); + + clnt = clnt_raw_create(PROGNUM, VERSNUM); + if (clnt == NULL) + ERRX(EXIT_FAILURE, "%s", + clnt_spcreateerror("clnt_raw_create")); + rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, + (xdrproc_t)xdr_int, (void *)&resp, tout); + if (rv != RPC_SUCCESS) + ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); + DPRINTF("Got %d\n", resp); + clnt_destroy(clnt); + svc_destroy(svc); + if (++num != resp) + ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); + + return EXIT_SUCCESS; +} + +static int +regtest(const char *hostname, const char *transp, const char *arg, int p) +{ + CLIENT *clnt; + int num, resp; + enum clnt_stat rv; + pid_t pid; + + if (arg) + num = atoi(arg); + else + num = 0; + +#ifdef __NetBSD__ + svc_fdset_init(p ? SVC_FDSET_POLL : 0); +#endif + if (!svc_create(server, PROGNUM, VERSNUM, transp)) +#ifdef __NetBSD__ + ERRX(EXIT_FAILURE, "Cannot create server %d", num); +#else + { + SKIPXI(EXIT_FAILURE, "Cannot create server %d", num); + } +#endif + + switch ((pid = fork())) { + case 0: + DPRINTF("Calling svc_run\n"); + svc_run(); + ERRX(EXIT_FAILURE, "svc_run returned %d!", num); + case -1: + ERRX(EXIT_FAILURE, "Fork failed (%s)", strerror(errno)); + default: + sleep(1); + break; + } + + DPRINTF("Initializing client\n"); + clnt = clnt_create(hostname, PROGNUM, VERSNUM, transp); + if (clnt == NULL) + ERRX(EXIT_FAILURE, "%s", + clnt_spcreateerror("clnt_raw_create")); + rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num, + (xdrproc_t)xdr_int, (void *)&resp, tout); + if (rv != RPC_SUCCESS) + ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); + DPRINTF("Got %d\n", resp); + if (++num != resp) + ERRX(EXIT_FAILURE, "expected %d got %d", num, resp); + rv = clnt_call(clnt, DESTROY, (xdrproc_t)xdr_void, NULL, + (xdrproc_t)xdr_void, NULL, tout); + if (rv != RPC_SUCCESS) + ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv)); + clnt_destroy(clnt); + + return EXIT_SUCCESS; +} + + #ifdef TEST static void -allhosts(void) +allhosts(const char *transp) { enum clnt_stat clnt_stat; @@ -103,28 +254,49 @@ int main(int argc, char *argv[]) { int ch; + int s, p; const char *transp = "udp"; - - while ((ch = getopt(argc, argv, "ut")) != -1) + p = s = 0; + while ((ch = getopt(argc, argv, "prstu")) != -1) switch (ch) { + case 'p': + p = 1; + break; + case 's': + s = 1; + break; case 't': transp = "tcp"; break; case 'u': transp = "udp"; break; + case 'r': + transp = NULL; + break; default: - fprintf(stderr, "Usage: %s -[t|u] [...]\n", + fprintf(stderr, + "Usage: %s -[r|s|t|u] [...]\n", getprogname()); return EXIT_FAILURE; } - if (argc == optind) - allhosts(); - else - for (; optind < argc; optind++) - onehost(argv[optind], transp); + if (argc == optind) { + if (transp) + allhosts(transp); + else + rawtest(NULL); + } else { + for (; optind < argc; optind++) { + if (transp) + s == 0 ? + onehost(argv[optind], transp) : + regtest(argv[optind], transp, "1", p); + else + rawtest(argv[optind]); + } + } return EXIT_SUCCESS; } @@ -156,10 +328,91 @@ ATF_TC_BODY(get_svc_addr_udp, tc) } +ATF_TC(raw); +ATF_TC_HEAD(raw, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks svc raw"); +} + +ATF_TC_BODY(raw, tc) +{ +#ifdef __FreeBSD__ + atf_tc_expect_fail("fails with: clnt_call: " + "RPC: Can't decode result -- PR # 211804"); +#endif + rawtest(NULL); + +} + +ATF_TC(tcp); +ATF_TC_HEAD(tcp, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks svc tcp (select)"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.user", "root"); +#endif +} + +ATF_TC_BODY(tcp, tc) +{ + regtest("localhost", "tcp", "1", 0); + +} + +ATF_TC(udp); +ATF_TC_HEAD(udp, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks svc udp (select)"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.user", "root"); +#endif +} + +ATF_TC_BODY(udp, tc) +{ + regtest("localhost", "udp", "1", 0); + +} + +ATF_TC(tcp_poll); +ATF_TC_HEAD(tcp_poll, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks svc tcp (poll)"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.user", "root"); +#endif +} + +ATF_TC_BODY(tcp_poll, tc) +{ + regtest("localhost", "tcp", "1", 1); + +} + +ATF_TC(udp_poll); +ATF_TC_HEAD(udp_poll, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks svc udp (poll)"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.user", "root"); +#endif +} + +ATF_TC_BODY(udp_poll, tc) +{ + regtest("localhost", "udp", "1", 1); + +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, get_svc_addr_udp); ATF_TP_ADD_TC(tp, get_svc_addr_tcp); + ATF_TP_ADD_TC(tp, raw); + ATF_TP_ADD_TC(tp, tcp); + ATF_TP_ADD_TC(tp, udp); + ATF_TP_ADD_TC(tp, tcp_poll); + ATF_TP_ADD_TC(tp, udp_poll); return atf_no_error(); } -- cgit v1.1 From 750f1a34fcae3f593c018c4da03043557f369339 Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 10 Feb 2017 01:26:49 +0000 Subject: Expect :raw to fail with a SIGSEGV on ^/stable/10 I haven't fully dug into why this happens, but it happens deterministically on ^/stable/10, but not on ^/stable/11 or ^/head PR: 216954 Sponsored by: Dell EMC Isilon --- contrib/netbsd-tests/lib/libc/rpc/t_rpc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'contrib/netbsd-tests/lib/libc/rpc') diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c index 28a8763..0254743 100644 --- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c +++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c @@ -45,6 +45,12 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); #define RPCBPROC_NULL 0 +/* XXX (ngie): for clarity on what needs to be reverted later. */ +#define __FreeBSD_bug_216954__ +#ifdef __FreeBSD_bug_216954__ +#include +#endif + static int reply(caddr_t replyp, struct netbuf * raddrp, struct netconfig * nconf) { @@ -337,9 +343,14 @@ ATF_TC_HEAD(raw, tc) ATF_TC_BODY(raw, tc) { #ifdef __FreeBSD__ +#ifdef __FreeBSD_bug_216954__ + atf_tc_expect_signal(SIGSEGV, + "fails with SIGSEGV only on ^/stable/10 -- bug # 216954"); +#else atf_tc_expect_fail("fails with: clnt_call: " "RPC: Can't decode result -- PR # 211804"); #endif +#endif rawtest(NULL); } -- cgit v1.1 From b39322d52d2dd66d37af0ffcbfb48d13896804ea Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 10 Feb 2017 07:13:16 +0000 Subject: MFC r311925,r311968,r311969,r312008: r311925: Import testcase updates with code contributed back to NetBSD This also (inadvertently) contains an update to contrib/netbsd-tests/lib/libc/sys/t_wait.c (new testcases). In collaboration with: christos@NetBSD.org r311968: Fix lib/libc/sys/access_test after r311925 sys/param.h needs to be #included in order for __FreeBSD_version to be checked r311969: Remove __HAVE_LONG_DOUBLE #define from t_strtod.c and place it in Makefile This is to enable support in other testcases Inspired by lib/msun/tests/Makefile . r312008: Upgrade NetBSD tests to 01.11.2017_23.20 snapshot This contains some new testcases in /usr/tests/...: - .../lib/libc - .../lib/libthr - .../lib/msun - .../sys/kern Tested on: amd64, i386 --- contrib/netbsd-tests/lib/libc/rpc/t_rpc.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'contrib/netbsd-tests/lib/libc/rpc') diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c index 0254743..9c14a22 100644 --- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c +++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c @@ -1,7 +1,7 @@ -/* $NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $ */ +/* $NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $ */ #include -__RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); +__RCSID("$NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $"); #include #include @@ -21,7 +21,7 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); #define SKIPX(ev, msg, ...) do { \ atf_tc_skip(msg, __VA_ARGS__); \ - return; \ + return ev; \ } while(/*CONSTCOND*/0) #ifdef __FreeBSD__ @@ -32,8 +32,8 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $"); #endif #else -#define ERRX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) -#define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__) +#define ERRX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__) +#define SKIPX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__) #endif #ifdef DEBUG @@ -89,7 +89,7 @@ onehost(const char *host, const char *transp) __rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv); if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL) - SKIPX(EXIT_FAILURE, "clnt_create (%s)", clnt_spcreateerror("")); + SKIPX(, "clnt_create (%s)", clnt_spcreateerror("")); tv.tv_sec = 1; tv.tv_usec = 0; @@ -101,7 +101,7 @@ onehost(const char *host, const char *transp) if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv) != RPC_SUCCESS) #endif - ERRX(EXIT_FAILURE, "clnt_call (%s)", clnt_sperror(clnt, "")); + ERRX(, "clnt_call (%s)", clnt_sperror(clnt, "")); clnt_control(clnt, CLGET_SVC_ADDR, (char *) &addr); reply(NULL, &addr, NULL); } @@ -123,13 +123,13 @@ server(struct svc_req *rqstp, SVCXPRT *transp) switch (rqstp->rq_proc) { case NULLPROC: if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) - ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); + ERRX(, "svc_sendreply failed %d", 0); return; case PLUSONE: break; case DESTROY: if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL)) - ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0); + ERRX(, "svc_sendreply failed %d", 0); svc_destroy(transp); exit(0); default: @@ -144,7 +144,7 @@ server(struct svc_req *rqstp, SVCXPRT *transp) DPRINTF("About to increment\n"); num++; if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num)) - ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1); + ERRX(, "svc_sendreply failed %d", 1); DPRINTF("Leaving server procedure.\n"); } @@ -201,13 +201,9 @@ regtest(const char *hostname, const char *transp, const char *arg, int p) svc_fdset_init(p ? SVC_FDSET_POLL : 0); #endif if (!svc_create(server, PROGNUM, VERSNUM, transp)) -#ifdef __NetBSD__ - ERRX(EXIT_FAILURE, "Cannot create server %d", num); -#else { SKIPXI(EXIT_FAILURE, "Cannot create server %d", num); } -#endif switch ((pid = fork())) { case 0: -- cgit v1.1