From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMZMS-0007wE-RL for qemu-devel@nongnu.org; Tue, 04 Aug 2015 06:22:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMZMR-0003nN-W0 for qemu-devel@nongnu.org; Tue, 04 Aug 2015 06:22:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMZMR-0003nF-QI for qemu-devel@nongnu.org; Tue, 04 Aug 2015 06:22:19 -0400 From: Stefan Hajnoczi Date: Tue, 4 Aug 2015 11:22:13 +0100 Message-Id: <1438683733-21111-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1438683733-21111-1-git-send-email-stefanha@redhat.com> References: <1438683733-21111-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] throttle: add throttle_max_is_missing_limit() test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alberto Garcia , Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi --- tests/test-throttle.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test-throttle.c b/tests/test-throttle.c index 0168445..85c9b6c 100644 --- a/tests/test-throttle.c +++ b/tests/test-throttle.c @@ -329,6 +329,26 @@ static void test_is_valid(void) test_is_valid_for_value(1, true); } +static void test_max_is_missing_limit(void) +{ + int i; + + for (i = 0; i < BUCKETS_COUNT; i++) { + memset(&cfg, 0, sizeof(cfg)); + cfg.buckets[i].max = 100; + cfg.buckets[i].avg = 0; + g_assert(throttle_max_is_missing_limit(&cfg)); + + cfg.buckets[i].max = 0; + cfg.buckets[i].avg = 0; + g_assert(!throttle_max_is_missing_limit(&cfg)); + + cfg.buckets[i].max = 0; + cfg.buckets[i].avg = 100; + g_assert(!throttle_max_is_missing_limit(&cfg)); + } +} + static void test_have_timer(void) { /* zero structures */ @@ -591,6 +611,7 @@ int main(int argc, char **argv) g_test_add_func("/throttle/config/enabled", test_enabled); g_test_add_func("/throttle/config/conflicting", test_conflicting_config); g_test_add_func("/throttle/config/is_valid", test_is_valid); + g_test_add_func("/throttle/config/max", test_max_is_missing_limit); g_test_add_func("/throttle/config_functions", test_config_functions); g_test_add_func("/throttle/accounting", test_accounting); g_test_add_func("/throttle/groups", test_groups); -- 2.4.3