ReactOS 0.4.16-dev-852-gcfcc8d8
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 <versionhelpers.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 681 of file misc.c.

682{
683 *(int *)ctx = 0xdeadc0de;
684 return *(int *)l - *(int *)r;
685}
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 30 of file misc.c.

30 {
31 if(d1-d2>-1e-30 && d1-d2<1e-30)
32 return TRUE;
33 return FALSE;
34}
#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 538 of file misc.c.

539{
540 UINT64 bi = *(UINT64*)&b;
541 UINT64 mask;
542
543#if defined(__i386__)
544 mask = 0xFFFFFFFF00000000ULL;
545#else
546 mask = ~0;
547#endif
548
549 ok((ai & mask) == (bi & mask), "comparing %s and %s\n",
551 return (ai & mask) == (bi & mask);
552}
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 554 of file misc.c.

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

Referenced by test_math_functions().

◆ int()

static int ( __cdecl prand_s)
static

Definition at line 49 of file misc.c.

57{
58 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
59
60 prand_s = (void *)GetProcAddress(hmod, "rand_s");
61 pI10_OUTPUT = (void*)GetProcAddress(hmod, "$I10_OUTPUT");
62 pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s");
63 p_get_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno");
64 p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
65 p_set_doserrno = (void *)GetProcAddress(hmod, "_set_doserrno");
66 p_set_errno = (void *)GetProcAddress(hmod, "_set_errno");
67 p__invalid_parameter = (void *)GetProcAddress(hmod, "_invalid_parameter");
68 p_qsort_s = (void *)GetProcAddress(hmod, "qsort_s");
69 p_atan = (void *)GetProcAddress(hmod, "atan");
70 p_exp = (void *)GetProcAddress(hmod, "exp");
71 p_tanh = (void *)GetProcAddress(hmod, "tanh");
72 p_lfind_s = (void *)GetProcAddress(hmod, "_lfind_s");
73}
#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 429 of file misc.c.

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

Referenced by test_qsort_s().

◆ START_TEST()

START_TEST ( misc  )

Definition at line 749 of file misc.c.

750{
751 int arg_c;
752 char** arg_v;
753
754 init();
755
756 arg_c = winetest_get_mainargs(&arg_v);
757 if(arg_c >= 3) {
758 if (!strcmp(arg_v[2], "popen_read"))
760 else if(arg_c == 4 && !strcmp(arg_v[2], "popen"))
761 test__popen_child(atoi(arg_v[3]));
762 else
763 ok(0, "invalid argument '%s'\n", arg_v[2]);
764
765 return;
766 }
767
768 test_rand_s();
775 test__popen(arg_v[0]);
777 test_qsort_s();
782}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
static void test__invalid_parameter(void)
Definition: misc.c:408
static void test__lfind_s(void)
Definition: misc.c:687
static void test__set_doserrno(void)
Definition: misc.c:281
static void test__popen_child(int fd)
Definition: misc.c:336
static void test_math_functions(void)
Definition: misc.c:561
static void test__popen_read_child(void)
Definition: misc.c:346
static void test_qsort_s(void)
Definition: misc.c:445
static void test__get_errno(void)
Definition: misc.c:259
static void test_thread_handle_close(void)
Definition: misc.c:624
static void test__set_errno(void)
Definition: misc.c:310
static void test__get_doserrno(void)
Definition: misc.c:234
static void test_I10_OUTPUT(void)
Definition: misc.c:157
static void test_strerror_s(void)
Definition: misc.c:187
static void test__popen(const char *name)
Definition: misc.c:360
static void test_rand_s(void)
Definition: misc.c:75
static void test_thread_suspended(void)
Definition: misc.c:668
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 234 of file misc.c.

235{
236 int ret, out;
237
238 if (!p_get_doserrno)
239 {
240 win_skip("_get_doserrno is not available\n");
241 return;
242 }
243
245 errno = EBADF;
246 ret = p_get_doserrno(NULL);
247 ok(ret == EINVAL, "Expected _get_doserrno to return EINVAL, got %d\n", ret);
248 ok(_doserrno == ERROR_INVALID_CMM, "Expected _doserrno to be ERROR_INVALID_CMM, got %ld\n", _doserrno);
249 ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
250
252 errno = EBADF;
253 out = 0xdeadbeef;
254 ret = p_get_doserrno(&out);
255 ok(ret == 0, "Expected _get_doserrno to return 0, got %d\n", ret);
256 ok(out == ERROR_INVALID_CMM, "Expected output variable to be ERROR_INVALID_CMM, got %d\n", out);
257}
#define EINVAL
Definition: acclib.h:90
#define EBADF
Definition: acclib.h:82
#define NULL
Definition: types.h:112
#define _doserrno
Definition: stdlib.h:131
#define errno
Definition: errno.h:18
#define win_skip
Definition: test.h:164
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
int ret
#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 259 of file misc.c.

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

Referenced by START_TEST().

◆ test__invalid_parameter()

static void test__invalid_parameter ( void  )
static

Definition at line 408 of file misc.c.

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

Referenced by START_TEST().

◆ test__lfind_s()

static void test__lfind_s ( void  )
static

Definition at line 687 of file misc.c.

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

Referenced by START_TEST().

◆ test__popen()

static void test__popen ( const char name)
static

Definition at line 360 of file misc.c.

361{
362 FILE *pipe;
363 char *tempf, buf[1024];
364 int ret, fd;
365
366 tempf = _tempnam(".", "wne");
367 ok(tempf != NULL, "_tempnam failed\n");
368 fd = _open(tempf, _O_CREAT | _O_WRONLY);
369 ok(fd != -1, "open failed\n");
370
371 sprintf(buf, "\"%s\" misc popen %d", name, fd);
372 pipe = _popen(buf, "r");
373 ok(pipe != NULL, "_popen failed with error: %d\n", errno);
374
375 fgets(buf, sizeof(buf), pipe);
376 ok(!strcmp(buf, "child output\n"), "buf = %s\n", buf);
377
378 ret = _pclose(pipe);
379 ok(ret == 0x37, "_pclose returned %x, expected 0x37\n", ret);
380 _close(fd);
381 _unlink(tempf);
382 free(tempf);
383
384 errno = 0xdeadbeef;
385 ret = _pclose((FILE*)0xdeadbeef);
386 ok(ret == -1, "_pclose returned %x, expected -1\n", ret);
387 if(p_set_errno)
388 ok(errno == EBADF, "errno = %d\n", errno);
389
390 sprintf(buf, "\"%s\" misc popen_read", name);
391 pipe = _popen(buf, "w");
392 ok(pipe != NULL, "_popen failed with error: %d\n", errno);
393
394 ret = fputs("child-to-parent\n", pipe);
395 ok(ret != EOF, "fputs returned %x\n", ret);
396
397#ifdef __REACTOS__
398 if (IsReactOS())
399 {
400 skip("Skipping _pclose, because it hangs on reactos\n");
401 return;
402 }
403#endif
404 ret = _pclose(pipe);
405 ok(ret == 0x3, "_pclose returned %x, expected 0x3\n", ret);
406}
#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 336 of file misc.c.

337{
338 /* don't execute any tests here */
339 /* ExitProcess is used to set return code of _pclose */
340 printf("child output\n");
342 ExitProcess(1);
343 ExitProcess(0x37);
344}
#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 346 of file misc.c.

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

Referenced by START_TEST().

◆ test__set_doserrno()

static void test__set_doserrno ( void  )
static

Definition at line 281 of file misc.c.

282{
283 int ret;
284
285 if (!p_set_doserrno)
286 {
287 win_skip("_set_doserrno is not available\n");
288 return;
289 }
290
292 ret = p_set_doserrno(ERROR_FILE_NOT_FOUND);
293 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
295 "Expected _doserrno to be ERROR_FILE_NOT_FOUND, got %ld\n", _doserrno);
296
298 ret = p_set_doserrno(-1);
299 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
300 ok(_doserrno == -1,
301 "Expected _doserrno to be -1, got %ld\n", _doserrno);
302
304 ret = p_set_doserrno(0xdeadbeef);
305 ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
306 ok(_doserrno == 0xdeadbeef,
307 "Expected _doserrno to be 0xdeadbeef, got %ld\n", _doserrno);
308}
#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 310 of file misc.c.

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

Referenced by START_TEST().

◆ test_I10_OUTPUT()

static void test_I10_OUTPUT ( void  )
static

Definition at line 157 of file misc.c.

158{
160 int i, j, ret;
161
162 if(!pI10_OUTPUT) {
163 win_skip("I10_OUTPUT not available\n");
164 return;
165 }
166
167 for(i=0; i<ARRAY_SIZE(I10_OUTPUT_tests); i++) {
168 memset(out.str, '#', sizeof(out.str));
170 ok(ret == I10_OUTPUT_tests[i].ret, "%d: ret = %d\n", i, ret);
171 ok(out.pos == I10_OUTPUT_tests[i].out.pos, "%d: out.pos = %hd\n", i, out.pos);
172 ok(out.sign == I10_OUTPUT_tests[i].out.sign, "%d: out.size = %c\n", i, out.sign);
173 ok(out.len == I10_OUTPUT_tests[i].out.len, "%d: out.len = %d\n", i, (int)out.len);
174 ok(!strcmp(out.str, I10_OUTPUT_tests[i].out.str), "%d: out.str = %s\n", i, out.str);
175
176 j = strlen(I10_OUTPUT_tests[i].remain);
177 todo_wine_if(j && I10_OUTPUT_tests[i].remain[j-1]=='9')
178 ok(!strncmp(out.str+out.len+1, I10_OUTPUT_tests[i].remain, j),
179 "%d: &out.str[%d] = %.25s...\n", i, out.len+1, out.str+out.len+1);
180
181 for(j=out.len+strlen(I10_OUTPUT_tests[i].remain)+1; j<sizeof(out.str); j++)
182 if(out.str[j] != '#')
183 ok(0, "%d: out.str[%d] = %c (expected \'#\')\n", i, j, out.str[j]);
184 }
185}
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:112
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
char sign
Definition: misc.c:97
BYTE len
Definition: misc.c:98
short pos
Definition: misc.c:96
char str[100]
Definition: misc.c:99
I10_OUTPUT_data out
Definition: misc.c:107
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by START_TEST().

◆ test_math_functions()

static void test_math_functions ( void  )
static

Definition at line 561 of file misc.c.

562{
563 static const UINT64 test_nan_i = 0xFFF0000123456780ULL;
564 static const DWORD test_nanf_i = 0xFF801234;
565 double test_nan = *(double*)&test_nan_i;
566 float test_nanf = *(float*)&test_nanf_i;
567 double ret;
568
569 errno = 0xdeadbeef;
570 p_atan(NAN);
571 ok(errno == EDOM, "errno = %d\n", errno);
572
573 errno = 0xdeadbeef;
574 ret = p_atan(INFINITY);
575 ok(almost_equal(ret, 1.57079632679489661923), "ret = %lf\n", ret);
576 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
577
578 errno = 0xdeadbeef;
579 ret = p_atan(-INFINITY);
580 ok(almost_equal(ret, -1.57079632679489661923), "ret = %lf\n", ret);
581 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
582
583 errno = 0xdeadbeef;
584 p_tanh(NAN);
585 ok(errno == EDOM, "errno = %d\n", errno);
586
587 errno = 0xdeadbeef;
588 ret = p_tanh(INFINITY);
589 ok(almost_equal(ret, 1.0), "ret = %lf\n", ret);
590 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
591
592 errno = 0xdeadbeef;
593 p_exp(NAN);
594 ok(errno == EDOM, "errno = %d\n", errno);
595
596 errno = 0xdeadbeef;
597 p_exp(INFINITY);
598 ok(errno == 0xdeadbeef, "errno = %d\n", errno);
599
600 ok(eq_nan(test_nan_i | (1ULL << 51), cosh(test_nan)), "cosh not preserving nan\n");
601 ok(eq_nan(test_nan_i | (1ULL << 51), sinh(test_nan)), "sinh not preserving nan\n");
602 ok(eq_nan(test_nan_i | (1ULL << 51), tanh(test_nan)), "tanh not preserving nan\n");
603 ok(eq_nanf(test_nanf_i | (1 << 22), coshf(test_nanf)), "coshf not preserving nan\n");
604 ok(eq_nanf(test_nanf_i | (1 << 22), sinhf(test_nanf)), "sinhf not preserving nan\n");
605 ok(eq_nanf(test_nanf_i | (1 << 22), tanhf(test_nanf)), "tanhf not preserving nan\n");
606}
_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:538
static BOOL almost_equal(double d1, double d2)
Definition: misc.c:30
static int eq_nanf(DWORD ai, float b)
Definition: misc.c:554

Referenced by START_TEST().

◆ test_qsort_s()

static void test_qsort_s ( void  )
static

Definition at line 445 of file misc.c.

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

Referenced by START_TEST().

◆ test_rand_s()

static void test_rand_s ( void  )
static

Definition at line 75 of file misc.c.

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

Referenced by START_TEST().

◆ test_strerror_s()

static void test_strerror_s ( void  )
static

Definition at line 187 of file misc.c.

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

Referenced by START_TEST().

◆ test_thread_func()

static void __cdecl test_thread_func ( void end_thread_type)
static

Definition at line 608 of file misc.c.

609{
610 if (end_thread_type == (void*)1)
611 _endthread();
612 else if (end_thread_type == (void*)2)
613 ExitThread(0);
614 else if (end_thread_type == (void*)3)
615 _endthreadex(0);
616}
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
_CRTIMP void __cdecl _endthreadex(_In_ unsigned _Retval)
_CRTIMP void __cdecl _endthread(void)
Definition: thread.c:95

Referenced by test_thread_handle_close().

◆ test_thread_func_ex()

static unsigned __stdcall test_thread_func_ex ( void arg)
static

Definition at line 618 of file misc.c.

619{
620 _endthread();
621 return 0;
622}

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 624 of file misc.c.

625{
627 DWORD ret;
628
629 /* _beginthread: handle is not closed on ExitThread and _endthreadex */
631 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
634 ok(!ret, "ret = %ld\n", ret);
635
637 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
640 ok(!ret, "ret = %ld\n", ret);
641
643 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
644 Sleep(150);
646 ok(ret == WAIT_OBJECT_0, "ret = %ld\n", ret);
648 ok(ret, "ret = %ld\n", ret);
649
651 ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
652 Sleep(150);
654 ok(ret == WAIT_OBJECT_0, "ret = %ld\n", ret);
656 ok(ret, "ret = %ld\n", ret);
657
658 /* _beginthreadex: handle is not closed on _endthread */
660 ok(hThread != NULL, "_beginthreadex failed (%d)\n", errno);
661 Sleep(150);
663 ok(ret == WAIT_OBJECT_0, "ret = %ld\n", ret);
665 ok(ret, "ret = %ld\n", ret);
666}
#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:608
static unsigned __stdcall test_thread_func_ex(void *arg)
Definition: misc.c:618
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:432

Referenced by START_TEST().

◆ test_thread_suspended()

static void test_thread_suspended ( void  )
static

Definition at line 668 of file misc.c.

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

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 112 of file misc.c.

Referenced by test_I10_OUTPUT().

◆ int

Definition at line 40 of file misc.c.

◆ size_t

Definition at line 41 of file misc.c.

◆ uintptr_t

Definition at line 47 of file misc.c.