Skip to content

Commit

Permalink
throttle: add throttle_max_is_missing_limit() test
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 1438683733-21111-3-git-send-email-stefanha@redhat.com
  • Loading branch information
stefanhaRH committed Aug 5, 2015
1 parent ee2bdc3 commit 92e11a1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test-throttle.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 92e11a1

Please sign in to comment.