ReactOS 0.4.16-dev-1481-ga753f34
misc.c File Reference
#include "wine/test.h"
#include <errno.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <math.h>
#include <process.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Classes

struct  uld
 
struct  _I10_OUTPUT_data
 
struct  _I10_OUTPUT_test
 
struct  qsort_test
 

Typedefs

typedef struct _I10_OUTPUT_data I10_OUTPUT_data
 
typedef struct _I10_OUTPUT_test I10_OUTPUT_test
 

Functions

static BOOL almost_equal (double d1, double d2)
 
static int (__cdecl *prand_s)(unsigned int *)
 
static void (__cdecl *p__invalid_parameter)(const wchar_t *
 
static void test_rand_s (void)
 
static void test_I10_OUTPUT (void)
 
static void test_strerror_s (void)
 
static void test__get_doserrno (void)
 
static void test__get_errno (void)
 
static void test__set_doserrno (void)
 
static void test__set_errno (void)
 
static void test__popen_child (int fd)
 
static void test__popen_read_child (void)
 
static void test__popen (const char *name)
 
static void test__invalid_parameter (void)
 
static int __cdecl qsort_comp (void *ctx, const void *l, const void *r)
 
static void test_qsort_s (void)
 
static int eq_nan (UINT64 ai, double b)
 
static int eq_nanf (DWORD ai, float b)
 
static void test_math_functions (void)
 
static void __cdecl test_thread_func (void *end_thread_type)
 
static unsigned __stdcall test_thread_func_ex (void *arg)
 
static void test_thread_handle_close (void)
 
static void test_thread_suspended (void)
 
static int __cdecl _lfind_s_comp (void *ctx, const void *l, const void *r)
 
static void test__lfind_s (void)
 
 START_TEST (misc)
 

Variables

static int
 
static void *static size_t
 
static const wchar_t const wchar_t unsigned uintptr_t
 
static const I10_OUTPUT_test I10_OUTPUT_tests []
 

Typedef Documentation

◆ I10_OUTPUT_data

◆ I10_OUTPUT_test

Function Documentation

◆ _lfind_s_comp()

static int __cdecl _lfind_s_comp ( void ctx,
const void l,
const void r 
)
static

Definition at line 683 of file misc.c.

684{
685 *(int *)ctx = 0xdeadc0de;
686 return *(int *)l - *(int *)r;
687}
r l[0]
Definition: byte_order.h:168
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

Referenced by test__lfind_s().

◆ almost_equal()

static BOOL almost_equal ( double  d1,
double  d2 
)
inlinestatic

Definition at line 32 of file misc.c.

32 {
33 if(d1-d2>-1e-30 && d1-d2<1e-30)
34 return TRUE;
35 return FALSE;
36}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define e
Definition: ke_i.h:82

Referenced by test_math_functions().

◆ eq_nan()

static int eq_nan ( UINT64  ai,
double  b 
)
static

Definition at line 540 of file misc.c.

541{
542 UINT64 bi = *(UINT64*)&b;
543 UINT64 mask;
544
545#if defined(__i386__)
546 mask = 0xFFFFFFFF00000000ULL;
547#else
548 mask = ~0;
549#endif
550
551 ok((ai & mask) == (bi & mask), "comparing %s and %s\n",
553 return (ai & mask) == (bi & mask);
554}
unsigned long long UINT64
#define ok(value,...)
Definition: atltest.h:57
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
GLenum GLint GLuint mask
Definition: glext.h:6028
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

Referenced by test_math_functions().

◆ eq_nanf()

static int eq_nanf ( DWORD  ai,
float  b 
)
static

Definition at line 556 of file misc.c.

557{
558 DWORD bi = *(DWORD*)&b;
559 ok(ai == bi, "comparing %08lx and %08lx\n", ai, bi);
560 return ai == bi;
561}
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by test_math_functions().

◆ int()

static int ( __cdecl prand_s)
static

Definition at line 51 of file misc.c.

59{
60 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
61
62 prand_s = (void *)GetProcAddress(hmod, "rand_s");
63 pI10_OUTPUT = (void*)GetProcAddress(hmod, "$I10_OUTPUT");
64 pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s");
65 p_get_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno");
66 p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
67 p_set_doserrno = (void *)GetProcAddress(hmod, "_set_doserrno");
68 p_set_errno = (void *)GetProcAddress(hmod, "_set_errno");
69 p__invalid_parameter = (void *)GetProcAddress(hmod, "_invalid_parameter");
70 p_qsort_s = (void *)GetProcAddress(hmod, "qsort_s");
71 p_atan = (void *)GetProcAddress(hmod, "atan");
72 p_exp = (void *)GetProcAddress(hmod, "exp");
73 p_tanh = (void *)GetProcAddress(hmod, "tanh");
74 p_lfind_s = (void *)GetProcAddress(hmod, "_lfind_s");
75}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:143

◆ qsort_comp()

static int __cdecl qsort_comp ( void ctx,
const void l,
const void r 
)
static

Definition at line 431 of file misc.c.

432{
433 struct qsort_test *qt = ctx;
434
435 if(qt) {
436 ok(qt->pos < 64, "qt->pos = %d\n", qt->pos);
437 ok(qt->cmp[qt->pos].l == (int*)l-qt->base,
438 "%d) l on %ld position\n", qt->pos, (long)((int*)l - qt->base));
439 ok(qt->cmp[qt->pos].r == (int*)r-qt->base,
440 "%d) r on %ld position\n", qt->pos, (long)((int*)r - qt->base));
441 qt->pos++;
442 }
443
444 return *(int*)l%1000 - *(int*)r%1000;
445}
int pos
Definition: misc.c:422
struct qsort_test::@1812 cmp[64]
int * base
Definition: misc.c:423

Referenced by test_qsort_s().

◆ START_TEST()

START_TEST ( misc  )

Definition at line 751 of file misc.c.

752{
753 int arg_c;
754 char** arg_v;
755
756 init();
757
758 arg_c = winetest_get_mainargs(&arg_v);
759 if(arg_c >= 3) {
760 if (!strcmp(arg_v[2], "popen_read"))
762 else if(arg_c == 4 && !strcmp(arg_v[2], "popen"))
763 test__popen_child(atoi(arg_v[3]));
764 else
765 ok(0, "invalid argument '%s'\n", arg_v[2]);
766
767 return;
768 }
769
770 test_rand_s();
777 test__popen(arg_v[0]);
779 test_qsort_s();
784}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static void test__invalid_parameter(void)
Definition: misc.c:410
static void test__lfind_s(void)
Definition: misc.c:689
static void test__set_doserrno(void)
Definition: misc.c:283
static void test__popen_child(int fd)
Definition: misc.c:338
static void test_math_functions(void)
Definition: misc.c:563
static void test__popen_read_child(void)
Definition: misc.c:348
static void test_qsort_s(void)
Definition: misc.c:447
static void test__get_errno(void)
Definition: misc.c:261
static void test_thread_handle_close(void)
Definition: misc.c:626
static void test__set_errno(void)
Definition: misc.c:312
static void test__get_doserrno(void)
Definition: misc.c:236
static void test_I10_OUTPUT(void)
Definition: misc.c:159
static void test_strerror_s(void)
Definition: misc.c:189
static void test__popen(const char *name)
Definition: misc.c:362
static void test_rand_s(void)
Definition: misc.c:77
static void test_thread_suspended(void)
Definition: misc.c:670
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
int winetest_get_mainargs(char ***pargv)
static int init
Definition: wintirpc.c:33

◆ test__get_doserrno()

static void test__get_doserrno ( void  )
static

Definition at line 236 of file misc.c.

237{
238 int ret, out;
239
240 if (!p_get_doserrno)
241 {
242 win_skip("_get_doserrno is not available\n");
243 return;
244 }
245
247 errno = EBADF;
248 ret = p_get_doserrno(NULL);
249 ok(ret == EINVAL, "Expected _get_doserrno to return EINVAL, got %d\n", ret);
250 ok(_doserrno == ERROR_INVALID_CMM, "Expected _doserrno to be ERROR_INVALID_CMM, got %ld\n", _doserrno);
251 ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
252
254 errno = EBADF;
255 out = 0xdeadbeef;
256 ret = p_get_doserrno(&out);
257 ok(ret == 0, "Expected _get_doserrno to return 0, got %d\n", ret);
258 ok(out == ERROR_INVALID_CMM, "Expected output variable to be ERROR_INVALID_CMM, got %d\n", out);
259}
#define EINVAL
Definition: acclib.h:90
#define EBADF
Definition: acclib.h:82
#define NULL
Definition: types.h:112
return ret
Definition: mutex.c:146
#define errno
Definition: errno.h:18
#define _doserrno
Definition: stdlib.h:131
#define win_skip
Definition: test.h:164
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define ERROR_INVALID_CMM
Definition: winerror.h:1185

Referenced by START_TEST().

◆ test__get_errno()

static void test__get_errno ( void  )
static

Definition at line 261 of file misc.c.

262{
263 int ret, out;
264
265 if (!p_get_errno)
266 {
267 win_skip("_get_errno is not available\n");
268 return;
269 }
270
271 errno = EBADF;
272 ret = p_get_errno(NULL);
273 ok(ret == EINVAL, "Expected _get_errno to return EINVAL, got %d\n", ret);
274 ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
275
276 errno = EBADF;
277 out = 0xdeadbeef;
278 ret = p_get_errno(&out);
279 ok(ret == 0, "Expected _get_errno to return 0, got %d\n", ret);
280 ok(out == EBADF, "Expected output variable to be EBADF, got %d\n", out);
281}

Referenced by START_TEST().

◆ test__invalid_parameter()

static void test__invalid_parameter ( void  )
static

Definition at line 410 of file misc.c.

411{
412 if(!p__invalid_parameter) {
413 win_skip("_invalid_parameter not available\n");
414 return;
415 }
416
417 p__invalid_parameter(NULL, NULL, NULL, 0, 0);
418}

Referenced by START_TEST().

◆ test__lfind_s()

static void test__lfind_s ( void  )
static

Definition at line 689 of file misc.c.

690{
691 static const int tests[] = {9000, 8001, 7002, 6003, 1003, 5004, 4005, 3006, 2007};
692 unsigned int num;
693 void *found;
694 int ctx;
695 int key;
696
697 if (!p_lfind_s)
698 {
699 win_skip("_lfind_s is not available\n");
700 return;
701 }
702
703 key = 1234;
705
706 errno = 0xdeadbeef;
707 found = p_lfind_s(NULL, tests, &num, sizeof(int), _lfind_s_comp, NULL);
708 ok(errno == EINVAL, "errno = %d\n", errno);
709 ok(!found, "Expected NULL, got %p\n", found);
710
711 errno = 0xdeadbeef;
712 found = p_lfind_s(&key, NULL, &num, sizeof(int), _lfind_s_comp, NULL);
713 ok(errno == EINVAL, "errno = %d\n", errno);
714 ok(!found, "Expected NULL, got %p\n", found);
715
716 errno = 0xdeadbeef;
717 found = p_lfind_s(&key, tests, &num, 0, _lfind_s_comp, NULL);
718 ok(errno == EINVAL, "errno = %d\n", errno);
719 ok(!found, "Expected NULL, got %p\n", found);
720
721 errno = 0xdeadbeef;
722 found = p_lfind_s(&key, tests, &num, sizeof(int), NULL, NULL);
723 ok(errno == EINVAL, "errno = %d\n", errno);
724 ok(!found, "Expected NULL, got %p\n", found);
725
726 ctx = -1;
727 key = 9000;
728 errno = 0xdeadbeef;
729 found = p_lfind_s(&key, tests, &num, sizeof(int), _lfind_s_comp, &ctx);
730 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
731 ok(found == tests, "Expected %p, got %p\n", tests, found);
732 ok(ctx == 0xdeadc0de, "Expected 0xdeadc0de, got %x\n", ctx);
733
734 ctx = -1;
735 key = 2007;
736 errno = 0xdeadbeef;
737 found = p_lfind_s(&key, tests, &num, sizeof(int), _lfind_s_comp, &ctx);
738 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
739 ok(found == tests+8, "Expected %p, got %p\n", tests+8, found);
740 ok(ctx == 0xdeadc0de, "Expected 0xdeadc0de, got %x\n", ctx);
741
742 ctx = -1;
743 key = 1234;
744 errno = 0xdeadbeef;
745 found = p_lfind_s(&key, tests, &num, sizeof(int), _lfind_s_comp, &ctx);
746 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
747 ok(!found, "Expected NULL, got %p\n", found);
748 ok(ctx == 0xdeadc0de, "Expected 0xdeadc0de, got %x\n", ctx);
749}
#define ARRAY_SIZE(A)
Definition: main.h:20
GLuint GLuint num
Definition: glext.h:9618
static struct test_info tests[]
static int __cdecl _lfind_s_comp(void *ctx, const void *l, const void *r)
Definition: misc.c:683
Definition: copy.c:22

Referenced by START_TEST().

◆ test__popen()

static void test__popen ( const char name)
static

Definition at line 362 of file misc.c.

363{
364 FILE *pipe;
365 char *tempf, buf[1024];
366 int ret, fd;
367
368 tempf = _tempnam(".", "wne");
369 ok(tempf != NULL, "_tempnam failed\n");
370 fd = _open(tempf, _O_CREAT | _O_WRONLY);
371 ok(fd != -1, "open failed\n");
372
373 sprintf(buf, "\"%s\" misc popen %d", name, fd);
374 pipe = _popen(buf, "r");
375 ok(pipe != NULL, "_popen failed with error: %d\n", errno);
376
377 fgets(buf, sizeof(buf), pipe);
378 ok(!strcmp(buf, "child output\n"), "buf = %s\n", buf);
379
380 ret = _pclose(pipe);
381 ok(ret == 0x37, "_pclose returned %x, expected 0x37\n", ret);
382 _close(fd);
383 _unlink(tempf);
384 free(tempf);
385
386 errno = 0xdeadbeef;
387 ret = _pclose((FILE*)0xdeadbeef);
388 ok(ret == -1, "_pclose returned %x, expected -1\n", ret);
389 if(p_set_errno)
390 ok(errno == EBADF, "errno = %d\n", errno);
391
392 sprintf(buf, "\"%s\" misc popen_read", name);
393 pipe = _popen(buf, "w");
394 ok(pipe != NULL, "_popen failed with error: %d\n", errno);
395
396 ret = fputs("child-to-parent\n", pipe);
397 ok(ret != EOF, "fputs returned %x\n", ret);
398
399#ifdef __REACTOS__
400 if (IsReactOS())
401 {
402 skip("Skipping _pclose, because it hangs on reactos\n");
403 return;
404 }
405#endif
406 ret = _pclose(pipe);
407 ok(ret == 0x3, "_pclose returned %x, expected 0x3\n", ret);
408}
#define skip(...)
Definition: atltest.h:64
#define free
Definition: debug_ros.c:5
#define _O_CREAT
Definition: cabinet.h:46
#define _O_WRONLY
Definition: cabinet.h:38
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP char *__cdecl _tempnam(_In_opt_z_ const char *_DirName, _In_opt_z_ const char *_FilePrefix)
#define EOF
Definition: stdio.h:24
_Check_return_opt_ _CRTIMP int __cdecl fputs(_In_z_ const char *_Str, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl _popen(_In_z_ const char *_Command, _In_z_ const char *_Mode)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_Check_return_opt_ _CRTIMP int __cdecl _close(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl _unlink(_In_z_ const char *_Filename)
_CRTIMP int __cdecl _open(const char *_Filename, int _OpenFlag,...)
Definition: file.c:2001
static int fd
Definition: io.c:51
Definition: name.c:39

Referenced by START_TEST().

◆ test__popen_child()

static void test__popen_child ( int  fd)
static

Definition at line 338 of file misc.c.

339{
340 /* don't execute any tests here */
341 /* ExitProcess is used to set return code of _pclose */
342 printf("child output\n");
344 ExitProcess(1);
345 ExitProcess(0x37);
346}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
#define printf
Definition: freeldr.h:97
_CRTIMP intptr_t __cdecl _get_osfhandle(_In_ int _FileHandle)

Referenced by START_TEST().

◆ test__popen_read_child()

static void test__popen_read_child ( void  )
static

Definition at line 348 of file misc.c.

349{
350 char buf[1024], *rets;
351
352 rets = fgets(buf, sizeof(buf), stdin);
353 if (strcmp(buf, "child-to-parent\n") != 0)
354 ExitProcess(1);
355
356 rets = fgets(buf, sizeof(buf), stdin);
357 if (rets)
358 ExitProcess(2);
359 ExitProcess(3);
360}
#define stdin
Definition: stdio.h:98

Referenced by START_TEST().

◆ test__set_doserrno()

static void test__set_doserrno ( void  )
static

Definition at line 283 of file misc.c.

284{
285 int ret;
286
287 if (!p_set_doserrno)
288 {
289 win_skip("_set_doserrno is not available\n");
290 return;
291 }
292
294 ret = p_set_doserrno(ERROR_FILE_NOT_FOUND);
295 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
297 "Expected _doserrno to be ERROR_FILE_NOT_FOUND, got %ld\n", _doserrno);
298
300 ret = p_set_doserrno(-1);
301 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
302 ok(_doserrno == -1,
303 "Expected _doserrno to be -1, got %ld\n", _doserrno);
304
306 ret = p_set_doserrno(0xdeadbeef);
307 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
308 ok(_doserrno == 0xdeadbeef,
309 "Expected _doserrno to be 0xdeadbeef, got %ld\n", _doserrno);
310}
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79

Referenced by START_TEST().

◆ test__set_errno()

static void test__set_errno ( void  )
static

Definition at line 312 of file misc.c.

313{
314 int ret;
315
316 if (!p_set_errno)
317 {
318 win_skip("_set_errno is not available\n");
319 return;
320 }
321
322 errno = EBADF;
323 ret = p_set_errno(EINVAL);
324 ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
325 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
326
327 errno = EBADF;
328 ret = p_set_errno(-1);
329 ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
330 ok(errno == -1, "Expected errno to be -1, got %d\n", errno);
331
332 errno = EBADF;
333 ret = p_set_errno(0xdeadbeef);
334 ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
335 ok(errno == 0xdeadbeef, "Expected errno to be 0xdeadbeef, got %d\n", errno);
336}

Referenced by START_TEST().

◆ test_I10_OUTPUT()

static void test_I10_OUTPUT ( void  )
static

Definition at line 159 of file misc.c.

160{
162 int i, j, ret;
163
164 if(!pI10_OUTPUT) {
165 win_skip("I10_OUTPUT not available\n");
166 return;
167 }
168
169 for(i=0; i<ARRAY_SIZE(I10_OUTPUT_tests); i++) {
170 memset(out.str, '#', sizeof(out.str));
172 ok(ret == I10_OUTPUT_tests[i].ret, "%d: ret = %d\n", i, ret);
173 ok(out.pos == I10_OUTPUT_tests[i].out.pos, "%d: out.pos = %hd\n", i, out.pos);
174 ok(out.sign == I10_OUTPUT_tests[i].out.sign, "%d: out.size = %c\n", i, out.sign);
175 ok(out.len == I10_OUTPUT_tests[i].out.len, "%d: out.len = %d\n", i, (int)out.len);
176 ok(!strcmp(out.str, I10_OUTPUT_tests[i].out.str), "%d: out.str = %s\n", i, out.str);
177
178 j = strlen(I10_OUTPUT_tests[i].remain);
179 todo_wine_if(j && I10_OUTPUT_tests[i].remain[j-1]=='9')
180 ok(!strncmp(out.str+out.len+1, I10_OUTPUT_tests[i].remain, j),
181 "%d: &out.str[%d] = %.25s...\n", i, out.len+1, out.str+out.len+1);
182
183 for(j=out.len+strlen(I10_OUTPUT_tests[i].remain)+1; j<sizeof(out.str); j++)
184 if(out.str[j] != '#')
185 ok(0, "%d: out.str[%d] = %c (expected \'#\')\n", i, j, out.str[j]);
186 }
187}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
GLdouble s
Definition: gl.h:2039
GLdouble n
Definition: glext.h:7729
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define d
Definition: ke_i.h:81
if(dx< 0)
Definition: linetemp.h:194
#define for
Definition: utility.h:88
#define todo_wine_if(is_todo)
Definition: custom.c:86
static const I10_OUTPUT_test I10_OUTPUT_tests[]
Definition: misc.c:114
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
char sign
Definition: misc.c:99
short pos
Definition: misc.c:98
char str[100]
Definition: misc.c:101
I10_OUTPUT_data out
Definition: misc.c:109
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by START_TEST().

◆ test_math_functions()

static void test_math_functions ( void  )
static

Definition at line 563 of file misc.c.

564{
565 static const UINT64 test_nan_i = 0xFFF0000123456780ULL;
566 static const DWORD test_nanf_i = 0xFF801234;
567 double test_nan = *(double*)&test_nan_i;
568 float test_nanf = *(float*)&test_nanf_i;
569 double ret;
570
571 errno = 0xdeadbeef;
572 p_atan(NAN);
573 ok(errno == EDOM, "errno = %d\n", errno);
574
575 errno = 0xdeadbeef;
576 ret = p_atan(INFINITY);
577 ok(almost_equal(ret, 1.57079632679489661923), "ret = %lf\n", ret);
578 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
579
580 errno = 0xdeadbeef;
581 ret = p_atan(-INFINITY);
582 ok(almost_equal(ret, -1.57079632679489661923), "ret = %lf\n", ret);
583 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
584
585 errno = 0xdeadbeef;
586 p_tanh(NAN);
587 ok(errno == EDOM, "errno = %d\n", errno);
588
589 errno = 0xdeadbeef;
590 ret = p_tanh(INFINITY);
591 ok(almost_equal(ret, 1.0), "ret = %lf\n", ret);
592 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
593
594 errno = 0xdeadbeef;
595 p_exp(NAN);
596 ok(errno == EDOM, "errno = %d\n", errno);
597
598 errno = 0xdeadbeef;
599 p_exp(INFINITY);
600 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
601
602 ok(eq_nan(test_nan_i | (1ULL << 51), cosh(test_nan)), "cosh not preserving nan\n");
603 ok(eq_nan(test_nan_i | (1ULL << 51), sinh(test_nan)), "sinh not preserving nan\n");
604 ok(eq_nan(test_nan_i | (1ULL << 51), tanh(test_nan)), "tanh not preserving nan\n");
605 ok(eq_nanf(test_nanf_i | (1 << 22), coshf(test_nanf)), "coshf not preserving nan\n");
606 ok(eq_nanf(test_nanf_i | (1 << 22), sinhf(test_nanf)), "sinhf not preserving nan\n");
607 ok(eq_nanf(test_nanf_i | (1 << 22), tanhf(test_nanf)), "tanhf not preserving nan\n");
608}
_STLP_DECLSPEC complex< float > _STLP_CALL sinh(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL cosh(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL tanh(const complex< float > &)
#define EDOM
Definition: errno.h:39
_Check_return_ float __cdecl tanhf(_In_ float x)
Definition: math.h:251
#define INFINITY
Definition: math.h:56
_Check_return_ float __cdecl coshf(_In_ float x)
Definition: math.h:239
_Check_return_ float __cdecl sinhf(_In_ float x)
Definition: math.h:248
#define NAN
Definition: mesh.c:39
static int eq_nan(UINT64 ai, double b)
Definition: misc.c:540
static BOOL almost_equal(double d1, double d2)
Definition: misc.c:32
static int eq_nanf(DWORD ai, float b)
Definition: misc.c:556

Referenced by START_TEST().

◆ test_qsort_s()

static void test_qsort_s ( void  )
static

Definition at line 447 of file misc.c.

448{
449 static const int nonstable_test[] = {9000, 8001, 7002, 6003, 1003, 5004, 4005, 3006, 2007};
450 int tab[100], i;
451
452 struct qsort_test small_sort = {
453 0, tab, {
454 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 5}, {7, 6},
455 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 5},
456 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4},
457 {1, 0}, {2, 1}, {3, 2}, {4, 3},
458 {1, 0}, {2, 1}, {3, 2},
459 {1, 0}, {2, 1},
460 {1, 0}
461 }
462 }, small_sort2 = {
463 0, tab, {
464 {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0},
465 {1, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1},
466 {1, 0}, {2, 1}, {3, 2}, {4, 2}, {5, 2},
467 {1, 0}, {2, 1}, {3, 2}, {4, 3},
468 {1, 0}, {2, 1}, {3, 2},
469 {1, 0}, {2, 1},
470 {1, 0}
471 }
472 }, quick_sort = {
473 0, tab, {
474 {0, 4}, {0, 8}, {4, 8},
475 {1, 4}, {2, 4}, {3, 4}, {5, 4}, {6, 4}, {7, 4}, {7, 4}, {6, 4},
476 {6, 4},
477 {8, 7},
478 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 4},
479 {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 3},
480 {1, 0}, {2, 1}, {3, 2}, {4, 2},
481 {1, 0}, {2, 1}, {3, 2},
482 {1, 0}, {2, 1},
483 {1, 0}
484 }
485 };
486
487 if(!p_qsort_s) {
488 win_skip("qsort_s not available\n");
489 return;
490 }
491
492 for(i=0; i<8; i++) tab[i] = i;
493 p_qsort_s(tab, 8, sizeof(int), qsort_comp, &small_sort);
494 ok(small_sort.pos == 28, "small_sort.pos = %d\n", small_sort.pos);
495 for(i=0; i<8; i++)
496 ok(tab[i] == i, "tab[%d] = %d\n", i, tab[i]);
497
498 for(i=0; i<8; i++) tab[i] = 7-i;
499 p_qsort_s(tab, 8, sizeof(int), qsort_comp, &small_sort2);
500 ok(small_sort2.pos == 28, "small_sort2.pos = %d\n", small_sort2.pos);
501 for(i=0; i<8; i++)
502 ok(tab[i] == i, "tab[%d] = %d\n", i, tab[i]);
503
504 for(i=0; i<9; i++) tab[i] = i;
505 tab[5] = 1;
506 tab[6] = 2;
507 p_qsort_s(tab, 9, sizeof(int), qsort_comp, &quick_sort);
508 ok(quick_sort.pos == 34, "quick_sort.pos = %d\n", quick_sort.pos);
509
510 /* show that qsort is not stable */
511 for(i=0; i<9; i++) tab[i] = 8-i + 1000*(i+1);
512 tab[0] = 1003;
513 p_qsort_s(tab, 9, sizeof(int), qsort_comp, NULL);
514 for(i=0; i<9; i++)
515 ok(tab[i] == nonstable_test[i], "tab[%d] = %d, expected %d\n", i, tab[i], nonstable_test[i]);
516
517 /* check if random data is sorted */
518 srand(0);
519 for(i=0; i<100; i++) tab[i] = rand()%1000;
520 p_qsort_s(tab, 100, sizeof(int), qsort_comp, NULL);
521 for(i=1; i<100; i++)
522 ok(tab[i-1] <= tab[i], "data sorted incorrectly on position %d: %d <= %d\n", i, tab[i-1], tab[i]);
523
524 /* test if random permutation is sorted correctly */
525 for(i=0; i<100; i++) tab[i] = i;
526 for(i=0; i<100; i++) {
527 int b = rand()%100;
528 int e = rand()%100;
529
530 if(b == e) continue;
531 tab[b] ^= tab[e];
532 tab[e] ^= tab[b];
533 tab[b] ^= tab[e];
534 }
535 p_qsort_s(tab, 100, sizeof(int), qsort_comp, NULL);
536 for(i=0; i<100; i++)
537 ok(tab[i] == i, "data sorted incorrectly on position %d: %d\n", i, tab[i]);
538}
#define b
Definition: ke_i.h:79
static int __cdecl qsort_comp(void *ctx, const void *l, const void *r)
Definition: misc.c:431
void __cdecl srand(_In_ unsigned int _Seed)
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
static struct wctab tab[]

Referenced by START_TEST().

◆ test_rand_s()

static void test_rand_s ( void  )
static

Definition at line 77 of file misc.c.

78{
79 int ret;
80 unsigned int rand;
81
82 if (!prand_s)
83 {
84 win_skip("rand_s is not available\n");
85 return;
86 }
87
88 errno = EBADF;
89 ret = prand_s(NULL);
90 ok(ret == EINVAL, "Expected rand_s to return EINVAL, got %d\n", ret);
91 ok(errno == EINVAL, "Expected errno to return EINVAL, got %d\n", errno);
92
93 ret = prand_s(&rand);
94 ok(ret == 0, "Expected rand_s to return 0, got %d\n", ret);
95}

Referenced by START_TEST().

◆ test_strerror_s()

static void test_strerror_s ( void  )
static

Definition at line 189 of file misc.c.

190{
191 int ret;
192 char buf[256];
193
194 if (!pstrerror_s)
195 {
196 win_skip("strerror_s is not available\n");
197 return;
198 }
199
200 errno = EBADF;
201 ret = pstrerror_s(NULL, 0, 0);
202 ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
203 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
204
205 errno = EBADF;
206 ret = pstrerror_s(NULL, sizeof(buf), 0);
207 ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
208 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
209
210 memset(buf, 'X', sizeof(buf));
211 errno = EBADF;
212 ret = pstrerror_s(buf, 0, 0);
213 ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
214 ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
215 ok(buf[0] == 'X', "Expected output buffer to be untouched\n");
216
217 memset(buf, 'X', sizeof(buf));
218 ret = pstrerror_s(buf, 1, 0);
219 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
220 ok(buf[0] == 0, "Expected output buffer to be null terminated\n");
221
222 memset(buf, 'X', sizeof(buf));
223 ret = pstrerror_s(buf, 2, 0);
224 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
225 ok(strlen(buf) == 1, "Expected output buffer to be truncated\n");
226
227 memset(buf, 'X', sizeof(buf));
228 ret = pstrerror_s(buf, sizeof(buf), 0);
229 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
230
231 memset(buf, 'X', sizeof(buf));
232 ret = pstrerror_s(buf, sizeof(buf), -1);
233 ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
234}

Referenced by START_TEST().

◆ test_thread_func()

static void __cdecl test_thread_func ( void end_thread_type)
static

Definition at line 610 of file misc.c.

611{
612 if (end_thread_type == (void*)1)
613 _endthread();
614 else if (end_thread_type == (void*)2)
615 ExitThread(0);
616 else if (end_thread_type == (void*)3)
617 _endthreadex(0);
618}
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
void CDECL _endthread(void)
Definition: thread.c:95
void CDECL _endthreadex(unsigned int)
Definition: thread.cpp:276

Referenced by test_thread_handle_close().

◆ test_thread_func_ex()

static unsigned __stdcall test_thread_func_ex ( void arg)
static

Definition at line 620 of file misc.c.

621{
622 _endthread();
623 return 0;
624}

Referenced by test_thread_handle_close(), and test_thread_suspended().

◆ test_thread_handle_close()

static void test_thread_handle_close ( void  )
static

Definition at line 626 of file misc.c.

627{
629 DWORD ret;
630
631 /* _beginthread: handle is not closed on ExitThread and _endthreadex */
633 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
636 ok(!ret, "ret = %ld\n", ret);
637
639 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
642 ok(!ret, "ret = %ld\n", ret);
643
645 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
646 Sleep(150);
648 ok(ret == WAIT_OBJECT_0, "ret = %ld\n", ret);
650 ok(ret, "ret = %ld\n", ret);
651
653 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
654 Sleep(150);
656 ok(ret == WAIT_OBJECT_0, "ret = %ld\n", ret);
658 ok(ret, "ret = %ld\n", ret);
659
660 /* _beginthreadex: handle is not closed on _endthread */
662 ok(hThread != NULL, "_beginthreadex failed (%d)\n", errno);
663 Sleep(150);
665 ok(ret == WAIT_OBJECT_0, "ret = %ld\n", ret);
667 ok(ret, "ret = %ld\n", ret);
668}
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
static void __cdecl test_thread_func(void *end_thread_type)
Definition: misc.c:610
static unsigned __stdcall test_thread_func_ex(void *arg)
Definition: misc.c:620
HANDLE hThread
Definition: wizard.c:28
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
_CRTIMP uintptr_t __cdecl _beginthread(_In_ void(__cdecl *_StartAddress)(void *), _In_ unsigned _StackSize, _In_opt_ void *_ArgList)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
PVOID HANDLE
Definition: typedefs.h:73
#define WAIT_OBJECT_0
Definition: winbase.h:439

Referenced by START_TEST().

◆ test_thread_suspended()

static void test_thread_suspended ( void  )
static

Definition at line 670 of file misc.c.

671{
673 DWORD ret;
674
676 ok(hThread != NULL, "_beginthreadex failed (%d)\n", errno);
678 ok(ret == 1, "suspend count = %ld\n", ret);
680 ok(ret == WAIT_OBJECT_0, "ret = %ld\n", ret);
681}
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
#define CREATE_SUSPENDED
Definition: winbase.h:188

Referenced by START_TEST().

◆ void()

static void ( __cdecl p__invalid_parameter) const
static

Variable Documentation

◆ I10_OUTPUT_tests

const I10_OUTPUT_test I10_OUTPUT_tests[]
static

Definition at line 114 of file misc.c.

Referenced by test_I10_OUTPUT().

◆ int

Definition at line 42 of file misc.c.

◆ size_t

Definition at line 43 of file misc.c.

◆ uintptr_t

Definition at line 49 of file misc.c.