mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 04:20:46 +00:00
[IPHLPAPI_APITEST] Add tests for IcmpSendEcho
This commit is contained in:
parent
63ad8a71c0
commit
fad8b1f545
1 changed files with 45 additions and 0 deletions
|
@ -82,9 +82,54 @@ test_IcmpCloseHandle(void)
|
|||
ok_err(ERROR_INVALID_HANDLE);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
test_IcmpSendEcho(void)
|
||||
{
|
||||
HANDLE hIcmp;
|
||||
unsigned long ipaddr = INADDR_NONE;
|
||||
DWORD bRet = 0, error = 0;
|
||||
char SendData[32] = "Data Buffer";
|
||||
PVOID ReplyBuffer = NULL;
|
||||
DWORD ReplySize = 0;
|
||||
|
||||
SetLastError(0xDEADBEEF);
|
||||
hIcmp = IcmpCreateFile();
|
||||
if (hIcmp == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
skip("IcmpCreateFile failed unexpectedly: %lu\n", GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
ipaddr = 0x08080808; // 8.8.8.8
|
||||
|
||||
ReplySize = sizeof(ICMP_ECHO_REPLY);
|
||||
ReplyBuffer = malloc(ReplySize);
|
||||
SetLastError(0xDEADBEEF);
|
||||
bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
|
||||
NULL, ReplyBuffer, ReplySize, 5000);
|
||||
|
||||
ok(!bRet, "IcmpSendEcho succeeded unexpectedly\n");
|
||||
error = GetLastError();
|
||||
ok(error == IP_GENERAL_FAILURE, "IcmpSendEcho returned unexpected error: %lu\n", error);
|
||||
free(ReplyBuffer);
|
||||
|
||||
ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
|
||||
ReplyBuffer = malloc(ReplySize);
|
||||
SetLastError(0xDEADBEEF);
|
||||
bRet = IcmpSendEcho(hIcmp, ipaddr, SendData, sizeof(SendData),
|
||||
NULL, ReplyBuffer, ReplySize, 5000);
|
||||
|
||||
ok(bRet, "IcmpSendEcho failed unexpectedly: %lu\n", GetLastError());
|
||||
free(ReplyBuffer);
|
||||
|
||||
IcmpCloseHandle(hIcmp);
|
||||
}
|
||||
|
||||
START_TEST(icmp)
|
||||
{
|
||||
test_IcmpCreateFile();
|
||||
test_Icmp6CreateFile();
|
||||
test_IcmpCloseHandle();
|
||||
test_IcmpSendEcho();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue