Better API compliance and test case for NetWkstaTransportEnum.
This commit is contained in:
parent
86666c51e2
commit
7b55bc45eb
|
@ -31,6 +31,8 @@ static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID)=NULL;
|
||||||
static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL;
|
static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL;
|
||||||
static NET_API_STATUS (WINAPI *pNetpGetComputerName)(LPWSTR*)=NULL;
|
static NET_API_STATUS (WINAPI *pNetpGetComputerName)(LPWSTR*)=NULL;
|
||||||
static NET_API_STATUS (WINAPI *pNetWkstaUserGetInfo)(LPWSTR,DWORD,PBYTE*)=NULL;
|
static NET_API_STATUS (WINAPI *pNetWkstaUserGetInfo)(LPWSTR,DWORD,PBYTE*)=NULL;
|
||||||
|
static NET_API_STATUS (WINAPI *pNetWkstaTransportEnum)(LPWSTR,DWORD,LPBYTE*,
|
||||||
|
DWORD,LPDWORD,LPDWORD,LPDWORD)=NULL;
|
||||||
|
|
||||||
WCHAR user_name[UNLEN + 1];
|
WCHAR user_name[UNLEN + 1];
|
||||||
WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
|
WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
|
||||||
|
@ -116,6 +118,54 @@ static void run_wkstausergetinfo_tests(void)
|
||||||
"Invalid level");
|
"Invalid level");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void run_wkstatransportenum_tests(void)
|
||||||
|
{
|
||||||
|
LPBYTE bufPtr;
|
||||||
|
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);
|
||||||
|
ok(apiReturn == ERROR_INVALID_LEVEL, "Invalid level");
|
||||||
|
|
||||||
|
/* 2nd check: is param 5 passed? (only if level passes?) */
|
||||||
|
apiReturn = pNetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH,
|
||||||
|
NULL, &totalEntries, NULL);
|
||||||
|
|
||||||
|
/* if no network adapter present, bail, the rest of the test will fail */
|
||||||
|
if (apiReturn == ERROR_NETWORK_UNREACHABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ok(apiReturn == STATUS_ACCESS_VIOLATION, "access violation");
|
||||||
|
|
||||||
|
/* 3rd check: is param 3 passed? */
|
||||||
|
apiReturn = pNetWkstaTransportEnum(NULL, 0, NULL, MAX_PREFERRED_LENGTH,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
ok(apiReturn == STATUS_ACCESS_VIOLATION, "STATUS_ACCESS_VIOLATION");
|
||||||
|
|
||||||
|
/* 4th check: is param 6 passed? */
|
||||||
|
apiReturn = pNetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH,
|
||||||
|
&entriesRead, NULL, NULL);
|
||||||
|
ok(apiReturn == RPC_X_NULL_REF_POINTER, "null pointer");
|
||||||
|
|
||||||
|
/* final check: valid return, actually get data back */
|
||||||
|
apiReturn = pNetWkstaTransportEnum(NULL, 0, &bufPtr, MAX_PREFERRED_LENGTH,
|
||||||
|
&entriesRead, &totalEntries, NULL);
|
||||||
|
ok(apiReturn == NERR_Success, "NetWkstaTransportEnum is successful");
|
||||||
|
if (apiReturn == NERR_Success) {
|
||||||
|
/* WKSTA_TRANSPORT_INFO_0 *transports = (WKSTA_TRANSPORT_INFO_0 *)bufPtr; */
|
||||||
|
|
||||||
|
ok(bufPtr != NULL, "got data back");
|
||||||
|
ok(entriesRead > 0, "read at least one transport");
|
||||||
|
ok(totalEntries > 0, "at least one transport");
|
||||||
|
NetApiBufferFree(bufPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(wksta)
|
START_TEST(wksta)
|
||||||
{
|
{
|
||||||
HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
|
HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
|
||||||
|
@ -123,11 +173,13 @@ START_TEST(wksta)
|
||||||
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");
|
||||||
if (!pNetApiBufferSize)
|
if (!pNetApiBufferSize)
|
||||||
trace("It appears there is no netapi32 functionality on this platform\n");
|
trace("It appears there is no netapi32 functionality on this platform\n");
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,13 @@ NetWkstaTransportEnum(LPCWSTR ServerName, DWORD level, LPBYTE* pbuf,
|
||||||
PWKSTA_TRANSPORT_INFO_0 ti;
|
PWKSTA_TRANSPORT_INFO_0 ti;
|
||||||
int i,size_needed,n_adapt = enum_hw();
|
int i,size_needed,n_adapt = enum_hw();
|
||||||
|
|
||||||
|
if (n_adapt == 0)
|
||||||
|
return ERROR_NETWORK_UNREACHABLE;
|
||||||
|
if (!read_entries)
|
||||||
|
return STATUS_ACCESS_VIOLATION;
|
||||||
|
if (!total_entries || !pbuf)
|
||||||
|
return RPC_X_NULL_REF_POINTER;
|
||||||
|
|
||||||
size_needed = n_adapt * (sizeof(WKSTA_TRANSPORT_INFO_0)
|
size_needed = n_adapt * (sizeof(WKSTA_TRANSPORT_INFO_0)
|
||||||
* 13 * sizeof (WCHAR));
|
* 13 * sizeof (WCHAR));
|
||||||
if (prefmaxlen == MAX_PREFERRED_LENGTH)
|
if (prefmaxlen == MAX_PREFERRED_LENGTH)
|
||||||
|
@ -115,8 +122,8 @@ NetWkstaTransportEnum(LPCWSTR ServerName, DWORD level, LPBYTE* pbuf,
|
||||||
TRACE("%d of %d:ti at %p transport_address at %p %s\n",i,n_adapt,
|
TRACE("%d of %d:ti at %p transport_address at %p %s\n",i,n_adapt,
|
||||||
ti, ti->wkti0_transport_address, debugstr_w(ti->wkti0_transport_address));
|
ti, ti->wkti0_transport_address, debugstr_w(ti->wkti0_transport_address));
|
||||||
}
|
}
|
||||||
if(read_entries)*read_entries = n_adapt;
|
*read_entries = n_adapt;
|
||||||
if(total_entries)*total_entries = n_adapt;
|
*total_entries = n_adapt;
|
||||||
if(hresume) *hresume= 0;
|
if(hresume) *hresume= 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue