annotate tests/test-sys_socket.c @ 17363:5a51fb7777a9

sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin Problem reported by Marco Atzeri in <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>. * lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]: Simply delegate to the system <sys/select.h> in this case too. Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to be needed on Solaris either. * lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]: Simply delgate to the system <sys/time.h> in this case.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 19 Mar 2013 09:08:47 -0700
parents e542fd46ad6f
children 6054142aae93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of <sys/socket.h> substitute.
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
2 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8499
diff changeset
4 This program is free software: you can redistribute it and/or modify
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8499
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8499
diff changeset
7 (at your option) any later version.
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8499
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <sys/socket.h>
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <errno.h>
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
8499
7304ea530640 Fix a compilation error on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8177
diff changeset
25 #if HAVE_SHUTDOWN
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 /* Check some integer constant expressions. */
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
8499
7304ea530640 Fix a compilation error on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8177
diff changeset
28 #endif
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29
13588
a17068cb741d sys_socket, netdb: Ensure socklen_t gets defined.
Bruno Haible <bruno@clisp.org>
parents: 13416
diff changeset
30 /* Check that the 'socklen_t' type is defined. */
a17068cb741d sys_socket, netdb: Ensure socklen_t gets defined.
Bruno Haible <bruno@clisp.org>
parents: 13416
diff changeset
31 socklen_t t1;
a17068cb741d sys_socket, netdb: Ensure socklen_t gets defined.
Bruno Haible <bruno@clisp.org>
parents: 13416
diff changeset
32
15620
04a6b94f5530 Support for MSVC compiler: Ensure ssize_t gets defined.
Bruno Haible <bruno@clisp.org>
parents: 14599
diff changeset
33 /* Check that the 'size_t' and 'ssize_t' types are defined. */
15640
e9fd9d86c6e0 sys_socket tests: Fix recent mistake.
Bruno Haible <bruno@clisp.org>
parents: 15620
diff changeset
34 size_t t2;
e9fd9d86c6e0 sys_socket tests: Fix recent mistake.
Bruno Haible <bruno@clisp.org>
parents: 15620
diff changeset
35 ssize_t t3;
15620
04a6b94f5530 Support for MSVC compiler: Ensure ssize_t gets defined.
Bruno Haible <bruno@clisp.org>
parents: 14599
diff changeset
36
14599
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
37 /* Check that 'struct iovec' is defined. */
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
38 struct iovec io;
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
39
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
40 /* Check that a minimal set of 'struct msghdr' is defined. */
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
41 struct msghdr msg;
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
42
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 int
12210
441d8820b5a5 tests: avoid some compiler warnings
Eric Blake <ebb9@byu.net>
parents: 11577
diff changeset
44 main (void)
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 {
11555
7612308943f7 sys_socket: Define sockaddr_storage.
Simon Josefsson <simon@josefsson.org>
parents: 9309
diff changeset
46 struct sockaddr_storage x;
11577
40afcbcc19ed sys_socket: MinGW and IRIX does not have sa_family_t type.
Simon Josefsson <simon@josefsson.org>
parents: 11555
diff changeset
47 sa_family_t i;
11555
7612308943f7 sys_socket: Define sockaddr_storage.
Simon Josefsson <simon@josefsson.org>
parents: 9309
diff changeset
48
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 /* Check some errno values. */
8499
7304ea530640 Fix a compilation error on BeOS.
Bruno Haible <bruno@clisp.org>
parents: 8177
diff changeset
50 switch (0)
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 {
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 case ENOTSOCK:
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 case EADDRINUSE:
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 case ENETRESET:
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 case ECONNABORTED:
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 case ECONNRESET:
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 case ENOTCONN:
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 case ESHUTDOWN:
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 break;
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 }
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61
11555
7612308943f7 sys_socket: Define sockaddr_storage.
Simon Josefsson <simon@josefsson.org>
parents: 9309
diff changeset
62 x.ss_family = 42;
12239
5f5176d05a2c test-sys_socket: Fix compilation warning.
Simon Josefsson <simon@josefsson.org>
parents: 12210
diff changeset
63 i = 42;
14599
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
64 msg.msg_iov = &io;
11555
7612308943f7 sys_socket: Define sockaddr_storage.
Simon Josefsson <simon@josefsson.org>
parents: 9309
diff changeset
65
14599
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
66 return (x.ss_family - i + msg.msg_namelen + msg.msg_iov->iov_len
2a40136b85ae passfd: allow compilation on mingw
Eric Blake <eblake@redhat.com>
parents: 14079
diff changeset
67 + msg.msg_iovlen);
8177
31854ec0c114 Tests for module 'sys_socket'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 }