| plars | 865695b | 2001-08-27 22:15:12 +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 |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * NAME |
| 22 | * sendfile02.c |
| 23 | * |
| 24 | * DESCRIPTION |
| 25 | * Testcase to test the basic functionality of the sendfile(2) system call. |
| 26 | * |
| 27 | * ALGORITHM |
| 28 | * 1. call sendfile(2) with offset = 0 |
| 29 | * 2. call sendfile(2) with offset in the middle of the file |
| 30 | * |
| 31 | * USAGE: <for command-line> |
| 32 | * sendfile02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 33 | * where, |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 34 | * -f : Turn off functionality Testing. |
| 35 | * -i n : Execute test n times. |
| 36 | * -I x : Execute test for x seconds. |
| 37 | * -P x : Pause for x seconds between iterations. |
| 38 | * -t : Turn on syscall timing. |
| 39 | * |
| 40 | * HISTORY |
| 41 | * 07/2001 Ported by Wayne Boyer |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 42 | * 08/2002 Make it use a socket so it works with 2.5 kernel |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 43 | * |
| 44 | * RESTRICTIONS |
| 45 | * NONE |
| 46 | */ |
| 47 | #include <stdio.h> |
| 48 | #include <errno.h> |
| 49 | #include <fcntl.h> |
| 50 | #include <sys/stat.h> |
| plars | 8b6d9bf | 2002-03-05 13:55:58 +0000 | [diff] [blame] | 51 | #include <sys/sendfile.h> |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 52 | #include <sys/types.h> |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 53 | #include <sys/wait.h> |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 54 | #include <sys/socket.h> |
| 55 | #include <netinet/in.h> |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 56 | #include <arpa/inet.h> |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 57 | #include <unistd.h> |
| subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 58 | #include <inttypes.h> |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 59 | |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 60 | #include "usctest.h" |
| 61 | #include "test.h" |
| 62 | |
| subrata_modak | b752e85 | 2007-11-28 11:20:03 +0000 | [diff] [blame] | 63 | #ifndef OFF_T |
| 64 | #define OFF_T off_t |
| 65 | #endif /* Not def: OFF_T */ |
| 66 | |
| subrata_modak | 585950c | 2008-08-20 10:55:19 +0000 | [diff] [blame] | 67 | TCID_DEFINE(sendfile02); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 68 | int TST_TOTAL = 4; |
| 69 | extern int Tst_count; |
| 70 | |
| 71 | char in_file[100]; |
| 72 | char out_file[100]; |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 73 | int out_fd; |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 74 | pid_t child_pid; |
| robbiew | 9827066 | 2003-05-14 14:17:45 +0000 | [diff] [blame] | 75 | static int sockfd, s; |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 76 | static struct sockaddr_in sin1; /* shared between do_child and create_server */ |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 77 | |
| 78 | void cleanup(void); |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 79 | void do_child(void); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 80 | void setup(void); |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 81 | int create_server(void); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 82 | |
| 83 | struct test_case_t { |
| 84 | char *desc; |
| 85 | int offset; |
| 86 | int exp_retval; |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 87 | int exp_updated_offset; |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 88 | } testcases[] = { |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 89 | { |
| 90 | "Test sendfile(2) with offset = 0", 0, 26, 26}, { |
| 91 | "Test sendfile(2) with offset in the middle of file", 2, 24, 26}, { |
| 92 | "Test sendfile(2) with offset in the middle of file", 4, 22, 26}, { |
| 93 | "Test sendfile(2) with offset in the middle of file", 6, 20, 26} |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 96 | #ifdef UCLINUX |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 97 | static char *argv0; |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 98 | #endif |
| 99 | |
| subrata_modak | b752e85 | 2007-11-28 11:20:03 +0000 | [diff] [blame] | 100 | void do_sendfile(OFF_T offset, int i) |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 101 | { |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 102 | int in_fd; |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 103 | struct stat sb; |
| robbiew | 33b7774 | 2002-10-02 14:56:00 +0000 | [diff] [blame] | 104 | int wait_status; |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 105 | int wait_stat; |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 106 | off_t before_pos, after_pos; |
| 107 | |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 108 | out_fd = create_server(); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 109 | |
| 110 | if ((in_fd = open(in_file, O_RDONLY)) < 0) { |
| 111 | tst_brkm(TBROK, cleanup, "open failed: %d", errno); |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 112 | } |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 113 | if (stat(in_file, &sb) < 0) { |
| 114 | tst_brkm(TBROK, cleanup, "stat failed: %d", errno); |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 115 | } |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 116 | |
| 117 | if ((before_pos = lseek(in_fd, 0, SEEK_CUR)) < 0) { |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 118 | tst_brkm(TBROK, cleanup, |
| 119 | "lseek before invoking sendfile failed: %d", errno); |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 120 | } |
| subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 121 | |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 122 | TEST(sendfile(out_fd, in_fd, &offset, sb.st_size - offset)); |
| 123 | |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 124 | if ((after_pos = lseek(in_fd, 0, SEEK_CUR)) < 0) { |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 125 | tst_brkm(TBROK, cleanup, |
| 126 | "lseek after invoking sendfile failed: %d", errno); |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 127 | } |
| subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 128 | |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 129 | if (STD_FUNCTIONAL_TEST) { |
| robbiew | 9827066 | 2003-05-14 14:17:45 +0000 | [diff] [blame] | 130 | /* Close the sockets */ |
| 131 | shutdown(sockfd, SHUT_RDWR); |
| 132 | shutdown(s, SHUT_RDWR); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 133 | if (TEST_RETURN != testcases[i].exp_retval) { |
| 134 | tst_resm(TFAIL, "sendfile(2) failed to return " |
| 135 | "expected value, expected: %d, " |
| subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 136 | "got: %ld", testcases[i].exp_retval, |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 137 | TEST_RETURN); |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 138 | kill(child_pid, SIGKILL); |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 139 | } else if (offset != testcases[i].exp_updated_offset) { |
| 140 | tst_resm(TFAIL, "sendfile(2) failed to update " |
| 141 | "OFFSET parameter to expected value, " |
| subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 142 | "expected: %d, got: %"PRId64, |
| 143 | testcases[i].exp_updated_offset, (int64_t)offset); |
| subrata_modak | 498546d | 2007-12-05 08:44:26 +0000 | [diff] [blame] | 144 | } else if (before_pos != after_pos) { |
| 145 | tst_resm(TFAIL, "sendfile(2) updated the file position " |
| subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 146 | " of in_fd unexpectedly, expected file position: %"PRId64", " |
| 147 | " actual file position %"PRId64, |
| 148 | (int64_t)before_pos, (int64_t)after_pos); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 149 | } else { |
| 150 | tst_resm(TPASS, "functionality of sendfile() is " |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 151 | "correct"); |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 152 | wait_status = waitpid(-1, &wait_stat, 0); |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 153 | } |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 154 | } else { |
| 155 | tst_resm(TPASS, "call succeeded"); |
| robbiew | 9827066 | 2003-05-14 14:17:45 +0000 | [diff] [blame] | 156 | /* Close the sockets */ |
| 157 | shutdown(sockfd, SHUT_RDWR); |
| 158 | shutdown(s, SHUT_RDWR); |
| 159 | if (TEST_RETURN != testcases[i].exp_retval) { |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 160 | kill(child_pid, SIGKILL); |
| robbiew | 9827066 | 2003-05-14 14:17:45 +0000 | [diff] [blame] | 161 | } else { |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 162 | wait_status = waitpid(-1, &wait_stat, 0); |
| robbiew | 9827066 | 2003-05-14 14:17:45 +0000 | [diff] [blame] | 163 | } |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 166 | close(in_fd); |
| robbiew | 33b7774 | 2002-10-02 14:56:00 +0000 | [diff] [blame] | 167 | |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | /* |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 171 | * do_child |
| 172 | */ |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 173 | void do_child() |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 174 | { |
| 175 | int lc; |
| vapier | 1968aef | 2006-05-26 06:35:43 +0000 | [diff] [blame] | 176 | socklen_t length; |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 177 | char rbuf[4096]; |
| 178 | |
| 179 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
| 180 | length = sizeof(sin1); |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 181 | recvfrom(sockfd, rbuf, 4096, 0, (struct sockaddr *)&sin1, |
| 182 | &length); |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 183 | } |
| 184 | exit(0); |
| 185 | } |
| 186 | |
| 187 | /* |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 188 | * setup() - performs all ONE TIME setup for this test. |
| 189 | */ |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 190 | void setup() |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 191 | { |
| 192 | int fd; |
| 193 | char buf[100]; |
| 194 | |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 195 | tst_sig(FORK, DEF_HANDLER, cleanup); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 196 | |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 197 | TEST_PAUSE; |
| 198 | |
| 199 | /* make a temporary directory and cd to it */ |
| 200 | tst_tmpdir(); |
| 201 | sprintf(in_file, "in.%d", getpid()); |
| 202 | if ((fd = creat(in_file, 00700)) < 0) { |
| 203 | tst_brkm(TBROK, cleanup, "creat failed in setup, errno: %d", |
| 204 | errno); |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 205 | } |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 206 | sprintf(buf, "abcdefghijklmnopqrstuvwxyz"); |
| 207 | if (write(fd, buf, strlen(buf)) < 0) { |
| 208 | tst_brkm(TBROK, cleanup, "write failed, errno: %d", errno); |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 209 | } |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 210 | close(fd); |
| 211 | sprintf(out_file, "out.%d", getpid()); |
| 212 | } |
| 213 | |
| 214 | /* |
| 215 | * cleanup() - performs all ONE TIME cleanup for this test at |
| 216 | * completion or premature exit. |
| 217 | */ |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 218 | void cleanup() |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 219 | { |
| 220 | /* |
| 221 | * print timing stats if that option was specified. |
| 222 | * print errno log if that option was specified. |
| 223 | */ |
| 224 | TEST_CLEANUP; |
| 225 | |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 226 | close(out_fd); |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 227 | /* delete the test directory created in setup() */ |
| 228 | tst_rmdir(); |
| 229 | |
| plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 232 | int create_server(void) |
| 233 | { |
| 234 | static int count = 0; |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 235 | |
| 236 | sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 237 | if (sockfd < 0) { |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 238 | tst_brkm(TBROK, cleanup, "call to socket() failed: %s", |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 239 | strerror(errno)); |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 240 | return -1; |
| 241 | } |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 242 | sin1.sin_family = AF_INET; |
| subrata_modak | 6b0adc9 | 2008-02-25 11:33:27 +0000 | [diff] [blame] | 243 | sin1.sin_port = htons(((getpid() * TST_TOTAL) % 32768) + 11000 + count); |
| robbiew | 31f6f67 | 2003-01-28 14:50:49 +0000 | [diff] [blame] | 244 | sin1.sin_addr.s_addr = INADDR_ANY; |
| robbiew | e93a324 | 2005-08-31 20:27:12 +0000 | [diff] [blame] | 245 | count++; |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 246 | if (bind(sockfd, (struct sockaddr *)&sin1, sizeof(sin1)) < 0) { |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 247 | tst_brkm(TBROK, cleanup, "call to bind() failed: %s", |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 248 | strerror(errno)); |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 249 | return -1; |
| 250 | } |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 251 | child_pid = FORK_OR_VFORK(); |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 252 | if (child_pid < 0) { |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 253 | tst_brkm(TBROK, cleanup, "client/server fork failed: %s", |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 254 | strerror(errno)); |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 255 | return -1; |
| 256 | } |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 257 | if (!child_pid) { /* child */ |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 258 | #ifdef UCLINUX |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 259 | if (self_exec(argv0, "") < 0) { |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 260 | tst_brkm(TBROK, cleanup, "self_exec failed"); |
| 261 | return -1; |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 262 | |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 263 | } |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 264 | #else |
| 265 | do_child(); |
| 266 | #endif |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | s = socket(PF_INET, SOCK_DGRAM, 0); |
| 270 | inet_aton("127.0.0.1", &sin1.sin_addr); |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 271 | if (s < 0) { |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 272 | tst_brkm(TBROK, cleanup, "call to socket() failed: %s", |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 273 | strerror(errno)); |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 274 | return -1; |
| 275 | } |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 276 | if (connect(s, (struct sockaddr *)&sin1, sizeof(sin1)) < 0) { |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 277 | tst_brkm(TBROK, cleanup, "call to connect() failed: %s", |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 278 | strerror(errno)); |
| plars | 16bfb44 | 2002-08-05 22:07:16 +0000 | [diff] [blame] | 279 | } |
| 280 | return s; |
| 281 | |
| 282 | } |
| robbiew | aa01abd | 2003-03-27 18:39:24 +0000 | [diff] [blame] | 283 | |
| 284 | int main(int ac, char **av) |
| 285 | { |
| 286 | int i; |
| subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 287 | int lc; /* loop counter */ |
| 288 | char *msg; /* parse_opts() return message */ |
| robbiew | aa01abd | 2003-03-27 18:39:24 +0000 | [diff] [blame] | 289 | |
| Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 290 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 291 | <<<<<<< HEAD |
| Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 292 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 293 | ======= |
| 294 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
| 295 | >>>>>>> master |
| 296 | } |
| robbiew | d34d581 | 2005-07-11 22:28:09 +0000 | [diff] [blame] | 297 | #ifdef UCLINUX |
| 298 | argv0 = av[0]; |
| 299 | maybe_run_child(&do_child, ""); |
| 300 | #endif |
| 301 | |
| robbiew | aa01abd | 2003-03-27 18:39:24 +0000 | [diff] [blame] | 302 | setup(); |
| 303 | |
| 304 | /* |
| 305 | * The following loop checks looping state if -c option given |
| 306 | */ |
| 307 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
| 308 | Tst_count = 0; |
| 309 | |
| 310 | for (i = 0; i < TST_TOTAL; ++i) { |
| 311 | do_sendfile(testcases[i].offset, i); |
| 312 | } |
| 313 | } |
| 314 | cleanup(); |
| 315 | |
| Garrett Cooper | 5374050 | 2010-12-16 00:04:01 -0800 | [diff] [blame] | 316 | tst_exit(); |
| Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame^] | 317 | } |