Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ const char *tr_tcname(TestResult * tr)
return tr->tcname;
}

const char *tr_tname(TestResult * tr)
{
return tr->tname;
}

static enum fork_status _fstat = CK_FORK;

void set_fork_status(enum fork_status fstat)
Expand Down
14 changes: 13 additions & 1 deletion src/check.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,17 @@ CK_DLL_EXP const char *CK_EXPORT tr_lfile(TestResult * tr);
*/
CK_DLL_EXP const char *CK_EXPORT tr_tcname(TestResult * tr);

/**
* Retrieve test name in which a failure occurred, if applicable.
*
* @return If the test resulted in a failure, returns a string
* containing the name of the test where the failure
* occurred; otherwise returns NULL.
*
* @since 0.15.3
*/
CK_DLL_EXP const char *CK_EXPORT tr_tname(TestResult * tr);

/**
* Creates a suite runner for the given suite.
*
Expand Down Expand Up @@ -2127,7 +2138,8 @@ CK_DLL_EXP TestResult **CK_EXPORT srunner_failures(SRunner * sr);
* failures due to setup function failure.
*
* Information about individual results can be queried using:
* tr_rtype(), tr_ctx(), tr_msg(), tr_lno(), tr_lfile(), and tr_tcname().
* tr_rtype(), tr_ctx(), tr_msg(), tr_lno(), tr_lfile(), tr_name(),
* and tr_tcname().
*
* Memory is malloc'ed and must be freed; however free the entire structure
* instead of individual test cases.
Expand Down
13 changes: 13 additions & 0 deletions tests/check_check_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,18 @@ START_TEST(test_check_tcnames)
}
END_TEST

START_TEST(test_check_tnames)
{
const char *tname;
tname = tr_tname(tr_all_array[_i]);
if (strcmp(tname, master_tests[_i].test_name) != 0) {
ck_abort_msg("Expected '%s', got '%s' for test %d:%s",
master_tests[_i].test_name, tname,
_i, master_tests[_i].test_name);
}
}
END_TEST

START_TEST(test_check_test_names)
{
int i;
Expand Down Expand Up @@ -742,6 +754,7 @@ Suite *make_master_suite (void)
tcase_add_test (tc_core, test_check_failure_lfiles);
tcase_add_test (tc_core, test_check_test_names);
tcase_add_loop_test (tc_core, test_check_tcnames, 0, sub_ntests);
tcase_add_loop_test (tc_core, test_check_tnames, 0, sub_ntests);
tcase_add_loop_test (tc_core, test_check_all_msgs, 0, sub_ntests);
tcase_add_loop_test (tc_core, test_check_all_ftypes, 0, nr_of_master_tests);
tcase_add_unchecked_fixture(tc_fixture, test_fixture_setup,
Expand Down
Loading