[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
This commit is contained in:
Aleksey Bragin 2011-04-18 21:56:44 +00:00
parent a63e424516
commit d4a462fbad
4 changed files with 232 additions and 0 deletions

View file

@ -40,6 +40,7 @@ list(APPEND SOURCE
version.c
virtual.c
volume.c
dosdev.c
testlist.c
resource.rc)

View file

@ -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();
}

View 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>

View file

@ -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 }
};