1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
25 # include <locale.h> /* for setlocale() */
29 # include <io.h> /* for setmode() */
33 # include <fcntl.h> /* for setmode() */
37 # define MEMDEBUG_NODEFINES
38 # include "memdebug.h"
41 int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
45 SET_SOCKERRNO(EINVAL);
50 * Winsock select() requires that at least one of the three fd_set
51 * pointers is not NULL and points to a non-empty fdset. IOW Winsock
52 * select() can not be used to sleep without a single fd_set.
55 Sleep(1000*tv->tv_sec + tv->tv_usec/1000);
59 return select(nfds, rd, wr, exc, tv);
66 ms -= (int)t.tv_sec * 1000;
67 t.tv_usec = ms * 1000;
68 select_wrapper(0, NULL, NULL , NULL, &t);
71 char *libtest_arg2=NULL;
72 char *libtest_arg3=NULL;
76 struct timeval tv_test_start; /* for test timing */
79 int unitfail; /* for unittests */
83 static void memory_tracking_init(void)
86 /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */
87 env = curl_getenv("CURL_MEMDEBUG");
89 /* use the value as file name */
90 char fname[CURL_MT_LOGFNAME_BUFSIZE];
91 if(strlen(env) >= CURL_MT_LOGFNAME_BUFSIZE)
92 env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0';
96 /* this weird stuff here is to make curl_free() get called
97 before curl_memdebug() as otherwise memory tracking will
98 log a free() without an alloc! */
100 /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
101 env = curl_getenv("CURL_MEMLIMIT");
104 long num = strtol(env, &endptr, 10);
105 if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
111 # define memory_tracking_init() Curl_nop_stmt
114 int main(int argc, char **argv)
120 _setmode(stdout, O_BINARY);
122 setmode(fileno(stdout), O_BINARY);
126 memory_tracking_init();
129 * Setup proper locale from environment. This is needed to enable locale-
130 * specific behaviour by the C library in order to test for undesired side
131 * effects that could cause in libcurl.
133 #ifdef HAVE_SETLOCALE
134 setlocale(LC_ALL, "");
138 fprintf(stderr, "Pass URL as argument please\n");
146 libtest_arg2=argv[2];
149 libtest_arg3=argv[3];
151 URL = argv[1]; /* provide this to the rest */
153 fprintf(stderr, "URL: %s\n", URL);