From 701de040b4e3cac2402321b7e70d106b25e28669 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Tue, 23 Nov 2021 18:03:10 +0100 Subject: [PATCH] [PATCH 130/144] tests: use EXIT_SUCCESS/EXIT_FAILURE in most tests Gbp-Pq: Name 0130-tests-use-EXIT_SUCCESS-EXIT_FAILURE-in-most-tests.patch --- tests/kernel/image_query_funcs.c | 2 +- tests/kernel/kernel.c | 3 +-- tests/kernel/sampler_address_clamp.c | 4 ++-- .../test_alignment_with_dynamic_wg.cpp | 10 +++++----- .../test_alignment_with_dynamic_wg2.cpp | 2 ++ .../test_alignment_with_dynamic_wg3.cpp | 9 +++++---- ...ign_loop_variable_to_privvar_makes_it_local.c | 8 +++++++- tests/regression/test_flatten_barrier_subs.cpp | 3 ++- tests/regression/test_issue_231.cpp | 2 ++ tests/regression/test_issue_445.cpp | 12 ++++++++++-- tests/regression/test_issue_553.cpp | 2 ++ tests/regression/test_issue_577.cpp | 4 ++-- tests/regression/test_locals.cpp | 8 +++++--- .../test_program_from_binary_with_local_1_1_1.c | 5 +++-- tests/runtime/test_clCreateKernel.c | 5 +---- tests/runtime/test_clCreateSubDevices.c | 4 +--- tests/runtime/test_enqueue_kernel_from_binary.c | 16 +++++++++------- tests/runtime/test_fill-buffer.c | 6 +++--- tests/runtime/test_kernel_cache_includes.c | 2 +- tests/workgroup/run_kernel.c | 6 +++++- 20 files changed, 69 insertions(+), 44 deletions(-) diff --git a/tests/kernel/image_query_funcs.c b/tests/kernel/image_query_funcs.c index a59c7bc..8299cc0 100644 --- a/tests/kernel/image_query_funcs.c +++ b/tests/kernel/image_query_funcs.c @@ -139,5 +139,5 @@ int main(int argc, char **argv) free (imageData); printf("OK\n"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/kernel/kernel.c b/tests/kernel/kernel.c index c2257e8..3b6149e 100644 --- a/tests/kernel/kernel.c +++ b/tests/kernel/kernel.c @@ -167,6 +167,5 @@ int main(int argc, char **argv) printf("OK\n"); fflush(stdout); fflush(stderr); - return (retval ? 1 : 0); + return (retval ? EXIT_FAILURE : EXIT_SUCCESS); } - diff --git a/tests/kernel/sampler_address_clamp.c b/tests/kernel/sampler_address_clamp.c index 9a688a3..fed2fc9 100644 --- a/tests/kernel/sampler_address_clamp.c +++ b/tests/kernel/sampler_address_clamp.c @@ -182,9 +182,9 @@ error: if (retval) { printf("FAIL\n"); - return 1; + return EXIT_FAILURE; } printf("OK\n"); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/regression/test_alignment_with_dynamic_wg.cpp b/tests/regression/test_alignment_with_dynamic_wg.cpp index f049184..731cfb5 100644 --- a/tests/regression/test_alignment_with_dynamic_wg.cpp +++ b/tests/regression/test_alignment_with_dynamic_wg.cpp @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) { if (argc < 4) { std::cout << "USAGE: $0 X Y Z\n"; - return 1; + return EXIT_FAILURE; } std::string arg_x(argv[1]); @@ -122,13 +122,13 @@ int main(int argc, char *argv[]) { unsigned z = std::stoi(argv[3]); if (!test_invocation(x, y, z, arg_x, arg_y, arg_z, queue)) - return 1; + return EXIT_FAILURE; if (!test_invocation(y, z, x, arg_y, arg_z, arg_x, queue)) - return 1; + return EXIT_FAILURE; if (!test_invocation(z, x, y, arg_z, arg_x, arg_y, queue)) - return 1; + return EXIT_FAILURE; - return 0; + return EXIT_SUCCESS; } diff --git a/tests/regression/test_alignment_with_dynamic_wg2.cpp b/tests/regression/test_alignment_with_dynamic_wg2.cpp index 91abd9e..76d48d5 100644 --- a/tests/regression/test_alignment_with_dynamic_wg2.cpp +++ b/tests/regression/test_alignment_with_dynamic_wg2.cpp @@ -82,4 +82,6 @@ int main(int argc, char *argv[]) { printf("Value: %le \n", out[0]); printf("Value: %le \n", out[1]); printf("Value: %le \n", out[2]); + + return EXIT_SUCCESS; } diff --git a/tests/regression/test_alignment_with_dynamic_wg3.cpp b/tests/regression/test_alignment_with_dynamic_wg3.cpp index 773772d..9a189f3 100644 --- a/tests/regression/test_alignment_with_dynamic_wg3.cpp +++ b/tests/regression/test_alignment_with_dynamic_wg3.cpp @@ -55,10 +55,11 @@ int main(int argc, char *argv[]) { queue.finish(); - if (out[0] == 1.0f) + if (out[0] == 1.0f) { printf("OK\n"); - else + return EXIT_SUCCESS; + } else { printf("FAIL\n"); - - return (out[0] == 1.0f) ? 0 : 1; + return EXIT_FAILURE; + } } diff --git a/tests/regression/test_assign_loop_variable_to_privvar_makes_it_local.c b/tests/regression/test_assign_loop_variable_to_privvar_makes_it_local.c index d8e8728..5812b86 100644 --- a/tests/regression/test_assign_loop_variable_to_privvar_makes_it_local.c +++ b/tests/regression/test_assign_loop_variable_to_privvar_makes_it_local.c @@ -25,6 +25,7 @@ #include #include "poclu.h" +#include #include const char* kernel_src = @@ -83,5 +84,10 @@ int main() { clFinish(command_queue); ret |= clReleaseKernel(kernel); - return ret; + + if (ret == 0) + { + return EXIT_SUCCESS; + } + return EXIT_FAILURE; } diff --git a/tests/regression/test_flatten_barrier_subs.cpp b/tests/regression/test_flatten_barrier_subs.cpp index 6930933..f8bc7a3 100644 --- a/tests/regression/test_flatten_barrier_subs.cpp +++ b/tests/regression/test_flatten_barrier_subs.cpp @@ -240,7 +240,8 @@ int main() { std::cout << "CL gave wrong results" << std::endl; print_vec(cl_indices); + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/regression/test_issue_231.cpp b/tests/regression/test_issue_231.cpp index 08a5b50..ee4c45e 100644 --- a/tests/regression/test_issue_231.cpp +++ b/tests/regression/test_issue_231.cpp @@ -100,4 +100,6 @@ int main(int argc, char *argv[]) queue.finish(); cl::Platform::getDefault().unloadCompiler(); + + return EXIT_SUCCESS; } diff --git a/tests/regression/test_issue_445.cpp b/tests/regression/test_issue_445.cpp index 359b2b4..e8acb8e 100644 --- a/tests/regression/test_issue_445.cpp +++ b/tests/regression/test_issue_445.cpp @@ -30,6 +30,7 @@ private_local_array(__global int *__restrict__ out) int main(int, char **) { + bool success = true; try { int N = 9; @@ -47,9 +48,11 @@ int main(int, char **) cl_int *output = (cl_int*)queue.enqueueMapBuffer( buffer, CL_TRUE, CL_MAP_READ, 0, N*sizeof(int)); for (int i = 0; i < N; i++) { - if ((int)output[i] != i + 1) + if ((int)output[i] != i + 1) { std::cout << "FAIL: " << output[i] << " should be " << i + 1 << std::endl; + success = false; + } } queue.enqueueUnmapMemObject(buffer, output); queue.finish(); @@ -57,6 +60,11 @@ int main(int, char **) } catch (cl::Error& err) { std::cout << "FAIL with OpenCL error = " << err.err() << std::endl; + return EXIT_FAILURE; } - return 0; + + if (success) { + return EXIT_SUCCESS; + } + return EXIT_FAILURE; } diff --git a/tests/regression/test_issue_553.cpp b/tests/regression/test_issue_553.cpp index b1f6381..9dada2d 100644 --- a/tests/regression/test_issue_553.cpp +++ b/tests/regression/test_issue_553.cpp @@ -72,4 +72,6 @@ int main(int argc, char *argv[]) queue.finish(); cl::Platform::getDefault().unloadCompiler(); + + return EXIT_SUCCESS; } diff --git a/tests/regression/test_issue_577.cpp b/tests/regression/test_issue_577.cpp index 927d82e..cde1af3 100644 --- a/tests/regression/test_issue_577.cpp +++ b/tests/regression/test_issue_577.cpp @@ -35,9 +35,9 @@ int main(int argc, char *argv[]) { if (error_count == 2) { std::cout << "OK\n"; - return 0; + return EXIT_SUCCESS; } else { std::cout << "FAIL\n"; - return 1; + return EXIT_FAILURE; } } diff --git a/tests/regression/test_locals.cpp b/tests/regression/test_locals.cpp index 3511e3c..e4d37f0 100644 --- a/tests/regression/test_locals.cpp +++ b/tests/regression/test_locals.cpp @@ -137,6 +137,10 @@ main(void) aBuffer, (void *) res); queue.finish(); platformList[0].unloadCompiler(); + + if (success) { + return EXIT_SUCCESS; + } } catch (cl::Error &err) { std::cerr @@ -146,9 +150,7 @@ main(void) << err.err() << ")" << std::endl; - - return EXIT_FAILURE; } - return success ? EXIT_SUCCESS : EXIT_FAILURE; + return EXIT_FAILURE; } diff --git a/tests/regression/test_program_from_binary_with_local_1_1_1.c b/tests/regression/test_program_from_binary_with_local_1_1_1.c index 5313deb..33abbdd 100644 --- a/tests/regression/test_program_from_binary_with_local_1_1_1.c +++ b/tests/regression/test_program_from_binary_with_local_1_1_1.c @@ -132,7 +132,7 @@ int main () { printf("Error at %u %u : %u != %u\n", k, i, output_buffer[k*vec_size+i], expected); - return 1; + return EXIT_FAILURE; } } } @@ -145,5 +145,6 @@ int main () clReleaseContext(context); clReleaseDevice(device); clUnloadPlatformCompiler(platform); - return 0; + + return EXIT_SUCCESS; } diff --git a/tests/runtime/test_clCreateKernel.c b/tests/runtime/test_clCreateKernel.c index 1cf38cf..b046f82 100644 --- a/tests/runtime/test_clCreateKernel.c +++ b/tests/runtime/test_clCreateKernel.c @@ -45,8 +45,5 @@ int main(int argc, char **argv) free ((void *)krn_src); printf("OK\n"); - - return 0; + return EXIT_SUCCESS; } - - diff --git a/tests/runtime/test_clCreateSubDevices.c b/tests/runtime/test_clCreateSubDevices.c index 91a4d26..fa5922e 100644 --- a/tests/runtime/test_clCreateSubDevices.c +++ b/tests/runtime/test_clCreateSubDevices.c @@ -405,7 +405,5 @@ int main(int argc, char **argv) free (dev_pt); printf ("OK\n"); - - return 0; + return EXIT_SUCCESS; } - diff --git a/tests/runtime/test_enqueue_kernel_from_binary.c b/tests/runtime/test_enqueue_kernel_from_binary.c index 875eade..8259af9 100644 --- a/tests/runtime/test_enqueue_kernel_from_binary.c +++ b/tests/runtime/test_enqueue_kernel_from_binary.c @@ -365,20 +365,20 @@ int main(void) if(h_c1[i] != h_c2[i]) { printf("[1] Check failed at offset %d, %i instead of %i\n", i, h_c2[i], h_c1[i]); - ++errors; - if (errors > 10) exit(1); + if (++errors > 10) + return EXIT_FAILURE; } if ((((i/128)%2) && (h_c1[i]-16 != h_c3[i]))) { printf("[2] Check failed at offset %d, %i instead of %i\n", i, h_c3[i], h_c1[i]-16); - ++errors; - if (errors > 10) exit(1); + if (++errors > 10) + return EXIT_FAILURE; } if (!((i/128)%2) && (h_c1[i] != h_c3[i])) { printf("[3] Check failed at offset %d, %i instead of %i\n", i, h_c3[i], h_c1[i]); - ++errors; - if (errors > 10) exit(1); + if (++errors > 10) + return EXIT_FAILURE; } } @@ -437,5 +437,7 @@ int main(void) free (static_wg_binary); free (static_wg_buf); - return 0; + if (errors) + return EXIT_FAILURE; + return EXIT_SUCCESS; } diff --git a/tests/runtime/test_fill-buffer.c b/tests/runtime/test_fill-buffer.c index 102b6e5..02b75fc 100644 --- a/tests/runtime/test_fill-buffer.c +++ b/tests/runtime/test_fill-buffer.c @@ -113,7 +113,7 @@ main (void) { printf ("Expected value at %d: 1, actual value: %d\n", i, host_buf1[i]); - exit (1); + return EXIT_FAILURE; } } for (int i = buf_size - pattern_size; i < buf_size; i++) @@ -122,7 +122,7 @@ main (void) { printf ("Expected value at %d: 1, actual value: %d\n", i, host_buf1[i]); - exit (1); + return EXIT_FAILURE; } } for (int i = pattern_size * 2; i < buf_size - pattern_size; @@ -136,7 +136,7 @@ main (void) printf ( "Expected value at %d: %d, actual value: %d\n", i + j, expected_value, host_buf1[i + j]); - exit (1); + return EXIT_FAILURE; } } } diff --git a/tests/runtime/test_kernel_cache_includes.c b/tests/runtime/test_kernel_cache_includes.c index 246f440..d164ed7 100644 --- a/tests/runtime/test_kernel_cache_includes.c +++ b/tests/runtime/test_kernel_cache_includes.c @@ -85,5 +85,5 @@ int main(int argc, char **argv) free ((void *)krn_src); - return 0; + return EXIT_SUCCESS; } diff --git a/tests/workgroup/run_kernel.c b/tests/workgroup/run_kernel.c index 9281f7b..f8d4b95 100644 --- a/tests/workgroup/run_kernel.c +++ b/tests/workgroup/run_kernel.c @@ -150,5 +150,9 @@ ERROR: if (context) clReleaseContext (context); - return (err == CL_SUCCESS) ? 0 : 1; + if (err == CL_SUCCESS) + { + return EXIT_SUCCESS; + } + return EXIT_FAILURE; } -- 2.30.2