Commit 649a2749 by David Malcolm Committed by David Malcolm

jit.exp: add __func__ to help test-{combination|threads}.c

gcc/testsuite/ChangeLog:
	* jit.dg/harness.h (CHECK_NON_NULL): Add __func__ to output, to
	make it easier to figure out the origin of each test result when
	running test-combination.c and test-threads.c.
	(CHECK_VALUE): Likewise.
	(CHECK_DOUBLE_VALUE): Likewise.
	(CHECK_STRING_VALUE): Likewise.
	(CHECK_STRING_STARTS_WITH): Likewise.
	(CHECK_STRING_CONTAINS): Likewise.
	(CHECK): Likewise.
	(check_string_value): Likewise, add "funcname" param.
	(check_string_starts_with): Likewise.
	(check_string_contains): Likewise.

From-SVN: r219314
parent ee756af8
2015-01-07 David Malcolm <dmalcolm@redhat.com> 2015-01-07 David Malcolm <dmalcolm@redhat.com>
* jit.dg/harness.h (CHECK_NON_NULL): Add __func__ to output, to
make it easier to figure out the origin of each test result when
running test-combination.c and test-threads.c.
(CHECK_VALUE): Likewise.
(CHECK_DOUBLE_VALUE): Likewise.
(CHECK_STRING_VALUE): Likewise.
(CHECK_STRING_STARTS_WITH): Likewise.
(CHECK_STRING_CONTAINS): Likewise.
(CHECK): Likewise.
(check_string_value): Likewise, add "funcname" param.
(check_string_starts_with): Likewise.
(check_string_contains): Likewise.
2015-01-07 David Malcolm <dmalcolm@redhat.com>
* jit.dg/jit.exp (jit-dg-test): Remove "rootname" call when * jit.dg/jit.exp (jit-dg-test): Remove "rootname" call when
generating name of built executable. generating name of built executable.
......
...@@ -39,11 +39,13 @@ static char test[1024]; ...@@ -39,11 +39,13 @@ static char test[1024];
do { \ do { \
if ((PTR) != NULL) \ if ((PTR) != NULL) \
{ \ { \
pass ("%s: %s is non-null", test, #PTR); \ pass ("%s: %s: %s is non-null", \
test, __func__, #PTR); \
} \ } \
else \ else \
{ \ { \
fail ("%s: %s is NULL", test, #PTR); \ fail ("%s: %s: %s is NULL", \
test, __func__, #PTR); \
abort (); \ abort (); \
} \ } \
} while (0) } while (0)
...@@ -52,11 +54,13 @@ static char test[1024]; ...@@ -52,11 +54,13 @@ static char test[1024];
do { \ do { \
if ((ACTUAL) == (EXPECTED)) \ if ((ACTUAL) == (EXPECTED)) \
{ \ { \
pass ("%s: actual: %s == expected: %s", test, #ACTUAL, #EXPECTED); \ pass ("%s: %s: actual: %s == expected: %s", \
test, __func__, #ACTUAL, #EXPECTED); \
} \ } \
else \ else \
{ \ { \
fail ("%s: actual: %s != expected: %s", test, #ACTUAL, #EXPECTED); \ fail ("%s: %s: actual: %s != expected: %s", \
test, __func__, #ACTUAL, #EXPECTED); \
fprintf (stderr, "incorrect value\n"); \ fprintf (stderr, "incorrect value\n"); \
abort (); \ abort (); \
} \ } \
...@@ -68,34 +72,36 @@ static char test[1024]; ...@@ -68,34 +72,36 @@ static char test[1024];
double actual = (ACTUAL); \ double actual = (ACTUAL); \
if (abs (actual - expected) < 0.00001) \ if (abs (actual - expected) < 0.00001) \
{ \ { \
pass ("%s: actual: %s == expected: %s", test, #ACTUAL, #EXPECTED); \ pass ("%s: %s: actual: %s == expected: %s", \
__func__, test, #ACTUAL, #EXPECTED); \
} \ } \
else \ else \
{ \ { \
fail ("%s: actual: %s != expected: %s", test, #ACTUAL, #EXPECTED); \ fail ("%s: %s: actual: %s != expected: %s", \
__func__, test, #ACTUAL, #EXPECTED); \
fprintf (stderr, "incorrect value: %f\n", actual); \ fprintf (stderr, "incorrect value: %f\n", actual); \
abort (); \ abort (); \
} \ } \
} while (0) } while (0)
#define CHECK_STRING_VALUE(ACTUAL, EXPECTED) \ #define CHECK_STRING_VALUE(ACTUAL, EXPECTED) \
check_string_value ((ACTUAL), (EXPECTED)); check_string_value (__func__, (ACTUAL), (EXPECTED));
#define CHECK_STRING_STARTS_WITH(ACTUAL, EXPECTED_PREFIX) \ #define CHECK_STRING_STARTS_WITH(ACTUAL, EXPECTED_PREFIX) \
check_string_starts_with ((ACTUAL), (EXPECTED_PREFIX)); check_string_starts_with (__func__, (ACTUAL), (EXPECTED_PREFIX));
#define CHECK_STRING_CONTAINS(ACTUAL, EXPECTED_SUBSTRING) \ #define CHECK_STRING_CONTAINS(ACTUAL, EXPECTED_SUBSTRING) \
check_string_contains (#ACTUAL, (ACTUAL), (EXPECTED_SUBSTRING)); check_string_contains (__func__, #ACTUAL, (ACTUAL), (EXPECTED_SUBSTRING));
#define CHECK(COND) \ #define CHECK(COND) \
do { \ do { \
if (COND) \ if (COND) \
{ \ { \
pass ("%s: %s", test, #COND); \ pass ("%s: %s: %s", test, __func__, #COND); \
} \ } \
else \ else \
{ \ { \
fail ("%s: %s", test, #COND); \ fail ("%s: %s: %s", test, __func__, #COND); \
abort (); \ abort (); \
} \ } \
} while (0) } while (0)
...@@ -107,14 +113,17 @@ create_code (gcc_jit_context *ctxt, void * user_data); ...@@ -107,14 +113,17 @@ create_code (gcc_jit_context *ctxt, void * user_data);
extern void extern void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result); verify_code (gcc_jit_context *ctxt, gcc_jit_result *result);
extern void check_string_value (const char *actual, const char *expected); extern void check_string_value (const char *funcname,
const char *actual, const char *expected);
extern void extern void
check_string_starts_with (const char *actual, check_string_starts_with (const char *funcname,
const char *actual,
const char *expected_prefix); const char *expected_prefix);
extern void extern void
check_string_contains (const char *name, check_string_contains (const char *funcname,
const char *name,
const char *actual, const char *actual,
const char *expected_substring); const char *expected_substring);
...@@ -124,17 +133,20 @@ check_string_contains (const char *name, ...@@ -124,17 +133,20 @@ check_string_contains (const char *name,
temporarily turning off this part of harness.h. */ temporarily turning off this part of harness.h. */
#ifndef COMBINED_TEST #ifndef COMBINED_TEST
void check_string_value (const char *actual, const char *expected) void check_string_value (const char *funcname,
const char *actual, const char *expected)
{ {
if (actual && !expected) if (actual && !expected)
{ {
fail ("%s: actual: \"%s\" != expected: NULL", test, actual); fail ("%s: %s: actual: \"%s\" != expected: NULL",
funcname, test, actual);
fprintf (stderr, "incorrect value\n"); fprintf (stderr, "incorrect value\n");
abort (); abort ();
} }
if (expected && !actual) if (expected && !actual)
{ {
fail ("%s: actual: NULL != expected: \"%s\"", test, expected); fail ("%s: %s: actual: NULL != expected: \"%s\"",
funcname, test, expected);
fprintf (stderr, "incorrect value\n"); fprintf (stderr, "incorrect value\n");
abort (); abort ();
} }
...@@ -142,32 +154,35 @@ void check_string_value (const char *actual, const char *expected) ...@@ -142,32 +154,35 @@ void check_string_value (const char *actual, const char *expected)
{ {
if (strcmp (actual, expected)) if (strcmp (actual, expected))
{ {
fail ("%s: actual: \"%s\" != expected: \"%s\"", test, actual, expected); fail ("%s: %s: actual: \"%s\" != expected: \"%s\"",
test, funcname, actual, expected);
fprintf (stderr, "incorrect valuen"); fprintf (stderr, "incorrect valuen");
abort (); abort ();
} }
pass ("%s: actual: \"%s\" == expected: \"%s\"", test, actual, expected); pass ("%s: %s: actual: \"%s\" == expected: \"%s\"",
test, funcname, actual, expected);
} }
else else
pass ("%s: actual: NULL == expected: NULL"); pass ("%s: actual: NULL == expected: NULL");
} }
void void
check_string_starts_with (const char *actual, check_string_starts_with (const char *funcname,
const char *actual,
const char *expected_prefix) const char *expected_prefix)
{ {
if (!actual) if (!actual)
{ {
fail ("%s: actual: NULL != expected prefix: \"%s\"", fail ("%s: %s: actual: NULL != expected prefix: \"%s\"",
test, expected_prefix); test, funcname, expected_prefix);
fprintf (stderr, "incorrect value\n"); fprintf (stderr, "incorrect value\n");
abort (); abort ();
} }
if (strncmp (actual, expected_prefix, strlen (expected_prefix))) if (strncmp (actual, expected_prefix, strlen (expected_prefix)))
{ {
fail ("%s: actual: \"%s\" did not begin with expected prefix: \"%s\"", fail ("%s: %s: actual: \"%s\" did not begin with expected prefix: \"%s\"",
test, actual, expected_prefix); test, funcname, actual, expected_prefix);
fprintf (stderr, "incorrect value\n"); fprintf (stderr, "incorrect value\n");
abort (); abort ();
} }
...@@ -177,28 +192,29 @@ check_string_starts_with (const char *actual, ...@@ -177,28 +192,29 @@ check_string_starts_with (const char *actual,
} }
void void
check_string_contains (const char *name, check_string_contains (const char *funcname,
const char *name,
const char *actual, const char *actual,
const char *expected_substring) const char *expected_substring)
{ {
if (!actual) if (!actual)
{ {
fail ("%s: %s: actual: NULL does not contain expected substring: \"%s\"", fail ("%s: %s, %s: actual: NULL does not contain expected substring: \"%s\"",
test, name, expected_substring); test, funcname, name, expected_substring);
fprintf (stderr, "incorrect value\n"); fprintf (stderr, "incorrect value\n");
abort (); abort ();
} }
if (!strstr (actual, expected_substring)) if (!strstr (actual, expected_substring))
{ {
fail ("%s: %s: actual: \"%s\" did not contain expected substring: \"%s\"", fail ("%s: %s: %s: actual: \"%s\" did not contain expected substring: \"%s\"",
test, name, actual, expected_substring); test, funcname, name, actual, expected_substring);
fprintf (stderr, "incorrect value\n"); fprintf (stderr, "incorrect value\n");
abort (); abort ();
} }
pass ("%s: %s: found substring: \"%s\"", pass ("%s: %s: %s: found substring: \"%s\"",
test, name, expected_substring); test, funcname, name, expected_substring);
} }
static void set_options (gcc_jit_context *ctxt, const char *argv0) static void set_options (gcc_jit_context *ctxt, const char *argv0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment