diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-06-24 14:30:15 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-06-24 17:13:31 -0500 |
commit | daaa551c92a793f95ec24198d8b62fc09618f035 (patch) | |
tree | 9504cb2dfb340ffd04886cd7e04e64f0d1c80e5b /main/test.c | |
parent | 71a4d1a033548f0f2bdfa0f42522f2c65f84e257 (diff) |
test.c: Add unit test registration checks for summary and description.
Added checks when a unit test is registered to see that the summary and
description strings do not end with a new-line '\n' for consistency.
The check generates a warning message and will cause the
/main/test/registrations unit test to fail.
* Updated struct ast_test_info member doxygen comments.
Change-Id: I295909b6bc013ed9b6882e85c05287082497534d
Diffstat (limited to 'main/test.c')
-rw-r--r-- | main/test.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/main/test.c b/main/test.c index d1dce09e8..2f6200f96 100644 --- a/main/test.c +++ b/main/test.c @@ -640,33 +640,53 @@ static struct ast_test *test_alloc(ast_test_cb_t *cb) if (ast_strlen_zero(test->info.category)) { ast_log(LOG_ERROR, "Test %s has no category, test registration refused.\n", - test->info.name); + test->info.name); return test_free(test); } if (test->info.category[0] != '/' || test->info.category[strlen(test->info.category) - 1] != '/') { ast_log(LOG_WARNING, "Test category '%s' for test '%s' is missing a leading or trailing slash.\n", - test->info.category, test->info.name); - /* Flag an error anyways so test_registrations fails but allow the test to be - * registered. */ - registration_errors++; + test->info.category, test->info.name); + /* + * Flag an error anyways so test_registrations fails but allow the + * test to be registered. + */ + ++registration_errors; } if (ast_strlen_zero(test->info.summary)) { ast_log(LOG_ERROR, "Test %s%s has no summary, test registration refused.\n", - test->info.category, test->info.name); + test->info.category, test->info.name); return test_free(test); } + if (test->info.summary[strlen(test->info.summary) - 1] == '\n') { + ast_log(LOG_WARNING, "Test %s%s summary has a trailing newline.\n", + test->info.category, test->info.name); + /* + * Flag an error anyways so test_registrations fails but allow the + * test to be registered. + */ + ++registration_errors; + } if (ast_strlen_zero(test->info.description)) { ast_log(LOG_ERROR, "Test %s%s has no description, test registration refused.\n", - test->info.category, test->info.name); + test->info.category, test->info.name); return test_free(test); } + if (test->info.description[strlen(test->info.description) - 1] == '\n') { + ast_log(LOG_WARNING, "Test %s%s description has a trailing newline.\n", + test->info.category, test->info.name); + /* + * Flag an error anyways so test_registrations fails but allow the + * test to be registered. + */ + ++registration_errors; + } if (!(test->status_str = ast_str_create(128))) { ast_log(LOG_ERROR, "Failed to allocate status_str for %s%s, test registration failed.\n", - test->info.category, test->info.name); + test->info.category, test->info.name); return test_free(test); } |