[MSVCRT_WINETEST] Sync with Wine Staging 1.7.43.
[reactos.git] / rostests / winetests / msvcrt / misc.c
1 /*
2 * Unit tests for miscellaneous msvcrt functions
3 *
4 * Copyright 2010 Andrew Nguyen
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "wine/test.h"
22 #include <errno.h>
23 #include <stdio.h>
24 #include "msvcrt.h"
25
26 static inline float __port_infinity(void)
27 {
28 static const unsigned __inf_bytes = 0x7f800000;
29 return *(const float *)&__inf_bytes;
30 }
31 #define INFINITY __port_infinity()
32
33 static inline float __port_nan(void)
34 {
35 static const unsigned __nan_bytes = 0x7fc00000;
36 return *(const float *)&__nan_bytes;
37 }
38 #define NAN __port_nan()
39
40 static inline BOOL almost_equal(double d1, double d2) {
41 if(d1-d2>-1e-30 && d1-d2<1e-30)
42 return TRUE;
43 return FALSE;
44 }
45
46 static int (__cdecl *prand_s)(unsigned int *);
47 static int (__cdecl *pI10_OUTPUT)(long double, int, int, void*);
48 static int (__cdecl *pstrerror_s)(char *, MSVCRT_size_t, int);
49 static int (__cdecl *p_get_doserrno)(int *);
50 static int (__cdecl *p_get_errno)(int *);
51 static int (__cdecl *p_set_doserrno)(int);
52 static int (__cdecl *p_set_errno)(int);
53 static void (__cdecl *p__invalid_parameter)(const wchar_t*,
54 const wchar_t*, const wchar_t*, unsigned int, uintptr_t);
55 static void (__cdecl *p_qsort_s)(void*, MSVCRT_size_t, MSVCRT_size_t,
56 int (__cdecl*)(void*, const void*, const void*), void*);
57 static double (__cdecl *p_atan)(double);
58 static double (__cdecl *p_exp)(double);
59 static double (__cdecl *p_tanh)(double);
60
61 static void init(void)
62 {
63 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
64
65 prand_s = (void *)GetProcAddress(hmod, "rand_s");
66 pI10_OUTPUT = (void*)GetProcAddress(hmod, "$I10_OUTPUT");
67 pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s");
68 p_get_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno");
69 p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
70 p_set_doserrno = (void *)GetProcAddress(hmod, "_set_doserrno");
71 p_set_errno = (void *)GetProcAddress(hmod, "_set_errno");
72 p__invalid_parameter = (void *)GetProcAddress(hmod, "_invalid_parameter");
73 p_qsort_s = (void *)GetProcAddress(hmod, "qsort_s");
74 p_atan = (void *)GetProcAddress(hmod, "atan");
75 p_exp = (void *)GetProcAddress(hmod, "exp");
76 p_tanh = (void *)GetProcAddress(hmod, "tanh");
77 }
78
79 static void test_rand_s(void)
80 {
81 int ret;
82 unsigned int rand;
83
84 if (!prand_s)
85 {
86 win_skip("rand_s is not available\n");
87 return;
88 }
89
90 errno = EBADF;
91 ret = prand_s(NULL);
92 ok(ret == EINVAL, "Expected rand_s to return EINVAL, got %d\n", ret);
93 ok(errno == EINVAL, "Expected errno to return EINVAL, got %d\n", errno);
94
95 ret = prand_s(&rand);
96 ok(ret == 0, "Expected rand_s to return 0, got %d\n", ret);
97 }
98
99 typedef struct _I10_OUTPUT_data {
100 short pos;
101 char sign;
102 BYTE len;
103 char str[100];
104 } I10_OUTPUT_data;
105
106 typedef struct _I10_OUTPUT_test {
107 long double d;
108 int size;
109 int flags;
110
111 I10_OUTPUT_data out;
112 int ret;
113 const char *remain;
114 } I10_OUTPUT_test;
115
116 static const I10_OUTPUT_test I10_OUTPUT_tests[] = {
117 /* arg3 = 0 */
118 { 0.0, 10, 0, {0, ' ', 1, "0"}, 1, "" },
119 { 1.0, 10, 0, {1, ' ', 1, "1"}, 1, "000000009" },
120 { -1.0, 10, 0, {1, '-', 1, "1"}, 1, "000000009" },
121 { 1.23, 10, 0, {1, ' ', 3, "123"}, 1, "0000009" },
122 { 1e13, 10, 0, {14, ' ', 1, "1"}, 1, "000000009" },
123 { 1e30, 30, 0, {31, ' ', 21, "100000000000000001988"}, 1, "" },
124 { 1e-13, 10, 0, {-12, ' ', 1, "1"}, 1, "000000000" },
125 { 0.25, 10, 0, {0, ' ', 2, "25"}, 1, "00000000" },
126 { 1.0000001, 10, 0, {1, ' ', 8, "10000001"}, 1, "00" },
127 /* arg3 = 1 */
128 { 0.0, 10, 1, {0, ' ', 1, "0"}, 1, "" },
129 { 1.0, 10, 1, {1, ' ', 1, "1"}, 1, "0000000009" },
130 { -1.0, 10, 1, {1, '-', 1, "1"}, 1, "0000000009" },
131 { 1.23, 10, 1, {1, ' ', 3, "123"}, 1, "00000009" },
132 { 1e13, 10, 1, {14, ' ', 1, "1"}, 1, "00000000000000000009" },
133 { 1e30, 30, 1, {31, ' ', 21, "100000000000000001988"}, 1, "" },
134 { 1e-13, 10, 1, {0, ' ', 1, "0"}, 1, "" },
135 { 1e-7, 10, 1, {-6, ' ', 1, "1"}, 1, "09" },
136 { 0.25, 10, 1, {0, ' ', 2, "25"}, 1, "00000000" },
137 { 1.0000001, 10, 1, {1, ' ', 8, "10000001"}, 1, "000" },
138 /* too small buffer */
139 { 0.0, 0, 0, {0, ' ', 1, "0"}, 1, "" },
140 { 0.0, 0, 1, {0, ' ', 1, "0"}, 1, "" },
141 { 123.0, 2, 0, {3, ' ', 2, "12"}, 1, "" },
142 { 123.0, 0, 0, {0, ' ', 1, "0"}, 1, "" },
143 { 123.0, 2, 1, {3, ' ', 3, "123"}, 1, "09" },
144 { 0.99, 1, 0, {1, ' ', 1, "1"}, 1, "" },
145 { 1264567.0, 2, 0, {7, ' ', 2, "13"}, 1, "" },
146 { 1264567.0, 2, 1, {7, ' ', 7, "1264567"}, 1, "00" },
147 { 1234567891.0, 2, 1, {10, ' ', 10, "1234567891"}, 1, "09" }
148 };
149
150 static void test_I10_OUTPUT(void)
151 {
152 I10_OUTPUT_data out;
153 int i, j = sizeof(long double), ret;
154
155 if(!pI10_OUTPUT) {
156 win_skip("I10_OUTPUT not available\n");
157 return;
158 }
159 if (j != 12)
160 trace("sizeof(long double) = %d on this machine\n", j);
161
162 for(i=0; i<sizeof(I10_OUTPUT_tests)/sizeof(I10_OUTPUT_test); i++) {
163 memset(out.str, '#', sizeof(out.str));
164
165 if (sizeof(long double) == 12)
166 ret = pI10_OUTPUT(I10_OUTPUT_tests[i].d, I10_OUTPUT_tests[i].size, I10_OUTPUT_tests[i].flags, &out);
167 else {
168 /* MS' "long double" is an 80 bit FP that takes 12 bytes*/
169 typedef struct { ULONG x80[3]; } uld; /* same calling convention */
170 union { long double ld; uld ld12; } fp80;
171 int (__cdecl *pI10_OUTPUT12)(uld, int, int, void*) = (void*)pI10_OUTPUT;
172 fp80.ld = I10_OUTPUT_tests[i].d;
173 ret = pI10_OUTPUT12(fp80.ld12, I10_OUTPUT_tests[i].size, I10_OUTPUT_tests[i].flags, &out);
174 }
175 ok(ret == I10_OUTPUT_tests[i].ret, "%d: ret = %d\n", i, ret);
176 ok(out.pos == I10_OUTPUT_tests[i].out.pos, "%d: out.pos = %hd\n", i, out.pos);
177 ok(out.sign == I10_OUTPUT_tests[i].out.sign, "%d: out.size = %c\n", i, out.sign);
178 ok(out.len == I10_OUTPUT_tests[i].out.len, "%d: out.len = %d\n", i, (int)out.len);
179 ok(!strcmp(out.str, I10_OUTPUT_tests[i].out.str), "%d: out.str = %s\n", i, out.str);
180
181 j = strlen(I10_OUTPUT_tests[i].remain);
182 if(j && I10_OUTPUT_tests[i].remain[j-1]=='9')
183 todo_wine ok(!strncmp(out.str+out.len+1, I10_OUTPUT_tests[i].remain, j),
184 "%d: &out.str[%d] = %.25s...\n", i, out.len+1, out.str+out.len+1);
185 else
186 ok(!strncmp(out.str+out.len+1, I10_OUTPUT_tests[i].remain, j),
187 "%d: &out.str[%d] = %.25s...\n", i, out.len+1, out.str+out.len+1);
188
189
190 for(j=out.len+strlen(I10_OUTPUT_tests[i].remain)+1; j<sizeof(out.str); j++)
191 if(out.str[j] != '#')
192 ok(0, "%d: out.str[%d] = %c (expected \'#\')\n", i, j, out.str[j]);
193 }
194 }
195
196 static void test_strerror_s(void)
197 {
198 int ret;
199 char buf[256];
200
201 if (!pstrerror_s)
202 {
203 win_skip("strerror_s is not available\n");
204 return;
205 }
206
207 errno = EBADF;
208 ret = pstrerror_s(NULL, 0, 0);
209 ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
210 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
211
212 errno = EBADF;
213 ret = pstrerror_s(NULL, sizeof(buf), 0);
214 ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
215 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
216
217 memset(buf, 'X', sizeof(buf));
218 errno = EBADF;
219 ret = pstrerror_s(buf, 0, 0);
220 ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
221 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
222 ok(buf[0] == 'X', "Expected output buffer to be untouched\n");
223
224 memset(buf, 'X', sizeof(buf));
225 ret = pstrerror_s(buf, 1, 0);
226 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
227 ok(strlen(buf) == 0, "Expected output buffer to be null terminated\n");
228
229 memset(buf, 'X', sizeof(buf));
230 ret = pstrerror_s(buf, 2, 0);
231 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
232 ok(strlen(buf) == 1, "Expected output buffer to be truncated\n");
233
234 memset(buf, 'X', sizeof(buf));
235 ret = pstrerror_s(buf, sizeof(buf), 0);
236 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
237
238 memset(buf, 'X', sizeof(buf));
239 ret = pstrerror_s(buf, sizeof(buf), -1);
240 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
241 }
242
243 static void test__get_doserrno(void)
244 {
245 int ret, out;
246
247 if (!p_get_doserrno)
248 {
249 win_skip("_get_doserrno is not available\n");
250 return;
251 }
252
253 _doserrno = ERROR_INVALID_CMM;
254 errno = EBADF;
255 ret = p_get_doserrno(NULL);
256 ok(ret == EINVAL, "Expected _get_doserrno to return EINVAL, got %d\n", ret);
257 ok(_doserrno == ERROR_INVALID_CMM, "Expected _doserrno to be ERROR_INVALID_CMM, got %d\n", _doserrno);
258 ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
259
260 _doserrno = ERROR_INVALID_CMM;
261 errno = EBADF;
262 out = 0xdeadbeef;
263 ret = p_get_doserrno(&out);
264 ok(ret == 0, "Expected _get_doserrno to return 0, got %d\n", ret);
265 ok(out == ERROR_INVALID_CMM, "Expected output variable to be ERROR_INVAID_CMM, got %d\n", out);
266 }
267
268 static void test__get_errno(void)
269 {
270 int ret, out;
271
272 if (!p_get_errno)
273 {
274 win_skip("_get_errno is not available\n");
275 return;
276 }
277
278 errno = EBADF;
279 ret = p_get_errno(NULL);
280 ok(ret == EINVAL, "Expected _get_errno to return EINVAL, got %d\n", ret);
281 ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
282
283 errno = EBADF;
284 out = 0xdeadbeef;
285 ret = p_get_errno(&out);
286 ok(ret == 0, "Expected _get_errno to return 0, got %d\n", ret);
287 ok(out == EBADF, "Expected output variable to be EBADF, got %d\n", out);
288 }
289
290 static void test__set_doserrno(void)
291 {
292 int ret;
293
294 if (!p_set_doserrno)
295 {
296 win_skip("_set_doserrno is not available\n");
297 return;
298 }
299
300 _doserrno = ERROR_INVALID_CMM;
301 ret = p_set_doserrno(ERROR_FILE_NOT_FOUND);
302 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
303 ok(_doserrno == ERROR_FILE_NOT_FOUND,
304 "Expected _doserrno to be ERROR_FILE_NOT_FOUND, got %d\n", _doserrno);
305
306 _doserrno = ERROR_INVALID_CMM;
307 ret = p_set_doserrno(-1);
308 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
309 ok(_doserrno == -1,
310 "Expected _doserrno to be -1, got %d\n", _doserrno);
311
312 _doserrno = ERROR_INVALID_CMM;
313 ret = p_set_doserrno(0xdeadbeef);
314 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
315 ok(_doserrno == 0xdeadbeef,
316 "Expected _doserrno to be 0xdeadbeef, got %d\n", _doserrno);
317 }
318
319 static void test__set_errno(void)
320 {
321 int ret;
322
323 if (!p_set_errno)
324 {
325 win_skip("_set_errno is not available\n");
326 return;
327 }
328
329 errno = EBADF;
330 ret = p_set_errno(EINVAL);
331 ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
332 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
333
334 errno = EBADF;
335 ret = p_set_errno(-1);
336 ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
337 ok(errno == -1, "Expected errno to be -1, got %d\n", errno);
338
339 errno = EBADF;
340 ret = p_set_errno(0xdeadbeef);
341 ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
342 ok(errno == 0xdeadbeef, "Expected errno to be 0xdeadbeef, got %d\n", errno);
343 }
344
345 static void test__popen_child(void)
346 {
347 /* don't execute any tests here */
348 /* ExitProcess is used to set return code of _pclose */
349 printf("child output\n");
350 ExitProcess(0x37);
351 }
352
353 static void test__popen(const char *name)
354 {
355 FILE *pipe;
356 char buf[1024];
357 int ret;
358
359 sprintf(buf, "\"%s\" misc popen", name);
360 pipe = _popen(buf, "r");
361 ok(pipe != NULL, "_popen failed with error: %d\n", errno);
362
363 fgets(buf, sizeof(buf), pipe);
364 ok(!strcmp(buf, "child output\n"), "buf = %s\n", buf);
365
366 ret = _pclose(pipe);
367 ok(ret == 0x37, "_pclose returned %x, expected 0x37\n", ret);
368
369 errno = 0xdeadbeef;
370 ret = _pclose((FILE*)0xdeadbeef);
371 ok(ret == -1, "_pclose returned %x, expected -1\n", ret);
372 if(p_set_errno)
373 ok(errno == EBADF, "errno = %d\n", errno);
374 }
375
376 static void test__invalid_parameter(void)
377 {
378 if(!p__invalid_parameter) {
379 win_skip("_invalid_parameter not available\n");
380 return;
381 }
382
383 p__invalid_parameter(NULL, NULL, NULL, 0, 0);
384 }
385
386 struct qsort_test
387 {
388 int pos;
389 int *base;
390
391 struct {
392 int l;
393 int r;
394 } cmp[64];
395 };
396
397 static int __cdecl qsort_comp(void *ctx, const void *l, const void *r)
398 {
399 struct qsort_test *qt = ctx;
400
401 if(qt) {
402 ok(qt->pos < 64, "qt->pos = %d\n", qt->pos);
403 ok(qt->cmp[qt->pos].l == (int*)l-qt->base,
404 "%d) l on %ld position\n", qt->pos, (long)((int*)l - qt->base));
405 ok(qt->cmp[qt->pos].r == (int*)r-qt->base,
406 "%d) r on %ld position\n", qt->pos, (long)((int*)r - qt->base));
407 qt->pos++;
408 }
409
410 return *(int*)l%1000 - *(int*)r%1000;
411 }
412
413 static void test_qsort_s(void)
414 {
415 static const int nonstable_test[] = {9000, 8001, 7002, 6003, 1003, 5004, 4005, 3006, 2007};
416 int tab[100], i;
417
418 struct qsort_test small_sort = {
419 0, tab, {
420 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 5}, {7, 6},
421 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 5},
422 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4},
423 {1, 0}, {2, 1}, {3, 2}, {4, 3},
424 {1, 0}, {2, 1}, {3, 2},
425 {1, 0}, {2, 1},
426 {1, 0}
427 }
428 }, small_sort2 = {
429 0, tab, {
430 {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0},
431 {1, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1},
432 {1, 0}, {2, 1}, {3, 2}, {4, 2}, {5, 2},
433 {1, 0}, {2, 1}, {3, 2}, {4, 3},
434 {1, 0}, {2, 1}, {3, 2},
435 {1, 0}, {2, 1},
436 {1, 0}
437 }
438 }, quick_sort = {
439 0, tab, {
440 {0, 4}, {0, 8}, {4, 8},
441 {1, 4}, {2, 4}, {3, 4}, {5, 4}, {6, 4}, {7, 4}, {7, 4}, {6, 4},
442 {6, 4},
443 {8, 7},
444 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 4},
445 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 3},
446 {1, 0}, {2, 1}, {3, 2}, {4, 2},
447 {1, 0}, {2, 1}, {3, 2},
448 {1, 0}, {2, 1},
449 {1, 0}
450 }
451 };
452
453 if(!p_qsort_s) {
454 win_skip("qsort_s not available\n");
455 return;
456 }
457
458 for(i=0; i<8; i++) tab[i] = i;
459 p_qsort_s(tab, 8, sizeof(int), qsort_comp, &small_sort);
460 ok(small_sort.pos == 28, "small_sort.pos = %d\n", small_sort.pos);
461 for(i=0; i<8; i++)
462 ok(tab[i] == i, "tab[%d] = %d\n", i, tab[i]);
463
464 for(i=0; i<8; i++) tab[i] = 7-i;
465 p_qsort_s(tab, 8, sizeof(int), qsort_comp, &small_sort2);
466 ok(small_sort2.pos == 28, "small_sort2.pos = %d\n", small_sort2.pos);
467 for(i=0; i<8; i++)
468 ok(tab[i] == i, "tab[%d] = %d\n", i, tab[i]);
469
470 for(i=0; i<9; i++) tab[i] = i;
471 tab[5] = 1;
472 tab[6] = 2;
473 p_qsort_s(tab, 9, sizeof(int), qsort_comp, &quick_sort);
474 ok(quick_sort.pos == 34, "quick_sort.pos = %d\n", quick_sort.pos);
475
476 /* show that qsort is not stable */
477 for(i=0; i<9; i++) tab[i] = 8-i + 1000*(i+1);
478 tab[0] = 1003;
479 p_qsort_s(tab, 9, sizeof(int), qsort_comp, NULL);
480 for(i=0; i<9; i++)
481 ok(tab[i] == nonstable_test[i], "tab[%d] = %d, expected %d\n", i, tab[i], nonstable_test[i]);
482
483 /* check if random data is sorted */
484 srand(0);
485 for(i=0; i<100; i++) tab[i] = rand()%1000;
486 p_qsort_s(tab, 100, sizeof(int), qsort_comp, NULL);
487 for(i=1; i<100; i++)
488 ok(tab[i-1] <= tab[i], "data sorted incorrectly on position %d: %d <= %d\n", i, tab[i-1], tab[i]);
489
490 /* test if random permutation is sorted correctly */
491 for(i=0; i<100; i++) tab[i] = i;
492 for(i=0; i<100; i++) {
493 int b = rand()%100;
494 int e = rand()%100;
495
496 if(b == e) continue;
497 tab[b] ^= tab[e];
498 tab[e] ^= tab[b];
499 tab[b] ^= tab[e];
500 }
501 p_qsort_s(tab, 100, sizeof(int), qsort_comp, NULL);
502 for(i=0; i<100; i++)
503 ok(tab[i] == i, "data sorted incorrectly on position %d: %d\n", i, tab[i]);
504 }
505
506 static void test_math_functions(void)
507 {
508 double ret;
509
510 errno = 0xdeadbeef;
511 p_atan(NAN);
512 ok(errno == EDOM, "errno = %d\n", errno);
513
514 errno = 0xdeadbeef;
515 ret = p_atan(INFINITY);
516 ok(almost_equal(ret, 1.57079632679489661923), "ret = %lf\n", ret);
517 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
518
519 errno = 0xdeadbeef;
520 ret = p_atan(-INFINITY);
521 ok(almost_equal(ret, -1.57079632679489661923), "ret = %lf\n", ret);
522 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
523
524 errno = 0xdeadbeef;
525 p_tanh(NAN);
526 ok(errno == EDOM, "errno = %d\n", errno);
527
528 errno = 0xdeadbeef;
529 ret = p_tanh(INFINITY);
530 ok(almost_equal(ret, 1.0), "ret = %lf\n", ret);
531 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
532
533 errno = 0xdeadbeef;
534 p_exp(NAN);
535 ok(errno == EDOM, "errno = %d\n", errno);
536
537 errno = 0xdeadbeef;
538 p_exp(INFINITY);
539 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
540 }
541
542 START_TEST(misc)
543 {
544 int arg_c;
545 char** arg_v;
546
547 init();
548
549 arg_c = winetest_get_mainargs(&arg_v);
550 if(arg_c >= 3) {
551 if(!strcmp(arg_v[2], "popen"))
552 test__popen_child();
553 else
554 ok(0, "invalid argument '%s'\n", arg_v[2]);
555
556 return;
557 }
558
559 test_rand_s();
560 test_I10_OUTPUT();
561 test_strerror_s();
562 test__get_doserrno();
563 test__get_errno();
564 test__set_doserrno();
565 test__set_errno();
566 test__popen(arg_v[0]);
567 test__invalid_parameter();
568 test_qsort_s();
569 test_math_functions();
570 }