From dabadc8eaf42d94b0ceb3fa22caa06fba891c364 Mon Sep 17 00:00:00 2001 From: YongHao Hu Date: Sat, 20 Feb 2016 00:40:34 +0800 Subject: [PATCH] msvcp110: Add tr2_sys__Unlink implementation and test. Signed-off-by: YongHao Hu Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcp110/msvcp110.spec | 4 +- dlls/msvcp120/msvcp120.spec | 4 +- dlls/msvcp120/tests/msvcp120.c | 60 +++++++++++++++++++++++++++++ dlls/msvcp120_app/msvcp120_app.spec | 4 +- dlls/msvcp90/ios.c | 11 ++++++ 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index 3d899245c5..1d9525cf70 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -1805,8 +1805,8 @@ @ cdecl -arch=win32 ?_Tidy@ios_base@std@@AAAXXZ(ptr) ios_base_Tidy @ stub -arch=i386 ?_Tidy@ios_base@std@@AAEXXZ @ cdecl -arch=win64 ?_Tidy@ios_base@std@@AEAAXXZ(ptr) ios_base_Tidy -@ stub -arch=win32 ?_Unlink@sys@tr2@std@@YAHPBD@Z -@ stub -arch=win64 ?_Unlink@sys@tr2@std@@YAHPEBD@Z +@ cdecl -arch=win32 ?_Unlink@sys@tr2@std@@YAHPBD@Z(str) tr2_sys__Unlink +@ cdecl -arch=win64 ?_Unlink@sys@tr2@std@@YAHPEBD@Z(str) tr2_sys__Unlink @ stub -arch=win32 ?_Unlink@sys@tr2@std@@YAHPB_W@Z @ stub -arch=win64 ?_Unlink@sys@tr2@std@@YAHPEB_W@Z @ cdecl -arch=arm ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAAXXZ(ptr) basic_streambuf_char__Unlock diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index 1bb487e7ea..e5daa62bdb 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -1766,8 +1766,8 @@ @ cdecl -arch=win32 ?_Tidy@ios_base@std@@AAAXXZ(ptr) ios_base_Tidy @ stub -arch=i386 ?_Tidy@ios_base@std@@AAEXXZ @ cdecl -arch=win64 ?_Tidy@ios_base@std@@AEAAXXZ(ptr) ios_base_Tidy -@ stub -arch=win32 ?_Unlink@sys@tr2@std@@YAHPBD@Z -@ stub -arch=win64 ?_Unlink@sys@tr2@std@@YAHPEBD@Z +@ cdecl -arch=win32 ?_Unlink@sys@tr2@std@@YAHPBD@Z(str) tr2_sys__Unlink +@ cdecl -arch=win64 ?_Unlink@sys@tr2@std@@YAHPEBD@Z(str) tr2_sys__Unlink @ stub -arch=win32 ?_Unlink@sys@tr2@std@@YAHPB_W@Z @ stub -arch=win64 ?_Unlink@sys@tr2@std@@YAHPEB_W@Z @ cdecl -arch=arm ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAAXXZ(ptr) basic_streambuf_char__Unlock diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index f884d0c87b..17a41d1463 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -134,6 +134,7 @@ static char* (__cdecl *p_tr2_sys__Read_dir)(char*, void*, enum file_type*); static void (__cdecl *p_tr2_sys__Close_dir)(void*); static int (__cdecl *p_tr2_sys__Link)(char const*, char const*); static int (__cdecl *p_tr2_sys__Symlink)(char const*, char const*); +static int (__cdecl *p_tr2_sys__Unlink)(char const*); /* thrd */ typedef struct @@ -271,6 +272,8 @@ static BOOL init(void) "?_Link@sys@tr2@std@@YAHPEBD0@Z"); SET(p_tr2_sys__Symlink, "?_Symlink@sys@tr2@std@@YAHPEBD0@Z"); + SET(p_tr2_sys__Unlink, + "?_Unlink@sys@tr2@std@@YAHPEBD@Z"); SET(p__Thrd_current, "_Thrd_current"); } else { @@ -328,6 +331,8 @@ static BOOL init(void) "?_Link@sys@tr2@std@@YAHPBD0@Z"); SET(p_tr2_sys__Symlink, "?_Symlink@sys@tr2@std@@YAHPBD0@Z"); + SET(p_tr2_sys__Unlink, + "?_Unlink@sys@tr2@std@@YAHPBD@Z"); #ifdef __i386__ SET(p_i386_Thrd_current, "_Thrd_current"); @@ -1460,6 +1465,60 @@ static void test_tr2_sys__Symlink(void) ok(ret == 1, "tr2_sys__Remove_dir(): expect 1 got %d\n", ret); } +static void test_tr2_sys__Unlink(void) +{ + int ret, i; + HANDLE file; + LARGE_INTEGER file_size; + struct { + char const *path; + int last_error; + MSVCP_bool is_todo; + } tests[] = { + { "tr2_test_dir\\f1_symlink", ERROR_SUCCESS, TRUE }, + { "tr2_test_dir\\f1_link", ERROR_SUCCESS, FALSE }, + { "tr2_test_dir\\f1", ERROR_SUCCESS, FALSE }, + { "tr2_test_dir", ERROR_ACCESS_DENIED, FALSE }, + { "not_exist", ERROR_FILE_NOT_FOUND, FALSE }, + { "not_exist_dir\\not_exist_file", ERROR_PATH_NOT_FOUND, FALSE }, + { NULL, ERROR_PATH_NOT_FOUND, FALSE } + }; + + ret = p_tr2_sys__Make_dir("tr2_test_dir"); + ok(ret == 1, "tr2_sys__Make_dir(): expect 1 got %d\n", ret); + file = CreateFileA("tr2_test_dir/f1", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + file_size.QuadPart = 7; + ok(SetFilePointerEx(file, file_size, NULL, FILE_BEGIN), "SetFilePointerEx failed\n"); + ok(SetEndOfFile(file), "SetEndOfFile failed\n"); + CloseHandle(file); + + ret = p_tr2_sys__Symlink("tr2_test_dir/f1", "tr2_test_dir/f1_symlink"); + if(ret==ERROR_PRIVILEGE_NOT_HELD || ret==ERROR_INVALID_FUNCTION) { + tests[0].last_error = ERROR_FILE_NOT_FOUND; + win_skip("Privilege not held or symbolic link not supported, skipping symbolic link tests.\n"); + }else { + ok(ret == ERROR_SUCCESS, "tr2_sys__Symlink(): expect: ERROR_SUCCESS, got %d\n", ret); + } + ret = p_tr2_sys__Link("tr2_test_dir/f1", "tr2_test_dir/f1_link"); + ok(ret == ERROR_SUCCESS, "tr2_sys__Link(): expect: ERROR_SUCCESS, got %d\n", ret); + + for(i=0; i