psapi/tests: Don't check for exact value in more tests

André Hentschel nerv at dawncrow.de
Sun Jul 19 10:26:42 CDT 2015


Because we get the data in comparison from two different Function calls, things could change a bit in between.
See https://test.winehq.org/data/tests/psapi:psapi_main.html
---
 dlls/psapi/tests/psapi_main.c | 43 +++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index cebfc5f..56a33b2 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -219,7 +219,7 @@ static void test_GetPerformanceInfo(void)
         SYSTEM_PERFORMANCE_INFORMATION *sys_performance_info = (SYSTEM_PERFORMANCE_INFORMATION *)performance_buffer;
         SYSTEM_PROCESS_INFORMATION *sys_process_info = NULL, *spi;
         SYSTEM_BASIC_INFORMATION sys_basic_info;
-        DWORD process_count, handle_count, thread_count;
+        DWORD process_count, handle_count, thread_count, usage;
 
         /* compare with values from SYSTEM_PERFORMANCE_INFORMATION */
         size = 0;
@@ -227,8 +227,9 @@ static void test_GetPerformanceInfo(void)
         ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
         ok(size >= sizeof(SYSTEM_PERFORMANCE_INFORMATION), "incorrect length %d\n", size);
 
-        ok(info.CommitTotal == sys_performance_info->TotalCommittedPages,
-           "expected info.CommitTotal=%u but got %u\n",
+        ok(info.CommitTotal >= max(sys_performance_info->TotalCommittedPages, 64) - 64 &&
+           info.CommitTotal <= sys_performance_info->TotalCommittedPages + 64,
+           "expected approximately info.CommitTotal=%u but got %u\n",
            sys_performance_info->TotalCommittedPages, (ULONG)info.CommitTotal);
 
         ok(info.CommitLimit == sys_performance_info->TotalCommitLimit,
@@ -239,23 +240,26 @@ static void test_GetPerformanceInfo(void)
            "expected info.CommitPeak=%u but got %u\n",
            sys_performance_info->PeakCommitment, (ULONG)info.CommitPeak);
 
-        ok(info.PhysicalAvailable >= max(sys_performance_info->AvailablePages, 25) - 25 &&
-           info.PhysicalAvailable <= sys_performance_info->AvailablePages + 25,
+        ok(info.PhysicalAvailable >= max(sys_performance_info->AvailablePages, 64) - 64 &&
+           info.PhysicalAvailable <= sys_performance_info->AvailablePages + 64,
            "expected approximately info.PhysicalAvailable=%u but got %u\n",
            sys_performance_info->AvailablePages, (ULONG)info.PhysicalAvailable);
 
         /* TODO: info.SystemCache not checked yet - to which field(s) does this value correspond to? */
 
-        ok(info.KernelTotal == sys_performance_info->PagedPoolUsage + sys_performance_info->NonPagedPoolUsage,
-            "expected info.KernelTotal=%u but got %u\n",
-            sys_performance_info->PagedPoolUsage + sys_performance_info->NonPagedPoolUsage, (ULONG)info.KernelTotal);
+        usage = sys_performance_info->PagedPoolUsage + sys_performance_info->NonPagedPoolUsage;
+        ok(info.KernelTotal >= max(usage, 64) - 64 &&
+           info.KernelTotal <= usage + 64,
+            "expected approximately info.KernelTotal=%u but got %u\n", usage, (ULONG)info.KernelTotal);
 
-        ok(info.KernelPaged == sys_performance_info->PagedPoolUsage,
-           "expected info.KernelPaged=%u but got %u\n",
+        ok(info.KernelPaged >= max(sys_performance_info->PagedPoolUsage, 64) - 64 &&
+           info.KernelPaged <= sys_performance_info->PagedPoolUsage + 64,
+           "expected approximately info.KernelPaged=%u but got %u\n",
            sys_performance_info->PagedPoolUsage, (ULONG)info.KernelPaged);
 
-        ok(info.KernelNonpaged == sys_performance_info->NonPagedPoolUsage,
-           "expected info.KernelNonpaged=%u but got %u\n",
+        ok(info.KernelNonpaged >= max(sys_performance_info->NonPagedPoolUsage, 64) - 64 &&
+           info.KernelNonpaged <= sys_performance_info->NonPagedPoolUsage + 64,
+           "expected approximately info.KernelNonpaged=%u but got %u\n",
            sys_performance_info->NonPagedPoolUsage, (ULONG)info.KernelNonpaged);
 
         /* compare with values from SYSTEM_BASIC_INFORMATION */
@@ -297,14 +301,17 @@ static void test_GetPerformanceInfo(void)
         }
         HeapFree(GetProcessHeap(), 0, sys_process_info);
 
-        ok(info.HandleCount == handle_count,
-           "expected info.HandleCount=%u but got %u\n", handle_count, info.HandleCount);
+        ok(info.HandleCount >= max(handle_count, 64) - 64 &&
+           info.HandleCount <= handle_count + 64,
+           "expected approximately info.HandleCount=%u but got %u\n", handle_count, info.HandleCount);
 
-        ok(info.ProcessCount == process_count,
-           "expected info.ProcessCount=%u but got %u\n", process_count, info.ProcessCount);
+        ok(info.ProcessCount >= max(process_count, 64) - 64 &&
+           info.ProcessCount <= process_count + 64,
+           "expected approximately info.ProcessCount=%u but got %u\n", process_count, info.ProcessCount);
 
-        ok(info.ThreadCount == thread_count,
-           "expected info.ThreadCount=%u but got %u\n", thread_count, info.ThreadCount);
+        ok(info.ThreadCount >= max(thread_count, 64) - 64 &&
+           info.ThreadCount <= thread_count + 64,
+           "expected approximately info.ThreadCount=%u but got %u\n", thread_count, info.ThreadCount);
     }
 }
 
-- 
1.9.1




More information about the wine-patches mailing list