https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1e9fb35fbc0dc50c99b36…
commit 1e9fb35fbc0dc50c99b36816e40154875f822809
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Thu Nov 29 08:42:13 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Thu Nov 29 20:30:22 2018 +0100
[IPHLPAPI_APITEST] Test GetExtendedTcpTable rather than
AllocateAndGetTcpExTable2FromStack
---
modules/rostests/apitests/iphlpapi/CMakeLists.txt | 2 +-
...cpExTable2FromStack.c => GetExtendedTcpTable.c} | 80 ++++++++++++----------
modules/rostests/apitests/iphlpapi/testlist.c | 12 ++--
3 files changed, 52 insertions(+), 42 deletions(-)
diff --git a/modules/rostests/apitests/iphlpapi/CMakeLists.txt
b/modules/rostests/apitests/iphlpapi/CMakeLists.txt
index 8e59d25643..23b8218972 100644
--- a/modules/rostests/apitests/iphlpapi/CMakeLists.txt
+++ b/modules/rostests/apitests/iphlpapi/CMakeLists.txt
@@ -1,6 +1,6 @@
list(APPEND SOURCE
- AllocateAndGetTcpExTable2FromStack.c
+ GetExtendedTcpTable.c
GetInterfaceName.c
GetNetworkParams.c
icmp.c
diff --git a/modules/rostests/apitests/iphlpapi/AllocateAndGetTcpExTable2FromStack.c
b/modules/rostests/apitests/iphlpapi/GetExtendedTcpTable.c
similarity index 76%
rename from modules/rostests/apitests/iphlpapi/AllocateAndGetTcpExTable2FromStack.c
rename to modules/rostests/apitests/iphlpapi/GetExtendedTcpTable.c
index 1f49664fc1..3beda7e8fd 100644
--- a/modules/rostests/apitests/iphlpapi/AllocateAndGetTcpExTable2FromStack.c
+++ b/modules/rostests/apitests/iphlpapi/GetExtendedTcpTable.c
@@ -11,9 +11,34 @@
#include <iphlpapi.h>
#include <winsock2.h>
-static DWORD (WINAPI *
pAllocateAndGetTcpExTable2FromStack)(PVOID*,BOOL,HANDLE,DWORD,DWORD,TCP_TABLE_CLASS);
+DWORD GetExtendedTcpTableWithAlloc(PVOID *TcpTable, BOOL Order, DWORD Family,
TCP_TABLE_CLASS Class)
+{
+ DWORD ret;
+ DWORD Size = 0;
+
+ *TcpTable = NULL;
+
+ ret = GetExtendedTcpTable(*TcpTable, &Size, Order, Family, Class, 0);
+ if (ret == ERROR_INSUFFICIENT_BUFFER)
+ {
+ *TcpTable = HeapAlloc(GetProcessHeap(), 0, Size);
+ if (*TcpTable == NULL)
+ {
+ return ERROR_OUTOFMEMORY;
+ }
+
+ ret = GetExtendedTcpTable(*TcpTable, &Size, Order, Family, Class, 0);
+ if (ret != NO_ERROR)
+ {
+ HeapFree(GetProcessHeap(), 0, *TcpTable);
+ *TcpTable = NULL;
+ }
+ }
-START_TEST(AllocateAndGetTcpExTable2FromStack)
+ return ret;
+}
+
+START_TEST(GetExtendedTcpTable)
{
WSADATA wsaData;
SOCKET sock;
@@ -23,25 +48,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
PMIB_TCPTABLE_OWNER_MODULE TcpTableOwnerMod;
DWORD i;
BOOLEAN Found;
- HINSTANCE hIpHlpApi;
FILETIME Creation;
LARGE_INTEGER CreationTime;
DWORD Pid = GetCurrentProcessId();
- hIpHlpApi = GetModuleHandleW(L"iphlpapi.dll");
- if (!hIpHlpApi)
- {
- skip("Failed to load iphlpapi.dll\n");
- return;
- }
-
- pAllocateAndGetTcpExTable2FromStack = (void *)GetProcAddress(hIpHlpApi,
"AllocateAndGetTcpExTable2FromStack");
- if (pAllocateAndGetTcpExTable2FromStack == NULL)
- {
- skip("AllocateAndGetTcpExTable2FromStack not found\n");
- return;
- }
-
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
{
skip("Failed to init WS2\n");
@@ -76,7 +86,7 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
goto quit2;
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTable, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_BASIC_ALL) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTable, TRUE, AF_INET,
TCP_TABLE_BASIC_ALL) == ERROR_SUCCESS)
{
ok(TcpTable->dwNumEntries > 0, "No TCP connections?!\n");
@@ -98,10 +108,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTable, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_BASIC_CONNECTIONS) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTable, TRUE, AF_INET,
TCP_TABLE_BASIC_CONNECTIONS) == ERROR_SUCCESS)
{
Found = FALSE;
for (i = 0; i < TcpTable->dwNumEntries; ++i)
@@ -121,10 +131,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTable, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_BASIC_LISTENER) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTable, TRUE, AF_INET,
TCP_TABLE_BASIC_LISTENER) == ERROR_SUCCESS)
{
ok(TcpTable->dwNumEntries > 0, "No TCP connections?!\n");
@@ -146,10 +156,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTableOwner, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_OWNER_PID_ALL) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTableOwner, TRUE, AF_INET,
TCP_TABLE_OWNER_PID_ALL) == ERROR_SUCCESS)
{
ok(TcpTableOwner->dwNumEntries > 0, "No TCP connections?!\n");
@@ -179,10 +189,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTableOwner, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_OWNER_PID_CONNECTIONS) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTableOwner, TRUE, AF_INET,
TCP_TABLE_OWNER_PID_CONNECTIONS) == ERROR_SUCCESS)
{
Found = FALSE;
for (i = 0; i < TcpTableOwner->dwNumEntries; ++i)
@@ -202,10 +212,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTableOwner, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_OWNER_PID_LISTENER) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTableOwner, TRUE, AF_INET,
TCP_TABLE_OWNER_PID_LISTENER) == ERROR_SUCCESS)
{
ok(TcpTableOwner->dwNumEntries > 0, "No TCP connections?!\n");
@@ -235,10 +245,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTableOwnerMod, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_OWNER_MODULE_ALL) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTableOwnerMod, TRUE, AF_INET,
TCP_TABLE_OWNER_MODULE_ALL) == ERROR_SUCCESS)
{
ok(TcpTableOwnerMod->dwNumEntries > 0, "No TCP
connections?!\n");
@@ -271,10 +281,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTableOwnerMod, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_OWNER_MODULE_CONNECTIONS) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTableOwnerMod, TRUE, AF_INET,
TCP_TABLE_OWNER_MODULE_CONNECTIONS) == ERROR_SUCCESS)
{
Found = FALSE;
for (i = 0; i < TcpTableOwnerMod->dwNumEntries; ++i)
@@ -294,10 +304,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
- if (pAllocateAndGetTcpExTable2FromStack((PVOID *)&TcpTableOwnerMod, TRUE,
GetProcessHeap(), 0, AF_INET, TCP_TABLE_OWNER_MODULE_LISTENER) == ERROR_SUCCESS)
+ if (GetExtendedTcpTableWithAlloc((PVOID *)&TcpTableOwnerMod, TRUE, AF_INET,
TCP_TABLE_OWNER_MODULE_LISTENER) == ERROR_SUCCESS)
{
ok(TcpTableOwnerMod->dwNumEntries > 0, "No TCP
connections?!\n");
@@ -330,7 +340,7 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
}
else
{
- skip("AllocateAndGetTcpExTable2FromStack failure\n");
+ skip("GetExtendedTcpTableWithAlloc failure\n");
}
quit2:
diff --git a/modules/rostests/apitests/iphlpapi/testlist.c
b/modules/rostests/apitests/iphlpapi/testlist.c
index 78843f5b5e..fb2e999445 100644
--- a/modules/rostests/apitests/iphlpapi/testlist.c
+++ b/modules/rostests/apitests/iphlpapi/testlist.c
@@ -3,7 +3,7 @@
#define STANDALONE
#include <apitest.h>
-extern void func_AllocateAndGetTcpExTable2FromStack(void);
+extern void func_GetExtendedTcpTable(void);
extern void func_GetInterfaceName(void);
extern void func_GetNetworkParams(void);
extern void func_icmp(void);
@@ -11,11 +11,11 @@ extern void func_SendARP(void);
const struct test winetest_testlist[] =
{
- { "AllocateAndGetTcpExTable2FromStack",
func_AllocateAndGetTcpExTable2FromStack },
- { "GetInterfaceName", func_GetInterfaceName },
- { "GetNetworkParams", func_GetNetworkParams },
- { "icmp", func_icmp },
- { "SendARP", func_SendARP },
+ { "GetExtendedTcpTable", func_GetExtendedTcpTable },
+ { "GetInterfaceName", func_GetInterfaceName },
+ { "GetNetworkParams", func_GetNetworkParams },
+ { "icmp", func_icmp },
+ { "SendARP", func_SendARP },
{ 0, 0 }
};