[KERNEL32_WINETEST]
authorAleksey Bragin <aleksey@reactos.org>
Mon, 18 Apr 2011 21:56:44 +0000 (21:56 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Mon, 18 Apr 2011 21:56:44 +0000 (21:56 +0000)
- Sam Arun Raj Seeniraj: Added new test cases to QueryDosDevice(). Should be sent to Wine (tm).
See issue #993 for more details.

svn path=/trunk/; revision=51394

rostests/winetests/kernel32/CMakeLists.txt
rostests/winetests/kernel32/dosdev.c [new file with mode: 0644]
rostests/winetests/kernel32/kernel32.rbuild
rostests/winetests/kernel32/testlist.c

index 00f3fbb..9ad88ff 100644 (file)
@@ -40,6 +40,7 @@ list(APPEND SOURCE
     version.c
     virtual.c
     volume.c
+    dosdev.c
     testlist.c
     resource.rc)
 
diff --git a/rostests/winetests/kernel32/dosdev.c b/rostests/winetests/kernel32/dosdev.c
new file mode 100644 (file)
index 0000000..50684da
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * Unit test suite for virtual substituted drive functions.
+ *
+ * Copyright 2011 Sam Arun Raj
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "wine/test.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+
+static void test_DefineDosDeviceA1(void)
+{
+    /* Test using lowercase drive letters */
+    CHAR Target[MAX_PATH];
+    CHAR Drive[] = "m:";
+    BOOL Result;
+
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp");
+    ok(Result, "Failed to subst drive using lowercase drive letter");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp");
+    ok(Result, "Failed to remove subst drive using lowercase drive letter");
+
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(!Result, "Subst drive is present even after remove attempt");
+}
+
+static void test_DefineDosDeviceA2(void)
+{
+    /* Test using trailing \ against drive letter */
+    CHAR Target[MAX_PATH];
+    CHAR Drive[] = "Q:\\";
+    BOOL Result;
+
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp");
+    ok(!Result, "Subst drive using trailing path seperator");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp");
+    ok(!Result, "Subst drive using trailing path seperator");
+
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(!Result, "Subst drive is present when it should not be created in the first place");
+}
+
+static void test_DefineDosDeviceA3(void)
+{
+    /* Test using arbitary string, not necessarily a DOS drive letter */
+    CHAR Target[MAX_PATH];
+    CHAR Drive[] = "!QHello:";
+    BOOL Result;
+
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp");
+    ok(Result, "Failed to subst drive using non-DOS drive name");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp");
+    ok(Result, "Failed to subst drive using non-DOS drive name");
+
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(!Result, "Subst drive is present even after remove attempt");
+}
+
+static void test_DefineDosDeviceA4(void)
+{
+    /* Test remove without using DDD_EXACT_MATCH_ON_REMOVE */
+    CHAR Target[MAX_PATH];
+    CHAR Drive[] = "M:";
+    BOOL Result;
+
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp");
+    ok(Result, "Failed to subst drive");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION, Drive, NULL);
+    ok(Result, "Failed to remove subst drive using NULL Target name");
+
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(!Result, "Subst drive is present even after remove attempt");
+}
+
+static void test_DefineDosDeviceA5(void)
+{
+    /* Test multiple adds and multiple removes in add order */
+    CHAR Target[MAX_PATH];
+    CHAR Drive[] = "M:";
+    BOOL Result;
+
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp1");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp2");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp3");
+    ok(Result, "Failed to subst drive");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp1");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp3") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp2");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp3") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp3");
+    ok(Result, "Failed to remove subst drive");
+
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(!Result, "Subst drive is present even after remove attempt");
+}
+
+static void test_DefineDosDeviceA6(void)
+{
+    /* Test multiple adds and multiple removes in reverse order */
+    CHAR Target[MAX_PATH];
+    CHAR Drive[] = "M:";
+    BOOL Result;
+
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp1");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp2");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp3");
+    ok(Result, "Failed to subst drive");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp3");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp2") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp2");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp1") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp1");
+    ok(Result, "Failed to remove subst drive");
+
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(!Result, "Subst drive is present even after remove attempt");
+}
+
+static void test_DefineDosDeviceA7(void)
+{
+    /* Test multiple adds and multiple removes out of order */
+    CHAR Target[MAX_PATH];
+    CHAR Drive[] = "M:";
+    BOOL Result;
+
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp1");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp2");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp3");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp4");
+    ok(Result, "Failed to subst drive");
+    Result = DefineDosDeviceA(0, Drive, "C:\\temp5");
+    ok(Result, "Failed to subst drive");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp2");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp5") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp5");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp4") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp1");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp4") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp3");
+    ok(Result, "Failed to remove subst drive");
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(Result, "Failed to query subst drive");
+    if (Result)
+        ok((_stricmp(Target, "\\??\\C:\\temp4") == 0), "Subst drive is not pointing to correct target");
+
+    Result = DefineDosDeviceA(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE, Drive, "C:\\temp4");
+    ok(Result, "Failed to remove subst drive");
+
+    Result = QueryDosDeviceA(Drive, Target, MAX_PATH);
+    ok(!Result, "Subst drive is present even after remove attempt");
+}
+
+START_TEST(dosdev)
+{
+    test_DefineDosDeviceA1();
+    test_DefineDosDeviceA2();
+    test_DefineDosDeviceA3();
+    test_DefineDosDeviceA4();
+    test_DefineDosDeviceA5();
+    test_DefineDosDeviceA6();
+    test_DefineDosDeviceA7();
+}
index 1b87f4b..03e64f8 100644 (file)
@@ -40,6 +40,7 @@
        <file>version.c</file>
        <file>virtual.c</file>
        <file>volume.c</file>
+       <file>dosdev.c</file>
        <file>testlist.c</file>
        <file>resource.rc</file>
 </module>
index 0102ea7..0b83171 100755 (executable)
@@ -42,6 +42,7 @@ extern void func_toolhelp(void);
 extern void func_virtual(void);
 extern void func_version(void);
 extern void func_volume(void);
+extern void func_dosdev(void);
 
 const struct test winetest_testlist[] =
 {
@@ -78,6 +79,7 @@ const struct test winetest_testlist[] =
     { "virtual", func_virtual },
     { "version", func_version },
     { "volume", func_volume },
+    { "dosdev", func_dosdev },
     { 0, 0 }
 };