jit.dg/test-combination.c was spelling out all of the passing test cases, twice, when test-threads.c already had this as metadata.
Move the metadata from test-threads.c into all-non-failing-tests.h, and use it from test-combination.c to avoid this repetition. Before/after test-combination.c both have 1900 passes. Before/after jit.sum both have 7152 passes. Committed to trunk as r219413. 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. --- gcc/testsuite/jit.dg/all-non-failing-tests.h | 88 ++++++++++++++++++++++++++++ gcc/testsuite/jit.dg/test-combination.c | 52 ++-------------- gcc/testsuite/jit.dg/test-threads.c | 86 --------------------------- 3 files changed, 92 insertions(+), 134 deletions(-) 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 13e414d..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; -- 1.8.5.3