utests: fix issue of CL_PROGRAM_BINARY_SIZES query

Submitted by Guo Yejun on July 25, 2016, 11:59 p.m.

Details

Message ID 1469491182-10616-1-git-send-email-yejun.guo@intel.com
State New
Headers show
Series "utests: fix issue of CL_PROGRAM_BINARY_SIZES query" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Guo Yejun July 25, 2016, 11:59 p.m.
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@intel.com>
---
 utests/get_cl_info.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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))));