aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-01-09 22:05:55 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-01-09 22:05:55 +0000
commit8cf8f223466df156ebbd5762f5c901f0a3812e43 (patch)
treee86f079a53565a0e2dacb12fbc71d2083050e291
parent5357406ff8f315c90a69b87862b11d00830cd159 (diff)
downloadgcc-8cf8f223466df156ebbd5762f5c901f0a3812e43.zip
gcc-8cf8f223466df156ebbd5762f5c901f0a3812e43.tar.gz
gcc-8cf8f223466df156ebbd5762f5c901f0a3812e43.tar.bz2
Simplify jit.dg/test-combination.c
gcc/testsuite/ChangeLog: * jit.dg/test-threads.c (struct testcase): Move declaration to jit.dg/all-non-failing-tests.h. (testcases): Likewise. * jit.dg/all-non-failing-tests.h (struct testcase): Move declaration here from jit.dg/all-non-failing-tests.h. (testcases): Likewise. * jit.dg/test-combination.c (create_code): Eliminate spelling out all of the testcases in favor of looping through the "testcases" metadata. (verify_code): Likewise. From-SVN: r219413
-rw-r--r--gcc/testsuite/ChangeLog13
-rw-r--r--gcc/testsuite/jit.dg/all-non-failing-tests.h88
-rw-r--r--gcc/testsuite/jit.dg/test-combination.c52
-rw-r--r--gcc/testsuite/jit.dg/test-threads.c86
4 files changed, 105 insertions, 134 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2aada90..496ba92 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2015-01-09 David Malcolm <dmalcolm@redhat.com>
+
+ * jit.dg/test-threads.c (struct testcase): Move declaration
+ to jit.dg/all-non-failing-tests.h.
+ (testcases): Likewise.
+ * jit.dg/all-non-failing-tests.h (struct testcase): Move
+ declaration here from jit.dg/all-non-failing-tests.h.
+ (testcases): Likewise.
+ * jit.dg/test-combination.c (create_code): Eliminate spelling
+ out all of the testcases in favor of looping through the
+ "testcases" metadata.
+ (verify_code): Likewise.
+
2015-01-09 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/64536
diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h
index 14211af..82ce736 100644
--- a/gcc/testsuite/jit.dg/all-non-failing-tests.h
+++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h
@@ -178,3 +178,91 @@
#include "test-volatile.c"
#undef create_code
#undef verify_code
+
+/* Now expose the individual testcases as instances of this struct. */
+
+struct testcase
+{
+ const char *m_name;
+ void (*m_hook_to_create_code) (gcc_jit_context *ctxt,
+ void * user_data);
+ void (*m_hook_to_verify_code) (gcc_jit_context *ctxt,
+ gcc_jit_result *result);
+};
+
+const struct testcase testcases[] = {
+ {"accessing_struct",
+ create_code_accessing_struct,
+ verify_code_accessing_struct},
+ {"accessing_union",
+ create_code_accessing_union,
+ verify_code_accessing_union},
+ {"arith_overflow",
+ create_code_arith_overflow,
+ verify_code_arith_overflow},
+ {"array_as_pointer",
+ create_code_array_as_pointer,
+ verify_code_array_as_pointer},
+ {"arrays",
+ create_code_arrays,
+ verify_code_arrays},
+ {"calling_external_function",
+ create_code_calling_external_function,
+ verify_code_calling_external_function},
+ {"calling_function_ptr",
+ create_code_calling_function_ptr,
+ verify_code_calling_function_ptr},
+ {"constants",
+ create_code_constants,
+ verify_code_constants},
+ {"dot_product",
+ create_code_dot_product,
+ verify_code_dot_product},
+ {"expressions",
+ create_code_expressions,
+ verify_code_expressions},
+ {"factorial",
+ create_code_factorial,
+ verify_code_factorial},
+ {"fibonacci",
+ create_code_fibonacci,
+ verify_code_fibonacci},
+ {"functions",
+ create_code_functions,
+ verify_code_functions},
+ {"hello_world",
+ create_code_hello_world,
+ verify_code_hello_world},
+ {"linked_list",
+ create_code_linked_list,
+ verify_code_linked_list},
+ {"long_names",
+ create_code_long_names,
+ verify_code_long_names},
+ {"quadratic",
+ create_code_quadratic,
+ verify_code_quadratic},
+ {"nested_loop",
+ create_code_nested_loop,
+ verify_code_nested_loop},
+ {"reading_struct ",
+ create_code_reading_struct ,
+ verify_code_reading_struct },
+ {"string_literal",
+ create_code_string_literal,
+ verify_code_string_literal},
+ {"sum_of_squares",
+ create_code_sum_of_squares,
+ verify_code_sum_of_squares},
+ {"types",
+ create_code_types,
+ verify_code_types},
+ {"using_global",
+ create_code_using_global,
+ verify_code_using_global},
+ {"volatile",
+ create_code_volatile,
+ verify_code_volatile}
+};
+
+const int num_testcases = (sizeof (testcases) / sizeof (testcases[0]));
diff --git a/gcc/testsuite/jit.dg/test-combination.c b/gcc/testsuite/jit.dg/test-combination.c
index 5131613..a9f3347 100644
--- a/gcc/testsuite/jit.dg/test-combination.c
+++ b/gcc/testsuite/jit.dg/test-combination.c
@@ -15,57 +15,13 @@
void
create_code (gcc_jit_context *ctxt, void * user_data)
{
- create_code_accessing_struct (ctxt, user_data);
- create_code_accessing_union (ctxt, user_data);
- create_code_arith_overflow (ctxt, user_data);
- create_code_array_as_pointer (ctxt, user_data);
- create_code_arrays (ctxt, user_data);
- create_code_calling_external_function (ctxt, user_data);
- create_code_calling_function_ptr (ctxt, user_data);
- create_code_constants (ctxt, user_data);
- create_code_dot_product (ctxt, user_data);
- create_code_expressions (ctxt, user_data);
- create_code_factorial (ctxt, user_data);
- create_code_fibonacci (ctxt, user_data);
- create_code_functions (ctxt, user_data);
- create_code_hello_world (ctxt, user_data);
- create_code_linked_list (ctxt, user_data);
- create_code_long_names (ctxt, user_data);
- create_code_quadratic (ctxt, user_data);
- create_code_nested_loop (ctxt, user_data);
- create_code_reading_struct (ctxt, user_data);
- create_code_string_literal (ctxt, user_data);
- create_code_sum_of_squares (ctxt, user_data);
- create_code_types (ctxt, user_data);
- create_code_using_global (ctxt, user_data);
- create_code_volatile (ctxt, user_data);
+ for (int i = 0; i < num_testcases; i++)
+ testcases[i].m_hook_to_create_code (ctxt, user_data);
}
void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
- verify_code_accessing_struct (ctxt, result);
- verify_code_accessing_union (ctxt, result);
- verify_code_arith_overflow (ctxt, result);
- verify_code_array_as_pointer (ctxt, result);
- verify_code_arrays (ctxt, result);
- verify_code_calling_external_function (ctxt, result);
- verify_code_calling_function_ptr (ctxt, result);
- verify_code_constants (ctxt, result);
- verify_code_dot_product (ctxt, result);
- verify_code_expressions (ctxt, result);
- verify_code_factorial (ctxt, result);
- verify_code_fibonacci (ctxt, result);
- verify_code_functions (ctxt, result);
- verify_code_hello_world (ctxt, result);
- verify_code_linked_list (ctxt, result);
- verify_code_long_names (ctxt, result);
- verify_code_quadratic (ctxt, result);
- verify_code_nested_loop (ctxt, result);
- verify_code_reading_struct (ctxt, result);
- verify_code_string_literal (ctxt, result);
- verify_code_sum_of_squares (ctxt, result);
- verify_code_types (ctxt, result);
- verify_code_using_global (ctxt, result);
- verify_code_volatile (ctxt, result);
+ for (int i = 0; i < num_testcases; i++)
+ testcases[i].m_hook_to_verify_code (ctxt, result);
}
diff --git a/gcc/testsuite/jit.dg/test-threads.c b/gcc/testsuite/jit.dg/test-threads.c
index 13e414db..d4e53b2 100644
--- a/gcc/testsuite/jit.dg/test-threads.c
+++ b/gcc/testsuite/jit.dg/test-threads.c
@@ -91,92 +91,6 @@ note (const char* fmt, ...)
#undef COMBINED_TEST
#include "harness.h"
-struct testcase
-{
- const char *m_name;
- void (*m_hook_to_create_code) (gcc_jit_context *ctxt,
- void * user_data);
- void (*m_hook_to_verify_code) (gcc_jit_context *ctxt,
- gcc_jit_result *result);
-};
-
-const struct testcase testcases[] = {
- {"accessing_struct",
- create_code_accessing_struct,
- verify_code_accessing_struct},
- {"accessing_union",
- create_code_accessing_union,
- verify_code_accessing_union},
- {"arith_overflow",
- create_code_arith_overflow,
- verify_code_arith_overflow},
- {"array_as_pointer",
- create_code_array_as_pointer,
- verify_code_array_as_pointer},
- {"arrays",
- create_code_arrays,
- verify_code_arrays},
- {"calling_external_function",
- create_code_calling_external_function,
- verify_code_calling_external_function},
- {"calling_function_ptr",
- create_code_calling_function_ptr,
- verify_code_calling_function_ptr},
- {"constants",
- create_code_constants,
- verify_code_constants},
- {"dot_product",
- create_code_dot_product,
- verify_code_dot_product},
- {"expressions",
- create_code_expressions,
- verify_code_expressions},
- {"factorial",
- create_code_factorial,
- verify_code_factorial},
- {"fibonacci",
- create_code_fibonacci,
- verify_code_fibonacci},
- {"functions",
- create_code_functions,
- verify_code_functions},
- {"hello_world",
- create_code_hello_world,
- verify_code_hello_world},
- {"linked_list",
- create_code_linked_list,
- verify_code_linked_list},
- {"long_names",
- create_code_long_names,
- verify_code_long_names},
- {"quadratic",
- create_code_quadratic,
- verify_code_quadratic},
- {"nested_loop",
- create_code_nested_loop,
- verify_code_nested_loop},
- {"reading_struct ",
- create_code_reading_struct ,
- verify_code_reading_struct },
- {"string_literal",
- create_code_string_literal,
- verify_code_string_literal},
- {"sum_of_squares",
- create_code_sum_of_squares,
- verify_code_sum_of_squares},
- {"types",
- create_code_types,
- verify_code_types},
- {"using_global",
- create_code_using_global,
- verify_code_using_global},
- {"volatile",
- create_code_volatile,
- verify_code_volatile}
-};
-
-const int num_testcases = (sizeof (testcases) / sizeof (testcases[0]));
-
struct thread_data
{
pthread_t m_tid;