netapi32/tests: Use LoadLibrary where needed and skip.

This commit is contained in:
Paul Vriens 2007-03-23 11:32:36 +01:00 committed by Alexandre Julliard
parent 76d153144f
commit 87b291a261
4 changed files with 45 additions and 49 deletions

View file

@ -32,6 +32,7 @@
WCHAR user_name[UNLEN + 1];
WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
/* FIXME : Tests should be language independent */
static const WCHAR sAdminUserName[] = {'A','d','m','i','n','i','s','t','r','a','t',
'o','r',0};
static const WCHAR sGuestUserName[] = {'G','u','e','s','t',0};
@ -64,7 +65,7 @@ static int init_access_tests(void)
rc=GetUserNameW(user_name, &dwSize);
if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{
skip("netapi32 functions seem to be missing.\n");
skip("GetUserNameW is not available.\n");
return 0;
}
ok(rc, "User Name Retrieved\n");
@ -82,13 +83,6 @@ static void run_usergetinfo_tests(void)
PUSER_INFO_10 ui10 = NULL;
DWORD dwSize;
/* If this one is not defined then none of the others will be defined */
if (!pNetUserGetInfo)
{
skip("netapi32 functions seem to be missing.\n");
return;
}
/* Level 0 */
rc=pNetUserGetInfo(NULL, sAdminUserName, 0, (LPBYTE *)&ui0);
if (rc != NERR_Success) {
@ -145,12 +139,6 @@ static void run_querydisplayinformation1_tests(void)
BOOL hasAdmin = FALSE;
BOOL hasGuest = FALSE;
if (!pNetQueryDisplayInformation)
{
skip("netapi32 functions seem to be missing.\n");
return;
}
do
{
Result = pNetQueryDisplayInformation(
@ -204,12 +192,6 @@ static void run_userhandling_tests(void)
NET_API_STATUS ret;
USER_INFO_1 usri;
if(!pNetUserAdd || !pNetUserChangePassword || !pNetUserDel)
{
skip("Functions for modifying the user database missing. Skipping test.\n");
return;
}
usri.usri1_name = (LPWSTR) sTestUserName;
usri.usri1_password = (LPWSTR) sTestUserOldPass;
usri.usri1_priv = USER_PRIV_USER;
@ -245,6 +227,7 @@ static void run_userhandling_tests(void)
START_TEST(access)
{
HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
pNetQueryDisplayInformation=(void*)GetProcAddress(hnetapi32,"NetQueryDisplayInformation");
@ -254,8 +237,14 @@ START_TEST(access)
pNetUserChangePassword=(void*)GetProcAddress(hnetapi32, "NetUserChangePassword");
pNetUserDel=(void*)GetProcAddress(hnetapi32, "NetUserDel");
if (!pNetApiBufferSize)
trace("It appears there is no netapi32 functionality on this platform\n");
/* These functions were introduced with NT. It's safe to assume that
* if one is not available, none are.
*/
if (!pNetApiBufferFree) {
skip("Needed functions are not available\n");
FreeLibrary(hnetapi32);
return;
}
if (init_access_tests()) {
run_usergetinfo_tests();
@ -263,4 +252,6 @@ START_TEST(access)
run_usermodalsget_tests();
run_userhandling_tests();
}
FreeLibrary(hnetapi32);
}

View file

@ -41,9 +41,6 @@ static void run_apibuf_tests(void)
DWORD dwSize;
NET_API_STATUS res;
if (!pNetApiBufferAllocate)
return;
/* test normal logic */
ok(pNetApiBufferAllocate(1024, (LPVOID *)&p) == NERR_Success,
"Reserved memory\n");
@ -96,12 +93,16 @@ static void run_apibuf_tests(void)
START_TEST(apibuf)
{
HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
pNetApiBufferAllocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferAllocate");
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
pNetApiBufferReallocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferReallocate");
pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
if (!pNetApiBufferSize)
trace("It appears there is no netapi32 functionality on this platform\n");
run_apibuf_tests();
if (pNetApiBufferAllocate && pNetApiBufferFree && pNetApiBufferReallocate && pNetApiBufferSize)
run_apibuf_tests();
else
skip("Needed functions are not available\n");
FreeLibrary(hnetapi32);
}

View file

@ -76,18 +76,18 @@ static void test_get(void)
START_TEST(ds)
{
HMODULE hnetapi32;
hnetapi32 = GetModuleHandleA("netapi32.dll");
HMODULE hnetapi32 = LoadLibrary("netapi32.dll");
pDsRoleGetPrimaryDomainInformation=(void*)GetProcAddress(hnetapi32,"DsRoleGetPrimaryDomainInformation");
if (!pDsRoleGetPrimaryDomainInformation)
if (pDsRoleGetPrimaryDomainInformation)
{
skip("DsRoleGetPrimaryDomainInformation is not available\n");
return;
}
pDsRoleFreeMemory=(void*)GetProcAddress(hnetapi32,"DsRoleFreeMemory");
pDsRoleFreeMemory=(void*)GetProcAddress(hnetapi32,"DsRoleFreeMemory");
test_params();
test_get();
test_params();
test_get();
}
else
skip("DsRoleGetPrimaryDomainInformation is not available\n");
FreeLibrary(hnetapi32);
}

View file

@ -50,8 +50,10 @@ static int init_wksta_tests(void)
user_name[0] = 0;
dwSize = sizeof(user_name);
rc=GetUserNameW(user_name, &dwSize);
if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) {
skip("GetUserNameW is not implemented\n");
return 0;
}
ok(rc, "User Name Retrieved\n");
computer_name[0] = 0;
@ -63,8 +65,6 @@ static int init_wksta_tests(void)
static void run_get_comp_name_tests(void)
{
LPWSTR ws = NULL;
if (!pNetpGetComputerName)
return;
ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved\n");
ok(!lstrcmpW(computer_name, ws), "This is really computer name\n");
@ -78,9 +78,6 @@ static void run_wkstausergetinfo_tests(void)
LPWKSTA_USER_INFO_1101 ui1101 = NULL;
DWORD dwSize;
if (!pNetWkstaUserGetInfo)
return;
/* Level 0 */
ok(pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success,
"NetWkstaUserGetInfo is successful\n");
@ -128,9 +125,6 @@ static void run_wkstatransportenum_tests(void)
NET_API_STATUS apiReturn;
DWORD entriesRead, totalEntries;
if (!pNetWkstaTransportEnum)
return;
/* 1st check: is param 2 (level) correct? (only if param 5 passed?) */
apiReturn = pNetWkstaTransportEnum(NULL, 1, NULL, MAX_PREFERRED_LENGTH,
NULL, &totalEntries, NULL);
@ -177,17 +171,27 @@ static void run_wkstatransportenum_tests(void)
START_TEST(wksta)
{
HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
pNetpGetComputerName=(void*)GetProcAddress(hnetapi32,"NetpGetComputerName");
pNetWkstaUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetWkstaUserGetInfo");
pNetWkstaTransportEnum=(void*)GetProcAddress(hnetapi32,"NetWkstaTransportEnum");
if (!pNetApiBufferSize)
trace("It appears there is no netapi32 functionality on this platform\n");
/* These functions were introduced with NT. It's safe to assume that
* if one is not available, none are.
*/
if (!pNetApiBufferFree) {
skip("Needed functions are not available\n");
FreeLibrary(hnetapi32);
return;
}
if (init_wksta_tests()) {
run_get_comp_name_tests();
run_wkstausergetinfo_tests();
run_wkstatransportenum_tests();
}
FreeLibrary(hnetapi32);
}