mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[KERNEL32_APITEST]
Add tests for PrivMoveFileIdentityW(). Tested on w2k3 by Thomas svn path=/trunk/; revision=67273
This commit is contained in:
parent
7a96f42b4a
commit
ad157d2c6f
3 changed files with 114 additions and 0 deletions
|
@ -8,6 +8,7 @@ list(APPEND SOURCE
|
||||||
interlck.c
|
interlck.c
|
||||||
lstrcpynW.c
|
lstrcpynW.c
|
||||||
MultiByteToWideChar.c
|
MultiByteToWideChar.c
|
||||||
|
PrivMoveFileIdentityW.c
|
||||||
SetCurrentDirectory.c
|
SetCurrentDirectory.c
|
||||||
SetUnhandledExceptionFilter.c
|
SetUnhandledExceptionFilter.c
|
||||||
TerminateProcess.c
|
TerminateProcess.c
|
||||||
|
|
111
rostests/apitests/kernel32/PrivMoveFileIdentityW.c
Normal file
111
rostests/apitests/kernel32/PrivMoveFileIdentityW.c
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS api tests
|
||||||
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||||
|
* PURPOSE: Test for PrivMoveFileIdentityW
|
||||||
|
* PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <apitest.h>
|
||||||
|
|
||||||
|
#define WIN32_NO_STATUS
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ndk/iofuncs.h>
|
||||||
|
#include <ndk/rtltypes.h>
|
||||||
|
|
||||||
|
static const WCHAR FileName[] = L"TestFile.xxx";
|
||||||
|
static const WCHAR Self[] = L"kernel32_apitest.exe";
|
||||||
|
|
||||||
|
static BOOL (WINAPI * pPrivMoveFileIdentityW)(LPCWSTR, LPCWSTR, DWORD);
|
||||||
|
|
||||||
|
static
|
||||||
|
BOOL
|
||||||
|
QueryFileInfo(
|
||||||
|
LPCWSTR File,
|
||||||
|
PFILE_BASIC_INFORMATION FileBasicInfo,
|
||||||
|
PFILE_STANDARD_INFORMATION FileStandardInfo)
|
||||||
|
{
|
||||||
|
HANDLE hFile;
|
||||||
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
hFile = CreateFileW(File, FILE_READ_ATTRIBUTES | SYNCHRONIZE,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||||
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_SYNCHRONOUS_IO_NONALERT,
|
||||||
|
NULL);
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtQueryInformationFile(hFile, &IoStatusBlock, FileBasicInfo,
|
||||||
|
sizeof(FILE_BASIC_INFORMATION), FileBasicInformation);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtQueryInformationFile(hFile, &IoStatusBlock, FileStandardInfo,
|
||||||
|
sizeof(FILE_STANDARD_INFORMATION), FileStandardInformation);
|
||||||
|
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return NT_SUCCESS(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
TestPrivMoveFileIdentityW(VOID)
|
||||||
|
{
|
||||||
|
FILE_BASIC_INFORMATION FileBasicInfo;
|
||||||
|
FILE_STANDARD_INFORMATION FileStandardInfo;
|
||||||
|
LARGE_INTEGER CreationTime, EndOfFile;
|
||||||
|
HANDLE hDest;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DeleteFileW(FileName);
|
||||||
|
|
||||||
|
if (!QueryFileInfo(Self, &FileBasicInfo, &FileStandardInfo))
|
||||||
|
{
|
||||||
|
win_skip("Failed querying self\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreationTime = FileBasicInfo.CreationTime;
|
||||||
|
EndOfFile = FileStandardInfo.EndOfFile;
|
||||||
|
|
||||||
|
Sleep(150);
|
||||||
|
|
||||||
|
hDest = CreateFileW(FileName, GENERIC_WRITE | SYNCHRONIZE,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||||
|
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_SYNCHRONOUS_IO_NONALERT,
|
||||||
|
NULL);
|
||||||
|
if (hDest == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
win_skip("Failed creating new\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(hDest);
|
||||||
|
|
||||||
|
ok(QueryFileInfo(FileName, &FileBasicInfo, &FileStandardInfo) == TRUE, "QueryFileInfo returned FALSE\n");
|
||||||
|
ok(FileBasicInfo.CreationTime.QuadPart != CreationTime.QuadPart, "Equal creation times\n");
|
||||||
|
ok(FileStandardInfo.EndOfFile.QuadPart == 0LL, "File wasn't created empty: %I64d\n", FileStandardInfo.EndOfFile.QuadPart);
|
||||||
|
Status = (NTSTATUS)pPrivMoveFileIdentityW(Self, FileName, 0);
|
||||||
|
ok(Status == STATUS_SUCCESS, "PrivMoveFileIdentityW failed with %lx\n", Status);
|
||||||
|
ok(QueryFileInfo(FileName, &FileBasicInfo, &FileStandardInfo) == TRUE, "QueryFileInfo returned FALSE\n");
|
||||||
|
ok(FileBasicInfo.CreationTime.QuadPart == CreationTime.QuadPart, "Creation time didn't change\n");
|
||||||
|
ok(FileStandardInfo.EndOfFile.QuadPart == 0LL, "File not empty anymore: %I64d\n", FileStandardInfo.EndOfFile.QuadPart);
|
||||||
|
ok(QueryFileInfo(Self, &FileBasicInfo, &FileStandardInfo) == TRUE, "QueryFileInfo returned FALSE\n");
|
||||||
|
ok(FileBasicInfo.CreationTime.QuadPart == CreationTime.QuadPart, "Creation time changed\n");
|
||||||
|
ok(FileStandardInfo.EndOfFile.QuadPart == EndOfFile.QuadPart, "File size changed: %I64d\n", FileStandardInfo.EndOfFile.QuadPart);
|
||||||
|
|
||||||
|
DeleteFileW(FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(PrivMoveFileIdentityW)
|
||||||
|
{
|
||||||
|
HMODULE hKern = GetModuleHandleA("kernel32.dll");
|
||||||
|
pPrivMoveFileIdentityW = (void *)GetProcAddress(hKern, "PrivMoveFileIdentityW");
|
||||||
|
|
||||||
|
TestPrivMoveFileIdentityW();
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ extern void func_GetModuleFileName(void);
|
||||||
extern void func_interlck(void);
|
extern void func_interlck(void);
|
||||||
extern void func_lstrcpynW(void);
|
extern void func_lstrcpynW(void);
|
||||||
extern void func_MultiByteToWideChar(void);
|
extern void func_MultiByteToWideChar(void);
|
||||||
|
extern void func_PrivMoveFileIdentityW(void);
|
||||||
extern void func_SetCurrentDirectory(void);
|
extern void func_SetCurrentDirectory(void);
|
||||||
extern void func_SetUnhandledExceptionFilter(void);
|
extern void func_SetUnhandledExceptionFilter(void);
|
||||||
extern void func_TerminateProcess(void);
|
extern void func_TerminateProcess(void);
|
||||||
|
@ -25,6 +26,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "interlck", func_interlck },
|
{ "interlck", func_interlck },
|
||||||
{ "lstrcpynW", func_lstrcpynW },
|
{ "lstrcpynW", func_lstrcpynW },
|
||||||
{ "MultiByteToWideChar", func_MultiByteToWideChar },
|
{ "MultiByteToWideChar", func_MultiByteToWideChar },
|
||||||
|
{ "PrivMoveFileIdentityW", func_PrivMoveFileIdentityW },
|
||||||
{ "SetCurrentDirectory", func_SetCurrentDirectory },
|
{ "SetCurrentDirectory", func_SetCurrentDirectory },
|
||||||
{ "SetUnhandledExceptionFilter", func_SetUnhandledExceptionFilter },
|
{ "SetUnhandledExceptionFilter", func_SetUnhandledExceptionFilter },
|
||||||
{ "TerminateProcess", func_TerminateProcess },
|
{ "TerminateProcess", func_TerminateProcess },
|
||||||
|
|
Loading…
Reference in a new issue