[Piglit] [PATCH 1/2] cl: make use of subtest for clGetKernelArgInfo

Serge Martin edb+piglit at sigluy.net
Sun Nov 27 13:54:23 UTC 2016


also fix wording and remove a comment
---
 tests/cl/api/get-kernel-arg-info.c | 49 ++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/tests/cl/api/get-kernel-arg-info.c b/tests/cl/api/get-kernel-arg-info.c
index 7b34724..7b336e4 100644
--- a/tests/cl/api/get-kernel-arg-info.c
+++ b/tests/cl/api/get-kernel-arg-info.c
@@ -53,6 +53,12 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
 
 PIGLIT_CL_API_TEST_CONFIG_END
 
+static void
+set_failure(enum piglit_result *result, const char* sub_name)
+{
+	piglit_merge_result(result, PIGLIT_FAIL);
+	piglit_report_subtest_result(PIGLIT_FAIL, "%s", sub_name);
+}
 
 enum piglit_result
 piglit_cl_test(const int argc,
@@ -88,7 +94,8 @@ piglit_cl_test(const int argc,
 
 	/*** Normal usage ***/
 	for(i = 0; i < num_kernel_arg_infos; ++i) {
-		printf("%s\n", piglit_cl_get_enum_name(kernel_arg_infos[i]));
+		const char* enum_name = piglit_cl_get_enum_name(kernel_arg_infos[i]);
+		printf("%s\n", enum_name);
 
 		param_value_size = 0;
 		ret_value_size = 0;
@@ -102,16 +109,15 @@ piglit_cl_test(const int argc,
 		if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
 			fprintf(stderr,
 			        "Failed (error code: %s): Get size of %s.\n",
-			        piglit_cl_get_error_name(errNo),
-			        piglit_cl_get_enum_name(kernel_arg_infos[i]));
-			piglit_merge_result(&result, PIGLIT_FAIL);
+			        piglit_cl_get_error_name(errNo), enum_name);
+			set_failure(&result, enum_name);
 			continue;
 		}
 
 		if (param_value_size > BUFFER_SIZE) {
 			fprintf(stderr,
-			        "Failed: BUFFER_SIZE is too low\n");
-			piglit_merge_result(&result, PIGLIT_FAIL);
+			        "Failed: BUFFER_SIZE is too small\n");
+			set_failure(&result, enum_name);
 			continue;
 		}
 
@@ -124,16 +130,15 @@ piglit_cl_test(const int argc,
 		if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
 			fprintf(stderr,
 			        "Failed (error code: %s): Get value of %s.\n",
-			        piglit_cl_get_error_name(errNo),
-			        piglit_cl_get_enum_name(kernel_arg_infos[i]));
-			piglit_merge_result(&result, PIGLIT_FAIL);
+			        piglit_cl_get_error_name(errNo), enum_name);
+			set_failure(&result, enum_name);
 			continue;
 		}
 
 		if (param_value_size != ret_value_size) {
 			fprintf(stderr,
 			        "Failed: the returned size doesn't matches the queried one\n");
-			piglit_merge_result(&result, PIGLIT_FAIL);
+			set_failure(&result, enum_name);
 			continue;
 		}
 
@@ -160,13 +165,17 @@ piglit_cl_test(const int argc,
 			fprintf(stderr,
 			        "Failed: the returned size doesn't matches. Expected %lu, got %lu\n",
 			        expected_size, ret_value_size);
-		piglit_merge_result(&result, PIGLIT_FAIL);
+			set_failure(&result, enum_name);
+			continue;
 		}
 
-	//TODO: test returned values
+		//TODO: test returned values
+
+		piglit_report_subtest_result(PIGLIT_PASS, "%s", enum_name);
 	}
 
 	/*** Errors ***/
+	enum piglit_result input_check_result = PIGLIT_PASS;
 
 	/*
 	* CL_INVALID_ARG_INDEX if arg_indx is not a valid argument index.
@@ -181,7 +190,7 @@ piglit_cl_test(const int argc,
 		fprintf(stderr,
 		        "Failed (error code: %s): Trigger CL_INVALID_ARG_INDEX if arg_indx is not a valid argument index.\n",
 		        piglit_cl_get_error_name(errNo));
-	piglit_merge_result(&result, PIGLIT_FAIL);
+		piglit_merge_result(&input_check_result, PIGLIT_FAIL);
 	}
 
 	/*
@@ -200,7 +209,7 @@ piglit_cl_test(const int argc,
 		fprintf(stderr,
 		        "Failed (error code: %s): Trigger CL_INVALID_VALUE if param_name is not one of the supported values.\n",
 		        piglit_cl_get_error_name(errNo));
-	piglit_merge_result(&result, PIGLIT_FAIL);
+		piglit_merge_result(&input_check_result, PIGLIT_FAIL);
 	}
 
 	errNo = clGetKernelArgInfo(kernel,
@@ -213,16 +222,13 @@ piglit_cl_test(const int argc,
 		fprintf(stderr,
 		        "Failed (error code: %s): Trigger CL_INVALID_VALUE if size in bytes specified by param_value is less than size of return type and param_value is not a NULL value.\n",
 	           piglit_cl_get_error_name(errNo));
-	piglit_merge_result(&result, PIGLIT_FAIL);
+		piglit_merge_result(&input_check_result, PIGLIT_FAIL);
 	}
 
 	/*
 	* CL_KERNEL_ARG_INFO_NOT_AVAILABLE
 	* if the argument information is not available for kernel.
 	*/
-	/*
-	* Note that PoCL, AMD and Intel libs always return arg info.
-	*/
 	{
 	char* strings[] = { "kernel void dummy_kernel(int param_a) {}" };
 
@@ -242,7 +248,7 @@ piglit_cl_test(const int argc,
 		fprintf(stderr,
 	           "Failed (error code: %s): Trigger CL_KERNEL_ARG_INFO_NOT_AVAILABLE if the argument information is not available for kernel.\n",
 	           piglit_cl_get_error_name(errNo));
-	piglit_merge_result(&result, PIGLIT_FAIL);
+		piglit_merge_result(&input_check_result, PIGLIT_FAIL);
 	}
 
 	clReleaseKernel(kern);
@@ -262,9 +268,12 @@ piglit_cl_test(const int argc,
 		fprintf(stderr,
 		        "Failed (error code: %s): Trigger CL_INVALID_KERNEL if kernel is not a valid kernel object.\n",
 		        piglit_cl_get_error_name(errNo));
-	piglit_merge_result(&result, PIGLIT_FAIL);
+		piglit_merge_result(&input_check_result, PIGLIT_FAIL);
 	}
 
+	piglit_report_subtest_result(input_check_result, "Input checks");
+	piglit_merge_result(&result, input_check_result);
+
 	clReleaseKernel(kernel);
 
 	return result;
-- 
2.5.5



More information about the Piglit mailing list