Skip to content

Commit

Permalink
fix testing leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
RobBoeckermann committed Mar 20, 2023
1 parent a5e9063 commit e398956
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/test_tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ void test_tag_match()
noit_metric_tagset_builder_t builder;
noit_metric_tag_search_ast_t *ast;
mtev_boolean match;
char *canonical;

for(size_t i = 0; i < sizeof(testmatches) / sizeof(*testmatches); i++) {
char *canonical = NULL;
test_assert_namef(true, "testing tagset '%s'", testmatches[i].tagstring);
noit_metric_tagset_builder_start(&builder);
noit_metric_tagset_builder_add_many(&builder, testmatches[i].tagstring, strlen(testmatches[i].tagstring));
Expand Down Expand Up @@ -527,7 +527,8 @@ void test_tag_match()
test_assert_namef(ast != NULL, "parsing error at %d in '%s'", erroroffset, testmatches[i].queries[j].query);
}
}
free(tagset.tags);
noit_metric_tagset_cleanup(&tagset);
free(canonical);
}
}

Expand All @@ -536,14 +537,14 @@ void test_implicit_tag_match() {
noit_metric_tagset_t tagset = {};
noit_metric_tag_search_ast_t *ast;
mtev_boolean match;
char *canonical;

test_assert(max_length_implicit_tag_pair.length() == NOIT_IMPLICIT_TAG_MAX_PAIR_LEN);
test_assert(too_long_implicit_tag_pair.length() > NOIT_IMPLICIT_TAG_MAX_PAIR_LEN);
test_assert(check_uuid_tag_pair.length() == sizeof("__check_uuid:") - 1 + UUID_STR_LEN);

for (size_t i = 0;
i < sizeof(implicit_testmatches) / sizeof(*implicit_testmatches); i++) {
char *canonical = NULL;
test_assert_namef(true, "testing tagset '%s'",
implicit_testmatches[i].tagstring);
memset(&tagset, 0, sizeof(tagset));
Expand Down Expand Up @@ -578,7 +579,8 @@ void test_implicit_tag_match() {
implicit_testmatches[i].queries[j].query);
}
}
free(tagset.tags);
noit_metric_tagset_cleanup(&tagset);
free(canonical);
}
}

Expand Down

0 comments on commit e398956

Please sign in to comment.