psapi/tests: Don't check for exact value (try 4)
André Hentschel
nerv at dawncrow.de
Mon Aug 3 14:31:16 CDT 2015
https://testbot.winehq.org/JobDetails.pl?Key=15736
try 4: use a function instead of a macro and don't make unneeded changes
---
dlls/psapi/tests/psapi_main.c | 51 ++++++++++++++-----------------------------
1 file changed, 16 insertions(+), 35 deletions(-)
diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index cebfc5f..eb8ef99 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -194,6 +194,12 @@ static void test_GetModuleInformation(void)
ok(info.lpBaseOfDll == hMod, "lpBaseOfDll=%p hMod=%p\n", info.lpBaseOfDll, hMod);
}
+static void check_with_margin(int line, ULONG perf, ULONG sysperf, ULONG err)
+{
+ ok_(__FILE__, line)(perf >= max(sysperf, err) - err && perf <= sysperf + err,
+ "expected approximately %u but got %u\n", sysperf, perf);
+}
+
static void test_GetPerformanceInfo(void)
{
PERFORMANCE_INFORMATION info;
@@ -227,36 +233,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_with_margin(__LINE__, info.CommitTotal, sys_performance_info->TotalCommittedPages, 64);
+ check_with_margin(__LINE__, info.CommitLimit, sys_performance_info->TotalCommitLimit, 64);
+ check_with_margin(__LINE__, info.CommitPeak, sys_performance_info->PeakCommitment, 64);
+ check_with_margin(__LINE__, 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_with_margin(__LINE__, info.KernelTotal, sys_performance_info->PagedPoolUsage + sys_performance_info->NonPagedPoolUsage, 64);
+ check_with_margin(__LINE__, info.KernelPaged, sys_performance_info->PagedPoolUsage, 64);
+ check_with_margin(__LINE__, info.KernelNonpaged, sys_performance_info->NonPagedPoolUsage, 64);
/* compare with values from SYSTEM_BASIC_INFORMATION */
size = 0;
@@ -297,14 +283,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_with_margin(__LINE__, info.HandleCount, handle_count, 4);
+ check_with_margin(__LINE__, info.ProcessCount, process_count, 4);
+ check_with_margin(__LINE__, info.ThreadCount, thread_count, 4);
}
}
--
1.9.1
More information about the wine-patches
mailing list