On Sat, 2015-09-12 at 13:18 +0200, Serge Martin wrote:
> ---
> tests/cl/api/get-mem-object-info.c | 285
> -
> 1 file changed, 246 insertions(+), 39 deletions(-)
>
> diff --git a/tests/cl/api/get-mem-object-info.c b/tests/cl/api/get
> -mem-object-info.c
> index c24b51d..2db3b6a 100644
> --- a/tests/cl/api/get-mem-object-info.c
> +++ b/tests/cl/api/get-mem-object-info.c
> @@ -46,6 +46,142 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
>
> PIGLIT_CL_API_TEST_CONFIG_END
>
> +#define BUFFER_SIZE 512
> +
> +static enum piglit_result
> +test_get_value(cl_mem memobj,
> + cl_mem_info param_name,
> + size_t *param_value_size,
> + void **param_value) {
> + cl_int errNo;
> +
> + errNo = clGetMemObjectInfo(memobj,
> +param_name,
> +0,
> +NULL,
> +param_value_size);
> + 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(param_name));
> + *param_value = NULL;
> + return PIGLIT_FAIL;
> + }
> +
> + *param_value = malloc(*param_value_size);
> + errNo = clGetMemObjectInfo(memobj,
> +param_name,
> +*param_value_size,
> +*param_value,
> +NULL);
> + 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(param_name));
> + free(*param_value);
> + *param_value = NULL;
> + return PIGLIT_FAIL;
> + }
> +
> + return PIGLIT_PASS;
> +}
> +
> +static enum piglit_result
> +test(int n,
> + cl_mem memobj,
> + cl_mem_info param_name,
> + cl_mem_object_type mem_type,
> + cl_mem_flags mem_flags,
> + size_t mem_size,
> + void *mem_ptr,
> + const struct piglit_cl_api_test_env *env,
> + cl_mem mem_parent,
> + size_t mem_offset) {
> + size_t param_value_size;
> + void* param_value;
> +
> + if (test_get_value(memobj,
> +param_name,
> +¶m_value_size,
> +¶m_value) != PIGLIT_PASS) {
> + fprintf(stderr,
> + "Buffer %d, test_get_value() failed.\n", n);
> + return PIGLIT_FAIL;
> + }
> +
> +#define CHECK_SIZE(_type_) \
> + if (param_value_size != sizeof(_type_)) { \
> + fprintf(stderr, \
> + "Buffer %d, failed: the returned size
> doesn't match. Expected %lu, got %lu\n", \
> + n, sizeof(_type_), param_value_size); \
> + return PIGLIT_FAIL; \
> + }
> +
> +#define CHECK_VALUE(_type_, _value_) \
> + if (*(_type_*)param_value != _value_) { \
> + fprintf(stderr, \
> + "Buffer %d, failed: the returned value
> doesn't match.\n", \
> + n); \
> + return PIGLIT_FAIL; \
> + }
> +
> + switch (param_name) {
> + case CL_MEM_TYPE:
> + CHECK_SIZE(cl_mem_object_type)
> + CHECK_VALUE(cl_mem_object_type, mem_type)
> + break;
> + case CL_MEM_FLAGS:
> + CHECK_SIZE(cl_mem_flags)
> + CHECK_VALUE(cl_mem_flags, mem_flags)
> + break;
> + case CL_MEM_SIZE:
> + CHECK_SIZE(size_t)
> + CHECK_VALUE(size_t, mem_size)
> + break;
> + case CL_MEM_HOST_PTR:
> + CHECK_SIZE(void *)
> + CHECK_VALUE(void *, mem_ptr)
> + break;
> + case CL_MEM_MAP_COUNT:
> + CHECK_SIZE(cl_uint)
> + //stale
> + break;
> + case CL_MEM_REFERENCE_COUNT:
> + CHECK_SIZE(cl_uint)
> + //stale
> + break;
> + case CL_MEM_CONTEXT:
> + CHECK_SIZE(cl_context)
> + CHECK_VALUE(cl_context, env->context
> ->cl_ctx)
> + break;
> +#if defined(CL_VERSION_1_1)
> + case CL_MEM_ASSOCIATED_MEMOBJECT:
> + if (env->version >= 11) {
> + CHECK_SIZE(cl_mem)
> + CHECK_VALUE(cl_mem, mem_parent)
> + }
> + break;
> + case CL_MEM_OFFSET:
> + if (env->version >= 11)