Commit 87b291a2 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

netapi32/tests: Use LoadLibrary where needed and skip.

parent 76d15314
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
WCHAR user_name[UNLEN + 1]; WCHAR user_name[UNLEN + 1];
WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 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', static const WCHAR sAdminUserName[] = {'A','d','m','i','n','i','s','t','r','a','t',
'o','r',0}; 'o','r',0};
static const WCHAR sGuestUserName[] = {'G','u','e','s','t',0}; static const WCHAR sGuestUserName[] = {'G','u','e','s','t',0};
...@@ -64,7 +65,7 @@ static int init_access_tests(void) ...@@ -64,7 +65,7 @@ static int init_access_tests(void)
rc=GetUserNameW(user_name, &dwSize); rc=GetUserNameW(user_name, &dwSize);
if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{ {
skip("netapi32 functions seem to be missing.\n"); skip("GetUserNameW is not available.\n");
return 0; return 0;
} }
ok(rc, "User Name Retrieved\n"); ok(rc, "User Name Retrieved\n");
...@@ -82,13 +83,6 @@ static void run_usergetinfo_tests(void) ...@@ -82,13 +83,6 @@ static void run_usergetinfo_tests(void)
PUSER_INFO_10 ui10 = NULL; PUSER_INFO_10 ui10 = NULL;
DWORD dwSize; 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 */ /* Level 0 */
rc=pNetUserGetInfo(NULL, sAdminUserName, 0, (LPBYTE *)&ui0); rc=pNetUserGetInfo(NULL, sAdminUserName, 0, (LPBYTE *)&ui0);
if (rc != NERR_Success) { if (rc != NERR_Success) {
...@@ -145,12 +139,6 @@ static void run_querydisplayinformation1_tests(void) ...@@ -145,12 +139,6 @@ static void run_querydisplayinformation1_tests(void)
BOOL hasAdmin = FALSE; BOOL hasAdmin = FALSE;
BOOL hasGuest = FALSE; BOOL hasGuest = FALSE;
if (!pNetQueryDisplayInformation)
{
skip("netapi32 functions seem to be missing.\n");
return;
}
do do
{ {
Result = pNetQueryDisplayInformation( Result = pNetQueryDisplayInformation(
...@@ -204,12 +192,6 @@ static void run_userhandling_tests(void) ...@@ -204,12 +192,6 @@ static void run_userhandling_tests(void)
NET_API_STATUS ret; NET_API_STATUS ret;
USER_INFO_1 usri; 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_name = (LPWSTR) sTestUserName;
usri.usri1_password = (LPWSTR) sTestUserOldPass; usri.usri1_password = (LPWSTR) sTestUserOldPass;
usri.usri1_priv = USER_PRIV_USER; usri.usri1_priv = USER_PRIV_USER;
...@@ -245,6 +227,7 @@ static void run_userhandling_tests(void) ...@@ -245,6 +227,7 @@ static void run_userhandling_tests(void)
START_TEST(access) START_TEST(access)
{ {
HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree"); pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize"); pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
pNetQueryDisplayInformation=(void*)GetProcAddress(hnetapi32,"NetQueryDisplayInformation"); pNetQueryDisplayInformation=(void*)GetProcAddress(hnetapi32,"NetQueryDisplayInformation");
...@@ -254,8 +237,14 @@ START_TEST(access) ...@@ -254,8 +237,14 @@ START_TEST(access)
pNetUserChangePassword=(void*)GetProcAddress(hnetapi32, "NetUserChangePassword"); pNetUserChangePassword=(void*)GetProcAddress(hnetapi32, "NetUserChangePassword");
pNetUserDel=(void*)GetProcAddress(hnetapi32, "NetUserDel"); pNetUserDel=(void*)GetProcAddress(hnetapi32, "NetUserDel");
if (!pNetApiBufferSize) /* These functions were introduced with NT. It's safe to assume that
trace("It appears there is no netapi32 functionality on this platform\n"); * if one is not available, none are.
*/
if (!pNetApiBufferFree) {
skip("Needed functions are not available\n");
FreeLibrary(hnetapi32);
return;
}
if (init_access_tests()) { if (init_access_tests()) {
run_usergetinfo_tests(); run_usergetinfo_tests();
...@@ -263,4 +252,6 @@ START_TEST(access) ...@@ -263,4 +252,6 @@ START_TEST(access)
run_usermodalsget_tests(); run_usermodalsget_tests();
run_userhandling_tests(); run_userhandling_tests();
} }
FreeLibrary(hnetapi32);
} }
...@@ -41,9 +41,6 @@ static void run_apibuf_tests(void) ...@@ -41,9 +41,6 @@ static void run_apibuf_tests(void)
DWORD dwSize; DWORD dwSize;
NET_API_STATUS res; NET_API_STATUS res;
if (!pNetApiBufferAllocate)
return;
/* test normal logic */ /* test normal logic */
ok(pNetApiBufferAllocate(1024, (LPVOID *)&p) == NERR_Success, ok(pNetApiBufferAllocate(1024, (LPVOID *)&p) == NERR_Success,
"Reserved memory\n"); "Reserved memory\n");
...@@ -96,12 +93,16 @@ static void run_apibuf_tests(void) ...@@ -96,12 +93,16 @@ static void run_apibuf_tests(void)
START_TEST(apibuf) START_TEST(apibuf)
{ {
HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
pNetApiBufferAllocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferAllocate"); pNetApiBufferAllocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferAllocate");
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree"); pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
pNetApiBufferReallocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferReallocate"); pNetApiBufferReallocate=(void*)GetProcAddress(hnetapi32,"NetApiBufferReallocate");
pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize"); pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
if (!pNetApiBufferSize)
trace("It appears there is no netapi32 functionality on this platform\n");
if (pNetApiBufferAllocate && pNetApiBufferFree && pNetApiBufferReallocate && pNetApiBufferSize)
run_apibuf_tests(); run_apibuf_tests();
else
skip("Needed functions are not available\n");
FreeLibrary(hnetapi32);
} }
...@@ -76,18 +76,18 @@ static void test_get(void) ...@@ -76,18 +76,18 @@ static void test_get(void)
START_TEST(ds) START_TEST(ds)
{ {
HMODULE hnetapi32; HMODULE hnetapi32 = LoadLibrary("netapi32.dll");
hnetapi32 = GetModuleHandleA("netapi32.dll");
pDsRoleGetPrimaryDomainInformation=(void*)GetProcAddress(hnetapi32,"DsRoleGetPrimaryDomainInformation"); 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_params();
test_get(); test_get();
}
else
skip("DsRoleGetPrimaryDomainInformation is not available\n");
FreeLibrary(hnetapi32);
} }
...@@ -50,8 +50,10 @@ static int init_wksta_tests(void) ...@@ -50,8 +50,10 @@ static int init_wksta_tests(void)
user_name[0] = 0; user_name[0] = 0;
dwSize = sizeof(user_name); dwSize = sizeof(user_name);
rc=GetUserNameW(user_name, &dwSize); 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; return 0;
}
ok(rc, "User Name Retrieved\n"); ok(rc, "User Name Retrieved\n");
computer_name[0] = 0; computer_name[0] = 0;
...@@ -63,8 +65,6 @@ static int init_wksta_tests(void) ...@@ -63,8 +65,6 @@ static int init_wksta_tests(void)
static void run_get_comp_name_tests(void) static void run_get_comp_name_tests(void)
{ {
LPWSTR ws = NULL; LPWSTR ws = NULL;
if (!pNetpGetComputerName)
return;
ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved\n"); ok(pNetpGetComputerName(&ws) == NERR_Success, "Computer name is retrieved\n");
ok(!lstrcmpW(computer_name, ws), "This is really computer name\n"); ok(!lstrcmpW(computer_name, ws), "This is really computer name\n");
...@@ -78,9 +78,6 @@ static void run_wkstausergetinfo_tests(void) ...@@ -78,9 +78,6 @@ static void run_wkstausergetinfo_tests(void)
LPWKSTA_USER_INFO_1101 ui1101 = NULL; LPWKSTA_USER_INFO_1101 ui1101 = NULL;
DWORD dwSize; DWORD dwSize;
if (!pNetWkstaUserGetInfo)
return;
/* Level 0 */ /* Level 0 */
ok(pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success, ok(pNetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success,
"NetWkstaUserGetInfo is successful\n"); "NetWkstaUserGetInfo is successful\n");
...@@ -128,9 +125,6 @@ static void run_wkstatransportenum_tests(void) ...@@ -128,9 +125,6 @@ static void run_wkstatransportenum_tests(void)
NET_API_STATUS apiReturn; NET_API_STATUS apiReturn;
DWORD entriesRead, totalEntries; DWORD entriesRead, totalEntries;
if (!pNetWkstaTransportEnum)
return;
/* 1st check: is param 2 (level) correct? (only if param 5 passed?) */ /* 1st check: is param 2 (level) correct? (only if param 5 passed?) */
apiReturn = pNetWkstaTransportEnum(NULL, 1, NULL, MAX_PREFERRED_LENGTH, apiReturn = pNetWkstaTransportEnum(NULL, 1, NULL, MAX_PREFERRED_LENGTH,
NULL, &totalEntries, NULL); NULL, &totalEntries, NULL);
...@@ -177,17 +171,27 @@ static void run_wkstatransportenum_tests(void) ...@@ -177,17 +171,27 @@ static void run_wkstatransportenum_tests(void)
START_TEST(wksta) START_TEST(wksta)
{ {
HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree"); pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize"); pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
pNetpGetComputerName=(void*)GetProcAddress(hnetapi32,"NetpGetComputerName"); pNetpGetComputerName=(void*)GetProcAddress(hnetapi32,"NetpGetComputerName");
pNetWkstaUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetWkstaUserGetInfo"); pNetWkstaUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetWkstaUserGetInfo");
pNetWkstaTransportEnum=(void*)GetProcAddress(hnetapi32,"NetWkstaTransportEnum"); 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()) { if (init_wksta_tests()) {
run_get_comp_name_tests(); run_get_comp_name_tests();
run_wkstausergetinfo_tests(); run_wkstausergetinfo_tests();
run_wkstatransportenum_tests(); run_wkstatransportenum_tests();
} }
FreeLibrary(hnetapi32);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment