From: Cyril H. <su...@li...> - 2012-10-10 13:56:59
|
The branch, master, has been updated via daa0d144075de22ba5668ab39bdec869dcceba35 (commit) via e5a53a087cb9aead753ecf8fd0f252151085d737 (commit) via 39451c3c8515e7da4dacb738598065cd3bac126f (commit) via 79d5b6eceaf5ecc13d763c18a11a81ff18a307c1 (commit) via a87dd2ad870711af60d87efd85508f2cbe9124d9 (commit) via 10c580b50c1234e5d7b5a5f4d5b3e21cd40b2bb5 (commit) via e90b03c8f259990fe6a40e75e5e6a4aec046a1db (commit) from cc6cc863b8a7ffa3ddf66cbdba954a45e2cfd72e (commit) - Log ----------------------------------------------------------------- commit daa0d144075de22ba5668ab39bdec869dcceba35 Merge: 39451c3 e5a53a0 Author: Cyril Hrubis <me...@uc...> Date: Wed Oct 10 15:29:56 2012 +0200 Merge ../ltp-dev commit e5a53a087cb9aead753ecf8fd0f252151085d737 Author: Cyril Hrubis <ch...@su...> Date: Wed Oct 10 15:28:34 2012 +0200 kernel/syscalls/send*: Fix tst_kvercmp() I got it wrong, my apologies. Signed-off-by: Cyril Hrubis <ch...@su...> commit 39451c3c8515e7da4dacb738598065cd3bac126f Merge: 79d5b6e cc6cc86 Author: Cyril Hrubis <me...@uc...> Date: Wed Oct 10 15:08:17 2012 +0200 Merge branch 'master' of github.com:linux-test-project/ltp commit 79d5b6eceaf5ecc13d763c18a11a81ff18a307c1 Author: Cyril Hrubis <ch...@su...> Date: Wed Oct 10 14:59:10 2012 +0200 Fix syscalls/send* testcases for kernel >=3.6.0. The return value and errno has changed for send, sendmsg and sendto with invalid flags in kernel commit: cf60af03ca4e71134206809ea892e49b92a88896 net-tcp: Fast Open client - sendmsg(MSG_FASTOPEN) From the LTP code it looks like the case with invalid flags wasn't really detected by kernel at all so I consider that kernel was fixed in this case. Anyway the code now checks for kernel version and set expectations accordingly. Signed-off-by: Cyril Hrubis <ch...@su...> commit a87dd2ad870711af60d87efd85508f2cbe9124d9 Author: Cyril Hrubis <ch...@su...> Date: Wed Oct 10 14:54:13 2012 +0200 syscalls/sendmsg/sendmsg01: Cleanup Cleanup the code first. Signed-off-by: Cyril Hrubis <ch...@su...> commit 10c580b50c1234e5d7b5a5f4d5b3e21cd40b2bb5 Author: Cyril Hrubis <ch...@su...> Date: Wed Oct 10 12:49:02 2012 +0200 syscalls/sendto/sendto01: Cleanup Cleanup the code first. Signed-off-by: Cyril Hrubis <ch...@su...> commit e90b03c8f259990fe6a40e75e5e6a4aec046a1db Author: Cyril Hrubis <ch...@su...> Date: Wed Oct 10 11:40:24 2012 +0200 syscalls/send/send01: Cleanup Cleanup the code first. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/send/send01.c | 222 ++++++---- testcases/kernel/syscalls/sendmsg/sendmsg01.c | 547 ++++++++++++++++--------- testcases/kernel/syscalls/sendto/sendto01.c | 311 +++++++++----- 3 files changed, 694 insertions(+), 386 deletions(-) diff --git a/testcases/kernel/syscalls/send/send01.c b/testcases/kernel/syscalls/send/send01.c index be311b8..97bce2e 100644 --- a/testcases/kernel/syscalls/send/send01.c +++ b/testcases/kernel/syscalls/send/send01.c @@ -1,6 +1,7 @@ /* * * Copyright (c) International Business Machines Corp., 2001 + * Copyright (c) Cyril Hrubis <ch...@su...> 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,21 +24,9 @@ * Test Description: * Verify that send() returns the proper errno for various failure cases * - * Usage: <for command-line> - * send01 [-c n] [-e] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * * HISTORY * 07/2001 Ported by Wayne Boyer * - * RESTRICTIONS: - * None. - * */ #include <stdio.h> @@ -55,16 +44,13 @@ #include "test.h" #include "usctest.h" -char *TCID = "send01"; /* Test program identifier. */ +char *TCID = "send01"; int testno; -char buf[1024], bigbuf[128 * 1024]; -int s; /* socket descriptor */ -struct sockaddr_in sin1; -static int sfd; /* shared between do_child and start_server */ - -void setup(void), setup0(void), setup1(void), setup2(void), -do_child(void), cleanup(void), cleanup0(void), cleanup1(void); +static char buf[1024], bigbuf[128 * 1024]; +static int s; +static struct sockaddr_in sin1; +static int sfd; /* shared between do_child and start_server */ struct test_case_t { /* test case structure */ int domain; /* PF_INET, PF_UNIX, ... */ @@ -73,52 +59,107 @@ struct test_case_t { /* test case structure */ void *buf; /* send data buffer */ int buflen; /* send's 3rd argument */ unsigned flags; /* send's 4th argument */ - int retval; /* syscall return value */ - int experrno; /* expected errno */ - void (*setup) (void); - void (*cleanup) (void); + int retval; + int experrno; + void (*setup)(void); + void (*cleanup)(void); char *desc; -} tdat[] = { - { - PF_INET, SOCK_STREAM, 0, buf, sizeof(buf), 0, - -1, EBADF, setup0, cleanup0, "bad file descriptor"} - , { - 0, 0, 0, buf, sizeof(buf), 0, - -1, ENOTSOCK, setup0, cleanup0, "invalid socket"} - , +}; + +static void cleanup(void); +static void do_child(void); +static void setup(void); +static void setup0(void); +static void setup1(void); +static void setup2(void); +static void setup3(void); +static void cleanup0(void); +static void cleanup1(void); + +static struct test_case_t tdat[] = { + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .retval = -1, + .experrno = EBADF, + .setup = setup0, + .cleanup = cleanup0, + .desc = "bad file descriptor"}, + {.domain = 0, + .type = 0, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .retval = -1, + .experrno = ENOTSOCK, + .setup = setup0, + .cleanup = cleanup0, + .desc = "invalid socket"}, #ifndef UCLINUX - /* Skip since uClinux does not implement memory protection */ - { - PF_INET, SOCK_STREAM, 0, (void *)-1, sizeof(buf), 0, - -1, EFAULT, setup1, cleanup1, "invalid send buffer"} - , + /* Skip since uClinux does not implement memory protection */ + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = (void *)-1, + .buflen = sizeof(buf), + .flags = 0, + .retval = -1, + .experrno = EFAULT, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid send buffer"}, #endif - { - PF_INET, SOCK_DGRAM, 0, bigbuf, sizeof(bigbuf), 0, - -1, EMSGSIZE, setup1, cleanup1, "UDP message too big"} - , { - PF_INET, SOCK_STREAM, 0, buf, sizeof(buf), 0, - -1, EPIPE, setup2, cleanup1, "local endpoint shutdown"} - , + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .buf = bigbuf, + .buflen = sizeof(bigbuf), + .flags = 0, + .retval = -1, + .experrno = EMSGSIZE, + .setup = setup1, + .cleanup = cleanup1, + .desc = "UDP message too big"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .retval = -1, + .experrno = EPIPE, + .setup = setup2, + .cleanup = cleanup1, + .desc = "local endpoint shutdown"}, #ifndef UCLINUX - /* Skip since uClinux does not implement memory protection */ - { - PF_INET, SOCK_STREAM, 0, (void *)-1, sizeof(buf), -1, - -1, EFAULT, setup1, cleanup1, "invalid flags set"} - , + /* Skip since uClinux does not implement memory protection */ + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = (void *)-1, + .buflen = sizeof(buf), + .flags = -1, + .retval = -1, + .experrno = EFAULT, + .setup = setup3, + .cleanup = cleanup1, + .desc = "invalid flags set"} #endif }; -int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); /* Total number of test cases. */ - -int exp_enos[] = { EBADF, ENOTSOCK, EFAULT, EMSGSIZE, EPIPE, EINVAL, 0 }; +int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); +int exp_enos[] = {EBADF, ENOTSOCK, EFAULT, EMSGSIZE, EPIPE, EINVAL, 0}; #ifdef UCLINUX static char *argv0; #endif -pid_t start_server(struct sockaddr_in *sin0) +static pid_t start_server(struct sockaddr_in *sin0) { struct sockaddr_in sin1 = *sin0; pid_t pid; @@ -137,26 +178,26 @@ pid_t start_server(struct sockaddr_in *sin0) return -1; } switch ((pid = FORK_OR_VFORK())) { - case 0: /* child */ + case 0: #ifdef UCLINUX if (self_exec(argv0, "d", sfd) < 0) - tst_brkm(TBROK|TERRNO, cleanup, "server self_exec failed"); + tst_brkm(TBROK|TERRNO, cleanup, + "server self_exec failed"); #else do_child(); #endif break; case -1: tst_brkm(TBROK|TERRNO, cleanup, "server fork failed"); - /* fall through */ - default: /* parent */ - (void)close(sfd); + default: + close(sfd); return pid; } - exit(1); + exit(1); } -void do_child() +static void do_child(void) { fd_set afds, rfds; int nfds, cc, fd; @@ -173,8 +214,7 @@ void do_child() memcpy(&rfds, &afds, sizeof(rfds)); - if (select(nfds, &rfds, (fd_set *) 0, (fd_set *) 0, - (struct timeval *)0) < 0) + if (select(nfds, &rfds, NULL, NULL, NULL) < 0) if (errno != EINTR) exit(1); if (FD_ISSET(sfd, &rfds)) { @@ -189,7 +229,7 @@ void do_child() if (fd != sfd && FD_ISSET(fd, &rfds)) { cc = read(fd, buf, sizeof(buf)); if (cc == 0 || (cc < 0 && errno != EINTR)) { - (void)close(fd); + close(fd); FD_CLR(fd, &afds); } } @@ -199,12 +239,12 @@ void do_child() int main(int ac, char *av[]) { - int lc; /* loop counter */ - char *msg; /* message returned from parse_opts */ + int lc; + char *msg; - /* Parse standard options given to run the test. */ if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + #ifdef UCLINUX argv0 = av[0]; maybe_run_child(&do_child, "d", &sfd); @@ -221,9 +261,8 @@ int main(int ac, char *av[]) for (testno = 0; testno < TST_TOTAL; ++testno) { tdat[testno].setup(); - TEST(send - (s, tdat[testno].buf, tdat[testno].buflen, - tdat[testno].flags)); + TEST(send(s, tdat[testno].buf, tdat[testno].buflen, + tdat[testno].flags)); if (TEST_RETURN != -1) { tst_resm(TFAIL, "call succeeded unexpectedly"); @@ -250,42 +289,44 @@ int main(int ac, char *av[]) tst_exit(); } -pid_t pid; +static pid_t server_pid; -void setup(void) +static void setup(void) { - TEST_PAUSE; /* if -P option specified */ + TEST_PAUSE; /* initialize sockaddr's */ sin1.sin_family = AF_INET; sin1.sin_port = htons((getpid() % 32768) + 11000); sin1.sin_addr.s_addr = INADDR_ANY; - pid = start_server(&sin1); + server_pid = start_server(&sin1); - (void)signal(SIGPIPE, SIG_IGN); + signal(SIGPIPE, SIG_IGN); } -void cleanup(void) +static void cleanup(void) { - (void)kill(pid, SIGKILL); /* kill server */ + kill(server_pid, SIGKILL); TEST_CLEANUP; } -void setup0(void) +static void setup0(void) { if (tdat[testno].experrno == EBADF) s = 400; /* anything not an open file */ - else if ((s = open("/dev/null", O_WRONLY)) == -1) - tst_brkm(TBROK|TERRNO, cleanup, "open(/dev/null) failed"); + else + if ((s = open("/dev/null", O_WRONLY)) == -1) + tst_brkm(TBROK|TERRNO, cleanup, + "open(/dev/null) failed"); } -void cleanup0(void) +static void cleanup0(void) { s = -1; } -void setup1(void) +static void setup1(void) { s = socket(tdat[testno].domain, tdat[testno].type, tdat[testno].proto); if (s < 0) @@ -294,16 +335,25 @@ void setup1(void) tst_brkm(TBROK|TERRNO, cleanup, "connect failed"); } -void cleanup1(void) +static void cleanup1(void) { - (void)close(s); + close(s); s = -1; } -void setup2(void) +static void setup2(void) { - setup1(); /* get a socket in s */ + setup1(); + if (shutdown(s, 1) < 0) tst_brkm(TBROK|TERRNO, cleanup, "socket setup failed connect " "test %d", testno); -} \ No newline at end of file +} + +static void setup3(void) +{ + setup1(); + + if (tst_kvercmp(3, 6, 0) >= 0) + tdat[testno].experrno = ENOTSUP; +} diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg01.c b/testcases/kernel/syscalls/sendmsg/sendmsg01.c index 8f6c4eb..01d6c5b 100644 --- a/testcases/kernel/syscalls/sendmsg/sendmsg01.c +++ b/testcases/kernel/syscalls/sendmsg/sendmsg01.c @@ -1,6 +1,7 @@ /* * * Copyright (c) International Business Machines Corp., 2001 + * Copyright (c) Cyril Hrubis <ch...@su...> 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,38 +25,24 @@ * Test Description: * Verify that sendmsg() returns the proper errno for various failure cases * - * Usage: <for command-line> - * sendmsg01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * * HISTORY * 07/2001 Ported by Wayne Boyer * 05/2003 Modified by Manoj Iyer - Make setup function set up lo device. - * - * RESTRICTIONS: - * None. - * */ -/* The #ifndef code below is for 2.5 64-bit kernels, where */ -/* the MSG_CMSG_COMPAT flag must be 0 in order for the syscall */ -/* and this test to function correctly. */ +/* + * The #ifndef code below is for 2.5 64-bit kernels, where + * the MSG_CMSG_COMPAT flag must be 0 in order for the syscall + * and this test to function correctly. + */ #ifndef MSG_CMSG_COMPAT - -#if defined (__powerpc64__) || defined (__mips64) || defined (__x86_64__) || defined (__sparc64__) || defined (__ia64__) || defined (__s390x__) -#define MSG_CMSG_COMPAT 0x80000000 -#else -#define MSG_CMSG_COMPAT 0 -#endif - -#endif -/***************************************************/ +# if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \ + defined(__sparc64__) || defined(__ia64__) || defined(__s390x__) +# define MSG_CMSG_COMPAT 0x80000000 +# else +# define MSG_CMSG_COMPAT 0 +# endif +#endif /* MSG_CMSG_COMPAT */ #include <stdio.h> #include <unistd.h> @@ -77,24 +64,38 @@ #include "test.h" #include "usctest.h" -char *TCID = "sendmsg01"; /* Test program identifier. */ +char *TCID = "sendmsg01"; int testno; -char buf[1024], bigbuf[128 * 1024]; -int s; /* socket descriptor */ -struct sockaddr_in sin1, sin2; -struct sockaddr_un sun1; -struct msghdr msgdat; -char cbuf[4096]; /* control message buffer */ -struct cmsghdr *control = 0; -int controllen = 0; -struct iovec iov[1]; +static char buf[1024], bigbuf[128 * 1024]; +static int s; +static struct sockaddr_in sin1, sin2; +static struct sockaddr_un sun1; +static struct msghdr msgdat; +static char cbuf[4096]; +static struct cmsghdr *control; +static int controllen; +static struct iovec iov[1]; static int sfd; /* shared between do_child and start_server */ static int ufd; /* shared between do_child and start_server */ -void setup(void), setup0(void), setup1(void), setup2(void), setup3(void), -setup4(void), setup5(void), setup6(void), setup7(void), setup8(void), -cleanup(void), cleanup0(void), cleanup1(void), cleanup4(void), do_child(void); +static void setup(void); +static void setup0(void); +static void setup1(void); +static void setup2(void); +static void setup3(void); +static void setup4(void); +static void setup5(void); +static void setup6(void); +static void setup7(void); +static void setup8(void); + +static void cleanup(void); +static void cleanup0(void); +static void cleanup1(void); +static void cleanup4(void); + +static void do_child(void); struct test_case_t { /* test case structure */ int domain; /* PF_INET, PF_UNIX, ... */ @@ -110,114 +111,276 @@ struct test_case_t { /* test case structure */ int tolen; /* length of "to" buffer */ int retval; /* syscall return value */ int experrno; /* expected errno */ - void (*setup) (void); - void (*cleanup) (void); + void (*setup)(void); + void (*cleanup)(void); char *desc; -} tdat[] = { -/* 1 */ - { - PF_INET, SOCK_STREAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sin1, sizeof(sin1), - -1, EBADF, setup0, cleanup0, "bad file descriptor"} - , -/* 2 */ - { - 0, 0, 0, iov, 1, (void *)buf, sizeof(buf), &msgdat, 0, - (struct sockaddr *)&sin1, sizeof(sin1), - -1, ENOTSOCK, setup0, cleanup0, "invalid socket"} - , -/* 3 */ - { - PF_INET, SOCK_DGRAM, 0, iov, 1, (void *)-1, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sin1, sizeof(sin1), - -1, EFAULT, setup1, cleanup1, "invalid send buffer"} - , -/* 4 */ - { - PF_INET, SOCK_STREAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sin2, sizeof(sin2), - 0, EFAULT, setup5, cleanup1, "connected TCP"} - , -/* 5 */ - { - PF_INET, SOCK_STREAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sin1, sizeof(sin1), - -1, EPIPE, setup3, cleanup1, "not connected TCP"} - , -/* 6 */ - { - PF_INET, SOCK_DGRAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sin1, -1, -1, - EINVAL, setup1, cleanup1, "invalid to buffer length"}, -/* 7 */ - { - PF_INET, SOCK_DGRAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)-1, -1, -1, EINVAL, - setup1, cleanup1, "invalid to buffer"}, -/* 8 */ - { - PF_INET, SOCK_DGRAM, 0, iov, 1, (void *)bigbuf, sizeof(bigbuf), - &msgdat, 0, - (struct sockaddr *)&sin1, sizeof(sin1), - -1, EMSGSIZE, setup1, cleanup1, "UDP message too big"} - , -/* 9 */ - { - PF_INET, SOCK_STREAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sin1, sizeof(sin1), - -1, EPIPE, setup2, cleanup1, "local endpoint shutdown"} - , -/* 10 */ - { - PF_INET, SOCK_STREAM, 0, 0, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sin1, sizeof(sin1), - -1, EFAULT, setup1, cleanup1, "invalid iovec pointer"} - , -/* 11 */ - { - PF_INET, SOCK_STREAM, 0, iov, 1, (void *)buf, sizeof(buf), 0, - 0, (struct sockaddr *)&sin1, sizeof(sin1), - -1, EFAULT, setup1, cleanup1, "invalid msghdr pointer"} - , -/* 12 */ - { - PF_UNIX, SOCK_DGRAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sun1, sizeof(sun1), - 0, 0, setup4, cleanup4, "rights passing"} - , -/* 13 */ - { - PF_UNIX, SOCK_DGRAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, ~MSG_CMSG_COMPAT, (struct sockaddr *)&sun1, - sizeof(sun1), -1, EOPNOTSUPP, setup4, cleanup4, - "invalid flags set w/ control"} - , -/* 14 */ - { - PF_INET, SOCK_STREAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, ~MSG_CMSG_COMPAT, (struct sockaddr *)&sin1, - sizeof(sin1), 0, EOPNOTSUPP, setup1, cleanup1, - "invalid flags set"} - , -/* 15 */ - { - PF_UNIX, SOCK_DGRAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sun1, sizeof(sun1), - 0, EOPNOTSUPP, setup6, cleanup4, "invalid cmsg length"} - , -/* 16 */ - { - PF_UNIX, SOCK_DGRAM, 0, iov, 1, (void *)buf, sizeof(buf), - &msgdat, 0, (struct sockaddr *)&sun1, sizeof(sun1), - -1, EFAULT, setup8, cleanup4, "invalid cmsg pointer"} -,}; - -int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); /* Total number of test cases. */ - -int exp_enos[] = - { EBADF, ENOTSOCK, EFAULT, EISCONN, ENOTCONN, EINVAL, EMSGSIZE, EPIPE, -ENOBUFS, 0 }; - +}; + +struct test_case_t tdat[] = { + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EBADF, + .setup = setup0, + .cleanup = cleanup0, + .desc = "bad file descriptor"}, + {.domain = 0, + .type = 0, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = ENOTSOCK, + .setup = setup0, + .cleanup = cleanup0, + .desc = "invalid socket"}, + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = (void *)-1, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EFAULT, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid send buffer"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin2, + .tolen = sizeof(sin2), + .retval = 0, + .experrno = EFAULT, + .setup = setup5, + .cleanup = cleanup1, + .desc = "connected TCP"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EPIPE, + .setup = setup3, + .cleanup = cleanup1, + .desc = "not connected TCP"}, + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = -1, + .retval = -1, + .experrno = EINVAL, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid to buffer length"}, + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)-1, + .tolen = -1, + .retval = -1, + .experrno = EINVAL, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid to buffer"}, + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = bigbuf, + .buflen = sizeof(bigbuf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EMSGSIZE, + .setup = setup1, + .cleanup = cleanup1, + .desc = "UDP message too big"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EPIPE, + .setup = setup2, + .cleanup = cleanup1, + .desc = "local endpoint shutdown"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .iov = NULL, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EFAULT, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid iovec pointer"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = NULL, + .flags = 0, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EFAULT, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid msghdr pointer"}, + {.domain = PF_UNIX, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sun1, + .tolen = sizeof(sun1), + .retval = 0, + .experrno = 0, + .setup = setup4, + .cleanup = cleanup4, + .desc = "rights passing"}, + {.domain = PF_UNIX, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = ~MSG_CMSG_COMPAT, + .to = (struct sockaddr *)&sun1, + .tolen = sizeof(sun1), + .retval = -1, + .experrno = EOPNOTSUPP, + .setup = setup4, + .cleanup = cleanup4, + .desc = "invalid flags set w/ control"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = ~MSG_CMSG_COMPAT, + .to = (struct sockaddr *)&sin1, + .tolen = sizeof(sin1), + .retval = 0, + .experrno = EOPNOTSUPP, + .setup = setup7, + .cleanup = cleanup1, + .desc = "invalid flags set"}, + {.domain = PF_UNIX, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sun1, + .tolen = sizeof(sun1), + .retval = 0, + .experrno = EOPNOTSUPP, + .setup = setup6, + .cleanup = cleanup4, + .desc = "invalid cmsg length"}, + {.domain = PF_UNIX, + .type = SOCK_DGRAM, + .proto = 0, + .iov = iov, + .iovcnt = 1, + .buf = buf, + .buflen = sizeof(buf), + .msg = &msgdat, + .flags = 0, + .to = (struct sockaddr *)&sun1, + .tolen = sizeof(sun1), + .retval = -1, + .experrno = EFAULT, + .setup = setup8, + .cleanup = cleanup4, + .desc = "invalid cmsg pointer"} +}; + +int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); + +int exp_enos[] = { + EBADF, ENOTSOCK, EFAULT, EISCONN, ENOTCONN, EINVAL, EMSGSIZE, EPIPE, + ENOBUFS, 0 +}; #ifdef UCLINUX static char *argv0; @@ -225,15 +388,13 @@ static char *argv0; int main(int argc, char *argv[]) { - int lc; /* loop counter */ - char *msg; /* message returned from parse_opts */ + int lc; + char *msg; - /* Parse standard options given to run the test. */ msg = parse_opts(argc, argv, NULL, NULL); - if (msg != NULL) { + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } + #ifdef UCLINUX argv0 = argv[0]; maybe_run_child(&do_child, "dd", &sfd, &ufd); @@ -286,7 +447,7 @@ int main(int argc, char *argv[]) tst_exit(); } -pid_t start_server(struct sockaddr_in * sin0, struct sockaddr_un * sun0) +static pid_t start_server(struct sockaddr_in *sin0, struct sockaddr_un *sun0) { struct sockaddr_in sin1 = *sin0; pid_t pid; @@ -322,11 +483,10 @@ pid_t start_server(struct sockaddr_in * sin0, struct sockaddr_un * sun0) } switch ((pid = FORK_OR_VFORK())) { - case 0: /* child */ + case 0: #ifdef UCLINUX - if (self_exec(argv0, "dd", sfd, ufd) < 0) { + if (self_exec(argv0, "dd", sfd, ufd) < 0) tst_brkm(TBROK, cleanup, "server self_exec failed"); - } #else do_child(); #endif @@ -334,17 +494,16 @@ pid_t start_server(struct sockaddr_in * sin0, struct sockaddr_un * sun0) case -1: tst_brkm(TBROK, cleanup, "server fork failed: %s", strerror(errno)); - /* fall through */ - default: /* parent */ - (void)close(sfd); - (void)close(ufd); + default: + close(sfd); + close(ufd); return pid; } exit(1); } -void do_child() +static void do_child(void) { struct sockaddr_in fsin; struct sockaddr_un fsun; @@ -363,8 +522,7 @@ void do_child() memcpy(&rfds, &afds, sizeof(rfds)); - if (select(nfds, &rfds, (fd_set *) 0, (fd_set *) 0, - (struct timeval *)0) < 0) + if (select(nfds, &rfds, NULL, NULL, NULL) < 0) if (errno != EINTR) exit(1); if (FD_ISSET(sfd, &rfds)) { @@ -387,7 +545,7 @@ void do_child() if (fd != sfd && fd != ufd && FD_ISSET(fd, &rfds)) { cc = read(fd, buf, sizeof(buf)); if (cc == 0 || (cc < 0 && errno != EINTR)) { - (void)close(fd); + close(fd); FD_CLR(fd, &afds); } } @@ -395,14 +553,14 @@ void do_child() } } -pid_t pid; -char tmpsunpath[1024]; +static pid_t pid; +static char tmpsunpath[1024]; -void setup(void) +static void setup(void) { int ret = 0; - TEST_PAUSE; /* if -P option specified */ + TEST_PAUSE; /* initialize sockaddr's */ sin1.sin_family = AF_INET; @@ -429,17 +587,17 @@ void setup(void) signal(SIGPIPE, SIG_IGN); } -void cleanup(void) +static void cleanup(void) { if (pid > 0) - (void)kill(pid, SIGKILL); /* kill server, if server exists */ + kill(pid, SIGKILL); /* kill server, if server exists */ unlink(tmpsunpath); TEST_CLEANUP; tst_rmdir(); } -void setup0(void) +static void setup0(void) { if (tdat[testno].experrno == EBADF) s = 400; /* anything not an open file */ @@ -448,12 +606,12 @@ void setup0(void) "errno: %s", strerror(errno)); } -void cleanup0(void) +static void cleanup0(void) { s = -1; } -void setup1(void) +static void setup1(void) { s = socket(tdat[testno].domain, tdat[testno].type, tdat[testno].proto); if (s < 0) { @@ -467,13 +625,13 @@ void setup1(void) } } -void cleanup1(void) +static void cleanup1(void) { - (void)close(s); + close(s); s = -1; } -void setup2(void) +static void setup2(void) { setup1(); /* get a socket in s */ if (shutdown(s, 1) < 0) { @@ -481,7 +639,8 @@ void setup2(void) "test %d: %s", testno, strerror(errno)); } } -void setup3(void) + +static void setup3(void) { s = socket(tdat[testno].domain, tdat[testno].type, tdat[testno].proto); if (s < 0) { @@ -490,15 +649,15 @@ void setup3(void) } } -char tmpfilename[1024]; -int tfd; +static char tmpfilename[1024]; +static int tfd; -void setup4(void) +static void setup4(void) { setup1(); /* get a socket in s */ - (void)strcpy(tmpfilename, "sockXXXXXX"); + strcpy(tmpfilename, "sockXXXXXX"); tfd = mkstemp(tmpfilename); if (tfd < 0) { tst_brkm(TBROK, cleanup4, "socket setup failed: %s", @@ -513,25 +672,26 @@ void setup4(void) controllen = control->cmsg_len; } -void cleanup4(void) +static void cleanup4(void) { cleanup1(); - (void)close(tfd); + close(tfd); tfd = -1; control = 0; controllen = 0; } -void setup5(void) +static void setup5(void) { s = socket(tdat[testno].domain, tdat[testno].type, tdat[testno].proto); if (s < 0) { tst_brkm(TBROK, cleanup, "socket setup failed: %s", strerror(errno)); } - if (connect(s, (struct sockaddr *)&sin1, sizeof(sin1)) < 0) { + + if (connect(s, (struct sockaddr *)&sin1, sizeof(sin1)) < 0) tst_brkm(TBROK, cleanup, "connect failed: %s", strerror(errno)); - } + /* slight change destination (port) so connect() is to different * 5-tuple than already connected */ @@ -539,7 +699,7 @@ void setup5(void) sin2.sin_port++; } -void setup6(void) +static void setup6(void) { setup4(); /* @@ -548,15 +708,16 @@ void setup6(void) controllen = control->cmsg_len = 0; } -void setup7(void) +static void setup7(void) { - setup4(); - controllen = 128 * 1024; - control->cmsg_len = 0; + setup1(); + + if (tst_kvercmp(3, 6, 0) >= 0) + tdat[testno].retval = -1; } -void setup8(void) +static void setup8(void) { setup4(); control = (struct cmsghdr *)-1; -} \ No newline at end of file +} diff --git a/testcases/kernel/syscalls/sendto/sendto01.c b/testcases/kernel/syscalls/sendto/sendto01.c index ad64c70..77712a8 100644 --- a/testcases/kernel/syscalls/sendto/sendto01.c +++ b/testcases/kernel/syscalls/sendto/sendto01.c @@ -1,6 +1,7 @@ /* * * Copyright (c) International Business Machines Corp., 2001 + * Copyright (c) Cyril Hrubis <ch...@su...> 2012 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,22 +24,8 @@ * Test Description: * Verify that sendto() returns the proper errno for various failure cases * - * Usage: <for command-line> - * sendto01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * * HISTORY * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - * */ #include <stdio.h> @@ -56,16 +43,13 @@ #include "test.h" #include "usctest.h" -char *TCID = "sendto01"; /* Test program identifier. */ +char *TCID = "sendto01"; int testno; -char buf[1024], bigbuf[128 * 1024]; -int s; /* socket descriptor */ -struct sockaddr_in sin1, sin2; -static int sfd; /* shared between do_child and start_server */ - -void setup(void), setup0(void), setup1(void), setup2(void), setup3(void), -do_child(void), cleanup(void), cleanup0(void), cleanup1(void); +static char buf[1024], bigbuf[128 * 1024]; +static int s; +static struct sockaddr_in sin1, sin2; +static int sfd; struct test_case_t { /* test case structure */ int domain; /* PF_INET, PF_UNIX, ... */ @@ -76,72 +60,174 @@ struct test_case_t { /* test case structure */ unsigned flags; /* send's 4th argument */ struct sockaddr_in *to; /* destination */ int tolen; /* length of "to" buffer */ - int retval; /* syscall return value */ - int experrno; /* expected errno */ - void (*setup) (void); - void (*cleanup) (void); + int retval; + int experrno; + void (*setup)(void); + void (*cleanup)(void); char *desc; -} tdat[] = { - { - PF_INET, SOCK_STREAM, 0, buf, sizeof(buf), 0, &sin1, - sizeof(sin1), -1, EBADF, setup0, cleanup0, - "bad file descriptor"} - , { - 0, 0, 0, buf, sizeof(buf), 0, &sin1, sizeof(sin1), - -1, ENOTSOCK, setup0, cleanup0, "invalid socket"} - , +}; + +static void setup(void); +static void setup0(void); +static void setup1(void); +static void setup2(void); +static void setup3(void); +static void setup4(void); +static void cleanup(void); +static void cleanup0(void); +static void cleanup1(void); +static void do_child(void); + +struct test_case_t tdat[] = { + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .to = &sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EBADF, + .setup = setup0, + .cleanup = cleanup0, + .desc = "bad file descriptor"}, + {.domain = 0, + .type = 0, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .to = &sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = ENOTSOCK, + .setup = setup0, + .cleanup = cleanup0, + .desc = "invalid socket"}, #ifndef UCLINUX - /* Skip since uClinux does not implement memory protection */ - { - PF_INET, SOCK_DGRAM, 0, (void *)-1, sizeof(buf), 0, &sin1, - sizeof(sin1), - -1, EFAULT, setup1, cleanup1, "invalid send buffer"} - , + /* Skip since uClinux does not implement memory protection */ + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .buf = (void *)-1, + .buflen = sizeof(buf), + .flags = 0, + .to = &sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EFAULT, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid send buffer"}, #endif - { - PF_INET, SOCK_STREAM, 0, buf, sizeof(buf), 0, &sin2, - sizeof(sin2), 0, EFAULT, setup1, cleanup1, "connected TCP"} - , { - PF_INET, SOCK_STREAM, 0, buf, sizeof(buf), 0, &sin1, - sizeof(sin1), -1, EPIPE, setup3, cleanup1, - "not connected TCP"} - , { - PF_INET, SOCK_DGRAM, 0, buf, sizeof(buf), 0, &sin1, -1, - -1, EINVAL, setup1, cleanup1, "invalid to buffer length"} - , + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .to = &sin2, + .tolen = sizeof(sin2), + .retval = 0, + .experrno = EFAULT, + .setup = setup1, + .cleanup = cleanup1, + .desc = "connected TCP"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .to = &sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EPIPE, + .setup = setup3, + .cleanup = cleanup1, + .desc = "not connected TCP"}, + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .to = &sin1, + .tolen = -1, + .retval = -1, + .experrno = EINVAL, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid to buffer length"}, #ifndef UCLINUX - /* Skip since uClinux does not implement memory protection */ - { - PF_INET, SOCK_DGRAM, 0, buf, sizeof(buf), 0, - (struct sockaddr_in *)-1, sizeof(sin1), -1, EFAULT, - setup1, cleanup1, "invalid to buffer"} - , + /* Skip since uClinux does not implement memory protection */ + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .to = (struct sockaddr_in *)-1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EFAULT, + .setup = setup1, + .cleanup = cleanup1, + .desc = "invalid to buffer"}, #endif - { - PF_INET, SOCK_DGRAM, 0, bigbuf, sizeof(bigbuf), 0, &sin1, - sizeof(sin1), - -1, EMSGSIZE, setup1, cleanup1, "UDP message too big"} - , { - PF_INET, SOCK_STREAM, 0, buf, sizeof(buf), 0, &sin1, - sizeof(sin1), -1, EPIPE, setup2, cleanup1, - "local endpoint shutdown"} - , { - PF_INET, SOCK_STREAM, 0, buf, sizeof(buf), -1, &sin1, - sizeof(sin1), 0, EPIPE, setup1, cleanup1, - "invalid flags set"} + {.domain = PF_INET, + .type = SOCK_DGRAM, + .proto = 0, + .buf = bigbuf, + .buflen = sizeof(bigbuf), + .flags = 0, + .to = &sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EMSGSIZE, + .setup = setup1, + .cleanup = cleanup1, + .desc = "UDP message too big"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = 0, + .to = &sin1, + .tolen = sizeof(sin1), + .retval = -1, + .experrno = EPIPE, + .setup = setup2, + .cleanup = cleanup1, + .desc = "local endpoint shutdown"}, + {.domain = PF_INET, + .type = SOCK_STREAM, + .proto = 0, + .buf = buf, + .buflen = sizeof(buf), + .flags = -1, + .to = &sin1, + .tolen = sizeof(sin1), + .retval = 0, + .experrno = EPIPE, + .setup = setup4, + .cleanup = cleanup1, + .desc = "invalid flags set"} }; -int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); /* Total number of test cases. */ - -int exp_enos[] = - { EBADF, ENOTSOCK, EFAULT, EISCONN, ENOTCONN, EINVAL, EMSGSIZE, EPIPE, 0 }; +int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]); +int exp_enos[] = { + EBADF, ENOTSOCK, EFAULT, EISCONN, ENOTCONN, EINVAL, EMSGSIZE, EPIPE, 0 +}; #ifdef UCLINUX static char *argv0; #endif -pid_t start_server(struct sockaddr_in *sin0) +static pid_t start_server(struct sockaddr_in *sin0) { struct sockaddr_in sin1 = *sin0; pid_t pid; @@ -160,26 +246,26 @@ pid_t start_server(struct sockaddr_in *sin0) return -1; } switch ((pid = FORK_OR_VFORK())) { - case 0: /* child */ + case 0: #ifdef UCLINUX if (self_exec(argv0, "d", sfd) < 0) - tst_brkm(TBROK|TERRNO, cleanup, "server self_exec failed"); + tst_brkm(TBROK|TERRNO, cleanup, + "server self_exec failed"); #else do_child(); #endif break; case -1: tst_brkm(TBROK|TERRNO, cleanup, "server fork failed"); - /* fall through */ - default: /* parent */ + default: (void)close(sfd); return pid; } - exit(1); + exit(1); } -void do_child() +static void do_child(void) { struct sockaddr_in fsin; fd_set afds, rfds; @@ -196,10 +282,9 @@ void do_child() memcpy(&rfds, &afds, sizeof(rfds)); - if (select(nfds, &rfds, (fd_set *) 0, (fd_set *) 0, - (struct timeval *)0) < 0) - if (errno != EINTR) - exit(1); + if (select(nfds, &rfds, NULL, NULL, NULL) < 0 && errno != EINTR) + exit(1); + if (FD_ISSET(sfd, &rfds)) { int newfd; @@ -222,12 +307,12 @@ void do_child() int main(int ac, char *av[]) { - int lc; /* loop counter */ - char *msg; /* message returned from parse_opts */ + int lc; + char *msg; - /* Parse standard options given to run the test. */ if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + #ifdef UCLINUX argv0 = av[0]; maybe_run_child(&do_child, "d", &sfd); @@ -273,42 +358,43 @@ int main(int ac, char *av[]) tst_exit(); } -pid_t pid; +static pid_t server_pid; -void setup(void) +static void setup(void) { - TEST_PAUSE; /* if -P option specified */ + TEST_PAUSE; /* initialize sockaddr's */ sin1.sin_family = AF_INET; sin1.sin_port = htons((getpid() % 32768) + 11000); sin1.sin_addr.s_addr = INADDR_ANY; - pid = start_server(&sin1); + server_pid = start_server(&sin1); - (void)signal(SIGPIPE, SIG_IGN); + signal(SIGPIPE, SIG_IGN); } -void cleanup(void) +static void cleanup(void) { - (void)kill(pid, SIGKILL); /* kill server */ + kill(server_pid, SIGKILL); TEST_CLEANUP; - } -void setup0(void) +static void setup0(void) { if (tdat[testno].experrno == EBADF) - s = 400; /* anything not an open file */ - else if ((s = open("/dev/null", O_WRONLY)) == -1) - tst_brkm(TBROK|TERRNO, cleanup, "open(/dev/null) failed"); + s = 400; + else + if ((s = open("/dev/null", O_WRONLY)) == -1) + tst_brkm(TBROK|TERRNO, cleanup, + "open(/dev/null) failed"); } -void cleanup0(void) +static void cleanup0(void) { s = -1; } -void setup1(void) +static void setup1(void) { s = socket(tdat[testno].domain, tdat[testno].type, tdat[testno].proto); if (s < 0) @@ -317,22 +403,33 @@ void setup1(void) tst_brkm(TBROK|TERRNO, cleanup, "connect failed"); } -void cleanup1(void) +static void cleanup1(void) { (void)close(s); s = -1; } -void setup2(void) +static void setup2(void) { - setup1(); /* get a socket in s */ + setup1(); if (shutdown(s, 1) < 0) tst_brkm(TBROK|TERRNO, cleanup, "socket setup failed connect " "test %d", testno); } -void setup3(void) + +static void setup3(void) { s = socket(tdat[testno].domain, tdat[testno].type, tdat[testno].proto); if (s < 0) tst_brkm(TBROK|TERRNO, cleanup, "socket setup failed"); -} \ No newline at end of file +} + +static void setup4(void) +{ + setup1(); + + if (tst_kvercmp(3, 6, 0) >= 0) { + tdat[testno].retval = -1; + tdat[testno].experrno = ENOTSUP; + } +} hooks/post-receive -- ltp |