Changelog: dlls/netapi32/wksta.c: dlls/netapi32/tests/wksta.c Better Api Compliance and test case for NetWkstaTransportEnum Juan Lang <juan_lang@yahoo.com> sent me that patch to try it. I changed the test so it compiled. Juan gave licence to Rewind too. -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ---------- Index: wine/dlls/netapi32/wksta.c =================================================================== RCS file: /home/wine/wine/dlls/netapi32/wksta.c,v retrieving revision 1.5 diff -u -r1.5 wksta.c --- wine/dlls/netapi32/wksta.c 14 Feb 2003 23:29:24 -0000 1.5 +++ wine/dlls/netapi32/wksta.c 26 Apr 2003 22:28:01 -0000 @@ -89,6 +89,13 @@ PWKSTA_TRANSPORT_INFO_0 ti; 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) * 13 * sizeof (WCHAR)); if (prefmaxlen == MAX_PREFERRED_LENGTH) @@ -115,8 +122,8 @@ 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)); } - if(read_entries)*read_entries = n_adapt; - if(total_entries)*total_entries = n_adapt; + *read_entries = n_adapt; + *total_entries = n_adapt; if(hresume) *hresume= 0; break; } Index: wine/dlls/netapi32/tests/wksta.c =================================================================== RCS file: /home/wine/wine/dlls/netapi32/tests/wksta.c,v retrieving revision 1.4 diff -u -r1.4 wksta.c --- wine/dlls/netapi32/tests/wksta.c 19 Dec 2002 01:04:12 -0000 1.4 +++ wine/dlls/netapi32/tests/wksta.c 26 Apr 2003 22:28:02 -0000 @@ -31,6 +31,8 @@ static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD)=NULL; static NET_API_STATUS (WINAPI *pNetpGetComputerName)(LPWSTR*)=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 computer_name[MAX_COMPUTERNAME_LENGTH + 1]; @@ -116,6 +118,54 @@ "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, "got data back"); + ok(entriesRead > 0, "read at least one transport"); + ok(totalEntries > 0, "at least one transport"); + NetApiBufferFree(bufPtr); + } +} + START_TEST(wksta) { HMODULE hnetapi32=LoadLibraryA("netapi32.dll"); @@ -123,11 +173,13 @@ 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"); if (init_wksta_tests()) { run_get_comp_name_tests(); run_wkstausergetinfo_tests(); + run_wkstatransportenum_tests(); } }