https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fad8b1f545e948c6ff538…
commit fad8b1f545e948c6ff538f487658b4bde1477e29
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Wed Jan 24 16:32:51 2018 +0300
Commit: Ged Murphy <gedmurphy(a)reactos.org>
CommitDate: Wed Jan 31 17:28:21 2018 +0000
[IPHLPAPI_APITEST] Add tests for IcmpSendEcho
---
modules/rostests/apitests/iphlpapi/icmp.c | 45 +++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/modules/rostests/apitests/iphlpapi/icmp.c
b/modules/rostests/apitests/iphlpapi/icmp.c
index bf6e9d55f5..0d853ffa57 100644
--- a/modules/rostests/apitests/iphlpapi/icmp.c
+++ b/modules/rostests/apitests/iphlpapi/icmp.c
@@ -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();
}