mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) International Business Machines Corp., 2001 |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 13 | * the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * Test Name: asapi_07 |
| 22 | * |
| 23 | * Test Description: |
| 24 | * These tests are for the "Advanced Sockets API" (RFC 3542) |
| 25 | * Section 20, ancillary data macros and structure definitions |
| 26 | * |
| 27 | * Usage: <for command-line> |
| 28 | * asapi_07 |
| 29 | * |
| 30 | * HISTORY |
| 31 | * 04/2005 written by David L Stevens |
| 32 | * |
| 33 | * RESTRICTIONS: |
| 34 | * None. |
| 35 | * |
| 36 | */ |
| 37 | |
| 38 | #include <stdio.h> |
| 39 | #include <unistd.h> |
| 40 | #include <errno.h> |
| 41 | |
| 42 | #include <sys/wait.h> |
| 43 | |
| 44 | #include <netinet/in.h> |
| 45 | #include <netinet/ip6.h> |
| 46 | #include <netinet/icmp6.h> |
| 47 | |
| 48 | #include "test.h" |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 49 | #include "runcc.h" |
| 50 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 51 | char *TCID = "asapi_07"; /* Test program identifier. */ |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 52 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 53 | void setup(void); |
| 54 | void cleanup(void); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 55 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 56 | void adatet(void); |
| 57 | void adatft(void); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 58 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 59 | int main(int argc, char *argv[]) |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 60 | { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 61 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 62 | const char *msg; |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 63 | |
| 64 | /* Parse standard options given to run the test. */ |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 65 | if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL) |
Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 66 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 67 | |
| 68 | setup(); |
| 69 | |
| 70 | for (lc = 0; TEST_LOOPING(lc); ++lc) { |
| 71 | adatet(); |
| 72 | } |
| 73 | |
| 74 | cleanup(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 75 | |
Garrett Cooper | 3483b6e | 2010-12-17 03:24:08 -0800 | [diff] [blame] | 76 | tst_exit(); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | enum ttype { EXISTS, ALIAS, VALUE, DEFINED }; |
| 80 | |
| 81 | struct etent { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 82 | char *et_tname; /* test name */ |
| 83 | int et_type; /* test type */ |
| 84 | char *et_incl; /* include file list */ |
| 85 | char *et_struct; /* structure name */ |
| 86 | char *et_field; /* field name */ |
| 87 | char *et_offset; /* field offset */ |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 88 | union { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 89 | char *fu_value; /* field size or value */ |
| 90 | char *fu_dname; /* #define name */ |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 91 | } ftun; |
| 92 | #define et_value ftun.fu_value |
| 93 | #define et_dname ftun.fu_dname |
| 94 | } etab[] = { |
| 95 | /* existence checks, RFC 3542 sections 5, 20 */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 96 | { |
| 97 | "msghdr msg_name", EXISTS, SOCKET_H, "msghdr", "msg_name", NULL, { |
| 98 | "sizeof(void *)"}}, { |
| 99 | "msghdr msg_namelen", EXISTS, SOCKET_H, "msghdr", |
| 100 | "msg_namelen", NULL, { |
| 101 | "sizeof(socklen_t)"}}, { |
| 102 | "msghdr msg_iov", EXISTS, SOCKET_H, "msghdr", "msg_iov", NULL, { |
| 103 | "sizeof(struct iovec *)"}}, { |
| 104 | "msghdr msg_iovlen", EXISTS, SOCKET_H, "msghdr", |
| 105 | "msg_iovlen", NULL, { |
Simon Xu | 0e85351 | 2013-12-05 10:11:58 +0800 | [diff] [blame] | 106 | "sizeof(size_t)"}}, { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 107 | "msghdr msg_control", EXISTS, SOCKET_H, "msghdr", |
| 108 | "msg_control", NULL, { |
| 109 | "sizeof(void *)"}}, { |
| 110 | "msghdr msg_controllen", EXISTS, SOCKET_H, "msghdr", |
| 111 | "msg_controllen", NULL, { |
Simon Xu | 0e85351 | 2013-12-05 10:11:58 +0800 | [diff] [blame] | 112 | "sizeof(size_t)"}}, { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 113 | "msghdr msg_flags", EXISTS, SOCKET_H, "msghdr", |
| 114 | "msg_flags", NULL, { |
| 115 | "sizeof(int)"}}, { |
| 116 | "cmsghdr cmsg_len", EXISTS, SOCKET_H, "cmsghdr", |
| 117 | "cmsg_len", NULL, { |
Simon Xu | 0e85351 | 2013-12-05 10:11:58 +0800 | [diff] [blame] | 118 | "sizeof(size_t)"}}, { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 119 | "cmsghdr cmsg_level", EXISTS, SOCKET_H, "cmsghdr", |
| 120 | "cmsg_level", NULL, { |
| 121 | "sizeof(int)"}}, { |
| 122 | "cmsghdr cmsg_type", EXISTS, SOCKET_H, "cmsghdr", |
| 123 | "cmsg_type", NULL, { |
| 124 | "sizeof(int)"}}, { |
| 125 | "CMSG_DATA", DEFINED, SOCKET_H, "CMSG_DATA", NULL, NULL, { |
| 126 | 0}}, { |
| 127 | "CMSG_NXTHDR", DEFINED, SOCKET_H, "CMSG_NXTHDR", NULL, NULL, { |
| 128 | 0}}, { |
| 129 | "CMSG_FIRSTHDR", DEFINED, SOCKET_H, "CMSG_FIRSTHDR", NULL, NULL, { |
| 130 | 0}}, { |
| 131 | "CMSG_SPACE", DEFINED, SOCKET_H, "CMSG_SPACE", NULL, NULL, { |
| 132 | 0}}, { |
| 133 | "CMSG_LEN", DEFINED, SOCKET_H, "CMSG_LEN", NULL, NULL, { |
| 134 | 0}},}; |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 135 | |
| 136 | #define ETCOUNT (sizeof(etab)/sizeof(etab[0])) |
| 137 | |
| 138 | /* existence tests */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 139 | void adatet(void) |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 140 | { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 141 | int i; |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 142 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 143 | for (i = 0; i < ETCOUNT; ++i) { |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 144 | switch (etab[i].et_type) { |
| 145 | case EXISTS: |
| 146 | structcheck(etab[i].et_tname, etab[i].et_incl, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 147 | etab[i].et_struct, etab[i].et_field, |
| 148 | etab[i].et_offset, etab[i].et_value); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 149 | break; |
| 150 | case ALIAS: |
| 151 | aliascheck(etab[i].et_tname, etab[i].et_incl, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 152 | etab[i].et_struct, etab[i].et_field, |
| 153 | etab[i].et_dname); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 154 | break; |
| 155 | case VALUE: |
| 156 | valuecheck(etab[i].et_tname, etab[i].et_incl, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 157 | etab[i].et_struct, etab[i].et_dname); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 158 | break; |
| 159 | case DEFINED: |
| 160 | funccheck(etab[i].et_tname, etab[i].et_incl, |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 161 | etab[i].et_struct); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 162 | break; |
| 163 | default: |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 164 | tst_resm(TBROK, "invalid type %d", etab[i].et_type); |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 165 | break; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 170 | void setup(void) |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 171 | { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 172 | TEST_PAUSE; /* if -P option specified */ |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 175 | void cleanup(void) |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 176 | { |
mridge | 949c5b1 | 2006-01-03 23:01:28 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 179 | int TST_TOTAL = ETCOUNT; |