ReactOS  0.4.14-dev-98-gb0d4763
misc.c File Reference
#include "wine/test.h"
#include <errno.h>
#include <stdio.h>
#include <math.h>
#include "msvcrt.h"
#include <process.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Classes

struct  _I10_OUTPUT_data
 
struct  _I10_OUTPUT_test
 
struct  qsort_test
 

Macros

#define INFINITY   __port_infinity()
 
#define NAN   __port_nan()
 

Typedefs

typedef struct _I10_OUTPUT_data I10_OUTPUT_data
 
typedef struct _I10_OUTPUT_test I10_OUTPUT_test
 

Functions

static float __port_infinity (void)
 
static float __port_nan (void)
 
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 (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 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 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 MSVCRT_size_t
 
static const wchar_t const wchar_t unsigned uintptr_t
 
static const I10_OUTPUT_test I10_OUTPUT_tests []
 

Macro Definition Documentation

◆ INFINITY

#define INFINITY   __port_infinity()

Definition at line 36 of file misc.c.

◆ NAN

#define NAN   __port_nan()

Definition at line 46 of file misc.c.

Typedef Documentation

◆ I10_OUTPUT_data

◆ I10_OUTPUT_test

Function Documentation

◆ __port_infinity()

static float __port_infinity ( void  )
inlinestatic

Definition at line 28 of file misc.c.

29 {
30  static const unsigned __inf_bytes = 0x7f800000;
31  return *(const float *)&__inf_bytes;
32 }

◆ __port_nan()

static float __port_nan ( void  )
inlinestatic

Definition at line 38 of file misc.c.

39 {
40  static const unsigned __nan_bytes = 0x7fc00000;
41  return *(const float *)&__nan_bytes;
42 }

◆ _lfind_s_comp()

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

Definition at line 609 of file misc.c.

610 {
611  *(int *)ctx = 0xdeadc0de;
612  return *(int *)l - *(int *)r;
613 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
r l[0]
Definition: byte_order.h:167

Referenced by test__lfind_s().

◆ almost_equal()

static BOOL almost_equal ( double  d1,
double  d2 
)
inlinestatic

Definition at line 48 of file misc.c.

48  {
49  if(d1-d2>-1e-30 && d1-d2<1e-30)
50  return TRUE;
51  return FALSE;
52 }
#define TRUE
Definition: types.h:120
#define e
Definition: ke_i.h:82

Referenced by test_math_functions().

◆ int()

static int ( __cdecl prand_s)
static

Definition at line 64 of file misc.c.

72 {
73  HMODULE hmod = GetModuleHandleA("msvcrt.dll");
74 
75  prand_s = (void *)GetProcAddress(hmod, "rand_s");
76  pI10_OUTPUT = (void*)GetProcAddress(hmod, "$I10_OUTPUT");
77  pstrerror_s = (void *)GetProcAddress(hmod, "strerror_s");
78  p_get_doserrno = (void *)GetProcAddress(hmod, "_get_doserrno");
79  p_get_errno = (void *)GetProcAddress(hmod, "_get_errno");
80  p_set_doserrno = (void *)GetProcAddress(hmod, "_set_doserrno");
81  p_set_errno = (void *)GetProcAddress(hmod, "_set_errno");
82  p__invalid_parameter = (void *)GetProcAddress(hmod, "_invalid_parameter");
83  p_qsort_s = (void *)GetProcAddress(hmod, "qsort_s");
84  p_atan = (void *)GetProcAddress(hmod, "atan");
85  p_exp = (void *)GetProcAddress(hmod, "exp");
86  p_tanh = (void *)GetProcAddress(hmod, "tanh");
87  p_lfind_s = (void *)GetProcAddress(hmod, "_lfind_s");
88 }
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define GetProcAddress(x, y)
Definition: compat.h:410

◆ qsort_comp()

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

Definition at line 404 of file misc.c.

405 {
406  struct qsort_test *qt = ctx;
407 
408  if(qt) {
409  ok(qt->pos < 64, "qt->pos = %d\n", qt->pos);
410  ok(qt->cmp[qt->pos].l == (int*)l-qt->base,
411  "%d) l on %ld position\n", qt->pos, (long)((int*)l - qt->base));
412  ok(qt->cmp[qt->pos].r == (int*)r-qt->base,
413  "%d) r on %ld position\n", qt->pos, (long)((int*)r - qt->base));
414  qt->pos++;
415  }
416 
417  return *(int*)l%1000 - *(int*)r%1000;
418 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int * base
Definition: misc.c:396
r l[0]
Definition: byte_order.h:167
struct qsort_test::@1618 cmp[64]
int pos
Definition: misc.c:395
#define ok(value,...)
Definition: atltest.h:57

Referenced by test_qsort_s().

◆ START_TEST()

START_TEST ( misc  )

Definition at line 677 of file misc.c.

678 {
679  int arg_c;
680  char** arg_v;
681 
682  init();
683 
684  arg_c = winetest_get_mainargs(&arg_v);
685  if(arg_c >= 3) {
686  if(!strcmp(arg_v[2], "popen"))
688  else
689  ok(0, "invalid argument '%s'\n", arg_v[2]);
690 
691  return;
692  }
693 
694  test_rand_s();
695  test_I10_OUTPUT();
696  test_strerror_s();
698  test__get_errno();
700  test__set_errno();
701  test__popen(arg_v[0]);
703  test_qsort_s();
706  test__lfind_s();
707 }
static void test_strerror_s(void)
Definition: misc.c:203
static void test_qsort_s(void)
Definition: misc.c:420
static void test__lfind_s(void)
Definition: misc.c:615
static void test__popen(const char *name)
Definition: misc.c:360
static int init
Definition: wintirpc.c:33
static void test_I10_OUTPUT(void)
Definition: misc.c:161
static void test_math_functions(void)
Definition: misc.c:513
static void test_thread_handle_close(void)
Definition: misc.c:565
static void test__set_doserrno(void)
Definition: misc.c:297
static void test__set_errno(void)
Definition: misc.c:326
static void test__popen_child(void)
Definition: misc.c:352
static void test__get_doserrno(void)
Definition: misc.c:250
int winetest_get_mainargs(char ***pargv)
static void test__get_errno(void)
Definition: misc.c:275
static void test_rand_s(void)
Definition: misc.c:90
#define ok(value,...)
Definition: atltest.h:57
static void test__invalid_parameter(void)
Definition: misc.c:383
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

◆ test__get_doserrno()

static void test__get_doserrno ( void  )
static

Definition at line 250 of file misc.c.

251 {
252  int ret, out;
253 
254  if (!p_get_doserrno)
255  {
256  win_skip("_get_doserrno is not available\n");
257  return;
258  }
259 
261  errno = EBADF;
262  ret = p_get_doserrno(NULL);
263  ok(ret == EINVAL, "Expected _get_doserrno to return EINVAL, got %d\n", ret);
264  ok(_doserrno == ERROR_INVALID_CMM, "Expected _doserrno to be ERROR_INVALID_CMM, got %d\n", _doserrno);
265  ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
266 
268  errno = EBADF;
269  out = 0xdeadbeef;
270  ret = p_get_doserrno(&out);
271  ok(ret == 0, "Expected _get_doserrno to return 0, got %d\n", ret);
272  ok(out == ERROR_INVALID_CMM, "Expected output variable to be ERROR_INVALID_CMM, got %d\n", out);
273 }
Definition: arc.h:39
int errno
Definition: arc.h:36
#define _doserrno
Definition: stdlib.h:143
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_INVALID_CMM
Definition: winerror.h:1185
static FILE * out
Definition: regtests2xml.c:44
int ret
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__get_errno()

static void test__get_errno ( void  )
static

Definition at line 275 of file misc.c.

276 {
277  int ret, out;
278 
279  if (!p_get_errno)
280  {
281  win_skip("_get_errno is not available\n");
282  return;
283  }
284 
285  errno = EBADF;
286  ret = p_get_errno(NULL);
287  ok(ret == EINVAL, "Expected _get_errno to return EINVAL, got %d\n", ret);
288  ok(errno == EBADF, "Expected errno to be EBADF, got %d\n", errno);
289 
290  errno = EBADF;
291  out = 0xdeadbeef;
292  ret = p_get_errno(&out);
293  ok(ret == 0, "Expected _get_errno to return 0, got %d\n", ret);
294  ok(out == EBADF, "Expected output variable to be EBADF, got %d\n", out);
295 }
Definition: arc.h:39
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
int ret
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__invalid_parameter()

static void test__invalid_parameter ( void  )
static

Definition at line 383 of file misc.c.

384 {
385  if(!p__invalid_parameter) {
386  win_skip("_invalid_parameter not available\n");
387  return;
388  }
389 
390  p__invalid_parameter(NULL, NULL, NULL, 0, 0);
391 }
smooth NULL
Definition: ftsmooth.c:416
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__lfind_s()

static void test__lfind_s ( void  )
static

Definition at line 615 of file misc.c.

616 {
617  static const int tests[] = {9000, 8001, 7002, 6003, 1003, 5004, 4005, 3006, 2007};
618  unsigned int num;
619  void *found;
620  int ctx;
621  int key;
622 
623  if (!p_lfind_s)
624  {
625  win_skip("_lfind_s is not available\n");
626  return;
627  }
628 
629  key = 1234;
630  num = ARRAY_SIZE(tests);
631 
632  errno = 0xdeadbeef;
633  found = p_lfind_s(NULL, tests, &num, sizeof(int), _lfind_s_comp, NULL);
634  ok(errno == EINVAL, "errno = %d\n", errno);
635  ok(!found, "Expected NULL, got %p\n", found);
636 
637  errno = 0xdeadbeef;
638  found = p_lfind_s(&key, NULL, &num, sizeof(int), _lfind_s_comp, NULL);
639  ok(errno == EINVAL, "errno = %d\n", errno);
640  ok(!found, "Expected NULL, got %p\n", found);
641 
642  errno = 0xdeadbeef;
643  found = p_lfind_s(&key, tests, &num, 0, _lfind_s_comp, NULL);
644  ok(errno == EINVAL, "errno = %d\n", errno);
645  ok(!found, "Expected NULL, got %p\n", found);
646 
647  errno = 0xdeadbeef;
648  found = p_lfind_s(&key, tests, &num, sizeof(int), NULL, NULL);
649  ok(errno == EINVAL, "errno = %d\n", errno);
650  ok(!found, "Expected NULL, got %p\n", found);
651 
652  ctx = -1;
653  key = 9000;
654  errno = 0xdeadbeef;
655  found = p_lfind_s(&key, tests, &num, sizeof(int), _lfind_s_comp, &ctx);
656  ok(errno == 0xdeadbeef, "errno = %d\n", errno);
657  ok(found == tests, "Expected %p, got %p\n", tests, found);
658  ok(ctx == 0xdeadc0de, "Expected 0xdeadc0de, got %x\n", ctx);
659 
660  ctx = -1;
661  key = 2007;
662  errno = 0xdeadbeef;
663  found = p_lfind_s(&key, tests, &num, sizeof(int), _lfind_s_comp, &ctx);
664  ok(errno == 0xdeadbeef, "errno = %d\n", errno);
665  ok(found == tests+8, "Expected %p, got %p\n", tests+8, found);
666  ok(ctx == 0xdeadc0de, "Expected 0xdeadc0de, got %x\n", ctx);
667 
668  ctx = -1;
669  key = 1234;
670  errno = 0xdeadbeef;
671  found = p_lfind_s(&key, tests, &num, sizeof(int), _lfind_s_comp, &ctx);
672  ok(errno == 0xdeadbeef, "errno = %d\n", errno);
673  ok(!found, "Expected NULL, got %p\n", found);
674  ok(ctx == 0xdeadc0de, "Expected 0xdeadc0de, got %x\n", ctx);
675 }
static int __cdecl _lfind_s_comp(void *ctx, const void *l, const void *r)
Definition: misc.c:609
struct param_test tests[]
Definition: arc.h:39
int errno
smooth NULL
Definition: ftsmooth.c:416
GLuint GLuint num
Definition: glext.h:9618
HKEY key
Definition: reg.c:42
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141
Definition: path.c:42

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 buf[1024];
364  int ret;
365 
366  sprintf(buf, "\"%s\" misc popen", name);
367  pipe = _popen(buf, "r");
368  ok(pipe != NULL, "_popen failed with error: %d\n", errno);
369 
370  fgets(buf, sizeof(buf), pipe);
371  ok(!strcmp(buf, "child output\n"), "buf = %s\n", buf);
372 
373  ret = _pclose(pipe);
374  ok(ret == 0x37, "_pclose returned %x, expected 0x37\n", ret);
375 
376  errno = 0xdeadbeef;
377  ret = _pclose((FILE*)0xdeadbeef);
378  ok(ret == -1, "_pclose returned %x, expected -1\n", ret);
379  if(p_set_errno)
380  ok(errno == EBADF, "errno = %d\n", errno);
381 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_opt_ _CRTIMP int __cdecl _pclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl _popen(_In_z_ const char *_Command, _In_z_ const char *_Mode)
int errno
Definition: arc.h:36
#define sprintf(buf, format,...)
Definition: sprintf.c:55
smooth NULL
Definition: ftsmooth.c:416
int ret
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
#define ok(value,...)
Definition: atltest.h:57
Definition: name.c:36
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by START_TEST().

◆ test__popen_child()

static void test__popen_child ( void  )
static

Definition at line 352 of file misc.c.

353 {
354  /* don't execute any tests here */
355  /* ExitProcess is used to set return code of _pclose */
356  printf("child output\n");
357  ExitProcess(0x37);
358 }
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
#define printf
Definition: config.h:203

Referenced by START_TEST().

◆ test__set_doserrno()

static void test__set_doserrno ( void  )
static

Definition at line 297 of file misc.c.

298 {
299  int ret;
300 
301  if (!p_set_doserrno)
302  {
303  win_skip("_set_doserrno is not available\n");
304  return;
305  }
306 
308  ret = p_set_doserrno(ERROR_FILE_NOT_FOUND);
309  ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
311  "Expected _doserrno to be ERROR_FILE_NOT_FOUND, got %d\n", _doserrno);
312 
314  ret = p_set_doserrno(-1);
315  ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
316  ok(_doserrno == -1,
317  "Expected _doserrno to be -1, got %d\n", _doserrno);
318 
320  ret = p_set_doserrno(0xdeadbeef);
321  ok(ret == 0, "Expected _set_doserrno to return 0, got %d\n", ret);
322  ok(_doserrno == 0xdeadbeef,
323  "Expected _doserrno to be 0xdeadbeef, got %d\n", _doserrno);
324 }
#define _doserrno
Definition: stdlib.h:143
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ERROR_INVALID_CMM
Definition: winerror.h:1185
int ret
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test__set_errno()

static void test__set_errno ( void  )
static

Definition at line 326 of file misc.c.

327 {
328  int ret;
329 
330  if (!p_set_errno)
331  {
332  win_skip("_set_errno is not available\n");
333  return;
334  }
335 
336  errno = EBADF;
337  ret = p_set_errno(EINVAL);
338  ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
339  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
340 
341  errno = EBADF;
342  ret = p_set_errno(-1);
343  ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
344  ok(errno == -1, "Expected errno to be -1, got %d\n", errno);
345 
346  errno = EBADF;
347  ret = p_set_errno(0xdeadbeef);
348  ok(ret == 0, "Expected _set_errno to return 0, got %d\n", ret);
349  ok(errno == 0xdeadbeef, "Expected errno to be 0xdeadbeef, got %d\n", errno);
350 }
Definition: arc.h:39
int errno
Definition: arc.h:36
int ret
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_I10_OUTPUT()

static void test_I10_OUTPUT ( void  )
static

Definition at line 161 of file misc.c.

162 {
164  int i, j = sizeof(long double), ret;
165 
166  if(!pI10_OUTPUT) {
167  win_skip("I10_OUTPUT not available\n");
168  return;
169  }
170  if (j != 12)
171  trace("sizeof(long double) = %d on this machine\n", j);
172 
173  for(i=0; i<ARRAY_SIZE(I10_OUTPUT_tests); i++) {
174  memset(out.str, '#', sizeof(out.str));
175 
176  if (sizeof(long double) == 12)
178  else {
179  /* MS' "long double" is an 80 bit FP that takes 12 bytes*/
180  typedef struct { ULONG x80[3]; } uld; /* same calling convention */
181  union { long double ld; uld ld12; } fp80;
182  int (__cdecl *pI10_OUTPUT12)(uld, int, int, void*) = (void*)pI10_OUTPUT;
183  fp80.ld = I10_OUTPUT_tests[i].d;
184  ret = pI10_OUTPUT12(fp80.ld12, I10_OUTPUT_tests[i].size, I10_OUTPUT_tests[i].flags, &out);
185  }
186  ok(ret == I10_OUTPUT_tests[i].ret, "%d: ret = %d\n", i, ret);
187  ok(out.pos == I10_OUTPUT_tests[i].out.pos, "%d: out.pos = %hd\n", i, out.pos);
188  ok(out.sign == I10_OUTPUT_tests[i].out.sign, "%d: out.size = %c\n", i, out.sign);
189  ok(out.len == I10_OUTPUT_tests[i].out.len, "%d: out.len = %d\n", i, (int)out.len);
190  ok(!strcmp(out.str, I10_OUTPUT_tests[i].out.str), "%d: out.str = %s\n", i, out.str);
191 
192  j = strlen(I10_OUTPUT_tests[i].remain);
193  todo_wine_if(j && I10_OUTPUT_tests[i].remain[j-1]=='9')
194  ok(!strncmp(out.str+out.len+1, I10_OUTPUT_tests[i].remain, j),
195  "%d: &out.str[%d] = %.25s...\n", i, out.len+1, out.str+out.len+1);
196 
197  for(j=out.len+strlen(I10_OUTPUT_tests[i].remain)+1; j<sizeof(out.str); j++)
198  if(out.str[j] != '#')
199  ok(0, "%d: out.str[%d] = %c (expected \'#\')\n", i, j, out.str[j]);
200  }
201 }
char str[100]
Definition: misc.c:114
#define __cdecl
Definition: accygwin.h:79
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
I10_OUTPUT_data out
Definition: misc.c:122
GLdouble n
Definition: glext.h:7729
static int
Definition: misc.c:55
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
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
const WCHAR * str
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 todo_wine_if(is_todo)
Definition: test.h:155
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
static const I10_OUTPUT_test I10_OUTPUT_tests[]
Definition: misc.c:127
#define d
Definition: ke_i.h:81
if(!(yy_init))
Definition: macro.lex.yy.c:714
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static FILE * out
Definition: regtests2xml.c:44
#define for
Definition: utility.h:88
long double d
Definition: misc.c:118
GLbitfield flags
Definition: glext.h:7161
int ret
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
short pos
Definition: misc.c:111
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_math_functions()

static void test_math_functions ( void  )
static

Definition at line 513 of file misc.c.

514 {
515  double ret;
516 
517  errno = 0xdeadbeef;
518  p_atan(NAN);
519  ok(errno == EDOM, "errno = %d\n", errno);
520 
521  errno = 0xdeadbeef;
522  ret = p_atan(INFINITY);
523  ok(almost_equal(ret, 1.57079632679489661923), "ret = %lf\n", ret);
524  ok(errno == 0xdeadbeef, "errno = %d\n", errno);
525 
526  errno = 0xdeadbeef;
527  ret = p_atan(-INFINITY);
528  ok(almost_equal(ret, -1.57079632679489661923), "ret = %lf\n", ret);
529  ok(errno == 0xdeadbeef, "errno = %d\n", errno);
530 
531  errno = 0xdeadbeef;
532  p_tanh(NAN);
533  ok(errno == EDOM, "errno = %d\n", errno);
534 
535  errno = 0xdeadbeef;
536  ret = p_tanh(INFINITY);
537  ok(almost_equal(ret, 1.0), "ret = %lf\n", ret);
538  ok(errno == 0xdeadbeef, "errno = %d\n", errno);
539 
540  errno = 0xdeadbeef;
541  p_exp(NAN);
542  ok(errno == EDOM, "errno = %d\n", errno);
543 
544  errno = 0xdeadbeef;
545  p_exp(INFINITY);
546  ok(errno == 0xdeadbeef, "errno = %d\n", errno);
547 }
int errno
#define EDOM
Definition: errno.h:39
static BOOL almost_equal(double d1, double d2)
Definition: misc.c:48
#define NAN
Definition: misc.c:46
int ret
#define ok(value,...)
Definition: atltest.h:57
#define INFINITY
Definition: misc.c:36

Referenced by START_TEST().

◆ test_qsort_s()

static void test_qsort_s ( void  )
static

Definition at line 420 of file misc.c.

421 {
422  static const int nonstable_test[] = {9000, 8001, 7002, 6003, 1003, 5004, 4005, 3006, 2007};
423  int tab[100], i;
424 
425  struct qsort_test small_sort = {
426  0, tab, {
427  {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 5}, {7, 6},
428  {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 5},
429  {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4},
430  {1, 0}, {2, 1}, {3, 2}, {4, 3},
431  {1, 0}, {2, 1}, {3, 2},
432  {1, 0}, {2, 1},
433  {1, 0}
434  }
435  }, small_sort2 = {
436  0, tab, {
437  {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0},
438  {1, 0}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1},
439  {1, 0}, {2, 1}, {3, 2}, {4, 2}, {5, 2},
440  {1, 0}, {2, 1}, {3, 2}, {4, 3},
441  {1, 0}, {2, 1}, {3, 2},
442  {1, 0}, {2, 1},
443  {1, 0}
444  }
445  }, quick_sort = {
446  0, tab, {
447  {0, 4}, {0, 8}, {4, 8},
448  {1, 4}, {2, 4}, {3, 4}, {5, 4}, {6, 4}, {7, 4}, {7, 4}, {6, 4},
449  {6, 4},
450  {8, 7},
451  {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 4},
452  {1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 3},
453  {1, 0}, {2, 1}, {3, 2}, {4, 2},
454  {1, 0}, {2, 1}, {3, 2},
455  {1, 0}, {2, 1},
456  {1, 0}
457  }
458  };
459 
460  if(!p_qsort_s) {
461  win_skip("qsort_s not available\n");
462  return;
463  }
464 
465  for(i=0; i<8; i++) tab[i] = i;
466  p_qsort_s(tab, 8, sizeof(int), qsort_comp, &small_sort);
467  ok(small_sort.pos == 28, "small_sort.pos = %d\n", small_sort.pos);
468  for(i=0; i<8; i++)
469  ok(tab[i] == i, "tab[%d] = %d\n", i, tab[i]);
470 
471  for(i=0; i<8; i++) tab[i] = 7-i;
472  p_qsort_s(tab, 8, sizeof(int), qsort_comp, &small_sort2);
473  ok(small_sort2.pos == 28, "small_sort2.pos = %d\n", small_sort2.pos);
474  for(i=0; i<8; i++)
475  ok(tab[i] == i, "tab[%d] = %d\n", i, tab[i]);
476 
477  for(i=0; i<9; i++) tab[i] = i;
478  tab[5] = 1;
479  tab[6] = 2;
480  p_qsort_s(tab, 9, sizeof(int), qsort_comp, &quick_sort);
481  ok(quick_sort.pos == 34, "quick_sort.pos = %d\n", quick_sort.pos);
482 
483  /* show that qsort is not stable */
484  for(i=0; i<9; i++) tab[i] = 8-i + 1000*(i+1);
485  tab[0] = 1003;
486  p_qsort_s(tab, 9, sizeof(int), qsort_comp, NULL);
487  for(i=0; i<9; i++)
488  ok(tab[i] == nonstable_test[i], "tab[%d] = %d, expected %d\n", i, tab[i], nonstable_test[i]);
489 
490  /* check if random data is sorted */
491  srand(0);
492  for(i=0; i<100; i++) tab[i] = rand()%1000;
493  p_qsort_s(tab, 100, sizeof(int), qsort_comp, NULL);
494  for(i=1; i<100; i++)
495  ok(tab[i-1] <= tab[i], "data sorted incorrectly on position %d: %d <= %d\n", i, tab[i-1], tab[i]);
496 
497  /* test if random permutation is sorted correctly */
498  for(i=0; i<100; i++) tab[i] = i;
499  for(i=0; i<100; i++) {
500  int b = rand()%100;
501  int e = rand()%100;
502 
503  if(b == e) continue;
504  tab[b] ^= tab[e];
505  tab[e] ^= tab[b];
506  tab[b] ^= tab[e];
507  }
508  p_qsort_s(tab, 100, sizeof(int), qsort_comp, NULL);
509  for(i=0; i<100; i++)
510  ok(tab[i] == i, "data sorted incorrectly on position %d: %d\n", i, tab[i]);
511 }
void __cdecl srand(_In_ unsigned int _Seed)
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
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#define e
Definition: ke_i.h:82
smooth NULL
Definition: ftsmooth.c:416
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
static int __cdecl qsort_comp(void *ctx, const void *l, const void *r)
Definition: misc.c:404
int pos
Definition: misc.c:395
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_rand_s()

static void test_rand_s ( void  )
static

Definition at line 90 of file misc.c.

91 {
92  int ret;
93  unsigned int rand;
94 
95  if (!prand_s)
96  {
97  win_skip("rand_s is not available\n");
98  return;
99  }
100 
101  errno = EBADF;
102  ret = prand_s(NULL);
103  ok(ret == EINVAL, "Expected rand_s to return EINVAL, got %d\n", ret);
104  ok(errno == EINVAL, "Expected errno to return EINVAL, got %d\n", errno);
105 
106  ret = prand_s(&rand);
107  ok(ret == 0, "Expected rand_s to return 0, got %d\n", ret);
108 }
Definition: arc.h:39
int errno
Definition: arc.h:36
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
smooth NULL
Definition: ftsmooth.c:416
int ret
#define ok(value,...)
Definition: atltest.h:57
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_strerror_s()

static void test_strerror_s ( void  )
static

Definition at line 203 of file misc.c.

204 {
205  int ret;
206  char buf[256];
207 
208  if (!pstrerror_s)
209  {
210  win_skip("strerror_s is not available\n");
211  return;
212  }
213 
214  errno = EBADF;
215  ret = pstrerror_s(NULL, 0, 0);
216  ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
217  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
218 
219  errno = EBADF;
220  ret = pstrerror_s(NULL, sizeof(buf), 0);
221  ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
222  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
223 
224  memset(buf, 'X', sizeof(buf));
225  errno = EBADF;
226  ret = pstrerror_s(buf, 0, 0);
227  ok(ret == EINVAL, "Expected strerror_s to return EINVAL, got %d\n", ret);
228  ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
229  ok(buf[0] == 'X', "Expected output buffer to be untouched\n");
230 
231  memset(buf, 'X', sizeof(buf));
232  ret = pstrerror_s(buf, 1, 0);
233  ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
234  ok(strlen(buf) == 0, "Expected output buffer to be null terminated\n");
235 
236  memset(buf, 'X', sizeof(buf));
237  ret = pstrerror_s(buf, 2, 0);
238  ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
239  ok(strlen(buf) == 1, "Expected output buffer to be truncated\n");
240 
241  memset(buf, 'X', sizeof(buf));
242  ret = pstrerror_s(buf, sizeof(buf), 0);
243  ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
244 
245  memset(buf, 'X', sizeof(buf));
246  ret = pstrerror_s(buf, sizeof(buf), -1);
247  ok(ret == 0, "Expected strerror_s to return 0, got %d\n", ret);
248 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: arc.h:39
int errno
Definition: arc.h:36
smooth NULL
Definition: ftsmooth.c:416
int ret
#define ok(value,...)
Definition: atltest.h:57
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_thread_func()

static void __cdecl test_thread_func ( void end_thread_type)
static

Definition at line 549 of file misc.c.

550 {
551  if (end_thread_type == (void*)1)
552  _endthread();
553  else if (end_thread_type == (void*)2)
554  ExitThread(0);
555  else if (end_thread_type == (void*)3)
556  _endthreadex(0);
557 }
_CRTIMP void __cdecl _endthread(void)
Definition: thread.c:95
_CRTIMP void __cdecl _endthreadex(_In_ unsigned _Retval)
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:364

Referenced by test_thread_handle_close().

◆ test_thread_func_ex()

static unsigned __stdcall test_thread_func_ex ( void arg)
static

Definition at line 559 of file misc.c.

560 {
561  _endthread();
562  return 0;
563 }
_CRTIMP void __cdecl _endthread(void)
Definition: thread.c:95

Referenced by test_thread_handle_close().

◆ test_thread_handle_close()

static void test_thread_handle_close ( void  )
static

Definition at line 565 of file misc.c.

566 {
567  HANDLE hThread;
568  DWORD ret;
569 
570  /* _beginthread: handle is not closed on ExitThread and _endthreadex */
572  ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
575  ok(!ret, "ret = %d\n", ret);
576 
577  hThread = (HANDLE)_beginthread(test_thread_func, 0, (void*)1);
578  ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
581  ok(!ret, "ret = %d\n", ret);
582 
583  hThread = (HANDLE)_beginthread(test_thread_func, 0, (void*)2);
584  ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
585  Sleep(150);
587  ok(ret == WAIT_OBJECT_0, "ret = %d\n", ret);
589  ok(ret, "ret = %d\n", ret);
590 
591  hThread = (HANDLE)_beginthread(test_thread_func, 0, (void*)3);
592  ok(hThread != INVALID_HANDLE_VALUE, "_beginthread failed (%d)\n", errno);
593  Sleep(150);
595  ok(ret == WAIT_OBJECT_0, "ret = %d\n", ret);
597  ok(ret, "ret = %d\n", ret);
598 
599  /* _beginthreadex: handle is not closed on _endthread */
601  ok(hThread != NULL, "_beginthreadex failed (%d)\n", errno);
602  Sleep(150);
604  ok(ret == WAIT_OBJECT_0, "ret = %d\n", ret);
606  ok(ret, "ret = %d\n", ret);
607 }
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
int errno
_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)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
static unsigned __stdcall test_thread_func_ex(void *arg)
Definition: misc.c:559
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
PVOID HANDLE
Definition: typedefs.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ok(value,...)
Definition: atltest.h:57
static void __cdecl test_thread_func(void *end_thread_type)
Definition: misc.c:549
HANDLE hThread
Definition: wizard.c:27
_CRTIMP uintptr_t __cdecl _beginthread(_In_ void(__cdecl *_StartAddress)(void *), _In_ unsigned _StackSize, _In_opt_ void *_ArgList)
#define INFINITE
Definition: serial.h:102

Referenced by START_TEST().

◆ void()

static void ( __cdecl p__invalid_parameter) const
static

Referenced by gl_ReadBuffer(), and hGetPEBHandle().

Variable Documentation

◆ I10_OUTPUT_tests

const I10_OUTPUT_test I10_OUTPUT_tests[]
static

Definition at line 127 of file misc.c.

Referenced by test_I10_OUTPUT().

◆ int

const wchar_t const wchar_t unsigned int

Definition at line 55 of file misc.c.

Referenced by test_CopyBindInfo(), test_I10_OUTPUT(), and test_LoadIconWithScaleDown().

◆ MSVCRT_size_t

Definition at line 56 of file misc.c.

◆ uintptr_t

Definition at line 62 of file misc.c.