YongHao Hu : msvcp110: Add tr2_sys__Symlink implementation and test.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Feb 19 08:56:20 CST 2016


Module: wine
Branch: master
Commit: d6dcc253bf907e4e92f24821eb960e528c2f5485
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d6dcc253bf907e4e92f24821eb960e528c2f5485

Author: YongHao Hu <christopherwuy at gmail.com>
Date:   Fri Feb 19 00:46:51 2016 +0800

msvcp110: Add tr2_sys__Symlink implementation and test.

Signed-off-by: YongHao Hu <christopherwuy at gmail.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcp110/msvcp110.spec         |  4 +--
 dlls/msvcp120/msvcp120.spec         |  4 +--
 dlls/msvcp120/tests/msvcp120.c      | 65 +++++++++++++++++++++++++++++++++++++
 dlls/msvcp120_app/msvcp120_app.spec |  4 +--
 dlls/msvcp90/ios.c                  | 13 ++++++++
 5 files changed, 84 insertions(+), 6 deletions(-)

diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index 1df4c55..3d89924 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -1771,8 +1771,8 @@
 @ cdecl -arch=arm ?_Swap_all at _Container_base12@std@@QAAXAAU12@@Z(ptr ptr) _Container_base12__Swap_all
 @ thiscall -arch=i386 ?_Swap_all at _Container_base12@std@@QAEXAAU12@@Z(ptr ptr) _Container_base12__Swap_all
 @ cdecl -arch=win64 ?_Swap_all at _Container_base12@std@@QEAAXAEAU12@@Z(ptr ptr) _Container_base12__Swap_all
-@ stub -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPBD0 at Z
-@ stub -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z
+@ cdecl -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPBD0 at Z(str str) tr2_sys__Symlink
+@ cdecl -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z(str str) tr2_sys__Symlink
 @ stub -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPB_W0 at Z
 @ stub -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEB_W0 at Z
 @ extern ?_Sync at ios_base@std@@0_NA ios_base_Sync
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 626ead8..1bb487e 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -1732,8 +1732,8 @@
 @ cdecl -arch=arm ?_Swap_all at _Container_base12@std@@QAAXAAU12@@Z(ptr ptr) _Container_base12__Swap_all
 @ thiscall -arch=i386 ?_Swap_all at _Container_base12@std@@QAEXAAU12@@Z(ptr ptr) _Container_base12__Swap_all
 @ cdecl -arch=win64 ?_Swap_all at _Container_base12@std@@QEAAXAEAU12@@Z(ptr ptr) _Container_base12__Swap_all
-@ stub -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPBD0 at Z
-@ stub -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z
+@ cdecl -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPBD0 at Z(str str) tr2_sys__Symlink
+@ cdecl -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z(str str) tr2_sys__Symlink
 @ stub -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPB_W0 at Z
 @ stub -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEB_W0 at Z
 @ extern ?_Sync at ios_base@std@@0_NA ios_base_Sync
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 1aaa251..f884d0c 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -133,6 +133,7 @@ static void* (__cdecl *p_tr2_sys__Open_dir)(char*, char const*, int *, enum file
 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*);
 
 /* thrd */
 typedef struct
@@ -268,6 +269,8 @@ static BOOL init(void)
                 "?_Close_dir at sys@tr2 at std@@YAXPEAX at Z");
         SET(p_tr2_sys__Link,
                 "?_Link at sys@tr2 at std@@YAHPEBD0 at Z");
+        SET(p_tr2_sys__Symlink,
+                "?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z");
         SET(p__Thrd_current,
                 "_Thrd_current");
     } else {
@@ -323,6 +326,8 @@ static BOOL init(void)
                 "?_Close_dir at sys@tr2 at std@@YAXPAX at Z");
         SET(p_tr2_sys__Link,
                 "?_Link at sys@tr2 at std@@YAHPBD0 at Z");
+        SET(p_tr2_sys__Symlink,
+                "?_Symlink at sys@tr2 at std@@YAHPBD0 at Z");
 #ifdef __i386__
         SET(p_i386_Thrd_current,
                 "_Thrd_current");
@@ -1396,6 +1401,65 @@ static void test_tr2_sys__Link(void)
     ok(SetCurrentDirectoryA(current_path), "SetCurrentDirectoryA failed\n");
 }
 
+static void test_tr2_sys__Symlink(void)
+{
+    int ret, i;
+    HANDLE file;
+    LARGE_INTEGER file_size;
+    struct {
+        char const *existing_path;
+        char const *new_path;
+        int last_error;
+        MSVCP_bool is_todo;
+    } tests[] = {
+        { "f1", "f1_link", ERROR_SUCCESS, FALSE },
+        { "f1", "tr2_test_dir\\f1_link", ERROR_SUCCESS, FALSE },
+        { "tr2_test_dir\\f1_link", "tr2_test_dir\\f1_link_link", ERROR_SUCCESS, FALSE },
+        { "tr2_test_dir", "dir_link", ERROR_SUCCESS, FALSE },
+        { NULL, "NULL_link", ERROR_INVALID_PARAMETER, FALSE },
+        { "f1", NULL, ERROR_INVALID_PARAMETER, FALSE },
+        { "not_exist",  "not_exist_link", ERROR_SUCCESS, FALSE },
+        { "f1", "not_exist_dir\\f1_link", ERROR_PATH_NOT_FOUND, TRUE }
+    };
+
+    ret = p_tr2_sys__Make_dir("tr2_test_dir");
+    ok(ret == 1, "test_tr2_sys__Make_dir(): expect 1 got %d\n", ret);
+    file = CreateFileA("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);
+
+    for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+        errno = 0xdeadbeef;
+        SetLastError(0xdeadbeef);
+        ret = p_tr2_sys__Symlink(tests[i].existing_path, tests[i].new_path);
+        if(!i && (ret==ERROR_PRIVILEGE_NOT_HELD || ret==ERROR_INVALID_FUNCTION)) {
+            win_skip("Privilege not held or symbolic link not supported, skipping symbolic link tests.\n");
+            ok(DeleteFileA("f1"), "expect f1 to exist\n");
+            ret = p_tr2_sys__Remove_dir("tr2_test_dir");
+            ok(ret == 1, "tr2_sys__Remove_dir(): expect 1 got %d\n", ret);
+            return;
+        }
+
+        ok(errno == 0xdeadbeef, "tr2_sys__Symlink(): test %d errno expect 0xdeadbeef, got %d\n", i+1, errno);
+        todo_wine_if(tests[i].is_todo)
+            ok(ret == tests[i].last_error, "tr2_sys__Symlink(): test %d expect: %d, got %d\n", i+1, tests[i].last_error, ret);
+        if(ret == ERROR_SUCCESS)
+            ok(p_tr2_sys__File_size(tests[i].new_path) == 0, "tr2_sys__Symlink(): expect 0, got %s\n", debugstr_longlong(p_tr2_sys__File_size(tests[i].new_path)));
+    }
+
+    ok(DeleteFileA("f1"), "expect f1 to exist\n");
+    todo_wine ok(DeleteFileA("f1_link"), "expect f1_link to exist\n");
+    todo_wine ok(DeleteFileA("tr2_test_dir/f1_link"), "expect tr2_test_dir/f1_link to exist\n");
+    todo_wine ok(DeleteFileA("tr2_test_dir/f1_link_link"), "expect tr2_test_dir/f1_link_link to exist\n");
+    todo_wine ok(DeleteFileA("not_exist_link"), "expect not_exist_link to exist\n");
+    todo_wine ok(DeleteFileA("dir_link"), "expect dir_link to exist\n");
+    ret = p_tr2_sys__Remove_dir("tr2_test_dir");
+    ok(ret == 1, "tr2_sys__Remove_dir(): expect 1 got %d\n", ret);
+}
+
 static int __cdecl thrd_thread(void *arg)
 {
     _Thrd_t *thr = arg;
@@ -1686,6 +1750,7 @@ START_TEST(msvcp120)
     test_tr2_sys__Last_write_time();
     test_tr2_sys__dir_operation();
     test_tr2_sys__Link();
+    test_tr2_sys__Symlink();
 
     test_thrd();
     test_cnd();
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index 517e1b0..2d0a95b 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -1732,8 +1732,8 @@
 @ cdecl -arch=arm ?_Swap_all at _Container_base12@std@@QAAXAAU12@@Z(ptr ptr) msvcp120.?_Swap_all at _Container_base12@std@@QAAXAAU12@@Z
 @ thiscall -arch=i386 ?_Swap_all at _Container_base12@std@@QAEXAAU12@@Z(ptr ptr) msvcp120.?_Swap_all at _Container_base12@std@@QAEXAAU12@@Z
 @ cdecl -arch=win64 ?_Swap_all at _Container_base12@std@@QEAAXAEAU12@@Z(ptr ptr) msvcp120.?_Swap_all at _Container_base12@std@@QEAAXAEAU12@@Z
-@ stub -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPBD0 at Z
-@ stub -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z
+@ cdecl -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPBD0 at Z(str str) msvcp120.?_Symlink at sys@tr2 at std@@YAHPBD0 at Z
+@ cdecl -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z(str str) msvcp120.?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z
 @ stub -arch=win32 ?_Symlink at sys@tr2 at std@@YAHPB_W0 at Z
 @ stub -arch=win64 ?_Symlink at sys@tr2 at std@@YAHPEB_W0 at Z
 @ extern ?_Sync at ios_base@std@@0_NA msvcp120.?_Sync at ios_base@std@@0_NA
diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index 12e2984..d9ff610 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -14769,6 +14769,19 @@ int __cdecl tr2_sys__Link(char const* existing_path, char const* new_path)
     return GetLastError();
 }
 
+/* ?_Symlink at sys@tr2 at std@@YAHPBD0 at Z */
+/* ?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z */
+int __cdecl tr2_sys__Symlink(char const* existing_file_name, char const* file_name)
+{
+    TRACE("(%s %s)\n", debugstr_a(existing_file_name), debugstr_a(file_name));
+    if(!existing_file_name || !file_name)
+        return ERROR_INVALID_PARAMETER;
+
+    if(CreateSymbolicLinkA(file_name, existing_file_name, 0))
+        return ERROR_SUCCESS;
+    return GetLastError();
+}
+
 /* ??0strstream at std@@QAE at PADHH@Z */
 /* ??0strstream at std@@QEAA at PEAD_JH@Z */
 #if STREAMSIZE_BITS == 64




More information about the wine-cvs mailing list