From 164ac96024bf0d4368c681c3967ce13fbbcbbf66 Mon Sep 17 00:00:00 2001 From: maxwell-demon Date: Thu, 22 Jan 2015 23:20:48 +0000 Subject: Fix census_log_tests on platforms with only one core. --- test/core/statistics/census_log_tests.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index 6a3c8adcc5..ca2d1dedb0 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -123,11 +123,11 @@ static void assert_log_empty(void) { /* Given log size and record size, computes the minimum usable space. */ static gpr_int32 min_usable_space(size_t log_size, size_t record_size) { gpr_int32 usable_space; - gpr_int32 num_blocks = log_size / CENSUS_LOG_MAX_RECORD_SIZE; + gpr_int32 num_blocks = GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE, + gpr_cpu_num_cores()); gpr_int32 waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size; /* In the worst case, all except one core-local block is full. */ - gpr_int32 num_full_blocks = GPR_MAX(gpr_cpu_num_cores() - 2, 2); - GPR_ASSERT(num_blocks >= num_full_blocks); + gpr_int32 num_full_blocks = num_blocks - 1; usable_space = (gpr_int32)log_size - (num_full_blocks * CENSUS_LOG_MAX_RECORD_SIZE) - ((num_blocks - num_full_blocks) * waste_per_block); -- cgit v1.2.3