tests: add simple buffer test

macos/master
Dave Airlie 10 years ago
parent bf8a951c1e
commit 2c32b28002
  1. 31
      tests/test_virgl_resource.c
  2. 15
      tests/testvirgl.c
  3. 1
      tests/testvirgl.h

@ -35,6 +35,25 @@
#include "testvirgl.h"
#include "pipe/p_defines.h"
/* create a buffer */
START_TEST(virgl_res_create_buffer)
{
int ret;
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_buffer(&res, 1);
ret = virgl_renderer_resource_create(&res, NULL, 0);
ck_assert_int_eq(ret, 0);
testvirgl_fini_single_ctx();
}
END_TEST
/* create a 1D texture */
START_TEST(virgl_res_create_1d)
{
@ -42,6 +61,7 @@ START_TEST(virgl_res_create_1d)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
@ -59,6 +79,7 @@ START_TEST(virgl_res_create_1d_with_height)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
@ -77,6 +98,7 @@ START_TEST(virgl_res_create_1d_with_depth)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
@ -95,6 +117,7 @@ START_TEST(virgl_res_create_1d_array)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
res.target = PIPE_TEXTURE_1D_ARRAY;
@ -113,6 +136,7 @@ START_TEST(virgl_res_create_1d_array_with_height)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
res.target = PIPE_TEXTURE_1D_ARRAY;
@ -132,6 +156,7 @@ START_TEST(virgl_res_create_1d_array_with_depth)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
res.target = PIPE_TEXTURE_1D_ARRAY;
@ -151,9 +176,9 @@ START_TEST(virgl_res_create_2d)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_2d_resource(&res, 1);
ret = virgl_renderer_resource_create(&res, NULL, 0);
ck_assert_int_eq(ret, 0);
@ -168,6 +193,7 @@ START_TEST(virgl_res_create_2d_with_depth)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
@ -186,6 +212,7 @@ START_TEST(virgl_res_create_2d_array)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_2d_resource(&res, 1);
res.target = PIPE_TEXTURE_2D_ARRAY;
@ -205,6 +232,7 @@ START_TEST(virgl_res_create_2d_array_with_depth)
struct virgl_renderer_resource_create_args res;
ret = testvirgl_init_single_ctx();
ck_assert_int_eq(ret, 0);
testvirgl_init_simple_1d_resource(&res, 1);
res.target = PIPE_TEXTURE_2D_ARRAY;
@ -226,6 +254,7 @@ Suite *virgl_init_suite(void)
s = suite_create("virgl_resource");
tc_core = tcase_create("resource");
tcase_add_test(tc_core, virgl_res_create_buffer);
tcase_add_test(tc_core, virgl_res_create_1d);
tcase_add_test(tc_core, virgl_res_create_1d_with_height);
tcase_add_test(tc_core, virgl_res_create_1d_with_depth);

@ -44,6 +44,21 @@ void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_arg
res->flags = 0;
}
void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *res, int handle)
{
res->handle = handle;
res->target = PIPE_BUFFER;
res->format = PIPE_FORMAT_R8_UNORM;
res->width = 50;
res->height = 1;
res->depth = 1;
res->array_size = 1;
res->last_level = 0;
res->nr_samples = 0;
res->bind = 0;
res->flags = 0;
}
void testvirgl_init_simple_2d_resource(struct virgl_renderer_resource_create_args *res, int handle)
{
res->handle = handle;

@ -27,6 +27,7 @@
#include "virglrenderer.h"
void testvirgl_init_simple_buffer(struct virgl_renderer_resource_create_args *res, int handle);
void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_args *args, int handle);
void testvirgl_init_simple_2d_resource(struct virgl_renderer_resource_create_args *res, int handle);
int testvirgl_init_single_ctx(void);

Loading…
Cancel
Save