iphlpapi/tests: Add more IcmpSendEcho tests related to the reply size

Bruno Jesus 00cpxxx at gmail.com
Wed Jan 8 17:47:11 CST 2014


wine forces the minimum ping data size to be ICMP_MINLEN (8 bytes),
windows does not complain when sending packets < 8 bytes.

In linux console it's also possible to see this (size 0 got 8 bytes):

$ ping -s 0 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 0(28) bytes of data.
8 bytes from 127.0.0.1: icmp_seq=1 ttl=64

While in windows with size zero we get 0 size answer (sorry for
Portuguese ping version, what matters is the bytes=0):

C:\>ping -l 0 127.0.0.1
Disparando contra 127.0.0.1 com 0 bytes de dados:
Resposta de 127.0.0.1: bytes=0 tempo<1ms TTL=128

I don't know if windows fakes the size or not, what matters now is
that the test fail.
-------------- next part --------------
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index dbf97b2..94716d7 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -44,6 +44,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#define ICMP_MINLEN 8 /* copied from dlls/iphlpapi/ip_icmp.h file */
+
 static HMODULE hLibrary = NULL;
 
 static DWORD (WINAPI *pGetNumberOfInterfaces)(PDWORD);
@@ -956,7 +958,8 @@ todo_wine
         "expected 87, got %d\n", error);
 
     SetLastError(0xdeadbeef);
-    ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, sizeof(replydata) - 1, 1000);
+    replysz = sizeof(replydata) - 1;
+    ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000);
     error = GetLastError();
     todo_wine {
     ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
@@ -965,8 +968,42 @@ todo_wine
         "expected 11050, got %d\n", error);
     }
 
+    SetLastError(0xdeadbeef);
+    replysz = sizeof(ICMP_ECHO_REPLY);
+    ret = pIcmpSendEcho(icmp, address, senddata, 0, NULL, replydata, replysz, 1000);
+    error = GetLastError();
+todo_wine
+    ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error);
+
+    SetLastError(0xdeadbeef);
+    replysz = sizeof(ICMP_ECHO_REPLY) + ICMP_MINLEN;
+    ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz, 1000);
+    error = GetLastError();
+todo_wine
+    ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error);
+
+    SetLastError(0xdeadbeef);
+    replysz = sizeof(ICMP_ECHO_REPLY) + ICMP_MINLEN;
+    ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN + 1, NULL, replydata, replysz, 1000);
+    error = GetLastError();
+    ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
+todo_wine
+    ok (error == IP_GENERAL_FAILURE
+        || broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */,
+        "expected 11050, got %d\n", error);
+
+    SetLastError(0xdeadbeef);
+    ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz - 1, 1000);
+    error = GetLastError();
+    ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
+todo_wine
+    ok (error == IP_GENERAL_FAILURE
+        || broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */,
+        "expected 11050, got %d\n", error);
+
     /* in windows >= vista the timeout can't be invalid */
     SetLastError(0xdeadbeef);
+    replysz = sizeof(replydata);
     ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 0);
     error = GetLastError();
     if (!ret) ok(error == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", error);


More information about the wine-patches mailing list