[IPHLPAPI_WINETEST]
[reactos.git] / rostests / winetests / iphlpapi / iphlpapi.c
index cd2e452..c03c56d 100644 (file)
@@ -775,11 +775,12 @@ GetBestRoute
 IpReleaseAddress
 IpRenewAddress
 */
-static void testWin98Functions(void)
+static DWORD CALLBACK testWin98Functions(void *p)
 {
   testGetInterfaceInfo();
   testGetAdaptersInfo();
   testGetNetworkParams();
+  return 0;
 }
 
 static void testGetPerAdapterInfo(void)
@@ -839,6 +840,7 @@ static void test_GetAdaptersAddresses(void)
     ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL);
     ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", ret);
 
+    size = 0;
     ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size);
     ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret);
     if (ret != ERROR_BUFFER_OVERFLOW) return;
@@ -849,16 +851,16 @@ static void test_GetAdaptersAddresses(void)
 
     while (!ret && winetest_debug > 1 && aa)
     {
-        trace("Length:                %u\n", aa->Length);
-        trace("IfIndex:               %u\n", aa->IfIndex);
+        trace("Length:                %u\n", S(U(*aa)).Length);
+        trace("IfIndex:               %u\n", S(U(*aa)).IfIndex);
         trace("Next:                  %p\n", aa->Next);
         trace("AdapterName:           %s\n", aa->AdapterName);
         trace("FirstUnicastAddress:   %p\n", aa->FirstUnicastAddress);
         ua = aa->FirstUnicastAddress;
         while (ua)
         {
-            trace("\tLength:                  %u\n", ua->Length);
-            trace("\tFlags:                   0x%08x\n", ua->Flags);
+            trace("\tLength:                  %u\n", S(U(*ua)).Length);
+            trace("\tFlags:                   0x%08x\n", S(U(*ua)).Flags);
             trace("\tNext:                    %p\n", ua->Next);
             trace("\tAddress.lpSockaddr:      %p\n", ua->Address.lpSockaddr);
             trace("\tAddress.iSockaddrLength: %d\n", ua->Address.iSockaddrLength);
@@ -894,9 +896,16 @@ START_TEST(iphlpapi)
 
   loadIPHlpApi();
   if (hLibrary) {
+    HANDLE thread;
+
     testWin98OnlyFunctions();
     testWinNT4Functions();
-    testWin98Functions();
+
+    /* run testGetXXXX in two threads at once to make sure we don't crash in that case */
+    thread = CreateThread(NULL, 0, testWin98Functions, NULL, 0, NULL);
+    testWin98Functions(NULL);
+    WaitForSingleObject(thread, INFINITE);
+
     testWin2KFunctions();
     test_GetAdaptersAddresses();
     freeIPHlpApi();