[Piglit] [PATCH] Add OpenCL test for building program with build options.
Aaron Watry
awatry at gmail.com
Thu Sep 27 07:01:51 PDT 2012
---
tests/cl/api/build-program.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/tests/cl/api/build-program.c b/tests/cl/api/build-program.c
index 470f1d4..6d5b1ad 100644
--- a/tests/cl/api/build-program.c
+++ b/tests/cl/api/build-program.c
@@ -53,6 +53,11 @@ const char* strings[] = {
"kernel void dummy_kernel() { dummy_function(); }",
};
+const char* build_options = "-D BUILD_OPT1=1 -D BUILD_OPT2=2";
+const char* kernel_with_build_options[] = {
+ "kernel void dummy_kernel(){ int var1 = BUILD_OPT1; int var2 = BUILD_OPT2; }",
+};
+
const char* invalid_strings[] = {
"kernel void dummy_kernel {}", // missing brackets intentionaly
};
@@ -98,6 +103,7 @@ piglit_cl_test(const int argc,
cl_int errNo;
cl_program program;
cl_program temp_program;
+ cl_program program_with_build_opts;
cl_kernel kernel;
/*** Normal usage ***/
@@ -126,8 +132,25 @@ piglit_cl_test(const int argc,
// TODO: test callback
- // TODO: test build options
-
+
+ /*
+ * CL_SUCCESS expected for valid program with valid build options
+ */
+ program_with_build_opts = clCreateProgramWithSource(env->context->cl_ctx,
+ 2,
+ kernel_with_build_options,
+ NULL,
+ &errNo);
+ if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+ fprintf(stderr,
+ "Failed (error code: %s): Create program with build options with source.\n",
+ piglit_cl_get_error_name(errNo));
+ return PIGLIT_FAIL;
+ }
+ test(program_with_build_opts, env->context->num_devices, env->context->device_ids, build_options,
+ NULL, NULL,
+ CL_SUCCESS, &result, "Build program with options");
+
/*** Errors ***/
/*
@@ -255,6 +278,8 @@ piglit_cl_test(const int argc,
*/
clReleaseProgram(program);
-
+ if (program_with_build_opts != NULL)
+ clReleaseProgram(program_with_build_opts);
+
return result;
}
--
1.7.9.5
More information about the Piglit
mailing list