psapi/tests: Don't check for exact value (try 3)
André Hentschel
nerv at dawncrow.de
Mon Jul 27 14:01:24 CDT 2015
try 3: according to the comments by slackner
---
dlls/psapi/tests/psapi_main.c | 58 ++++++++++++-------------------------------
1 file changed, 16 insertions(+), 42 deletions(-)
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index cebfc5f..7e9fe8f 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -44,6 +44,10 @@
return FALSE; \
}
+#define CHECK_MARGIN(perf, sys, err) \
+ ok(perf >= max(sys, err) - err && perf <= sys + err, \
+ "expected approximately " #perf "=%u but got %u\n", sys, (ULONG)perf)
+
static BOOL (WINAPI *pEmptyWorkingSet)(HANDLE);
static BOOL (WINAPI *pEnumProcesses)(DWORD*, DWORD, DWORD*);
static BOOL (WINAPI *pEnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD);
@@ -227,36 +231,16 @@ 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",
- sys_performance_info->TotalCommittedPages, (ULONG)info.CommitTotal);
-
- ok(info.CommitLimit == sys_performance_info->TotalCommitLimit,
- "expected info.CommitLimit=%u but got %u\n",
- sys_performance_info->TotalCommitLimit, (ULONG)info.CommitLimit);
-
- ok(info.CommitPeak == sys_performance_info->PeakCommitment,
- "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,
- "expected approximately info.PhysicalAvailable=%u but got %u\n",
- sys_performance_info->AvailablePages, (ULONG)info.PhysicalAvailable);
+ CHECK_MARGIN(info.CommitTotal, sys_performance_info->TotalCommittedPages, 64);
+ CHECK_MARGIN(info.CommitLimit, sys_performance_info->TotalCommitLimit, 64);
+ CHECK_MARGIN(info.CommitPeak, sys_performance_info->PeakCommitment, 64);
+ CHECK_MARGIN(info.PhysicalAvailable, sys_performance_info->AvailablePages, 64);
/* 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);
-
- ok(info.KernelPaged == sys_performance_info->PagedPoolUsage,
- "expected 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",
- sys_performance_info->NonPagedPoolUsage, (ULONG)info.KernelNonpaged);
+ CHECK_MARGIN(info.KernelTotal, sys_performance_info->PagedPoolUsage + sys_performance_info->NonPagedPoolUsage, 64);
+ CHECK_MARGIN(info.KernelPaged, sys_performance_info->PagedPoolUsage, 64);
+ CHECK_MARGIN(info.KernelNonpaged, sys_performance_info->NonPagedPoolUsage, 64);
/* compare with values from SYSTEM_BASIC_INFORMATION */
size = 0;
@@ -264,13 +248,8 @@ static void test_GetPerformanceInfo(void)
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %08x\n", status);
ok(size >= sizeof(SYSTEM_BASIC_INFORMATION), "incorrect length %d\n", size);
- ok(info.PhysicalTotal == sys_basic_info.MmNumberOfPhysicalPages,
- "expected info.PhysicalTotal=%u but got %u\n",
- sys_basic_info.MmNumberOfPhysicalPages, (ULONG)info.PhysicalTotal);
-
- ok(info.PageSize == sys_basic_info.PageSize,
- "expected info.PageSize=%u but got %u\n",
- sys_basic_info.PageSize, (ULONG)info.PageSize);
+ CHECK_MARGIN(info.PhysicalTotal, sys_basic_info.MmNumberOfPhysicalPages, 0);
+ CHECK_MARGIN(info.PageSize, sys_basic_info.PageSize, 0);
/* compare with values from SYSTEM_PROCESS_INFORMATION */
size = 0;
@@ -297,14 +276,9 @@ 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.ProcessCount == process_count,
- "expected 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);
+ CHECK_MARGIN(info.HandleCount, handle_count, 4);
+ CHECK_MARGIN(info.ProcessCount, process_count, 4);
+ CHECK_MARGIN(info.ThreadCount, thread_count, 4);
}
}
--
1.9.1
More information about the wine-patches
mailing list