xref: /aosp_15_r20/external/OpenCL-CTS/test_conformance/allocations/testBase.h (revision 6467f958c7de8070b317fc65bcb0f6472e388d82)
1*6467f958SSadaf Ebrahimi //
2*6467f958SSadaf Ebrahimi // Copyright (c) 2017 The Khronos Group Inc.
3*6467f958SSadaf Ebrahimi //
4*6467f958SSadaf Ebrahimi // Licensed under the Apache License, Version 2.0 (the "License");
5*6467f958SSadaf Ebrahimi // you may not use this file except in compliance with the License.
6*6467f958SSadaf Ebrahimi // You may obtain a copy of the License at
7*6467f958SSadaf Ebrahimi //
8*6467f958SSadaf Ebrahimi //    http://www.apache.org/licenses/LICENSE-2.0
9*6467f958SSadaf Ebrahimi //
10*6467f958SSadaf Ebrahimi // Unless required by applicable law or agreed to in writing, software
11*6467f958SSadaf Ebrahimi // distributed under the License is distributed on an "AS IS" BASIS,
12*6467f958SSadaf Ebrahimi // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*6467f958SSadaf Ebrahimi // See the License for the specific language governing permissions and
14*6467f958SSadaf Ebrahimi // limitations under the License.
15*6467f958SSadaf Ebrahimi //
16*6467f958SSadaf Ebrahimi #ifndef _testBase_h
17*6467f958SSadaf Ebrahimi #define _testBase_h
18*6467f958SSadaf Ebrahimi 
19*6467f958SSadaf Ebrahimi #include "harness/compat.h"
20*6467f958SSadaf Ebrahimi #include <stdio.h>
21*6467f958SSadaf Ebrahimi #include <stdlib.h>
22*6467f958SSadaf Ebrahimi #include <string.h>
23*6467f958SSadaf Ebrahimi 
24*6467f958SSadaf Ebrahimi #include <sys/types.h>
25*6467f958SSadaf Ebrahimi #include <sys/stat.h>
26*6467f958SSadaf Ebrahimi 
27*6467f958SSadaf Ebrahimi #if !defined(_WIN32)
28*6467f958SSadaf Ebrahimi #include <unistd.h>
29*6467f958SSadaf Ebrahimi #endif
30*6467f958SSadaf Ebrahimi 
31*6467f958SSadaf Ebrahimi #include "harness/errorHelpers.h"
32*6467f958SSadaf Ebrahimi #include "harness/kernelHelpers.h"
33*6467f958SSadaf Ebrahimi #include "harness/typeWrappers.h"
34*6467f958SSadaf Ebrahimi #include "harness/testHarness.h"
35*6467f958SSadaf Ebrahimi 
36*6467f958SSadaf Ebrahimi 
37*6467f958SSadaf Ebrahimi #define MAX_NUMBER_TO_ALLOCATE 100
38*6467f958SSadaf Ebrahimi 
39*6467f958SSadaf Ebrahimi #define FAILED_CORRUPTED_QUEUE -2
40*6467f958SSadaf Ebrahimi #define FAILED_ABORT -1
41*6467f958SSadaf Ebrahimi #define FAILED_TOO_BIG 1
42*6467f958SSadaf Ebrahimi // On Windows macro `SUCCEEDED' is defined in `WinError.h'. It causes compiler warnings. Let us avoid them.
43*6467f958SSadaf Ebrahimi #if defined( _WIN32 ) && defined( SUCCEEDED )
44*6467f958SSadaf Ebrahimi     #undef SUCCEEDED
45*6467f958SSadaf Ebrahimi #endif
46*6467f958SSadaf Ebrahimi #define SUCCEEDED 0
47*6467f958SSadaf Ebrahimi 
48*6467f958SSadaf Ebrahimi enum AllocType
49*6467f958SSadaf Ebrahimi {
50*6467f958SSadaf Ebrahimi     BUFFER,
51*6467f958SSadaf Ebrahimi     IMAGE_READ,
52*6467f958SSadaf Ebrahimi     IMAGE_WRITE,
53*6467f958SSadaf Ebrahimi     BUFFER_NON_BLOCKING,
54*6467f958SSadaf Ebrahimi     IMAGE_READ_NON_BLOCKING,
55*6467f958SSadaf Ebrahimi     IMAGE_WRITE_NON_BLOCKING,
56*6467f958SSadaf Ebrahimi };
57*6467f958SSadaf Ebrahimi 
58*6467f958SSadaf Ebrahimi #define test_error_abort(errCode,msg)    test_error_ret_abort(errCode,msg,errCode)
59*6467f958SSadaf Ebrahimi #define test_error_ret_abort(errCode,msg,retValue)    { if( errCode != CL_SUCCESS ) { print_error( errCode, msg ); return FAILED_ABORT ; } }
60*6467f958SSadaf Ebrahimi 
61*6467f958SSadaf Ebrahimi 
62*6467f958SSadaf Ebrahimi #endif // _testBase_h
63*6467f958SSadaf Ebrahimi 
64*6467f958SSadaf Ebrahimi 
65*6467f958SSadaf Ebrahimi 
66