[KERNEL32_APITEST]

Add simple tests regarding renaming and tunnel cache behavior for short names in user mode.
Longer tests should be added to show what happens in case of cache expiry.
All pass on w2k3 but not on ReactOS.

CORE-3875

svn path=/trunk/; revision=67897
This commit is contained in:
Pierre Schweitzer 2015-05-25 10:30:12 +00:00
parent 3704750e43
commit 11f128b53d
3 changed files with 104 additions and 0 deletions

View file

@ -12,6 +12,7 @@ list(APPEND SOURCE
SetCurrentDirectory.c
SetUnhandledExceptionFilter.c
TerminateProcess.c
TunnelCache.c
testlist.c)
add_executable(kernel32_apitest ${SOURCE})

View file

@ -0,0 +1,101 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPLv2+ - See COPYING in the top level directory
* PURPOSE: Tests for Tunnel Cache
* PROGRAMMER: Pierre Schweitzer <pierre.schweitzer@reactos.org>
*/
#include <apitest.h>
#define WIN32_NO_STATUS
#include <stdio.h>
#include <ndk/rtlfuncs.h>
static
void
Test_ShortTests(void)
{
UCHAR i = 0;
CHAR ShortName[14];
HANDLE hFile, hFind;
WIN32_FIND_DATA FileInfo;
CHAR TestDir[] = "XTestDirTunnelCache";
CHAR OldDir[MAX_PATH];
/* Create a blank test directory */
if (GetCurrentDirectory(MAX_PATH, OldDir) == 0)
{
win_skip("No test directory available\n");
return;
}
/* Create a blank test directory */
for (; i < 10; ++i)
{
TestDir[0] = '0' + i;
if (CreateDirectory(TestDir, NULL))
{
if (SetCurrentDirectory(TestDir) == 0)
{
RemoveDirectory(TestDir);
win_skip("No test directory available\n");
return;
}
break;
}
}
if (i == 10)
{
win_skip("No test directory available\n");
return;
}
hFile = CreateFile("verylongfilename",
GENERIC_READ | GENERIC_WRITE,
0, NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
CloseHandle(hFile);
hFind = FindFirstFile("verylongfilename", &FileInfo);
ok(hFind != INVALID_HANDLE_VALUE, "FindFirstFile() failed\n");
FindClose(hFind);
RtlCopyMemory(ShortName, FileInfo.cAlternateFileName, sizeof(ShortName));
ok(MoveFile("verylongfilename", "verylongfilename2") != FALSE, "MoveFile() failed\n");
hFind = FindFirstFile("verylongfilename2", &FileInfo);
ok(hFind != INVALID_HANDLE_VALUE, "FindFirstFile() failed\n");
FindClose(hFind);
ok(strcmp(FileInfo.cAlternateFileName, ShortName) == 0, "strcmp() failed\n");
hFile = CreateFile("randomfilename",
GENERIC_READ | GENERIC_WRITE,
0, NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile() failed\n");
CloseHandle(hFile);
ok(MoveFileEx("randomfilename", "verylongfilename2", MOVEFILE_REPLACE_EXISTING) != FALSE, "MoveFile() failed\n");
hFind = FindFirstFile("verylongfilename2", &FileInfo);
ok(hFind != INVALID_HANDLE_VALUE, "FindFirstFile() failed\n");
FindClose(hFind);
ok(strcmp(FileInfo.cAlternateFileName, ShortName) == 0, "strcmp() failed\n");
DeleteFile("randomfilename");
DeleteFile("verylongfilename");
DeleteFile("verylongfilename2");
SetCurrentDirectory(OldDir);
RemoveDirectory(TestDir);
}
START_TEST(TunnelCache)
{
Test_ShortTests();
}

View file

@ -15,6 +15,7 @@ extern void func_PrivMoveFileIdentityW(void);
extern void func_SetCurrentDirectory(void);
extern void func_SetUnhandledExceptionFilter(void);
extern void func_TerminateProcess(void);
extern void func_TunnelCache(void);
const struct test winetest_testlist[] =
{
@ -30,6 +31,7 @@ const struct test winetest_testlist[] =
{ "SetCurrentDirectory", func_SetCurrentDirectory },
{ "SetUnhandledExceptionFilter", func_SetUnhandledExceptionFilter },
{ "TerminateProcess", func_TerminateProcess },
{ "TunnelCache", func_TunnelCache },
{ 0, 0 }
};