From d4a462fbad8ccde3a0565d7b252d912628f6aa89 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 18 Apr 2011 21:56:44 +0000 Subject: [PATCH] [KERNEL32_WINETEST] - 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 | 1 + rostests/winetests/kernel32/dosdev.c | 228 ++++++++++++++++++++ rostests/winetests/kernel32/kernel32.rbuild | 1 + rostests/winetests/kernel32/testlist.c | 2 + 4 files changed, 232 insertions(+) create mode 100644 rostests/winetests/kernel32/dosdev.c diff --git a/rostests/winetests/kernel32/CMakeLists.txt b/rostests/winetests/kernel32/CMakeLists.txt index 00f3fbb46ee..9ad88ff3862 100644 --- a/rostests/winetests/kernel32/CMakeLists.txt +++ b/rostests/winetests/kernel32/CMakeLists.txt @@ -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 index 00000000000..50684da4200 --- /dev/null +++ b/rostests/winetests/kernel32/dosdev.c @@ -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 + +#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(); +} diff --git a/rostests/winetests/kernel32/kernel32.rbuild b/rostests/winetests/kernel32/kernel32.rbuild index 1b87f4b5414..03e64f87615 100644 --- a/rostests/winetests/kernel32/kernel32.rbuild +++ b/rostests/winetests/kernel32/kernel32.rbuild @@ -40,6 +40,7 @@ version.c virtual.c volume.c + dosdev.c testlist.c resource.rc diff --git a/rostests/winetests/kernel32/testlist.c b/rostests/winetests/kernel32/testlist.c index 0102ea70159..0b8317136ba 100755 --- a/rostests/winetests/kernel32/testlist.c +++ b/rostests/winetests/kernel32/testlist.c @@ -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 } };