[Piglit] [PATCH] cl: fix invalid platform test in create-context

Serge Martin (EdB) edb+piglit at sigluy.net
Fri Aug 14 12:05:48 PDT 2015


OpenCL objects are just pointers in the end, using random pointer value
is likely to make an application crash.
Also, all others tests use NULL as an invalid object.

See also Francisco Jerez comments:
http://lists.freedesktop.org/archives/mesa-dev/2014-November/070520.html
http://lists.freedesktop.org/archives/mesa-dev/2013-October/046830.html
---
 tests/cl/api/create-context.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/tests/cl/api/create-context.c b/tests/cl/api/create-context.c
index f4929f0..551f8a2 100644
--- a/tests/cl/api/create-context.c
+++ b/tests/cl/api/create-context.c
@@ -139,7 +139,7 @@ piglit_cl_test(const int argc,
 	bool found_invalid_platform = false;
 	cl_platform_id* platform_ids;
 	unsigned int num_platform_ids;
-	cl_platform_id invalid_platform_id;
+	cl_platform_id invalid_platform_id = NULL;
 
 	//TODO: test also CL_CONTEXT_INTEROP_USER_SYNC
 	cl_context_properties context_properties[] = {
@@ -160,20 +160,6 @@ piglit_cl_test(const int argc,
 		0
 	};
 
-	/* Find invalid platform_id */
-	invalid_platform_id = 0;
-	num_platform_ids = piglit_cl_get_platform_ids(&platform_ids);
-	while(!found_invalid_platform) {
-		found_invalid_platform = true;
-		invalid_platform_id = (cl_platform_id)1;
-		for(i = 0; i < num_platform_ids; i++) {
-			if(invalid_platform_id == platform_ids[i]) {
-				found_invalid_platform = false;
-				break;
-			}
-		}
-	}
-	free(platform_ids);
 	invalid_platform_context_properties[1] =
 		(cl_context_properties)invalid_platform_id;
 
-- 
2.5.0



More information about the Piglit mailing list