mirror of
https://github.com/reactos/reactos.git
synced 2025-05-16 15:50:24 +00:00
[KERNEL32_APITEST]
- Add a test checking that GetModuleFileName returns a full path See issue #6786 for more details. svn path=/trunk/; revision=56494
This commit is contained in:
parent
6c68899cf1
commit
3d4754e67f
3 changed files with 133 additions and 1 deletions
|
@ -4,11 +4,12 @@ add_definitions(-D_DLL -D__USE_CRTIMP)
|
|||
list(APPEND SOURCE
|
||||
GetCurrentDirectory.c
|
||||
GetDriveType.c
|
||||
GetModuleFileName.c
|
||||
SetCurrentDirectory.c
|
||||
testlist.c)
|
||||
|
||||
add_executable(kernel32_apitest ${SOURCE})
|
||||
target_link_libraries(kernel32_apitest wine ${PSEH_LIB})
|
||||
set_module_type(kernel32_apitest win32cui)
|
||||
add_importlibs(kernel32_apitest gdi32 user32 msvcrt kernel32 ntdll)
|
||||
add_importlibs(kernel32_apitest gdi32 user32 shlwapi msvcrt kernel32 ntdll)
|
||||
add_cd_file(TARGET kernel32_apitest DESTINATION reactos/bin FOR all)
|
||||
|
|
129
rostests/apitests/kernel32/GetModuleFileName.c
Normal file
129
rostests/apitests/kernel32/GetModuleFileName.c
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* PROJECT: ReactOS api tests
|
||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||
* PURPOSE: Test for GetModuleFileName
|
||||
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
|
||||
*/
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
#define UNICODE
|
||||
#include <stdio.h>
|
||||
#include <wine/test.h>
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
static
|
||||
VOID
|
||||
StartChild(char **argv)
|
||||
{
|
||||
BOOL Success;
|
||||
WCHAR Path[MAX_PATH];
|
||||
PWSTR FileName;
|
||||
PWSTR Slash;
|
||||
WCHAR CommandLine[MAX_PATH];
|
||||
STARTUPINFO StartupInfo;
|
||||
PROCESS_INFORMATION ProcessInfo;
|
||||
DWORD Ret;
|
||||
int Length;
|
||||
|
||||
Length = MultiByteToWideChar(CP_ACP,
|
||||
0,
|
||||
argv[0],
|
||||
-1,
|
||||
Path,
|
||||
sizeof(Path) / sizeof(WCHAR));
|
||||
|
||||
FileName = wcsrchr(Path, '\\');
|
||||
Slash = wcsrchr(Path, L'/');
|
||||
if (Slash && (!FileName || Slash > FileName))
|
||||
FileName = Slash;
|
||||
|
||||
if (FileName)
|
||||
{
|
||||
/* It's an absolute path. Set it as current dir and get the file name */
|
||||
FileName++;
|
||||
FileName[-1] = L'\0';
|
||||
|
||||
Success = SetCurrentDirectory(Path);
|
||||
ok(Success == TRUE, "SetCurrentDirectory failed for path '%ls'\n", Path);
|
||||
|
||||
trace("Starting '%ls' in path '%ls'\n", FileName, Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileName = Path;
|
||||
trace("Starting '%ls', which is already relative\n", FileName);
|
||||
}
|
||||
|
||||
swprintf(CommandLine, L"\"%ls\" GetModuleFileName relative", FileName);
|
||||
|
||||
RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
||||
StartupInfo.cb = sizeof(StartupInfo);
|
||||
|
||||
Success = CreateProcess(FileName,
|
||||
CommandLine,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
&StartupInfo,
|
||||
&ProcessInfo);
|
||||
if (!Success)
|
||||
{
|
||||
skip("CreateProcess failed with %lu\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
Ret = WaitForSingleObject(ProcessInfo.hProcess, 30 * 1000);
|
||||
ok(Ret == WAIT_OBJECT_0, "WaitForSingleObject returns %lu\n", Ret);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
TestGetModuleFileNameA(VOID)
|
||||
{
|
||||
CHAR Buffer[MAX_PATH];
|
||||
DWORD Length;
|
||||
BOOL Relative;
|
||||
|
||||
Length = GetModuleFileNameA(NULL, Buffer, sizeof(Buffer));
|
||||
ok(Length != 0, "Length = %lu\n", Length);
|
||||
ok(Length < sizeof(Buffer), "Length = %lu\n", Length);
|
||||
ok(Buffer[Length] == 0, "Buffer not null terminated\n");
|
||||
Relative = PathIsRelativeA(Buffer);
|
||||
ok(Relative == FALSE, "GetModuleFileNameA returned relative path: %s\n", Buffer);
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
TestGetModuleFileNameW(VOID)
|
||||
{
|
||||
WCHAR Buffer[MAX_PATH];
|
||||
DWORD Length;
|
||||
BOOL Relative;
|
||||
|
||||
Length = GetModuleFileNameW(NULL, Buffer, sizeof(Buffer) / sizeof(WCHAR));
|
||||
ok(Length != 0, "Length = %lu\n", Length);
|
||||
ok(Length < sizeof(Buffer) / sizeof(WCHAR), "Length = %lu\n", Length);
|
||||
ok(Buffer[Length] == 0, "Buffer not null terminated\n");
|
||||
Relative = PathIsRelativeW(Buffer);
|
||||
ok(Relative == FALSE, "GetModuleFileNameA returned relative path: %ls\n", Buffer);
|
||||
}
|
||||
|
||||
START_TEST(GetModuleFileName)
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
argc = winetest_get_mainargs(&argv);
|
||||
if (argc < 3)
|
||||
StartChild(argv);
|
||||
else
|
||||
{
|
||||
TestGetModuleFileNameA();
|
||||
TestGetModuleFileNameW();
|
||||
}
|
||||
}
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
extern void func_GetCurrentDirectory(void);
|
||||
extern void func_GetDriveType(void);
|
||||
extern void func_GetModuleFileName(void);
|
||||
extern void func_SetCurrentDirectory(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "GetCurrentDirectory", func_GetCurrentDirectory },
|
||||
{ "GetDriveType", func_GetDriveType },
|
||||
{ "GetModuleFileName", func_GetModuleFileName },
|
||||
{ "SetCurrentDirectory", func_SetCurrentDirectory },
|
||||
|
||||
{ 0, 0 }
|
||||
|
|
Loading…
Reference in a new issue