[PSAPI_APITEST]

Add tests for GetDeviceDriverBaseName
Replace 0x00000000 -> NULL. Dedicated to Thomas ;-)

svn path=/trunk/; revision=60601
This commit is contained in:
Pierre Schweitzer 2013-10-10 19:18:43 +00:00
parent 196ba3d618
commit 9b29c6967f
2 changed files with 80 additions and 11 deletions

View file

@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPLv2+ - See COPYING in the top level directory
* PURPOSE: Test for GetDeviceDriverFileName
* PURPOSE: Test for GetDeviceDriverFileName & GetDeviceDriverBaseName
* PROGRAMMER: Pierre Schweitzer
*/
@ -25,14 +25,14 @@ static LPVOID IntGetImageBase(LPCSTR Image)
Snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
if (Snap == INVALID_HANDLE_VALUE)
{
return (LPVOID)0x00000000;
return NULL;
}
Module.dwSize = sizeof(MODULEENTRY32);
if(!Module32First(Snap, &Module))
{
CloseHandle(Snap);
return (LPVOID)0x00000000;
return NULL;
}
do
@ -45,10 +45,10 @@ static LPVOID IntGetImageBase(LPCSTR Image)
} while(Module32Next(Snap, &Module));
CloseHandle(Snap);
return (LPVOID)0x00000000;
return NULL;
}
static BOOLEAN IntGetModuleInformation(LPCSTR Module, BOOLEAN IsDriver, BOOLEAN IsProcMod, TEST_MODULE_INFO * Info)
static BOOLEAN IntGetModuleInformation(LPCSTR Module, BOOLEAN IsDriver, BOOLEAN IsProcMod, BOOLEAN BaseName, TEST_MODULE_INFO * Info)
{
CHAR System[255];
UINT Len;
@ -85,9 +85,17 @@ static BOOLEAN IntGetModuleInformation(LPCSTR Module, BOOLEAN IsDriver, BOOLEAN
return FALSE;
}
/* Skip disk */
strcpy(Info->Path, System + 2);
Info->Len = strlen(Info->Path);
if (BaseName)
{
strcpy(Info->Path, Module);
Info->Len = strlen(Info->Path);
}
else
{
/* Skip disk */
strcpy(Info->Path, System + 2);
Info->Len = strlen(Info->Path);
}
return TRUE;
}
@ -103,7 +111,7 @@ START_TEST(GetDeviceDriverFileName)
ok(Len == 0, "Len: %lu\n", Len);
ok(GetLastError() == ERROR_INVALID_HANDLE, "Error: %lx\n", GetLastError());
if (IntGetModuleInformation("ntdll.dll", FALSE, TRUE, &ModInfo))
if (IntGetModuleInformation("ntdll.dll", FALSE, TRUE, FALSE, &ModInfo))
{
SetLastError(0xDEADBEEF);
Len = GetDeviceDriverFileNameA(ModInfo.ImageBase, FileName, 255);
@ -126,7 +134,7 @@ START_TEST(GetDeviceDriverFileName)
skip("Couldn't find info about ntdll.dll\n");
}
if (IntGetModuleInformation("msvcrt.dll", FALSE, TRUE, &ModInfo))
if (IntGetModuleInformation("msvcrt.dll", FALSE, TRUE, FALSE, &ModInfo))
{
SetLastError(0xDEADBEEF);
Len = GetDeviceDriverFileNameA(ModInfo.ImageBase, FileName, 255);
@ -138,7 +146,7 @@ START_TEST(GetDeviceDriverFileName)
skip("Couldn't find info about msvcrt.dll\n");
}
if (IntGetModuleInformation("psapi.dll", FALSE, TRUE, &ModInfo))
if (IntGetModuleInformation("psapi.dll", FALSE, TRUE, FALSE, &ModInfo))
{
SetLastError(0xDEADBEEF);
Len = GetDeviceDriverFileNameA(ModInfo.ImageBase, FileName, 255);
@ -150,3 +158,62 @@ START_TEST(GetDeviceDriverFileName)
skip("Couldn't find info about psapi.dll\n");
}
}
START_TEST(GetDeviceDriverBaseName)
{
DWORD Len;
CHAR FileName[255];
TEST_MODULE_INFO ModInfo;
SetLastError(0xDEADBEEF);
Len = GetDeviceDriverBaseNameA(0, FileName, 255);
ok(Len == 0, "Len: %lu\n", Len);
ok(GetLastError() == ERROR_INVALID_HANDLE, "Error: %lx\n", GetLastError());
if (IntGetModuleInformation("ntdll.dll", FALSE, TRUE, TRUE, &ModInfo))
{
SetLastError(0xDEADBEEF);
Len = GetDeviceDriverBaseNameA(ModInfo.ImageBase, FileName, 255);
ok(Len == ModInfo.Len, "Len: %lu\n", Len);
ok(GetLastError() == 0xDEADBEEF, "Error: %lx\n", GetLastError());
ok(lstrcmpiA(ModInfo.Path, FileName) == 0, "File name: %s\n", FileName);
/* Test with too small buffer */
SetLastError(0xDEADBEEF);
ModInfo.Len--;
ModInfo.Path[ModInfo.Len] = 0;
FileName[ModInfo.Len] = 0;
Len = GetDeviceDriverBaseNameA(ModInfo.ImageBase, FileName, ModInfo.Len);
ok(Len == ModInfo.Len, "Len: %lu\n", Len);
ok(GetLastError() == 0xDEADBEEF, "Error: %lx\n", GetLastError());
ok(lstrcmpiA(ModInfo.Path, FileName) == 0, "File name: %s\n", FileName);
}
else
{
skip("Couldn't find info about ntdll.dll\n");
}
if (IntGetModuleInformation("msvcrt.dll", FALSE, TRUE, TRUE, &ModInfo))
{
SetLastError(0xDEADBEEF);
Len = GetDeviceDriverBaseNameA(ModInfo.ImageBase, FileName, 255);
ok(Len == 0, "Len: %lu\n", Len);
ok(GetLastError() == ERROR_INVALID_HANDLE, "Error: %lx\n", GetLastError());
}
else
{
skip("Couldn't find info about msvcrt.dll\n");
}
if (IntGetModuleInformation("psapi.dll", FALSE, TRUE, TRUE, &ModInfo))
{
SetLastError(0xDEADBEEF);
Len = GetDeviceDriverBaseNameA(ModInfo.ImageBase, FileName, 255);
ok(Len == 0, "Len: %lu\n", Len);
ok(GetLastError() == ERROR_INVALID_HANDLE, "Error: %lx\n", GetLastError());
}
else
{
skip("Couldn't find info about psapi.dll\n");
}
}

View file

@ -4,10 +4,12 @@
#include <wine/test.h>
extern void func_GetDeviceDriverFileName(void);
extern void func_GetDeviceDriverBaseName(void);
const struct test winetest_testlist[] =
{
{ "GetDeviceDriverFileName", func_GetDeviceDriverFileName },
{ "GetDeviceDriverBaseName", func_GetDeviceDriverBaseName },
{ 0, 0 }
};