2 * Copyright 2014 Yifu Wang for ESRI
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
27 static inline float __port_infinity(void)
29 static const unsigned __inf_bytes
= 0x7f800000;
30 return *(const float *)&__inf_bytes
;
32 #define INFINITY __port_infinity()
34 static inline float __port_nan(void)
36 static const unsigned __nan_bytes
= 0x7fc00000;
37 return *(const float *)&__nan_bytes
;
39 #define NAN __port_nan()
41 typedef int MSVCRT_long
;
42 typedef unsigned char MSVCP_bool
;
64 status_unknown
, file_not_found
, regular_file
, directory_file
,
65 symlink_file
, block_file
, character_file
, fifo_file
, socket_file
,
69 static BOOL
compare_float(float f
, float g
, unsigned int ulps
)
79 if (abs(x
- y
) > ulps
)
85 static inline const char* debugstr_longlong(ULONGLONG ll
)
87 static char string
[17];
88 if (sizeof(ll
) > sizeof(unsigned long) && ll
>> 32)
89 sprintf(string
, "%lx%08lx", (unsigned long)(ll
>> 32), (unsigned long)ll
);
91 sprintf(string
, "%lx", (unsigned long)ll
);
95 static char* (__cdecl
*p_setlocale
)(int, const char*);
96 static int (__cdecl
*p__setmbcp
)(int);
97 static int (__cdecl
*p_isleadbyte
)(int);
99 static MSVCRT_long (__cdecl
*p__Xtime_diff_to_millis2
)(const xtime
*, const xtime
*);
100 static int (__cdecl
*p_xtime_get
)(xtime
*, int);
101 static _Cvtvec
* (__cdecl
*p__Getcvt
)(_Cvtvec
*);
102 static void (CDECL
*p__Call_once
)(int *once
, void (CDECL
*func
)(void));
103 static void (CDECL
*p__Call_onceEx
)(int *once
, void (CDECL
*func
)(void*), void *argv
);
104 static void (CDECL
*p__Do_call
)(void *this);
105 static short (__cdecl
*p__Dtest
)(double *d
);
106 static short (__cdecl
*p__Dscale
)(double *d
, int exp
);
107 static short (__cdecl
*p__FExp
)(float *x
, float y
, int exp
);
110 static ULONGLONG(__cdecl
*p_tr2_sys__File_size
)(char const*);
111 static ULONGLONG(__cdecl
*p_tr2_sys__File_size_wchar
)(WCHAR
const*);
112 static int (__cdecl
*p_tr2_sys__Equivalent
)(char const*, char const*);
113 static int (__cdecl
*p_tr2_sys__Equivalent_wchar
)(WCHAR
const*, WCHAR
const*);
114 static char* (__cdecl
*p_tr2_sys__Current_get
)(char *);
115 static WCHAR
* (__cdecl
*p_tr2_sys__Current_get_wchar
)(WCHAR
*);
116 static MSVCP_bool (__cdecl
*p_tr2_sys__Current_set
)(char const*);
117 static MSVCP_bool (__cdecl
*p_tr2_sys__Current_set_wchar
)(WCHAR
const*);
118 static int (__cdecl
*p_tr2_sys__Make_dir
)(char const*);
119 static int (__cdecl
*p_tr2_sys__Make_dir_wchar
)(WCHAR
const*);
120 static MSVCP_bool (__cdecl
*p_tr2_sys__Remove_dir
)(char const*);
121 static MSVCP_bool (__cdecl
*p_tr2_sys__Remove_dir_wchar
)(WCHAR
const*);
122 static int (__cdecl
*p_tr2_sys__Copy_file
)(char const*, char const*, MSVCP_bool
);
123 static int (__cdecl
*p_tr2_sys__Copy_file_wchar
)(WCHAR
const*, WCHAR
const*, MSVCP_bool
);
124 static int (__cdecl
*p_tr2_sys__Rename
)(char const*, char const*);
125 static int (__cdecl
*p_tr2_sys__Rename_wchar
)(WCHAR
const*, WCHAR
const*);
126 static struct space_info
* (__cdecl
*p_tr2_sys__Statvfs
)(struct space_info
*, char const*);
127 static struct space_info
* (__cdecl
*p_tr2_sys__Statvfs_wchar
)(struct space_info
*, WCHAR
const*);
128 static enum file_type (__cdecl
*p_tr2_sys__Stat
)(char const*, int *);
129 static enum file_type (__cdecl
*p_tr2_sys__Lstat
)(char const*, int *);
130 static __int64 (__cdecl
*p_tr2_sys__Last_write_time
)(char const*);
131 static void (__cdecl
*p_tr2_sys__Last_write_time_set
)(char const*, __int64
);
132 static void* (__cdecl
*p_tr2_sys__Open_dir
)(char*, char const*, int *, enum file_type
*);
133 static char* (__cdecl
*p_tr2_sys__Read_dir
)(char*, void*, enum file_type
*);
134 static void (__cdecl
*p_tr2_sys__Close_dir
)(void*);
143 #define TIMEDELTA 250 /* 250 ms uncertainty allowed */
145 typedef int (__cdecl
*_Thrd_start_t
)(void*);
147 static int (__cdecl
*p__Thrd_equal
)(_Thrd_t
, _Thrd_t
);
148 static int (__cdecl
*p__Thrd_lt
)(_Thrd_t
, _Thrd_t
);
149 static void (__cdecl
*p__Thrd_sleep
)(const xtime
*);
150 static _Thrd_t (__cdecl
*p__Thrd_current
)(void);
151 static int (__cdecl
*p__Thrd_create
)(_Thrd_t
*, _Thrd_start_t
, void*);
152 static int (__cdecl
*p__Thrd_join
)(_Thrd_t
, int*);
155 static ULONGLONG (__cdecl
*p_i386_Thrd_current
)(void);
156 static _Thrd_t __cdecl
i386_Thrd_current(void)
162 r
.ull
= p_i386_Thrd_current();
168 typedef void *_Mtx_t
;
169 static int (__cdecl
*p__Mtx_init
)(_Mtx_t
*, int);
170 static void (__cdecl
*p__Mtx_destroy
)(_Mtx_t
*);
171 static int (__cdecl
*p__Mtx_lock
)(_Mtx_t
*);
172 static int (__cdecl
*p__Mtx_unlock
)(_Mtx_t
*);
175 typedef void *_Cnd_t
;
177 static int (__cdecl
*p__Cnd_init
)(_Cnd_t
*);
178 static void (__cdecl
*p__Cnd_destroy
)(_Cnd_t
*);
179 static int (__cdecl
*p__Cnd_wait
)(_Cnd_t
*, _Mtx_t
*);
180 static int (__cdecl
*p__Cnd_timedwait
)(_Cnd_t
*, _Mtx_t
*, const xtime
*);
181 static int (__cdecl
*p__Cnd_broadcast
)(_Cnd_t
*);
182 static int (__cdecl
*p__Cnd_signal
)(_Cnd_t
*);
185 static HMODULE msvcp
;
186 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
187 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
188 static BOOL
init(void)
192 msvcp
= LoadLibraryA("msvcp120.dll");
195 win_skip("msvcp120.dll not installed\n");
199 SET(p__Xtime_diff_to_millis2
,
200 "_Xtime_diff_to_millis2");
217 if(sizeof(void*) == 8) { /* 64-bit initialization */
218 SET(p_tr2_sys__File_size
,
219 "?_File_size@sys@tr2@std@@YA_KPEBD@Z");
220 SET(p_tr2_sys__File_size_wchar
,
221 "?_File_size@sys@tr2@std@@YA_KPEB_W@Z");
222 SET(p_tr2_sys__Equivalent
,
223 "?_Equivalent@sys@tr2@std@@YAHPEBD0@Z");
224 SET(p_tr2_sys__Equivalent_wchar
,
225 "?_Equivalent@sys@tr2@std@@YAHPEB_W0@Z");
226 SET(p_tr2_sys__Current_get
,
227 "?_Current_get@sys@tr2@std@@YAPEADAEAY0BAE@D@Z");
228 SET(p_tr2_sys__Current_get_wchar
,
229 "?_Current_get@sys@tr2@std@@YAPEA_WAEAY0BAE@_W@Z");
230 SET(p_tr2_sys__Current_set
,
231 "?_Current_set@sys@tr2@std@@YA_NPEBD@Z");
232 SET(p_tr2_sys__Current_set_wchar
,
233 "?_Current_set@sys@tr2@std@@YA_NPEB_W@Z");
234 SET(p_tr2_sys__Make_dir
,
235 "?_Make_dir@sys@tr2@std@@YAHPEBD@Z");
236 SET(p_tr2_sys__Make_dir_wchar
,
237 "?_Make_dir@sys@tr2@std@@YAHPEB_W@Z");
238 SET(p_tr2_sys__Remove_dir
,
239 "?_Remove_dir@sys@tr2@std@@YA_NPEBD@Z");
240 SET(p_tr2_sys__Remove_dir_wchar
,
241 "?_Remove_dir@sys@tr2@std@@YA_NPEB_W@Z");
242 SET(p_tr2_sys__Copy_file
,
243 "?_Copy_file@sys@tr2@std@@YAHPEBD0_N@Z");
244 SET(p_tr2_sys__Copy_file_wchar
,
245 "?_Copy_file@sys@tr2@std@@YAHPEB_W0_N@Z");
246 SET(p_tr2_sys__Rename
,
247 "?_Rename@sys@tr2@std@@YAHPEBD0@Z");
248 SET(p_tr2_sys__Rename_wchar
,
249 "?_Rename@sys@tr2@std@@YAHPEB_W0@Z");
250 SET(p_tr2_sys__Statvfs
,
251 "?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z");
252 SET(p_tr2_sys__Statvfs_wchar
,
253 "?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEB_W@Z");
255 "?_Stat@sys@tr2@std@@YA?AW4file_type@123@PEBDAEAH@Z");
256 SET(p_tr2_sys__Lstat
,
257 "?_Lstat@sys@tr2@std@@YA?AW4file_type@123@PEBDAEAH@Z");
258 SET(p_tr2_sys__Last_write_time
,
259 "?_Last_write_time@sys@tr2@std@@YA_JPEBD@Z");
260 SET(p_tr2_sys__Last_write_time_set
,
261 "?_Last_write_time@sys@tr2@std@@YAXPEBD_J@Z");
262 SET(p_tr2_sys__Open_dir
,
263 "?_Open_dir@sys@tr2@std@@YAPEAXAEAY0BAE@DPEBDAEAHAEAW4file_type@123@@Z");
264 SET(p_tr2_sys__Read_dir
,
265 "?_Read_dir@sys@tr2@std@@YAPEADAEAY0BAE@DPEAXAEAW4file_type@123@@Z");
266 SET(p_tr2_sys__Close_dir
,
267 "?_Close_dir@sys@tr2@std@@YAXPEAX@Z");
271 SET(p_tr2_sys__File_size
,
272 "?_File_size@sys@tr2@std@@YA_KPBD@Z");
273 SET(p_tr2_sys__File_size_wchar
,
274 "?_File_size@sys@tr2@std@@YA_KPB_W@Z");
275 SET(p_tr2_sys__Equivalent
,
276 "?_Equivalent@sys@tr2@std@@YAHPBD0@Z");
277 SET(p_tr2_sys__Equivalent_wchar
,
278 "?_Equivalent@sys@tr2@std@@YAHPB_W0@Z");
279 SET(p_tr2_sys__Current_get
,
280 "?_Current_get@sys@tr2@std@@YAPADAAY0BAE@D@Z");
281 SET(p_tr2_sys__Current_get_wchar
,
282 "?_Current_get@sys@tr2@std@@YAPA_WAAY0BAE@_W@Z");
283 SET(p_tr2_sys__Current_set
,
284 "?_Current_set@sys@tr2@std@@YA_NPBD@Z");
285 SET(p_tr2_sys__Current_set_wchar
,
286 "?_Current_set@sys@tr2@std@@YA_NPB_W@Z");
287 SET(p_tr2_sys__Make_dir
,
288 "?_Make_dir@sys@tr2@std@@YAHPBD@Z");
289 SET(p_tr2_sys__Make_dir_wchar
,
290 "?_Make_dir@sys@tr2@std@@YAHPB_W@Z");
291 SET(p_tr2_sys__Remove_dir
,
292 "?_Remove_dir@sys@tr2@std@@YA_NPBD@Z");
293 SET(p_tr2_sys__Remove_dir_wchar
,
294 "?_Remove_dir@sys@tr2@std@@YA_NPB_W@Z");
295 SET(p_tr2_sys__Copy_file
,
296 "?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z");
297 SET(p_tr2_sys__Copy_file_wchar
,
298 "?_Copy_file@sys@tr2@std@@YAHPB_W0_N@Z");
299 SET(p_tr2_sys__Rename
,
300 "?_Rename@sys@tr2@std@@YAHPBD0@Z");
301 SET(p_tr2_sys__Rename_wchar
,
302 "?_Rename@sys@tr2@std@@YAHPB_W0@Z");
303 SET(p_tr2_sys__Statvfs
,
304 "?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z");
305 SET(p_tr2_sys__Statvfs_wchar
,
306 "?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PB_W@Z");
308 "?_Stat@sys@tr2@std@@YA?AW4file_type@123@PBDAAH@Z");
309 SET(p_tr2_sys__Lstat
,
310 "?_Lstat@sys@tr2@std@@YA?AW4file_type@123@PBDAAH@Z");
311 SET(p_tr2_sys__Last_write_time
,
312 "?_Last_write_time@sys@tr2@std@@YA_JPBD@Z");
313 SET(p_tr2_sys__Last_write_time_set
,
314 "?_Last_write_time@sys@tr2@std@@YAXPBD_J@Z");
315 SET(p_tr2_sys__Open_dir
,
316 "?_Open_dir@sys@tr2@std@@YAPAXAAY0BAE@DPBDAAHAAW4file_type@123@@Z");
317 SET(p_tr2_sys__Read_dir
,
318 "?_Read_dir@sys@tr2@std@@YAPADAAY0BAE@DPAXAAW4file_type@123@@Z");
319 SET(p_tr2_sys__Close_dir
,
320 "?_Close_dir@sys@tr2@std@@YAXPAX@Z");
322 SET(p_i386_Thrd_current
,
324 p__Thrd_current
= i386_Thrd_current
;
356 SET(p__Cnd_timedwait
,
358 SET(p__Cnd_broadcast
,
363 msvcr
= GetModuleHandleA("msvcr120.dll");
364 p_setlocale
= (void*)GetProcAddress(msvcr
, "setlocale");
365 p__setmbcp
= (void*)GetProcAddress(msvcr
, "_setmbcp");
366 p_isleadbyte
= (void*)GetProcAddress(msvcr
, "isleadbyte");
370 static void test__Xtime_diff_to_millis2(void)
373 __time64_t sec_before
;
374 MSVCRT_long nsec_before
;
375 __time64_t sec_after
;
376 MSVCRT_long nsec_after
;
380 {0, 1000000000, 0, 2000000000, 1000},
381 {1, 100000000, 2, 100000000, 1000},
382 {1, 100000000, 1, 200000000, 100},
383 {0, 0, 0, 1000000000, 1000},
384 {0, 0, 0, 1200000000, 1200},
385 {0, 0, 0, 1230000000, 1230},
386 {0, 0, 0, 1234000000, 1234},
387 {0, 0, 0, 1234100000, 1235},
388 {0, 0, 0, 1234900000, 1235},
389 {0, 0, 0, 1234010000, 1235},
390 {0, 0, 0, 1234090000, 1235},
391 {0, 0, 0, 1234000001, 1235},
392 {0, 0, 0, 1234000009, 1235},
394 {0, 0, 0, -10000000, 0},
395 {0, 0, -1, -100000000, 0},
397 {0, -100000000, 0, 0, 100},
398 {-1, -100000000, 0, 0, 1100},
399 {0, 0, -1, 2000000000, 1000},
400 {0, 0, -2, 2000000000, 0},
401 {0, 0, -2, 2100000000, 100}
407 for(i
= 0; i
< sizeof(tests
) / sizeof(tests
[0]); ++ i
)
409 t1
.sec
= tests
[i
].sec_before
;
410 t1
.nsec
= tests
[i
].nsec_before
;
411 t2
.sec
= tests
[i
].sec_after
;
412 t2
.nsec
= tests
[i
].nsec_after
;
413 ret
= p__Xtime_diff_to_millis2(&t2
, &t1
);
414 ok(ret
== tests
[i
].expect
,
415 "_Xtime_diff_to_millis2(): test: %d expect: %d, got: %d\n",
416 i
, tests
[i
].expect
, ret
);
420 static void test_xtime_get(void)
422 static const MSVCRT_long tests
[] = {1, 50, 100, 200, 500};
427 for(i
= 0; i
< sizeof(tests
) / sizeof(tests
[0]); i
++)
429 p_xtime_get(&before
, 1);
431 p_xtime_get(&after
, 1);
433 diff
= p__Xtime_diff_to_millis2(&after
, &before
);
436 "xtime_get() not functioning correctly, test: %d, expect: ge %d, got: %d\n",
440 /* Test parameter and return value */
441 before
.sec
= 0xdeadbeef, before
.nsec
= 0xdeadbeef;
442 i
= p_xtime_get(&before
, 0);
443 ok(i
== 0, "expect xtime_get() to return 0, got: %d\n", i
);
444 ok(before
.sec
== 0xdeadbeef && before
.nsec
== 0xdeadbeef,
445 "xtime_get() shouldn't have modified the xtime struct with the given option\n");
447 before
.sec
= 0xdeadbeef, before
.nsec
= 0xdeadbeef;
448 i
= p_xtime_get(&before
, 1);
449 ok(i
== 1, "expect xtime_get() to return 1, got: %d\n", i
);
450 ok(before
.sec
!= 0xdeadbeef && before
.nsec
!= 0xdeadbeef,
451 "xtime_get() should have modified the xtime struct with the given option\n");
454 static void test__Getcvt(void)
460 ok(cvtvec
.page
== 0, "cvtvec.page = %d\n", cvtvec
.page
);
461 ok(cvtvec
.mb_max
== 1, "cvtvec.mb_max = %d\n", cvtvec
.mb_max
);
462 todo_wine
ok(cvtvec
.unk
== 1, "cvtvec.unk = %d\n", cvtvec
.unk
);
464 ok(cvtvec
.isleadbyte
[i
] == 0, "cvtvec.isleadbyte[%d] = %x\n", i
, cvtvec
.isleadbyte
[i
]);
466 if(!p_setlocale(LC_ALL
, ".936")) {
467 win_skip("_Getcvt tests\n");
471 ok(cvtvec
.page
== 936, "cvtvec.page = %d\n", cvtvec
.page
);
472 ok(cvtvec
.mb_max
== 2, "cvtvec.mb_max = %d\n", cvtvec
.mb_max
);
473 ok(cvtvec
.unk
== 0, "cvtvec.unk = %d\n", cvtvec
.unk
);
475 ok(cvtvec
.isleadbyte
[i
] == 0, "cvtvec.isleadbyte[%d] = %x\n", i
, cvtvec
.isleadbyte
[i
]);
479 ok(cvtvec
.page
== 936, "cvtvec.page = %d\n", cvtvec
.page
);
480 ok(cvtvec
.mb_max
== 2, "cvtvec.mb_max = %d\n", cvtvec
.mb_max
);
481 ok(cvtvec
.unk
== 0, "cvtvec.unk = %d\n", cvtvec
.unk
);
482 for(i
=0; i
<32; i
++) {
487 b
|= (p_isleadbyte(i
*8+j
) ? 1 : 0) << j
;
488 ok(cvtvec
.isleadbyte
[i
] ==b
, "cvtvec.isleadbyte[%d] = %x (%x)\n", i
, cvtvec
.isleadbyte
[i
], b
);
495 static void __cdecl
call_once_func(void)
497 ok(!once
, "once != 0\n");
501 static void __cdecl
call_once_ex_func(void *arg
)
505 ok(!once
, "once != 0\n");
509 static DWORD WINAPI
call_once_thread(void *arg
)
511 p__Call_once(&once
, call_once_func
);
515 static DWORD WINAPI
call_once_ex_thread(void *arg
)
517 p__Call_onceEx(&once
, call_once_ex_func
, &cnt
);
521 static void test__Call_once(void)
527 h
[i
] = CreateThread(NULL
, 0, call_once_thread
, &once
, 0, NULL
);
528 ok(WaitForMultipleObjects(4, h
, TRUE
, INFINITE
) == WAIT_OBJECT_0
,
529 "error waiting for all threads to finish\n");
530 ok(cnt
== 0x10000, "cnt = %x\n", cnt
);
531 ok(once
== 1, "once = %x\n", once
);
535 h
[i
] = CreateThread(NULL
, 0, call_once_ex_thread
, &once
, 0, NULL
);
536 ok(WaitForMultipleObjects(4, h
, TRUE
, INFINITE
) == WAIT_OBJECT_0
,
537 "error waiting for all threads to finish\n");
538 ok(cnt
== 1, "cnt = %x\n", cnt
);
539 ok(once
== 1, "once = %x\n", once
);
542 static void **vtbl_func0
;
544 /* TODO: this should be a __thiscall function */
545 static void __stdcall
thiscall_func(void)
550 static void __cdecl
thiscall_func(void *this)
552 ok(this == &vtbl_func0
, "incorrect this value\n");
557 static void test__Do_call(void)
559 void *pfunc
= thiscall_func
;
563 p__Do_call(&vtbl_func0
);
564 ok(cnt
== 1, "func was not called\n");
567 static void test__Dtest(void)
574 ok(ret
== FP_ZERO
, "_Dtest(0) returned %x\n", ret
);
578 ok(ret
== FP_NORMAL
, "_Dtest(1) returned %x\n", ret
);
582 ok(ret
== FP_NORMAL
, "_Dtest(-1) returned %x\n", ret
);
586 ok(ret
== FP_INFINITE
, "_Dtest(INF) returned %x\n", ret
);
590 ok(ret
== FP_NAN
, "_Dtest(NAN) returned %x\n", ret
);
593 static void test__Dscale(void)
599 ret
= p__Dscale(&d
, 0);
600 ok(d
== 0, "d = %f\n", d
);
601 ok(ret
== FP_ZERO
, "ret = %x\n", ret
);
604 ret
= p__Dscale(&d
, 1);
605 ok(d
== 0, "d = %f\n", d
);
606 ok(ret
== FP_ZERO
, "ret = %x\n", ret
);
609 ret
= p__Dscale(&d
, -1);
610 ok(d
== 0, "d = %f\n", d
);
611 ok(ret
== FP_ZERO
, "ret = %x\n", ret
);
614 ret
= p__Dscale(&d
, 0);
615 ok(d
== 1, "d = %f\n", d
);
616 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
619 ret
= p__Dscale(&d
, 1);
620 ok(d
== 2, "d = %f\n", d
);
621 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
624 ret
= p__Dscale(&d
, -1);
625 ok(d
== 0.5, "d = %f\n", d
);
626 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
629 ret
= p__Dscale(&d
, -99999);
630 ok(d
== 0, "d = %f\n", d
);
631 ok(ret
== FP_ZERO
, "ret = %x\n", ret
);
634 ret
= p__Dscale(&d
, 999999);
635 ok(d
== INFINITY
, "d = %f\n", d
);
636 ok(ret
== FP_INFINITE
, "ret = %x\n", ret
);
639 ret
= p__Dscale(&d
, 1);
640 ok(ret
== FP_NAN
, "ret = %x\n", ret
);
643 static void test__FExp(void)
649 ret
= p__FExp(&d
, 0, 0);
650 ok(d
== 0, "d = %f\n", d
);
651 ok(ret
== FP_ZERO
, "ret = %x\n", ret
);
654 ret
= p__FExp(&d
, 1, 0);
655 ok(d
== 1.0, "d = %f\n", d
);
656 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
659 ret
= p__FExp(&d
, 1, 1);
660 ok(d
== 2.0, "d = %f\n", d
);
661 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
664 ret
= p__FExp(&d
, 1, 2);
665 ok(d
== 4.0, "d = %f\n", d
);
666 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
669 ret
= p__FExp(&d
, 10, 0);
670 ok(d
== 10.0, "d = %f\n", d
);
671 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
674 ret
= p__FExp(&d
, 0, 0);
675 ok(d
== 0, "d = %f\n", d
);
676 ok(ret
== FP_ZERO
, "ret = %x\n", ret
);
679 ret
= p__FExp(&d
, 1, 0);
680 ok(compare_float(d
, 2.7182817, 4), "d = %f\n", d
);
681 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
684 ret
= p__FExp(&d
, 0, 0);
685 ok(d
== 0, "d = %f\n", d
);
686 ok(ret
== FP_ZERO
, "ret = %x\n", ret
);
689 ret
= p__FExp(&d
, 1, 0);
690 ok(ret
== FP_INFINITE
, "ret = %x\n", ret
);
693 ret
= p__FExp(&d
, 1, -50);
694 ok(compare_float(d
, 1.0839359e+024, 4), "d = %g\n", d
);
695 ok(ret
== FP_NORMAL
, "ret = %x\n", ret
);
698 static void test_tr2_sys__File_size(void)
702 LARGE_INTEGER file_size
;
703 WCHAR testW
[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','1',0};
704 CreateDirectoryA("tr2_test_dir", NULL
);
706 file
= CreateFileA("tr2_test_dir/f1", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
707 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
708 file_size
.QuadPart
= 7;
709 ok(SetFilePointerEx(file
, file_size
, NULL
, FILE_BEGIN
), "SetFilePointerEx failed\n");
710 ok(SetEndOfFile(file
), "SetEndOfFile failed\n");
712 val
= p_tr2_sys__File_size("tr2_test_dir/f1");
713 ok(val
== 7, "file_size is %s\n", debugstr_longlong(val
));
714 val
= p_tr2_sys__File_size_wchar(testW
);
715 ok(val
== 7, "file_size is %s\n", debugstr_longlong(val
));
717 file
= CreateFileA("tr2_test_dir/f2", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
718 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
720 val
= p_tr2_sys__File_size("tr2_test_dir/f2");
721 ok(val
== 0, "file_size is %s\n", debugstr_longlong(val
));
723 val
= p_tr2_sys__File_size("tr2_test_dir");
724 ok(val
== 0, "file_size is %s\n", debugstr_longlong(val
));
727 val
= p_tr2_sys__File_size("tr2_test_dir/not_exists_file");
728 ok(val
== 0, "file_size is %s\n", debugstr_longlong(val
));
729 ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
732 val
= p_tr2_sys__File_size(NULL
);
733 ok(val
== 0, "file_size is %s\n", debugstr_longlong(val
));
734 ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
736 ok(DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 to exist\n");
737 ok(DeleteFileA("tr2_test_dir/f2"), "expect tr2_test_dir/f2 to exist\n");
738 ok(p_tr2_sys__Remove_dir("tr2_test_dir"), "expect tr2_test_dir to exist\n");
741 static void test_tr2_sys__Equivalent(void)
745 char temp_path
[MAX_PATH
], current_path
[MAX_PATH
];
746 WCHAR testW
[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','1',0};
747 WCHAR testW2
[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','2',0};
756 { "f1", "tr2_test_dir", -1 },
757 { "tr2_test_dir", "f1", -1 },
758 { "tr2_test_dir", "tr2_test_dir", -1 },
759 { "tr2_test_dir/./f1", "tr2_test_dir/f2", 0 },
760 { "tr2_test_dir/f1" , "tr2_test_dir/f1", 1 },
761 { "not_exists_file" , "tr2_test_dir/f1", 0 },
762 { "tr2_test_dir\\f1" , "tr2_test_dir/./f1", 1 },
763 { "not_exists_file" , "not_exists_file", -1 },
764 { "tr2_test_dir/f1" , "not_exists_file", 0 },
765 { "tr2_test_dir/../tr2_test_dir/f1", "tr2_test_dir/f1", 1 }
768 memset(current_path
, 0, MAX_PATH
);
769 GetCurrentDirectoryA(MAX_PATH
, current_path
);
770 memset(temp_path
, 0, MAX_PATH
);
771 GetTempPathA(MAX_PATH
, temp_path
);
772 ok(SetCurrentDirectoryA(temp_path
), "SetCurrentDirectoryA to temp_path failed\n");
773 CreateDirectoryA("tr2_test_dir", NULL
);
775 file
= CreateFileA("tr2_test_dir/f1", 0, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
776 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
778 file
= CreateFileA("tr2_test_dir/f2", 0, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
779 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
782 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
784 val
= p_tr2_sys__Equivalent(tests
[i
].path1
, tests
[i
].path2
);
785 ok(tests
[i
].equivalent
== val
, "tr2_sys__Equivalent(): test %d expect: %d, got %d\n", i
+1, tests
[i
].equivalent
, val
);
786 ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
789 val
= p_tr2_sys__Equivalent_wchar(testW
, testW
);
790 ok(val
== 1, "tr2_sys__Equivalent(): expect: 1, got %d\n", val
);
791 val
= p_tr2_sys__Equivalent_wchar(testW
, testW2
);
792 ok(val
== 0, "tr2_sys__Equivalent(): expect: 0, got %d\n", val
);
794 ok(DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 to exist\n");
795 ok(DeleteFileA("tr2_test_dir/f2"), "expect tr2_test_dir/f2 to exist\n");
796 ok(p_tr2_sys__Remove_dir("tr2_test_dir"), "expect tr2_test_dir to exist\n");
797 ok(SetCurrentDirectoryA(current_path
), "SetCurrentDirectoryA failed\n");
800 static void test_tr2_sys__Current_get(void)
802 char temp_path
[MAX_PATH
], current_path
[MAX_PATH
], origin_path
[MAX_PATH
];
804 WCHAR temp_path_wchar
[MAX_PATH
], current_path_wchar
[MAX_PATH
];
806 memset(origin_path
, 0, MAX_PATH
);
807 GetCurrentDirectoryA(MAX_PATH
, origin_path
);
808 memset(temp_path
, 0, MAX_PATH
);
809 GetTempPathA(MAX_PATH
, temp_path
);
811 ok(SetCurrentDirectoryA(temp_path
), "SetCurrentDirectoryA to temp_path failed\n");
812 memset(current_path
, 0, MAX_PATH
);
813 temp
= p_tr2_sys__Current_get(current_path
);
814 ok(temp
== current_path
, "p_tr2_sys__Current_get returned different buffer\n");
815 temp
[strlen(temp
)] = '\\';
816 ok(!strcmp(temp_path
, current_path
), "test_tr2_sys__Current_get(): expect: %s, got %s\n", temp_path
, current_path
);
818 GetTempPathW(MAX_PATH
, temp_path_wchar
);
819 ok(SetCurrentDirectoryW(temp_path_wchar
), "SetCurrentDirectoryW to temp_path_wchar failed\n");
820 memset(current_path_wchar
, 0, MAX_PATH
);
821 temp_wchar
= p_tr2_sys__Current_get_wchar(current_path_wchar
);
822 ok(temp_wchar
== current_path_wchar
, "p_tr2_sys__Current_get_wchar returned different buffer\n");
823 temp_wchar
[wcslen(temp_wchar
)] = '\\';
824 ok(!wcscmp(temp_path_wchar
, current_path_wchar
), "test_tr2_sys__Current_get(): expect: %s, got %s\n", wine_dbgstr_w(temp_path_wchar
), wine_dbgstr_w(current_path_wchar
));
826 ok(SetCurrentDirectoryA(origin_path
), "SetCurrentDirectoryA to origin_path failed\n");
827 memset(current_path
, 0, MAX_PATH
);
828 temp
= p_tr2_sys__Current_get(current_path
);
829 ok(temp
== current_path
, "p_tr2_sys__Current_get returned different buffer\n");
830 ok(!strcmp(origin_path
, current_path
), "test_tr2_sys__Current_get(): expect: %s, got %s\n", origin_path
, current_path
);
833 static void test_tr2_sys__Current_set(void)
835 char temp_path
[MAX_PATH
], current_path
[MAX_PATH
], origin_path
[MAX_PATH
];
837 WCHAR testW
[] = {'.','/',0};
838 memset(temp_path
, 0, MAX_PATH
);
839 GetTempPathA(MAX_PATH
, temp_path
);
840 memset(origin_path
, 0, MAX_PATH
);
841 GetCurrentDirectoryA(MAX_PATH
, origin_path
);
842 temp
= p_tr2_sys__Current_get(origin_path
);
843 ok(temp
== origin_path
, "p_tr2_sys__Current_get returned different buffer\n");
845 ok(p_tr2_sys__Current_set(temp_path
), "p_tr2_sys__Current_set to temp_path failed\n");
846 memset(current_path
, 0, MAX_PATH
);
847 temp
= p_tr2_sys__Current_get(current_path
);
848 ok(temp
== current_path
, "p_tr2_sys__Current_get returned different buffer\n");
849 temp
[strlen(temp
)] = '\\';
850 ok(!strcmp(temp_path
, current_path
), "test_tr2_sys__Current_get(): expect: %s, got %s\n", temp_path
, current_path
);
852 ok(p_tr2_sys__Current_set_wchar(testW
), "p_tr2_sys__Current_set_wchar to temp_path failed\n");
853 memset(current_path
, 0, MAX_PATH
);
854 temp
= p_tr2_sys__Current_get(current_path
);
855 ok(temp
== current_path
, "p_tr2_sys__Current_get returned different buffer\n");
856 temp
[strlen(temp
)] = '\\';
857 ok(!strcmp(temp_path
, current_path
), "test_tr2_sys__Current_get(): expect: %s, got %s\n", temp_path
, current_path
);
860 ok(!p_tr2_sys__Current_set("not_exisist_dir"), "p_tr2_sys__Current_set to not_exist_dir succeed\n");
861 ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
864 ok(!p_tr2_sys__Current_set("??invalid_name>>"), "p_tr2_sys__Current_set to ??invalid_name>> succeed\n");
865 ok(errno
== 0xdeadbeef, "errno = %d\n", errno
);
867 ok(p_tr2_sys__Current_set(origin_path
), "p_tr2_sys__Current_set to origin_path failed\n");
868 memset(current_path
, 0, MAX_PATH
);
869 temp
= p_tr2_sys__Current_get(current_path
);
870 ok(temp
== current_path
, "p_tr2_sys__Current_get returned different buffer\n");
871 ok(!strcmp(origin_path
, current_path
), "test_tr2_sys__Current_get(): expect: %s, got %s\n", origin_path
, current_path
);
874 static void test_tr2_sys__Make_dir(void)
877 WCHAR testW
[] = {'w','d',0};
882 { "tr2_test_dir", 1 },
883 { "tr2_test_dir", 0 },
885 { "??invalid_name>>", -1 }
888 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
890 ret
= p_tr2_sys__Make_dir(tests
[i
].path
);
891 ok(ret
== tests
[i
].val
, "tr2_sys__Make_dir(): test %d expect: %d, got %d\n", i
+1, tests
[i
].val
, ret
);
892 ok(errno
== 0xdeadbeef, "tr2_sys__Make_dir(): test %d errno expect 0xdeadbeef, got %d\n", i
+1, errno
);
894 ret
= p_tr2_sys__Make_dir_wchar(testW
);
895 ok(ret
== 1, "tr2_sys__Make_dir(): expect: 1, got %d\n", ret
);
897 ok(p_tr2_sys__Remove_dir("tr2_test_dir"), "expect tr2_test_dir to exist\n");
898 ok(p_tr2_sys__Remove_dir_wchar(testW
), "expect wd to exist\n");
901 static void test_tr2_sys__Remove_dir(void)
909 { "tr2_test_dir", TRUE
},
910 { "tr2_test_dir", FALSE
},
912 { "??invalid_name>>", FALSE
}
915 ok(p_tr2_sys__Make_dir("tr2_test_dir"), "tr2_sys__Make_dir() failed\n");
917 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
919 ret
= p_tr2_sys__Remove_dir(tests
[i
].path
);
920 ok(ret
== tests
[i
].val
, "test_tr2_sys__Remove_dir(): test %d expect: %d, got %d\n", i
+1, tests
[i
].val
, ret
);
921 ok(errno
== 0xdeadbeef, "test_tr2_sys__Remove_dir(): test %d errno expect 0xdeadbeef, got %d\n", i
+1, errno
);
925 static void test_tr2_sys__Copy_file(void)
929 LARGE_INTEGER file_size
;
930 WCHAR testW
[] = {'f','1',0}, testW2
[] = {'f','w',0};
934 MSVCP_bool fail_if_exists
;
939 { "f1", "f1_copy", TRUE
, ERROR_SUCCESS
, ERROR_SUCCESS
, FALSE
},
940 { "f1", "tr2_test_dir\\f1_copy", TRUE
, ERROR_SUCCESS
, ERROR_SUCCESS
, FALSE
},
941 { "f1", "tr2_test_dir\\f1_copy", TRUE
, ERROR_FILE_EXISTS
, ERROR_FILE_EXISTS
, FALSE
},
942 { "f1", "tr2_test_dir\\f1_copy", FALSE
, ERROR_SUCCESS
, ERROR_SUCCESS
, FALSE
},
943 { "tr2_test_dir", "f1", TRUE
, ERROR_ACCESS_DENIED
, ERROR_ACCESS_DENIED
, FALSE
},
944 { "tr2_test_dir", "tr2_test_dir_copy", TRUE
, ERROR_ACCESS_DENIED
, ERROR_ACCESS_DENIED
, FALSE
},
945 { NULL
, "f1", TRUE
, ERROR_INVALID_PARAMETER
, ERROR_INVALID_PARAMETER
, TRUE
},
946 { "f1", NULL
, TRUE
, ERROR_INVALID_PARAMETER
, ERROR_INVALID_PARAMETER
, TRUE
},
947 { "not_exist", "tr2_test_dir", TRUE
, ERROR_FILE_NOT_FOUND
, ERROR_FILE_NOT_FOUND
, FALSE
},
948 { "f1", "not_exist_dir\\f1_copy", TRUE
, ERROR_PATH_NOT_FOUND
, ERROR_FILE_NOT_FOUND
, FALSE
},
949 { "f1", "tr2_test_dir", TRUE
, ERROR_ACCESS_DENIED
, ERROR_FILE_EXISTS
, FALSE
}
952 ret
= p_tr2_sys__Make_dir("tr2_test_dir");
953 ok(ret
== 1, "test_tr2_sys__Make_dir(): expect 1 got %d\n", ret
);
954 file
= CreateFileA("f1", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
955 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
956 file_size
.QuadPart
= 7;
957 ok(SetFilePointerEx(file
, file_size
, NULL
, FILE_BEGIN
), "SetFilePointerEx failed\n");
958 ok(SetEndOfFile(file
), "SetEndOfFile failed\n");
961 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
963 ret
= p_tr2_sys__Copy_file(tests
[i
].source
, tests
[i
].dest
, tests
[i
].fail_if_exists
);
965 todo_wine
ok(ret
== tests
[i
].last_error
|| ret
== tests
[i
].last_error2
,
966 "test_tr2_sys__Copy_file(): test %d expect: %d, got %d\n",
967 i
+1, tests
[i
].last_error
, ret
);
969 ok(ret
== tests
[i
].last_error
|| ret
== tests
[i
].last_error2
,
970 "test_tr2_sys__Copy_file(): test %d expect: %d, got %d\n",
971 i
+1, tests
[i
].last_error
, ret
);
972 ok(errno
== 0xdeadbeef, "test_tr2_sys__Copy_file(): test %d errno expect 0xdeadbeef, got %d\n", i
+1, errno
);
973 if(ret
== ERROR_SUCCESS
)
974 ok(p_tr2_sys__File_size(tests
[i
].source
) == p_tr2_sys__File_size(tests
[i
].dest
),
975 "test_tr2_sys__Copy_file(): test %d failed, two files' size are not equal\n", i
+1);
977 ret
= p_tr2_sys__Copy_file_wchar(testW
, testW2
, TRUE
);
978 ok(ret
== ERROR_SUCCESS
, "test_tr2_sys__Copy_file_wchar() expect ERROR_SUCCESS, got %d\n", ret
);
980 ok(DeleteFileA("f1"), "expect f1 to exist\n");
981 ok(DeleteFileW(testW2
), "expect fw to exist\n");
982 ok(DeleteFileA("f1_copy"), "expect f1_copy to exist\n");
983 ok(DeleteFileA("tr2_test_dir/f1_copy"), "expect tr2_test_dir/f1 to exist\n");
984 ret
= p_tr2_sys__Remove_dir("tr2_test_dir");
985 ok(ret
== 1, "test_tr2_sys__Remove_dir(): expect 1 got %d\n", ret
);
988 static void test_tr2_sys__Rename(void)
992 BY_HANDLE_FILE_INFORMATION info1
, info2
;
993 char temp_path
[MAX_PATH
], current_path
[MAX_PATH
];
994 LARGE_INTEGER file_size
;
995 WCHAR testW
[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','1',0};
996 WCHAR testW2
[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','w',0};
998 char const *old_path
;
999 char const *new_path
;
1002 { "tr2_test_dir\\f1", "tr2_test_dir\\f1_rename", ERROR_SUCCESS
},
1003 { "tr2_test_dir\\f1", NULL
, ERROR_INVALID_PARAMETER
},
1004 { "tr2_test_dir\\f1", "tr2_test_dir\\f1_rename", ERROR_FILE_NOT_FOUND
},
1005 { NULL
, "tr2_test_dir\\NULL_rename", ERROR_INVALID_PARAMETER
},
1006 { "tr2_test_dir\\f1_rename", "tr2_test_dir\\??invalid_name>>", ERROR_INVALID_NAME
},
1007 { "tr2_test_dir\\not_exist_file", "tr2_test_dir\\not_exist_rename", ERROR_FILE_NOT_FOUND
}
1010 memset(current_path
, 0, MAX_PATH
);
1011 GetCurrentDirectoryA(MAX_PATH
, current_path
);
1012 memset(temp_path
, 0, MAX_PATH
);
1013 GetTempPathA(MAX_PATH
, temp_path
);
1014 ok(SetCurrentDirectoryA(temp_path
), "SetCurrentDirectoryA to temp_path failed\n");
1015 ret
= p_tr2_sys__Make_dir("tr2_test_dir");
1017 ok(ret
== 1, "test_tr2_sys__Make_dir(): expect 1 got %d\n", ret
);
1018 file
= CreateFileA("tr2_test_dir\\f1", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1019 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1022 ret
= p_tr2_sys__Rename("tr2_test_dir\\f1", "tr2_test_dir\\f1");
1023 todo_wine
ok(ERROR_SUCCESS
== ret
, "test_tr2_sys__Rename(): expect: ERROR_SUCCESS, got %d\n", ret
);
1024 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
1026 if(tests
[i
].val
== ERROR_SUCCESS
) {
1027 h1
= CreateFileA(tests
[i
].old_path
, 0, FILE_SHARE_DELETE
| FILE_SHARE_READ
| FILE_SHARE_WRITE
,
1028 NULL
, OPEN_EXISTING
, 0, 0);
1029 ok(h1
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1030 ok(GetFileInformationByHandle(h1
, &info1
), "GetFileInformationByHandle failed\n");
1033 SetLastError(0xdeadbeef);
1034 ret
= p_tr2_sys__Rename(tests
[i
].old_path
, tests
[i
].new_path
);
1035 ok(ret
== tests
[i
].val
, "test_tr2_sys__Rename(): test %d expect: %d, got %d\n", i
+1, tests
[i
].val
, ret
);
1036 ok(errno
== 0xdeadbeef, "test_tr2_sys__Rename(): test %d errno expect 0xdeadbeef, got %d\n", i
+1, errno
);
1037 if(ret
== ERROR_SUCCESS
) {
1038 h2
= CreateFileA(tests
[i
].new_path
, 0, FILE_SHARE_DELETE
| FILE_SHARE_READ
| FILE_SHARE_WRITE
,
1039 NULL
, OPEN_EXISTING
, 0, 0);
1040 ok(h2
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1041 ok(GetFileInformationByHandle(h2
, &info2
), "GetFileInformationByHandle failed\n");
1043 ok(info1
.nFileIndexHigh
== info2
.nFileIndexHigh
1044 && info1
.nFileIndexLow
== info2
.nFileIndexLow
,
1045 "test_tr2_sys__Rename(): test %d expect two files equivalent\n", i
+1);
1049 file
= CreateFileA("tr2_test_dir\\f1", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1050 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1051 file_size
.QuadPart
= 7;
1052 ok(SetFilePointerEx(file
, file_size
, NULL
, FILE_BEGIN
), "SetFilePointerEx failed\n");
1053 ok(SetEndOfFile(file
), "SetEndOfFile failed\n");
1055 ret
= p_tr2_sys__Rename("tr2_test_dir\\f1", "tr2_test_dir\\f1_rename");
1056 ok(ret
== ERROR_ALREADY_EXISTS
, "test_tr2_sys__Rename(): expect: ERROR_ALREADY_EXISTS, got %d\n", ret
);
1057 ok(p_tr2_sys__File_size("tr2_test_dir\\f1") == 7, "test_tr2_sys__Rename(): expect: 7, got %s\n", debugstr_longlong(p_tr2_sys__File_size("tr2_test_dir\\f1")));
1058 ok(p_tr2_sys__File_size("tr2_test_dir\\f1_rename") == 0, "test_tr2_sys__Rename(): expect: 0, got %s\n",debugstr_longlong(p_tr2_sys__File_size("tr2_test_dir\\f1_rename")));
1059 ret
= p_tr2_sys__Rename_wchar(testW
, testW2
);
1060 ok(ret
== ERROR_SUCCESS
, "tr2_sys__Rename_wchar(): expect: ERROR_SUCCESS, got %d\n", ret
);
1062 ok(DeleteFileW(testW2
), "expect fw to exist\n");
1063 ok(DeleteFileA("tr2_test_dir\\f1_rename"), "expect f1_rename to exist\n");
1064 ret
= p_tr2_sys__Remove_dir("tr2_test_dir");
1065 ok(ret
== 1, "test_tr2_sys__Remove_dir(): expect %d got %d\n", 1, ret
);
1066 ok(SetCurrentDirectoryA(current_path
), "SetCurrentDirectoryA failed\n");
1069 static void test_tr2_sys__Statvfs(void)
1071 struct space_info info
;
1072 char current_path
[MAX_PATH
];
1073 WCHAR current_path_wchar
[MAX_PATH
];
1074 memset(current_path
, 0, MAX_PATH
);
1075 p_tr2_sys__Current_get(current_path
);
1076 memset(current_path_wchar
, 0, MAX_PATH
);
1077 p_tr2_sys__Current_get_wchar(current_path_wchar
);
1079 p_tr2_sys__Statvfs(&info
, current_path
);
1080 ok(info
.capacity
>= info
.free
, "test_tr2_sys__Statvfs(): info.capacity < info.free\n");
1081 ok(info
.free
>= info
.available
, "test_tr2_sys__Statvfs(): info.free < info.available\n");
1083 p_tr2_sys__Statvfs_wchar(&info
, current_path_wchar
);
1084 ok(info
.capacity
>= info
.free
, "tr2_sys__Statvfs_wchar(): info.capacity < info.free\n");
1085 ok(info
.free
>= info
.available
, "tr2_sys__Statvfs_wchar(): info.free < info.available\n");
1087 p_tr2_sys__Statvfs(&info
, NULL
);
1088 ok(info
.available
== 0, "test_tr2_sys__Statvfs(): info.available expect: %d, got %s\n",
1089 0, debugstr_longlong(info
.available
));
1090 ok(info
.capacity
== 0, "test_tr2_sys__Statvfs(): info.capacity expect: %d, got %s\n",
1091 0, debugstr_longlong(info
.capacity
));
1092 ok(info
.free
== 0, "test_tr2_sys__Statvfs(): info.free expect: %d, got %s\n",
1093 0, debugstr_longlong(info
.free
));
1095 p_tr2_sys__Statvfs(&info
, "not_exist");
1096 ok(info
.available
== 0, "test_tr2_sys__Statvfs(): info.available expect: %d, got %s\n",
1097 0, debugstr_longlong(info
.available
));
1098 ok(info
.capacity
== 0, "test_tr2_sys__Statvfs(): info.capacity expect: %d, got %s\n",
1099 0, debugstr_longlong(info
.capacity
));
1100 ok(info
.free
== 0, "test_tr2_sys__Statvfs(): info.free expect: %d, got %s\n",
1101 0, debugstr_longlong(info
.free
));
1104 static void test_tr2_sys__Stat(void)
1106 int i
, err_code
, ret
;
1115 { NULL
, status_unknown
, ERROR_INVALID_PARAMETER
, FALSE
},
1116 { "tr2_test_dir", directory_file
, ERROR_SUCCESS
, FALSE
},
1117 { "tr2_test_dir\\f1", regular_file
, ERROR_SUCCESS
, FALSE
},
1118 { "tr2_test_dir\\not_exist_file ", file_not_found
, ERROR_SUCCESS
, FALSE
},
1119 { "tr2_test_dir\\??invalid_name>>", file_not_found
, ERROR_SUCCESS
, FALSE
},
1120 { "tr2_test_dir\\f1_link" , regular_file
, ERROR_SUCCESS
, TRUE
},
1121 { "tr2_test_dir\\dir_link", directory_file
, ERROR_SUCCESS
, TRUE
},
1124 CreateDirectoryA("tr2_test_dir", NULL
);
1125 file
= CreateFileA("tr2_test_dir/f1", 0, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1126 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1127 ok(CloseHandle(file
), "CloseHandle\n");
1128 SetLastError(0xdeadbeef);
1129 ret
= CreateSymbolicLinkA("tr2_test_dir/f1_link", "tr2_test_dir/f1", 0);
1130 if(!ret
&& (GetLastError()==ERROR_PRIVILEGE_NOT_HELD
||GetLastError()==ERROR_INVALID_FUNCTION
)) {
1131 tests
[5].ret
= tests
[6].ret
= file_not_found
;
1132 win_skip("Privilege not held or symbolic link not supported, skipping symbolic link tests.\n");
1134 ok(ret
, "CreateSymbolicLinkA failed\n");
1135 ok(CreateSymbolicLinkA("tr2_test_dir/dir_link", "tr2_test_dir", 1), "CreateSymbolicLinkA failed\n");
1138 file
= CreateNamedPipeA("\\\\.\\PiPe\\tests_pipe.c",
1139 PIPE_ACCESS_DUPLEX
, PIPE_TYPE_BYTE
| PIPE_WAIT
, 2, 1024, 1024,
1140 NMPWAIT_USE_DEFAULT_WAIT
, NULL
);
1141 ok(file
!= INVALID_HANDLE_VALUE
, "CreateNamedPipe failed\n");
1142 err_code
= 0xdeadbeef;
1143 val
= p_tr2_sys__Stat("\\\\.\\PiPe\\tests_pipe.c", &err_code
);
1144 todo_wine
ok(regular_file
== val
, "tr2_sys__Stat(): expect: regular_file, got %d\n", val
);
1145 todo_wine
ok(ERROR_SUCCESS
== err_code
, "tr2_sys__Stat(): err_code expect: ERROR_SUCCESS, got %d\n", err_code
);
1146 err_code
= 0xdeadbeef;
1147 val
= p_tr2_sys__Lstat("\\\\.\\PiPe\\tests_pipe.c", &err_code
);
1148 ok(status_unknown
== val
, "tr2_sys__Lstat(): expect: status_unknown, got %d\n", val
);
1149 todo_wine
ok(ERROR_PIPE_BUSY
== err_code
, "tr2_sys__Lstat(): err_code expect: ERROR_PIPE_BUSY, got %d\n", err_code
);
1150 ok(CloseHandle(file
), "CloseHandle\n");
1151 file
= CreateNamedPipeA("\\\\.\\PiPe\\tests_pipe.c",
1152 PIPE_ACCESS_DUPLEX
, PIPE_TYPE_BYTE
| PIPE_WAIT
, 2, 1024, 1024,
1153 NMPWAIT_USE_DEFAULT_WAIT
, NULL
);
1154 ok(file
!= INVALID_HANDLE_VALUE
, "CreateNamedPipe failed\n");
1155 err_code
= 0xdeadbeef;
1156 val
= p_tr2_sys__Lstat("\\\\.\\PiPe\\tests_pipe.c", &err_code
);
1157 todo_wine
ok(regular_file
== val
, "tr2_sys__Lstat(): expect: regular_file, got %d\n", val
);
1158 todo_wine
ok(ERROR_SUCCESS
== err_code
, "tr2_sys__Lstat(): err_code expect: ERROR_SUCCESS, got %d\n", err_code
);
1159 ok(CloseHandle(file
), "CloseHandle\n");
1161 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
1162 err_code
= 0xdeadbeef;
1163 val
= p_tr2_sys__Stat(tests
[i
].path
, &err_code
);
1164 if(tests
[i
].is_todo
)
1165 todo_wine
ok(tests
[i
].ret
== val
, "tr2_sys__Stat(): test %d expect: %d, got %d\n",
1166 i
+1, tests
[i
].ret
, val
);
1168 ok(tests
[i
].ret
== val
, "tr2_sys__Stat(): test %d expect: %d, got %d\n", i
+1, tests
[i
].ret
, val
);
1169 ok(tests
[i
].err_code
== err_code
, "tr2_sys__Stat(): test %d err_code expect: %d, got %d\n",
1170 i
+1, tests
[i
].err_code
, err_code
);
1172 /* test tr2_sys__Lstat */
1173 err_code
= 0xdeadbeef;
1174 val
= p_tr2_sys__Lstat(tests
[i
].path
, &err_code
);
1175 if(tests
[i
].is_todo
)
1176 todo_wine
ok(tests
[i
].ret
== val
, "tr2_sys__Lstat(): test %d expect: %d, got %d\n",
1177 i
+1, tests
[i
].ret
, val
);
1179 ok(tests
[i
].ret
== val
, "tr2_sys__Lstat(): test %d expect: %d, got %d\n", i
+1, tests
[i
].ret
, val
);
1181 ok(tests
[i
].err_code
== err_code
, "tr2_sys__Lstat(): test %d err_code expect: %d, got %d\n",
1182 i
+1, tests
[i
].err_code
, err_code
);
1186 todo_wine
ok(DeleteFileA("tr2_test_dir/f1_link"), "expect tr2_test_dir/f1_link to exist\n");
1187 todo_wine
ok(RemoveDirectoryA("tr2_test_dir/dir_link"), "expect tr2_test_dir/dir_link to exist\n");
1189 ok(DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 to exist\n");
1190 ok(RemoveDirectoryA("tr2_test_dir"), "expect tr2_test_dir to exist\n");
1193 static void test_tr2_sys__Last_write_time(void)
1197 __int64 last_write_time
, newtime
;
1198 ret
= p_tr2_sys__Make_dir("tr2_test_dir");
1199 ok(ret
== 1, "tr2_sys__Make_dir() expect 1 got %d\n", ret
);
1201 file
= CreateFileA("tr2_test_dir/f1", GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1202 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1205 last_write_time
= p_tr2_sys__Last_write_time("tr2_test_dir/f1");
1206 newtime
= last_write_time
+ 123456789;
1207 p_tr2_sys__Last_write_time_set("tr2_test_dir/f1", newtime
);
1208 todo_wine
ok(last_write_time
== p_tr2_sys__Last_write_time("tr2_test_dir/f1"),
1209 "last_write_time before modfied should not equal to last_write_time %s\n",
1210 debugstr_longlong(last_write_time
));
1213 last_write_time
= p_tr2_sys__Last_write_time("not_exist");
1214 ok(errno
== 0xdeadbeef, "tr2_sys__Last_write_time(): errno expect 0xdeadbeef, got %d\n", errno
);
1215 ok(last_write_time
== 0, "expect 0 got %s\n", debugstr_longlong(last_write_time
));
1216 last_write_time
= p_tr2_sys__Last_write_time(NULL
);
1217 ok(last_write_time
== 0, "expect 0 got %s\n", debugstr_longlong(last_write_time
));
1219 p_tr2_sys__Last_write_time_set("not_exist", newtime
);
1221 p_tr2_sys__Last_write_time_set(NULL
, newtime
);
1222 ok(errno
== 0xdeadbeef, "tr2_sys__Last_write_time(): errno expect 0xdeadbeef, got %d\n", errno
);
1224 ok(DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 to exist\n");
1225 ret
= p_tr2_sys__Remove_dir("tr2_test_dir");
1226 ok(ret
== 1, "test_tr2_sys__Remove_dir(): expect 1 got %d\n", ret
);
1229 static void test_tr2_sys__dir_operation(void)
1231 char *file_name
, first_file_name
[MAX_PATH
], dest
[MAX_PATH
], longer_path
[MAX_PATH
];
1232 HANDLE file
, result_handle
;
1233 enum file_type type
;
1234 int err
, num_of_f1
= 0, num_of_f2
= 0, num_of_sub_dir
= 0, num_of_other_files
= 0;
1236 CreateDirectoryA("tr2_test_dir", NULL
);
1237 file
= CreateFileA("tr2_test_dir/f1", 0, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1238 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1240 file
= CreateFileA("tr2_test_dir/f2", 0, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1241 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1243 CreateDirectoryA("tr2_test_dir/sub_dir", NULL
);
1244 file
= CreateFileA("tr2_test_dir/sub_dir/sub_f1", 0, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
1245 ok(file
!= INVALID_HANDLE_VALUE
, "create file failed: INVALID_HANDLE_VALUE\n");
1248 memset(longer_path
, 0, MAX_PATH
);
1249 GetCurrentDirectoryA(MAX_PATH
, longer_path
);
1250 strcat(longer_path
, "\\tr2_test_dir\\");
1251 while(lstrlenA(longer_path
) < MAX_PATH
-1)
1252 strcat(longer_path
, "s");
1253 ok(lstrlenA(longer_path
) == MAX_PATH
-1, "tr2_sys__Open_dir(): expect MAX_PATH, got %d\n", lstrlenA(longer_path
));
1254 memset(first_file_name
, 0, MAX_PATH
);
1255 type
= err
= 0xdeadbeef;
1256 result_handle
= NULL
;
1257 result_handle
= p_tr2_sys__Open_dir(first_file_name
, longer_path
, &err
, &type
);
1258 ok(result_handle
== NULL
, "tr2_sys__Open_dir(): expect NULL, got %p\n", result_handle
);
1259 ok(!*first_file_name
, "tr2_sys__Open_dir(): expect: 0, got %s\n", first_file_name
);
1260 ok(err
== ERROR_BAD_PATHNAME
, "tr2_sys__Open_dir(): expect: ERROR_BAD_PATHNAME, got %d\n", err
);
1261 ok((int)type
== 0xdeadbeef, "tr2_sys__Open_dir(): expect 0xdeadbeef, got %d\n", type
);
1263 memset(first_file_name
, 0, MAX_PATH
);
1264 memset(dest
, 0, MAX_PATH
);
1265 err
= type
= 0xdeadbeef;
1266 result_handle
= NULL
;
1267 result_handle
= p_tr2_sys__Open_dir(first_file_name
, "tr2_test_dir", &err
, &type
);
1268 ok(result_handle
!= NULL
, "tr2_sys__Open_dir(): expect: not NULL, got %p\n", result_handle
);
1269 ok(err
== ERROR_SUCCESS
, "tr2_sys__Open_dir(): expect: ERROR_SUCCESS, got %d\n", err
);
1270 file_name
= first_file_name
;
1272 if (!strcmp(file_name
, "f1")) {
1274 ok(type
== regular_file
, "expect regular_file, got %d\n", type
);
1275 }else if(!strcmp(file_name
, "f2")) {
1277 ok(type
== regular_file
, "expect regular_file, got %d\n", type
);
1278 }else if(!strcmp(file_name
, "sub_dir")) {
1280 ok(type
== directory_file
, "expect directory_file, got %d\n", type
);
1282 ++num_of_other_files
;
1284 file_name
= p_tr2_sys__Read_dir(dest
, result_handle
, &type
);
1286 p_tr2_sys__Close_dir(result_handle
);
1287 ok(result_handle
!= NULL
, "tr2_sys__Open_dir(): expect: not NULL, got %p\n", result_handle
);
1288 ok(num_of_f1
== 1, "found f1 %d times\n", num_of_f1
);
1289 ok(num_of_f2
== 1, "found f2 %d times\n", num_of_f2
);
1290 ok(num_of_sub_dir
== 1, "found sub_dir %d times\n", num_of_sub_dir
);
1291 ok(num_of_other_files
== 0, "found %d other files\n", num_of_other_files
);
1293 memset(first_file_name
, 0, MAX_PATH
);
1294 err
= type
= 0xdeadbeef;
1295 result_handle
= file
;
1296 result_handle
= p_tr2_sys__Open_dir(first_file_name
, "not_exist", &err
, &type
);
1297 ok(result_handle
== NULL
, "tr2_sys__Open_dir(): expect: NULL, got %p\n", result_handle
);
1298 todo_wine
ok(err
== ERROR_BAD_PATHNAME
, "tr2_sys__Open_dir(): expect: ERROR_BAD_PATHNAME, got %d\n", err
);
1299 ok((int)type
== 0xdeadbeef, "tr2_sys__Open_dir(): expect: 0xdeadbeef, got %d\n", type
);
1300 ok(!*first_file_name
, "tr2_sys__Open_dir(): expect: 0, got %s\n", first_file_name
);
1302 CreateDirectoryA("empty_dir", NULL
);
1303 memset(first_file_name
, 0, MAX_PATH
);
1304 err
= type
= 0xdeadbeef;
1305 result_handle
= file
;
1306 result_handle
= p_tr2_sys__Open_dir(first_file_name
, "empty_dir", &err
, &type
);
1307 ok(result_handle
== NULL
, "tr2_sys__Open_dir(): expect: NULL, got %p\n", result_handle
);
1308 ok(err
== ERROR_SUCCESS
, "tr2_sys__Open_dir(): expect: ERROR_SUCCESS, got %d\n", err
);
1309 ok(type
== status_unknown
, "tr2_sys__Open_dir(): expect: status_unknown, got %d\n", type
);
1310 ok(!*first_file_name
, "tr2_sys__Open_dir(): expect: 0, got %s\n", first_file_name
);
1311 p_tr2_sys__Close_dir(result_handle
);
1312 ok(result_handle
== NULL
, "tr2_sys__Open_dir(): expect: NULL, got %p\n", result_handle
);
1314 ok(RemoveDirectoryA("empty_dir"), "expect empty_dir to exist\n");
1315 ok(DeleteFileA("tr2_test_dir/sub_dir/sub_f1"), "expect tr2_test_dir/sub_dir/sub_f1 to exist\n");
1316 ok(RemoveDirectoryA("tr2_test_dir/sub_dir"), "expect tr2_test_dir/sub_dir to exist\n");
1317 ok(DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 to exist\n");
1318 ok(DeleteFileA("tr2_test_dir/f2"), "expect tr2_test_dir/f2 to exist\n");
1319 ok(RemoveDirectoryA("tr2_test_dir"), "expect tr2_test_dir to exist\n");
1322 static int __cdecl
thrd_thread(void *arg
)
1326 *thr
= p__Thrd_current();
1330 static void test_thrd(void)
1338 const HANDLE hnd1
= (HANDLE
)0xcccccccc;
1339 const HANDLE hnd2
= (HANDLE
)0xdeadbeef;
1340 xtime xt
, before
, after
;
1344 struct test testeq
[] = {
1345 { {0, 0}, {0, 0}, 1 },
1346 { {0, 1}, {0, 0}, 0 },
1347 { {hnd1
, 0}, {hnd1
, 1}, 0 },
1348 { {hnd1
, 0}, {hnd2
, 0}, 1 }
1351 struct test testlt
[] = {
1352 { {0, 0}, {0, 0}, 0 },
1353 { {0, 0}, {0, 1}, 1 },
1354 { {0, 1}, {0, 0}, 0 },
1355 { {hnd1
, 0}, {hnd2
, 0}, 0 },
1356 { {hnd1
, 0}, {hnd2
, 1}, 1 }
1359 /* test for equal */
1360 for(i
=0; i
<sizeof(testeq
)/sizeof(testeq
[0]); i
++) {
1361 ret
= p__Thrd_equal(testeq
[i
].a
, testeq
[i
].b
);
1362 ok(ret
== testeq
[i
].r
, "(%p %u) = (%p %u) expected %d, got %d\n",
1363 testeq
[i
].a
.hnd
, testeq
[i
].a
.id
, testeq
[i
].b
.hnd
, testeq
[i
].b
.id
, testeq
[i
].r
, ret
);
1366 /* test for less than */
1367 for(i
=0; i
<sizeof(testlt
)/sizeof(testlt
[0]); i
++) {
1368 ret
= p__Thrd_lt(testlt
[i
].a
, testlt
[i
].b
);
1369 ok(ret
== testlt
[i
].r
, "(%p %u) < (%p %u) expected %d, got %d\n",
1370 testlt
[i
].a
.hnd
, testlt
[i
].a
.id
, testlt
[i
].b
.hnd
, testlt
[i
].b
.id
, testlt
[i
].r
, ret
);
1373 /* test for sleep */
1374 if (0) /* crash on Windows */
1375 p__Thrd_sleep(NULL
);
1376 p_xtime_get(&xt
, 1);
1378 p_xtime_get(&before
, 1);
1380 p_xtime_get(&after
, 1);
1381 diff
= p__Xtime_diff_to_millis2(&after
, &before
);
1382 ok(diff
> 2000 - TIMEDELTA
, "got %d\n", diff
);
1384 /* test for current */
1385 ta
= p__Thrd_current();
1386 tb
= p__Thrd_current();
1387 ok(ta
.id
== tb
.id
, "got a %d b %d\n", ta
.id
, tb
.id
);
1388 ok(ta
.id
== GetCurrentThreadId(), "expected %d, got %d\n", GetCurrentThreadId(), ta
.id
);
1389 /* these can be different if new threads are created at same time */
1390 ok(ta
.hnd
== tb
.hnd
, "got a %p b %p\n", ta
.hnd
, tb
.hnd
);
1391 ok(!CloseHandle(ta
.hnd
), "handle %p not closed\n", ta
.hnd
);
1392 ok(!CloseHandle(tb
.hnd
), "handle %p not closed\n", tb
.hnd
);
1394 /* test for create/join */
1395 if (0) /* crash on Windows */
1397 p__Thrd_create(NULL
, thrd_thread
, NULL
);
1398 p__Thrd_create(&ta
, NULL
, NULL
);
1401 ret
= p__Thrd_create(&ta
, thrd_thread
, (void*)&tb
);
1402 ok(!ret
, "failed to create thread, got %d\n", ret
);
1403 ret
= p__Thrd_join(ta
, &r
);
1404 ok(!ret
, "failed to join thread, got %d\n", ret
);
1405 ok(ta
.id
== tb
.id
, "expected %d, got %d\n", ta
.id
, tb
.id
);
1406 ok(ta
.hnd
!= tb
.hnd
, "same handles, got %p\n", ta
.hnd
);
1407 ok(r
== 0x42, "expected 0x42, got %d\n", r
);
1408 ok(!CloseHandle(ta
.hnd
), "handle %p not closed\n", ta
.hnd
);
1411 #define NUM_THREADS 10
1423 static int __cdecl
cnd_wait_thread(void *arg
)
1425 struct cndmtx
*cm
= arg
;
1428 p__Mtx_lock(&cm
->mtx
);
1430 if(InterlockedIncrement(&cm
->started
) == cm
->thread_no
)
1431 SetEvent(cm
->initialized
);
1433 if(cm
->timed_wait
) {
1436 p_xtime_get(&xt
, 1);
1438 r
= p__Cnd_timedwait(&cm
->cnd
, &cm
->mtx
, &xt
);
1439 ok(!r
, "timed wait failed\n");
1441 r
= p__Cnd_wait(&cm
->cnd
, &cm
->mtx
);
1442 ok(!r
, "wait failed\n");
1445 p__Mtx_unlock(&cm
->mtx
);
1449 static void test_cnd(void)
1451 _Thrd_t threads
[NUM_THREADS
];
1452 xtime xt
, before
, after
;
1459 r
= p__Cnd_init(&cnd
);
1460 ok(!r
, "failed to init cnd\n");
1462 r
= p__Mtx_init(&mtx
, 0);
1463 ok(!r
, "failed to init mtx\n");
1465 if (0) /* crash on Windows */
1468 p__Cnd_wait(NULL
, &mtx
);
1469 p__Cnd_wait(&cnd
, NULL
);
1470 p__Cnd_timedwait(NULL
, &mtx
, &xt
);
1471 p__Cnd_timedwait(&cnd
, &mtx
, &xt
);
1473 p__Cnd_destroy(NULL
);
1475 /* test _Cnd_signal/_Cnd_wait */
1476 cm
.initialized
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
1481 cm
.timed_wait
= FALSE
;
1482 p__Thrd_create(&threads
[0], cnd_wait_thread
, (void*)&cm
);
1484 WaitForSingleObject(cm
.initialized
, INFINITE
);
1486 p__Mtx_unlock(&mtx
);
1488 r
= p__Cnd_signal(&cm
.cnd
);
1489 ok(!r
, "failed to signal\n");
1490 p__Thrd_join(threads
[0], NULL
);
1492 /* test _Cnd_timedwait time out */
1494 p_xtime_get(&before
, 1);
1497 r
= p__Cnd_timedwait(&cnd
, &mtx
, &xt
);
1498 p_xtime_get(&after
, 1);
1499 p__Mtx_unlock(&mtx
);
1501 diff
= p__Xtime_diff_to_millis2(&after
, &before
);
1502 ok(r
== 2, "should have timed out\n");
1503 ok(diff
> 1000 - TIMEDELTA
, "got %d\n", diff
);
1505 /* test _Cnd_timedwait */
1507 cm
.timed_wait
= TRUE
;
1508 p__Thrd_create(&threads
[0], cnd_wait_thread
, (void*)&cm
);
1510 WaitForSingleObject(cm
.initialized
, INFINITE
);
1512 p__Mtx_unlock(&mtx
);
1514 r
= p__Cnd_signal(&cm
.cnd
);
1515 ok(!r
, "failed to signal\n");
1516 p__Thrd_join(threads
[0], NULL
);
1518 /* test _Cnd_broadcast */
1520 cm
.thread_no
= NUM_THREADS
;
1521 cm
.timed_wait
= FALSE
;
1523 for(i
= 0; i
< cm
.thread_no
; i
++)
1524 p__Thrd_create(&threads
[i
], cnd_wait_thread
, (void*)&cm
);
1526 WaitForSingleObject(cm
.initialized
, INFINITE
);
1528 p__Mtx_unlock(&mtx
);
1530 r
= p__Cnd_broadcast(&cnd
);
1531 ok(!r
, "failed to broadcast\n");
1532 for(i
= 0; i
< cm
.thread_no
; i
++)
1533 p__Thrd_join(threads
[i
], NULL
);
1535 /* test broadcast with _Cnd_destroy */
1537 for(i
= 0; i
< cm
.thread_no
; i
++)
1538 p__Thrd_create(&threads
[i
], cnd_wait_thread
, (void*)&cm
);
1540 WaitForSingleObject(cm
.initialized
, INFINITE
);
1542 p__Mtx_unlock(&mtx
);
1544 p__Cnd_destroy(&cnd
);
1545 for(i
= 0; i
< cm
.thread_no
; i
++)
1546 p__Thrd_join(threads
[i
], NULL
);
1548 p__Mtx_destroy(&mtx
);
1549 CloseHandle(cm
.initialized
);
1552 START_TEST(msvcp120
)
1555 test__Xtime_diff_to_millis2();
1564 test_tr2_sys__File_size();
1565 test_tr2_sys__Equivalent();
1566 test_tr2_sys__Current_get();
1567 test_tr2_sys__Current_set();
1568 test_tr2_sys__Make_dir();
1569 test_tr2_sys__Remove_dir();
1570 test_tr2_sys__Copy_file();
1571 test_tr2_sys__Rename();
1572 test_tr2_sys__Statvfs();
1573 test_tr2_sys__Stat();
1574 test_tr2_sys__Last_write_time();
1575 test_tr2_sys__dir_operation();