[Beignet] [PATCH] utests: fix issue of CL_PROGRAM_BINARY_SIZES query

Guo Yejun yejun.guo at intel.com
Mon Jul 25 23:59:42 UTC 2016


the return type of CL_PROGRAM_BINARY_SIZES query is unsigned char*[],
and param_value_size must be >= size of the return type, see spec 1.2
section 5.6.7 (P151)

Signed-off-by: Guo Yejun <yejun.guo at intel.com>
---
 utests/get_cl_info.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/utests/get_cl_info.cpp b/utests/get_cl_info.cpp
index bdd7e0c..afdf8ca 100644
--- a/utests/get_cl_info.cpp
+++ b/utests/get_cl_info.cpp
@@ -78,9 +78,11 @@ struct Info_Result<char **> {
     int *elt_size;
     int size;
     typedef char** type_value;
+    int array_size;
 
     Info_Result(char **other, int *sz, int elt_num) {
-        size = elt_num;
+        array_size = elt_num;
+        size = elt_num * sizeof(char**);
 
         ret = (char **)malloc(elt_num * sizeof(char *));
         memset(ret, 0, (elt_num * sizeof(char *)));
@@ -106,7 +108,7 @@ struct Info_Result<char **> {
 
     ~Info_Result(void) {
         int i = 0;
-        for (; i < size; i++) {
+        for (; i < array_size; i++) {
             if (refer[i])
                 free(refer[i]);
             free(ret[i]);
@@ -122,7 +124,7 @@ struct Info_Result<char **> {
 
     bool check_result (void) {
         int i = 0;
-        for (; i < size; i++) {
+        for (; i < array_size; i++) {
             if (refer[i] && ::memcmp(ret[i], refer[i], elt_size[i]))
                 return false;
         }
@@ -222,7 +224,7 @@ void get_program_info(void)
     expect_value = NO_STANDARD_REF;
     maps.insert(make_pair(CL_PROGRAM_BINARY_SIZES,
                           (void *)(new Info_Result<size_t>((size_t)expect_value))));
-    sz = 4096; //big enough?
+    sz = 8192; //big enough?
     expect_source = NULL;
     maps.insert(make_pair(CL_PROGRAM_BINARIES,
                           (void *)(new Info_Result<char **>(&expect_source, &sz, 1))));
-- 
1.9.1



More information about the Beignet mailing list