mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[MSVCRT_WINETEST] Sync with Wine Staging 1.9.11. CORE-11368
svn path=/trunk/; revision=71780
This commit is contained in:
parent
5ed7ca77cb
commit
2e960e0505
5 changed files with 144 additions and 98 deletions
|
@ -1109,10 +1109,8 @@ static void test_demangle_datatype(void)
|
|||
for (i = 0; i < num_test; i++)
|
||||
{
|
||||
name = p__unDName(0, demangle[i].mangled, 0, pmalloc, pfree, 0x2800);
|
||||
if (demangle[i].test_in_wine)
|
||||
ok(name != NULL && !strcmp(name,demangle[i].result), "Got name \"%s\" for %d\n", name, i);
|
||||
else
|
||||
todo_wine ok(name != NULL && !strcmp(name,demangle[i].result), "Got name %s for %d\n", name, i);
|
||||
todo_wine_if (!demangle[i].test_in_wine)
|
||||
ok(name != NULL && !strcmp(name,demangle[i].result), "Got name \"%s\" for %d\n", name, i);
|
||||
if(name)
|
||||
pfree(name);
|
||||
}
|
||||
|
|
|
@ -1350,55 +1350,6 @@ static void test_file_inherit_child_no(const char* fd_s)
|
|||
"Wrong write result in child process on %d (%s)\n", fd, strerror(errno));
|
||||
}
|
||||
|
||||
static void test_file_refcount_child(void)
|
||||
{
|
||||
static const char buffer1[] = "test1";
|
||||
static const char buffer2[] = "test2";
|
||||
static const char buffer3[] = "test3";
|
||||
static const char buffer4[] = "test4";
|
||||
HANDLE f0, f1, f2, h0, h1, h2;
|
||||
DWORD written, flags, ret;
|
||||
|
||||
f0 = (HANDLE)_get_osfhandle(STDIN_FILENO);
|
||||
f1 = (HANDLE)_get_osfhandle(STDOUT_FILENO);
|
||||
f2 = (HANDLE)_get_osfhandle(STDERR_FILENO);
|
||||
ok(f0 == f1, "expected same handles, got %p, %p\n", f0, f1);
|
||||
ok(f1 == f2, "expected same handles, got %p, %p\n", f1, f2);
|
||||
|
||||
h0 = GetStdHandle(STD_INPUT_HANDLE);
|
||||
h1 = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
h2 = GetStdHandle(STD_ERROR_HANDLE);
|
||||
ok(h0 == h1, "expected same handles, got %p, %p\n", h0, h1);
|
||||
ok(h1 == h2, "expected same handles, got %p, %p\n", h1, h2);
|
||||
ok(f0 == h0, "expected same handles, got %p, %p\n", f0, h0);
|
||||
|
||||
ret = GetHandleInformation(h1, &flags);
|
||||
ok(ret, "GetHandleInformation failed\n");
|
||||
ret = WriteFile(h1, buffer1, strlen(buffer1), &written, 0);
|
||||
ok(ret, "WriteFile failed\n");
|
||||
|
||||
ret = fclose(stdout);
|
||||
ok(ret == 0, "fclose failed\n");
|
||||
ret = GetHandleInformation(h1, &flags);
|
||||
ok(ret, "GetHandleInformation failed\n");
|
||||
ret = WriteFile(h1, buffer2, strlen(buffer2), &written, 0);
|
||||
ok(ret, "WriteFile failed\n");
|
||||
|
||||
ret = fclose(stdout);
|
||||
ok(ret != 0, "fclose should fail\n");
|
||||
ret = GetHandleInformation(h1, &flags);
|
||||
ok(ret, "GetHandleInformation failed\n");
|
||||
ret = WriteFile(h1, buffer3, strlen(buffer3), &written, 0);
|
||||
ok(ret, "WriteFile failed\n");
|
||||
|
||||
ret = fclose(stderr);
|
||||
ok(ret == 0, "fclose failed\n");
|
||||
ret = GetHandleInformation(h1, &flags);
|
||||
ok(!ret, "GetHandleInformation should fail\n");
|
||||
ret = WriteFile(h1, buffer4, strlen(buffer4), &written, 0);
|
||||
ok(!ret, "WriteFile should fail\n");
|
||||
}
|
||||
|
||||
static void create_io_inherit_block( STARTUPINFOA *startup, unsigned int count, const HANDLE *handles )
|
||||
{
|
||||
static BYTE block[1024];
|
||||
|
@ -1472,36 +1423,6 @@ static void test_stdout_handle( STARTUPINFOA *startup, char *cmdline, HANDLE hst
|
|||
DeleteFileA( "fdopen.err" );
|
||||
}
|
||||
|
||||
static void test_file_refcount( STARTUPINFOA *startup, char *cmdline, const char *descr )
|
||||
{
|
||||
const char *data;
|
||||
HANDLE hMixFile;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
PROCESS_INFORMATION proc;
|
||||
|
||||
/* make file handle inheritable */
|
||||
sa.nLength = sizeof(sa);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = TRUE;
|
||||
|
||||
hMixFile = CreateFileA( "fdopen.mix", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL );
|
||||
startup->dwFlags = STARTF_USESTDHANDLES;
|
||||
startup->hStdInput = hMixFile;
|
||||
startup->hStdOutput = hMixFile;
|
||||
startup->hStdError = hMixFile;
|
||||
|
||||
CreateProcessA( NULL, cmdline, NULL, NULL, TRUE,
|
||||
CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, NULL, NULL, startup, &proc );
|
||||
winetest_wait_child_process( proc.hProcess );
|
||||
|
||||
data = read_file( hMixFile );
|
||||
ok( !strcmp( data, "test1test2test3" ), "%s: Wrong error data (%s)\n", descr, data );
|
||||
|
||||
CloseHandle( hMixFile );
|
||||
DeleteFileA( "fdopen.mix" );
|
||||
}
|
||||
|
||||
static void test_file_inherit( const char* selfname )
|
||||
{
|
||||
int fd;
|
||||
|
@ -1595,12 +1516,6 @@ static void test_file_inherit( const char* selfname )
|
|||
test_stdout_handle( &startup, cmdline, handles[1], TRUE, "large size block" );
|
||||
CloseHandle( handles[1] );
|
||||
DeleteFileA("fdopen.tst");
|
||||
|
||||
/* test refcount of handles */
|
||||
create_io_inherit_block( &startup, 0, NULL );
|
||||
sprintf(cmdline, "%s file refcount", selfname);
|
||||
test_file_refcount( &startup, cmdline, "file refcount" );
|
||||
DeleteFileA("fdopen.tst");
|
||||
}
|
||||
|
||||
static void test_tmpnam( void )
|
||||
|
@ -2347,8 +2262,8 @@ static void test_write_flush_size(FILE *file, int bufsize)
|
|||
fpos_t pos, pos2;
|
||||
|
||||
fd = fileno(file);
|
||||
inbuffer = calloc(bufsize + 1, 1);
|
||||
outbuffer = calloc(bufsize + 1, 1);
|
||||
inbuffer = calloc(1, bufsize + 1);
|
||||
outbuffer = calloc(1, bufsize + 1);
|
||||
_snprintf(outbuffer, bufsize + 1, "0,1,2,3,4,5,6,7,8,9");
|
||||
|
||||
for (size = bufsize + 1; size >= bufsize - 1; size--) {
|
||||
|
@ -2412,6 +2327,65 @@ static void test_write_flush(void)
|
|||
free(tempf);
|
||||
}
|
||||
|
||||
static void test_close(void)
|
||||
{
|
||||
ioinfo *stdout_info, stdout_copy, *stderr_info, stderr_copy;
|
||||
int fd1, fd2, ret1, ret2, ret3, ret4;
|
||||
DWORD flags;
|
||||
HANDLE h;
|
||||
|
||||
/* test close on fds that use the same handle */
|
||||
h = CreateFileA("fdopen.tst", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
ok(h != INVALID_HANDLE_VALUE, "error opening fdopen.tst file\n");
|
||||
|
||||
fd1 = _open_osfhandle((intptr_t)h, 0);
|
||||
ok(fd1 != -1, "_open_osfhandle failed (%d)\n", errno);
|
||||
fd2 = _open_osfhandle((intptr_t)h, 0);
|
||||
ok(fd2 != -1, "_open_osfhandle failed (%d)\n", errno);
|
||||
ok(fd1 != fd2, "fd1 == fd2\n");
|
||||
|
||||
ok((HANDLE)_get_osfhandle(fd1) == h, "handles mismatch (%p != %p)\n",
|
||||
(HANDLE)_get_osfhandle(fd1), h);
|
||||
ok((HANDLE)_get_osfhandle(fd2) == h, "handles mismatch (%p != %p)\n",
|
||||
(HANDLE)_get_osfhandle(fd2), h);
|
||||
ret1 = close(fd1);
|
||||
ok(!ret1, "close(fd1) failed (%d)\n", errno);
|
||||
ok(!GetHandleInformation(h, &flags), "GetHandleInformation succeeded\n");
|
||||
ok(close(fd2), "close(fd2) succeeded\n");
|
||||
|
||||
/* test close on stdout and stderr that use the same handle */
|
||||
h = CreateFileA("fdopen.tst", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
ok(h != INVALID_HANDLE_VALUE, "error opening fdopen.tst file\n");
|
||||
|
||||
/* tests output will not be visible from now on */
|
||||
stdout_info = &__pioinfo[STDOUT_FILENO/MSVCRT_FD_BLOCK_SIZE][STDOUT_FILENO%MSVCRT_FD_BLOCK_SIZE];
|
||||
stderr_info = &__pioinfo[STDERR_FILENO/MSVCRT_FD_BLOCK_SIZE][STDERR_FILENO%MSVCRT_FD_BLOCK_SIZE];
|
||||
stdout_copy = *stdout_info;
|
||||
stderr_copy = *stderr_info;
|
||||
stdout_info->handle = h;
|
||||
stderr_info->handle = h;
|
||||
|
||||
ret1 = close(STDOUT_FILENO);
|
||||
ret2 = GetHandleInformation(h, &flags);
|
||||
ret3 = close(STDERR_FILENO);
|
||||
ret4 = GetHandleInformation(h, &flags);
|
||||
|
||||
*stdout_info = stdout_copy;
|
||||
*stderr_info = stderr_copy;
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, stdout_info->handle);
|
||||
SetStdHandle(STD_ERROR_HANDLE, stderr_info->handle);
|
||||
/* stdout and stderr restored */
|
||||
|
||||
ok(!ret1, "close(STDOUT_FILENO) failed\n");
|
||||
ok(ret2, "GetHandleInformation failed\n");
|
||||
ok(!ret3, "close(STDERR_FILENO) failed\n");
|
||||
ok(!ret4, "GetHandleInformation succeeded\n");
|
||||
|
||||
DeleteFileA( "fdopen.tst" );
|
||||
}
|
||||
|
||||
START_TEST(file)
|
||||
{
|
||||
int arg_c;
|
||||
|
@ -2430,8 +2404,6 @@ START_TEST(file)
|
|||
test_file_inherit_child_no(arg_v[3]);
|
||||
else if (strcmp(arg_v[2], "pipes") == 0)
|
||||
test_pipes_child(arg_c, arg_v);
|
||||
else if (strcmp(arg_v[2], "refcount") == 0)
|
||||
test_file_refcount_child();
|
||||
else
|
||||
ok(0, "invalid argument '%s'\n", arg_v[2]);
|
||||
return;
|
||||
|
@ -2480,6 +2452,7 @@ START_TEST(file)
|
|||
test_mktemp();
|
||||
test__open_osfhandle();
|
||||
test_write_flush();
|
||||
test_close();
|
||||
|
||||
/* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report
|
||||
* file contains lines in the correct order
|
||||
|
|
|
@ -456,6 +456,29 @@ static void test_sbheap(void)
|
|||
free(mem);
|
||||
}
|
||||
|
||||
static void test_calloc(void)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
ptr = calloc(1, 0);
|
||||
ok(ptr != NULL, "got %p\n", ptr);
|
||||
free(ptr);
|
||||
|
||||
ptr = calloc(0, 0);
|
||||
ok(ptr != NULL, "got %p\n", ptr);
|
||||
free(ptr);
|
||||
|
||||
ptr = calloc(0, 1);
|
||||
ok(ptr != NULL, "got %p\n", ptr);
|
||||
free(ptr);
|
||||
|
||||
errno = 0;
|
||||
ptr = calloc(~(size_t)0 / 2, ~(size_t)0 / 2);
|
||||
ok(ptr == NULL || broken(ptr != NULL) /* winxp sp0 */, "got %p\n", ptr);
|
||||
ok(errno == ENOMEM || broken(errno == 0) /* winxp, win2k3 */, "got errno %d\n", errno);
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
START_TEST(heap)
|
||||
{
|
||||
void *mem;
|
||||
|
@ -480,4 +503,5 @@ START_TEST(heap)
|
|||
|
||||
test_aligned();
|
||||
test_sbheap();
|
||||
test_calloc();
|
||||
}
|
||||
|
|
|
@ -180,14 +180,10 @@ static void test_I10_OUTPUT(void)
|
|||
ok(!strcmp(out.str, I10_OUTPUT_tests[i].out.str), "%d: out.str = %s\n", i, out.str);
|
||||
|
||||
j = strlen(I10_OUTPUT_tests[i].remain);
|
||||
if(j && I10_OUTPUT_tests[i].remain[j-1]=='9')
|
||||
todo_wine ok(!strncmp(out.str+out.len+1, I10_OUTPUT_tests[i].remain, j),
|
||||
"%d: &out.str[%d] = %.25s...\n", i, out.len+1, out.str+out.len+1);
|
||||
else
|
||||
todo_wine_if(j && I10_OUTPUT_tests[i].remain[j-1]=='9')
|
||||
ok(!strncmp(out.str+out.len+1, I10_OUTPUT_tests[i].remain, j),
|
||||
"%d: &out.str[%d] = %.25s...\n", i, out.len+1, out.str+out.len+1);
|
||||
|
||||
|
||||
for(j=out.len+strlen(I10_OUTPUT_tests[i].remain)+1; j<sizeof(out.str); j++)
|
||||
if(out.str[j] != '#')
|
||||
ok(0, "%d: out.str[%d] = %c (expected \'#\')\n", i, j, out.str[j]);
|
||||
|
|
|
@ -74,6 +74,7 @@ static unsigned __int64 (__cdecl *p_wcstoui64)(const wchar_t *, wchar_t **, int)
|
|||
static int (__cdecl *pwcstombs_s)(size_t*,char*,size_t,const wchar_t*,size_t);
|
||||
static int (__cdecl *pmbstowcs_s)(size_t*,wchar_t*,size_t,const char*,size_t);
|
||||
static size_t (__cdecl *p_mbsrtowcs)(wchar_t*, const char**, size_t, mbstate_t*);
|
||||
static int (__cdecl *p_mbsrtowcs_s)(size_t*,wchar_t*,size_t,const char**,size_t,mbstate_t*);
|
||||
static size_t (__cdecl *pwcsrtombs)(char*, const wchar_t**, size_t, int*);
|
||||
static errno_t (__cdecl *p_gcvt_s)(char*,size_t,double,int);
|
||||
static errno_t (__cdecl *p_itoa_s)(int,char*,size_t,int);
|
||||
|
@ -1946,6 +1947,11 @@ static void test_mbstowcs(void)
|
|||
return;
|
||||
}
|
||||
|
||||
pmbstr = mHiragana;
|
||||
ret = p_mbsrtowcs(NULL, &pmbstr, 6, NULL);
|
||||
ok(ret == 2, "mbsrtowcs did not return 2\n");
|
||||
ok(pmbstr == mHiragana, "pmbstr = %p, expected %p\n", pmbstr, mHiragana);
|
||||
|
||||
pmbstr = mHiragana;
|
||||
ret = p_mbsrtowcs(wOut, &pmbstr, 6, NULL);
|
||||
ok(ret == 2, "mbsrtowcs did not return 2\n");
|
||||
|
@ -1966,6 +1972,54 @@ static void test_mbstowcs(void)
|
|||
ok(ret == -1, "mbsrtowcs did not return -1\n");
|
||||
ok(errno == EINVAL, "Expected errno to be EINVAL, got %d\n", errno);
|
||||
|
||||
if(!p_mbsrtowcs_s) {
|
||||
setlocale(LC_ALL, "C");
|
||||
win_skip("mbsrtowcs_s not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pmbstr = mHiragana;
|
||||
err = p_mbsrtowcs_s(&ret, NULL, 0, NULL, 6, NULL);
|
||||
ok(ret == -1, "mbsrtowcs_s did not return -1\n");
|
||||
ok(err == EINVAL, "err = %d\n", err);
|
||||
err = p_mbsrtowcs_s(&ret, NULL, 1, &pmbstr, 6, NULL);
|
||||
ok(ret == -1, "mbsrtowcs_s did not return -1\n");
|
||||
ok(err == EINVAL, "err = %d\n", err);
|
||||
err = p_mbsrtowcs_s(&ret, wOut, 0, &pmbstr, 6, NULL);
|
||||
ok(ret == -1, "mbsrtowcs_s did not return -1\n");
|
||||
ok(err == EINVAL, "err = %d\n", err);
|
||||
|
||||
pmbstr = mHiragana;
|
||||
errno = 0;
|
||||
err = p_mbsrtowcs_s(&ret, NULL, 0, &pmbstr, 6, NULL);
|
||||
ok(ret == 3, "mbsrtowcs_s did not return 3\n");
|
||||
ok(err == 0, "err = %d\n", err);
|
||||
ok(pmbstr == mHiragana, "pmbstr = %p, expected %p\n", pmbstr, mHiragana);
|
||||
ok(errno == 0, "errno = %d\n", errno);
|
||||
|
||||
pmbstr = mHiragana;
|
||||
err = p_mbsrtowcs_s(&ret, wOut, 1, &pmbstr, 6, NULL);
|
||||
ok(ret == 2, "mbsrtowcs_s did not return 2\n");
|
||||
ok(err == 0, "err = %d\n", err);
|
||||
ok(!wOut[0], "wOut[0] = '%c'\n", wOut[0]);
|
||||
ok(pmbstr == mHiragana+2, "pmbstr = %p, expected %p\n", pmbstr, mHiragana+2);
|
||||
ok(errno == 0, "errno = %d\n", errno);
|
||||
|
||||
pmbstr = mHiragana;
|
||||
err = p_mbsrtowcs_s(&ret, wOut, 2, &pmbstr, 6, NULL);
|
||||
ok(ret == 3, "mbsrtowcs_s did not return 3\n");
|
||||
ok(err == 0, "err = %d\n", err);
|
||||
ok(!wOut[0], "wOut[0] = '%c'\n", wOut[0]);
|
||||
ok(pmbstr == mHiragana+4, "pmbstr = %p, expected %p\n", pmbstr, mHiragana+4);
|
||||
ok(errno == 0, "errno = %d\n", errno);
|
||||
|
||||
pmbstr = mHiragana;
|
||||
err = p_mbsrtowcs_s(&ret, wOut, 3, &pmbstr, 6, NULL);
|
||||
ok(ret == 3, "mbsrtowcs_s did not return 3\n");
|
||||
ok(err == 0, "err = %d\n", err);
|
||||
ok(!pmbstr, "pmbstr != NULL\n");
|
||||
ok(errno == 0, "errno = %d\n", errno);
|
||||
|
||||
setlocale(LC_ALL, "C");
|
||||
}
|
||||
|
||||
|
@ -3106,6 +3160,7 @@ START_TEST(string)
|
|||
p_mbrlen = (void*)GetProcAddress(hMsvcrt, "mbrlen");
|
||||
p_mbrtowc = (void*)GetProcAddress(hMsvcrt, "mbrtowc");
|
||||
p_mbsrtowcs = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs");
|
||||
p_mbsrtowcs_s = (void*)GetProcAddress(hMsvcrt, "mbsrtowcs_s");
|
||||
p__atodbl_l = (void*)GetProcAddress(hMsvcrt, "_atodbl_l");
|
||||
p__atof_l = (void*)GetProcAddress(hMsvcrt, "_atof_l");
|
||||
p__strtod_l = (void*)GetProcAddress(hMsvcrt, "_strtod_l");
|
||||
|
|
Loading…
Reference in a new issue