1 /**************************************************************************
2  *
3  * Copyright (C) 2014 Red Hat Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22  *
23  **************************************************************************/
24 
25 /*
26  * resource tests
27  * test illegal resource combinations
28  - 1D resources with height or depth
29  - 2D with depth
30 */
31 #include <check.h>
32 #include <stdlib.h>
33 #include <errno.h>
34 #include <virglrenderer.h>
35 #include "virgl_hw.h"
36 #include "testvirgl.h"
37 
38 #include "pipe/p_defines.h"
39 #include "pipe/p_format.h"
40 
41 #ifndef ARRAY_SIZE
42 #  define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
43 #endif
44 
45 struct res_test {
46     struct virgl_renderer_resource_create_args args;
47     int retval;
48 };
49 
50 #define TEST(thandle, ttarget, tformat, tbind, twidth, theight, tdepth, tarray_size, tnr_samples, tretval) \
51   { .args = { .handle = (thandle),					\
52 	      .target = (ttarget),					\
53 	      .format = (tformat),					\
54 	      .bind = (tbind),						\
55 	      .width = (twidth),					\
56 	      .height = (theight),					\
57 	      .depth = (tdepth),					\
58 	      .array_size = (tarray_size),				\
59 	      .last_level = 0,						\
60 	      .nr_samples = (tnr_samples),				\
61 	      .flags = 0 },					\
62       .retval = (tretval)}
63 
64 #define TEST_MIP(thandle, ttarget, tformat, tbind, twidth, theight, tdepth, tarray_size, tnr_samples, tlast_level, tretval) \
65   { .args = { .handle = (thandle),					\
66 	      .target = (ttarget),					\
67 	      .format = (tformat),					\
68 	      .bind = (tbind),						\
69 	      .width = (twidth),					\
70 	      .height = (theight),					\
71 	      .depth = (tdepth),					\
72 	      .array_size = (tarray_size),				\
73 	      .last_level = (tlast_level),				\
74 	      .nr_samples = (tnr_samples),				\
75 	      .flags = 0 },					\
76       .retval = (tretval)}
77 
78 #define TEST_F(thandle, ttarget, tformat, tbind, twidth, theight, tdepth, tarray_size, tnr_samples, tflags, tretval) \
79   { .args = { .handle = (thandle),					\
80 	      .target = (ttarget),					\
81 	      .format = (tformat),					\
82 	      .bind = (tbind),						\
83 	      .width = (twidth),					\
84 	      .height = (theight),					\
85 	      .depth = (tdepth),					\
86 	      .array_size = (tarray_size),				\
87 	      .nr_samples = (tnr_samples),				\
88 	      .flags = (tflags) },					\
89       .retval = (tretval)}
90 
91 
92 static struct res_test testlist[] = {
93 
94   /* illegal target - FAIL */
95   TEST(1, PIPE_MAX_TEXTURE_TYPES + 1, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 0, EINVAL),
96 
97   /* illegal format - FAIL */
98   TEST(1, PIPE_BUFFER, PIPE_FORMAT_COUNT + 1, 0, 50, 1, 1, 1, 0, EINVAL),
99 
100   /* legal flags - PASS */
101   TEST_F(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, 0),
102   /* legal flags - PASS */
103   TEST_F(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, 0),
104   /* illegal flags - FAIL */
105   TEST_F(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0xF, EINVAL),
106   /* illegal flags - FAIL */
107   TEST_F(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, EINVAL),
108   /* illegal flags - FAIL */
109   TEST_F(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, VIRGL_RESOURCE_Y_0_TOP, EINVAL),
110 
111   /* buffer test - PASS */
112   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 0, 0),
113   /* buffer test with height - FAIL */
114   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 50, 1, 1, 0, EINVAL),
115   /* buffer test with depth - FAIL */
116   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 5, 1, 0, EINVAL),
117   /* buffer test with array - FAIL */
118   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 4, 0, EINVAL),
119   /* buffer test with samples - FAIL */
120   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 4, EINVAL),
121   /* buffer test with miplevels - FAIL */
122   TEST_MIP(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 1, 4, EINVAL),
123 
124   /* buffer test - sampler view */
125   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
126   /* buffer test - custom binding */
127   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_CUSTOM, 50, 1, 1, 1, 0, 0),
128   /* buffer test - vertex binding */
129   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_VERTEX_BUFFER, 50, 1, 1, 1, 0, 0),
130   /* buffer test - index binding */
131   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_INDEX_BUFFER, 50, 1, 1, 1, 0, 0),
132   /* buffer test - constant binding */
133   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_CONSTANT_BUFFER, 50, 1, 1, 1, 0, 0),
134   /* buffer test - stream binding */
135   TEST(1, PIPE_BUFFER, PIPE_FORMAT_R8_UNORM, PIPE_BIND_STREAM_OUTPUT, 50, 1, 1, 1, 0, 0),
136 
137   /* 1D test - stream binding - FAIL */
138   TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_R8_UNORM, PIPE_BIND_VERTEX_BUFFER, 50, 1, 1, 1, 0, EINVAL),
139   /* 1D test - no binding - FAIL */
140   TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_R8_UNORM, 0, 50, 1, 1, 1, 0, EINVAL),
141 
142   /* 1D texture - PASS */
143   TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
144   /* 1D texture with height - FAIL */
145   TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, EINVAL),
146   /* 1D texture with depth - FAIL */
147   TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
148   /* 1D texture with array - FAIL */
149   TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
150   /* 1D texture with samples - FAIL */
151   TEST(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
152   /* 1D texture with miplevels - PASS */
153   TEST_MIP(1, PIPE_TEXTURE_1D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 1, 4, 0),
154 
155   /* 1D array texture - PASS */
156   TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
157   /* 1D array texture with height - FAIL */
158   TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, EINVAL),
159   /* 1D texture with depth - FAIL */
160   TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
161   /* 1D texture with array - PASS */
162   TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, 0),
163   /* 1D texture with samples - FAIL */
164   TEST(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
165   /* 1D array texture with miplevels - PASS */
166   TEST_MIP(1, PIPE_TEXTURE_1D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 1, 4, 0),
167 
168   /* 2D texture - PASS */
169   TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
170   TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_CURSOR, 50, 50, 1, 1, 0, 0),
171   /* 2D texture with height - PASS */
172   TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
173   /* 2D texture with depth - FAIL */
174   TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
175   /* 2D texture with array - FAIL */
176   TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
177   /* 2D texture with samples - PASS */
178   TEST(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 0),
179   /* 2D texture with miplevels - PASS */
180   TEST_MIP(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 1, 4, 0),
181   /* 2D texture with samples and miplevels - FAIL */
182   TEST_MIP(1, PIPE_TEXTURE_2D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 4, EINVAL),
183 
184   /* RECT texture - PASS */
185   TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
186   /* RECT texture with height - PASS */
187   TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
188   /* RECT texture with depth - FAIL */
189   TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
190   /* RECT texture with array - FAIL */
191   TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
192   /* RECT texture with samples - FAIL */
193   TEST(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
194   /* RECT texture with miplevels - FAIL */
195   TEST_MIP(1, PIPE_TEXTURE_RECT, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 1, 4, EINVAL),
196 
197   /* 2D texture array - PASS */
198   TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
199   /* 2D texture with height - PASS */
200   TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
201   /* 2D texture with depth - FAIL */
202   TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, EINVAL),
203   /* 2D texture with array - FAIL */
204   TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, 0),
205   /* 2D texture with samples - PASS */
206   TEST(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 0),
207   /* 2D texture with miplevels - PASS */
208   TEST_MIP(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 1, 4, 0),
209   /* 2D texture with samplesmiplevels - FAIL */
210   TEST_MIP(1, PIPE_TEXTURE_2D_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, 4, EINVAL),
211 
212   /* 3D texture - PASS */
213   TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, 0),
214   /* 3D texture with height - PASS */
215   TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 1, 0, 0),
216   /* 3D texture with depth - PASS */
217   TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 1, 0, 0),
218   /* 3D texture with array - FAIL */
219   TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 5, 0, EINVAL),
220   /* 3D texture with samples - FAIL */
221   TEST(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 4, EINVAL),
222   /* 3D texture with miplevels - PASS */
223   TEST_MIP(1, PIPE_TEXTURE_3D, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 1, 4, 0),
224 
225   /* CUBE texture with array size == 6 - PASS */
226   TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 6, 0, 0),
227   /* CUBE texture with array size != 6 - FAIL */
228   TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 1, 0, EINVAL),
229   /* CUBE texture with height - PASS */
230   TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 6, 0, 0),
231   /* CUBE texture with depth - FAIL */
232   TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 5, 6, 0, EINVAL),
233   /* CUBE texture with samples - FAIL */
234   TEST(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 6, 4, EINVAL),
235   /* CUBE texture with miplevels - PASS */
236   TEST_MIP(1, PIPE_TEXTURE_CUBE, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 6, 1, 4, 0),
237 };
238 
239 /* separate since these may fail on a GL that doesn't support cube map arrays */
240 static struct res_test cubemaparray_testlist[] = {
241   /* CUBE array with array size = 6 - PASS */
242   TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 6, 1, 0),
243   /* CUBE array with array size = 12 - PASS */
244   TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 12, 1, 0),
245   /* CUBE array with array size = 10 - FAIL */
246   TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 1, 1, 10, 1, EINVAL),
247   /* CUBE array with array size = 12 and height - PASS */
248   TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 12, 1, 0),
249   /* CUBE array with array size = 12 and depth - FAIL */
250   TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 5, 12, 1, EINVAL),
251   /* CUBE array with array size = 12 and samples - FAIL */
252   TEST(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 12, 4, EINVAL),
253   /* CUBE array with array size = 12 and miplevels - PASS */
254   TEST_MIP(1, PIPE_TEXTURE_CUBE_ARRAY, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_BIND_SAMPLER_VIEW, 50, 50, 1, 12, 1, 4, 0),
255 };
256 
START_TEST(virgl_res_tests)257 START_TEST(virgl_res_tests)
258 {
259   int ret;
260   ret = testvirgl_init_single_ctx();
261   ck_assert_int_eq(ret, 0);
262 
263   /* Do not test if multisample is not available */
264   unsigned multisample = testvirgl_get_multisample_from_caps();
265   if (!multisample) {
266     testvirgl_fini_single_ctx();
267     return;
268   }
269 
270   ret = virgl_renderer_resource_create(&testlist[_i].args, NULL, 0);
271   ck_assert_int_eq(ret, testlist[_i].retval);
272 
273   testvirgl_fini_single_ctx();
274 }
275 END_TEST
276 
START_TEST(cubemaparray_res_tests)277 START_TEST(cubemaparray_res_tests)
278 {
279   int ret;
280   ret = testvirgl_init_single_ctx();
281   ck_assert_int_eq(ret, 0);
282 
283   ret = virgl_renderer_resource_create(&cubemaparray_testlist[_i].args, NULL, 0);
284   ck_assert_int_eq(ret, cubemaparray_testlist[_i].retval);
285 
286   testvirgl_fini_single_ctx();
287 }
288 END_TEST
289 
virgl_init_suite(void)290 static Suite *virgl_init_suite(void)
291 {
292   Suite *s;
293   TCase *tc_core;
294 
295   s = suite_create("virgl_resource");
296   tc_core = tcase_create("resource");
297 
298   tcase_add_loop_test(tc_core, virgl_res_tests, 0, ARRAY_SIZE(testlist));
299   tcase_add_loop_test(tc_core, cubemaparray_res_tests, 0, ARRAY_SIZE(cubemaparray_testlist));
300   suite_add_tcase(s, tc_core);
301   return s;
302 
303 }
304 
305 
main(void)306 int main(void)
307 {
308   Suite *s;
309   SRunner *sr;
310   int number_failed;
311 
312   s = virgl_init_suite();
313   sr = srunner_create(s);
314 
315   srunner_run_all(sr, CK_NORMAL);
316   number_failed = srunner_ntests_failed(sr);
317   srunner_free(sr);
318 
319   return number_failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
320 }
321