[IPHLPAPI_APITEST] Add tests for IcmpSendEcho

This commit is contained in:
Stanislav Motylkov 2018-01-24 16:32:51 +03:00 committed by Ged Murphy
parent 63ad8a71c0
commit fad8b1f545

View file

@ -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();
}