TestResult **tr_fail_array;
TestResult **tr_all_array;
-
#define MAXSTR 300
typedef struct {
const char *tcname;
- int line_nos;
int failure_type;
const char *msg;
} master_test_t;
/* FIXME: all these line numbers are kind of hard to maintain */
static master_test_t master_tests[] = {
- { "Simple Tests", 18, CK_FAILURE, "Failure expected" },
- { "Simple Tests", 23, CK_ERROR, "Early exit with return value 1" },
- { "Simple Tests", -1, CK_PASS, "Passed" },
- { "Simple Tests", -1, CK_FAILURE, "This test should fail" },
- { "Simple Tests", -1, CK_PASS, "Passed" },
- { "Simple Tests", -1, CK_FAILURE, "This test should fail" },
- { "Simple Tests", -1, CK_FAILURE, "Assertion '2 == 3' failed" },
- { "Simple Tests", -1, CK_FAILURE, "Assertion '4 == 5' failed" },
- { "Simple Tests", -1, CK_FAILURE, "Failure '2 != 3' occured" },
- { "Simple Tests", -1, CK_FAILURE, "Failure '4 != 5' occured" },
- { "Simple Tests", -1, CK_FAILURE, "3 != 4" },
- { "Simple Tests", -1, CK_FAILURE, "5 != 6" },
- { "Simple Tests", -1, CK_FAILURE, "7 == 7" },
- { "Simple Tests", -1, CK_FAILURE, "Failed" },
- { "Simple Tests", 114, CK_FAILURE, "Failed" },
- { "Simple Tests", 120, CK_FAILURE, "Failure expected" },
- { "Simple Tests", 127, CK_FAILURE, "Failed" },
- { "Simple Tests", 139, CK_FAILURE, "Assertion 'x == y' failed" },
- { "Simple Tests", 145, CK_FAILURE, "Assertion '0' failed" },
- { "Simple Tests", 170, CK_FAILURE, "Assertion 'x==y' failed: x==3, y==4" },
- { "Simple Tests", 180, CK_FAILURE, "Assertion 'x!=y' failed: x==3, y==3" },
- { "Simple Tests", 188, CK_FAILURE, "Assertion '\"test1\"==s' failed: \"test1\"==\"test1\", s==\"test2\"" },
- { "Simple Tests", 198, CK_FAILURE, "Assertion 't!=s' failed: t==\"test2\", s==\"test2\"" },
-
- { "Signal Tests", -1, CK_ERROR, signal_11_str },
- { "Signal Tests", -1, CK_PASS, "Passed" },
- { "Signal Tests", 228, CK_ERROR, signal_11_8_str },
- { "Signal Tests", -1, CK_FAILURE, "Early exit with return value 0" },
- { "Signal Tests", -1, CK_FAILURE, "Early exit with return value 1" },
- { "Signal Tests", -1, CK_ERROR, signal_8_str },
- { "Signal Tests", -1, CK_ERROR, signal_8_str },
+ { "Simple Tests", CK_FAILURE, "Failure expected" },
+ { "Simple Tests", CK_ERROR, "Early exit with return value 1" },
+ { "Simple Tests", CK_PASS, "Passed" },
+ { "Simple Tests", CK_FAILURE, "This test should fail" },
+ { "Simple Tests", CK_PASS, "Passed" },
+ { "Simple Tests", CK_FAILURE, "This test should fail" },
+ { "Simple Tests", CK_FAILURE, "Assertion '2 == 3' failed" },
+ { "Simple Tests", CK_FAILURE, "Assertion '4 == 5' failed" },
+ { "Simple Tests", CK_FAILURE, "Failure '2 != 3' occured" },
+ { "Simple Tests", CK_FAILURE, "Failure '4 != 5' occured" },
+ { "Simple Tests", CK_FAILURE, "3 != 4" },
+ { "Simple Tests", CK_FAILURE, "5 != 6" },
+ { "Simple Tests", CK_FAILURE, "7 == 7" },
+ { "Simple Tests", CK_FAILURE, "Failed" },
+ { "Simple Tests", CK_FAILURE, "Failed" },
+ { "Simple Tests", CK_FAILURE, "Failure expected" },
+ { "Simple Tests", CK_FAILURE, "Failed" },
+ { "Simple Tests", CK_FAILURE, "Assertion 'x == y' failed" },
+ { "Simple Tests", CK_FAILURE, "Assertion '0' failed" },
+ { "Simple Tests", CK_FAILURE, "Assertion 'x==y' failed: x==3, y==4" },
+ { "Simple Tests", CK_FAILURE, "Assertion 'x!=y' failed: x==3, y==3" },
+ { "Simple Tests", CK_FAILURE, "Assertion '\"test1\"==s' failed: \"test1\"==\"test1\", s==\"test2\"" },
+ { "Simple Tests", CK_FAILURE, "Assertion 't!=s' failed: t==\"test2\", s==\"test2\"" },
+
+ { "Signal Tests", CK_ERROR, signal_11_str },
+ { "Signal Tests", CK_PASS, "Passed" },
+ { "Signal Tests", CK_ERROR, signal_11_8_str },
+ { "Signal Tests", CK_FAILURE, "Early exit with return value 0" },
+ { "Signal Tests", CK_FAILURE, "Early exit with return value 1" },
+ { "Signal Tests", CK_ERROR, signal_8_str },
+ { "Signal Tests", CK_ERROR, signal_8_str },
#if TIMEOUT_TESTS_ENABLED
- { "Environment Timeout Tests", 256, CK_ERROR, "Test timeout expired" },
- { "Environment Timeout Tests", -1, CK_PASS, "Passed" },
- { "Environment Timeout Tests", -1, CK_PASS, "Passed" },
- { "Environment Timeout Tests", 275, CK_ERROR, "Test timeout expired" },
- { "Timeout Tests", 256, CK_ERROR, "Test timeout expired" },
- { "Timeout Tests", -1, CK_PASS, "Passed" },
- { "Timeout Tests", 269, CK_ERROR, "Test timeout expired" },
- { "Timeout Tests", 275, CK_ERROR, "Test timeout expired" },
- { "User Timeout Tests", 256, CK_ERROR, "Test timeout expired" },
- { "User Timeout Tests", -1, CK_PASS, "Passed" },
- { "User Timeout Tests", -1, CK_PASS, "Passed" },
- { "User Timeout Tests", 275, CK_ERROR, "Test timeout expired" },
+ { "Environment Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "Environment Timeout Tests", CK_PASS, "Passed" },
+ { "Environment Timeout Tests", CK_PASS, "Passed" },
+ { "Environment Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "Timeout Tests", CK_PASS, "Passed" },
+ { "Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "User Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "User Timeout Tests", CK_PASS, "Passed" },
+ { "User Timeout Tests", CK_PASS, "Passed" },
+ { "User Timeout Tests", CK_ERROR, "Test timeout expired" },
/* Timeout tests are run twice , see check_check_sub.c:make_sub_suite() */
- { "Timeout Tests", 256, CK_ERROR, "Test timeout expired" },
- { "Timeout Tests", -1, CK_PASS, "Passed" },
- { "Timeout Tests", 269, CK_ERROR, "Test timeout expired" },
- { "Timeout Tests", 275, CK_ERROR, "Test timeout expired" },
+ { "Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "Timeout Tests", CK_PASS, "Passed" },
+ { "Timeout Tests", CK_ERROR, "Test timeout expired" },
+ { "Timeout Tests", CK_ERROR, "Test timeout expired" },
#endif
- { "Limit Tests", -1, CK_ERROR, "Early exit with return value 1" },
- { "Limit Tests", -1, CK_FAILURE, "Completed properly" },
- { "Limit Tests", -1, CK_FAILURE, "Completed properly" },
+ { "Limit Tests", CK_ERROR, "Early exit with return value 1" },
+ { "Limit Tests", CK_FAILURE, "Completed properly" },
+ { "Limit Tests", CK_FAILURE, "Completed properly" },
- { "Msg and fork Tests", -1, CK_PASS, "Passed" },
- { "Msg and fork Tests", -1, CK_FAILURE, "Expected fail" },
- { "Msg and fork Tests", -1, CK_PASS, "Passed" },
- { "Msg and fork Tests", -1, CK_FAILURE, "Expected fail" },
- { "Msg and fork Tests", -1, CK_PASS, "Passed" },
- { "Msg and fork Tests", -1, CK_FAILURE, "Expected fail" },
+ { "Msg and fork Tests", CK_PASS, "Passed" },
+ { "Msg and fork Tests", CK_FAILURE, "Expected fail" },
+ { "Msg and fork Tests", CK_PASS, "Passed" },
+ { "Msg and fork Tests", CK_FAILURE, "Expected fail" },
+ { "Msg and fork Tests", CK_PASS, "Passed" },
+ { "Msg and fork Tests", CK_FAILURE, "Expected fail" },
- { "Core", -1, CK_PASS, "Passed" },
- { "Core", -1, CK_FAILURE, "We failed" }
+ { "Core", CK_PASS, "Passed" },
+ { "Core", CK_FAILURE, "We failed" }
};
static int nr_of_master_tests = sizeof master_tests /sizeof master_tests[0];
+int master_tests_lineno[sizeof master_tests /sizeof master_tests[0]];
+
START_TEST(test_check_nfailures)
{
int i;
fail_if(i - passed > sub_nfailed, NULL);
tr = tr_fail_array[i - passed];
fail_unless(tr != NULL, NULL);
- line_no = master_tests[i].line_nos;
+ line_no = master_tests_lineno[i];
if (line_no > 0 && tr_lno(tr) != line_no) {
char *emsg = malloc(MAXSTR);
snprintf(emsg, MAXSTR, "For test %d: Expected lno %d, got %d",
Suite *s = make_sub_suite();
SRunner *sr = srunner_create(s);
+ init_master_tests_lineno();
init_signal_strings();
srunner_add_suite(sr, make_sub2_suite());
#include <check.h>
#include "check_check.h"
-
-
-
-
-
+#define _STR(Y) #Y
START_TEST(test_lno)
{
- fail("Failure expected"); /* line 18*/
+ fail("Failure expected");
+ #define LINENO_lno _STR(__LINE__)
}
END_TEST
+
START_TEST(test_mark_lno)
{
- mark_point(); /* line 23*/
+ mark_point();
+ #define LINENO_mark_lno _STR(__LINE__)
#ifdef _POSIX_VERSION
- exit(EXIT_FAILURE); /* should fail at line 23*/
+ exit(EXIT_FAILURE); /* should fail with mark_point above as line */
#endif /* _POSIX_VERSION */
}
+
END_TEST
START_TEST(test_pass)
{
fail_unless(9999, "This test should pass");
}
END_TEST
+
/* FIXME: this should really be called test_fail_unless */
START_TEST(test_fail)
{
fail("%d == %d", x, y);
}
END_TEST
+
#if defined(__GNUC__)
START_TEST(test_fail_empty)
{ /* plain fail() doesn't compile with xlc in C mode because of `, ## __VA_ARGS__' problem */
}
END_TEST
#endif /* __GNUC__ */
+
START_TEST(test_ck_abort)
{
- ck_abort(); /* line 114 */
+ ck_abort();
+ #define LINENO_ck_abort _STR(__LINE__)
}
END_TEST
START_TEST(test_ck_abort_msg)
{
- ck_abort_msg("Failure expected"); /* line 120 */
+ ck_abort_msg("Failure expected");
+ #define LINENO_ck_abort_msg _STR(__LINE__)
}
END_TEST
/* FIXME: perhaps passing NULL to ck_abort_msg should be an error. */
START_TEST(test_ck_abort_msg_null)
{
- ck_abort_msg(NULL); /* line 127 */
+ ck_abort_msg(NULL);
+ #define LINENO_ck_abort_msg_null _STR(__LINE__)
}
END_TEST
ck_assert(x == y);
y++;
ck_assert(x != y);
- ck_assert(x == y); /* line 139 */
+ ck_assert(x == y);
+ #define LINENO_ck_assert _STR(__LINE__)
}
END_TEST
START_TEST(test_ck_assert_null)
{
- ck_assert(0); /* line 145 */
+ ck_assert(0);
+ #define LINENO_ck_assert_null _STR(__LINE__)
}
END_TEST
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
START_TEST(test_ck_assert_int_eq)
{
int x = 3;
int y = 3;
ck_assert_int_eq(x, y);
y++;
- ck_assert_int_eq(x, y); /* line 170 */
+ ck_assert_int_eq(x, y);
+ #define LINENO_ck_assert_int_eq _STR(__LINE__)
}
END_TEST
int y = 2;
ck_assert_int_ne(x, y);
y++;
- ck_assert_int_ne(x, y); /* line 180 */
+ ck_assert_int_ne(x, y);
+ #define LINENO_ck_assert_int_ne _STR(__LINE__)
}
END_TEST
{
const char *s = "test2";
ck_assert_str_eq("test2", s);
- ck_assert_str_eq("test1", s); /* line 188 */
+ ck_assert_str_eq("test1", s);
+ #define LINENO_ck_assert_str_eq _STR(__LINE__)
}
END_TEST
const char *t = "test1";
ck_assert_str_ne(t, s);
t = "test2";
- ck_assert_str_ne(t, s); /* line 198 */
+ ck_assert_str_ne(t, s);
+ #define LINENO_ck_assert_str_ne _STR(__LINE__)
}
END_TEST
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-START_TEST(test_segv) /* line 228 */
+START_TEST(test_segv)
+ #define LINENO_segv _STR(__LINE__)
{
raise (SIGSEGV);
}
END_TEST
#if TIMEOUT_TESTS_ENABLED
-START_TEST(test_eternal) /* line 256 */
+START_TEST(test_eternal)
+ #define LINENO_eternal _STR(__LINE__)
{
for (;;)
;
}
END_TEST
-START_TEST(test_sleep5) /* line 269 */
+START_TEST(test_sleep5)
+ #define LINENO_sleep5 _STR(__LINE__)
{
sleep(5);
}
END_TEST
-START_TEST(test_sleep8) /* line 275 */
+START_TEST(test_sleep8)
+ #define LINENO_sleep8 _STR(__LINE__)
{
sleep(8);
}
return s;
}
+void init_master_tests_lineno(void) {
+ const char * lineno[] = {
+/* Simple Tests */
+ LINENO_lno,
+ LINENO_mark_lno,
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ LINENO_ck_abort,
+ LINENO_ck_abort_msg,
+ LINENO_ck_abort_msg_null,
+ LINENO_ck_assert,
+ LINENO_ck_assert_null,
+ LINENO_ck_assert_int_eq,
+ LINENO_ck_assert_int_ne,
+ LINENO_ck_assert_str_eq,
+ LINENO_ck_assert_str_ne,
+
+/* Signal Tests */
+ "-1",
+ "-1",
+ LINENO_segv,
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+
+#if TIMEOUT_TESTS_ENABLED
+/* Timeout Tests */
+ LINENO_eternal,
+ "-1",
+ "-1",
+ LINENO_sleep8,
+ LINENO_eternal,
+ "-1",
+ LINENO_sleep5,
+ LINENO_sleep8,
+ LINENO_eternal,
+ "-1",
+ "-1",
+ LINENO_sleep8,
+ LINENO_eternal,
+ "-1",
+ LINENO_sleep5,
+ LINENO_sleep8,
+#endif
+
+/* Limit Tests */
+ "-1",
+ "-1",
+ "-1",
+
+/* Msg and fork Tests */
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+ "-1",
+
+/* Core */
+ "-1",
+ "-1"
+ };
+ int s = sizeof lineno /sizeof lineno[0];
+ int i;
+
+ for (i = 0; i < s; i++) {
+ master_tests_lineno[i] = atoi(lineno[i]) - 1;
+ }
+}
+
Suite *make_sub_suite(void)
{
Suite *s;
tcase_add_test (tc_timeout_usr, test_sleep2);
tcase_add_test (tc_timeout_usr, test_sleep5);
tcase_add_test (tc_timeout_usr, test_sleep8);
+#if 0
+ tcase_set_timeout (tc_timeout_kill, 2);
+ tcase_add_test (tc_timeout_kill, test_sleep);
+#endif
#endif
tcase_add_test (tc_limit, test_early_exit);