tests: start adding a reuseable test library

Initial function is just a simple resource create for a 1D resource
macos/master
Dave Airlie 10 years ago
parent 797dfc028b
commit 8e391a0b86
  1. 6
      tests/Makefile.am
  2. 25
      tests/test_virgl_init.c
  3. 21
      tests/testvirgl.c
  4. 8
      tests/testvirgl.h

@ -1,11 +1,13 @@
if BUILD_TESTS
AM_CPPFLAGS = -I$(top_srcdir)/src $(CHECK_CFLAGS)
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/gallium/include $(CHECK_CFLAGS)
TEST_LIBS = $(top_builddir)/src/libvirglrenderer.la $(CHECK_LIBS)
TEST_LIBS = libvrtest.la $(top_builddir)/src/libvirglrenderer.la $(CHECK_LIBS)
run_tests = test_virgl_init
noinst_LTLIBRARIES = libvrtest.la
libvrtest_la_SOURCES = testvirgl.c
noinst_PROGRAMS = $(run_tests)
TESTS = $(run_tests)

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <virglrenderer.h>
#include "testvirgl.h"
struct myinfo_struct {
uint32_t test;
};
@ -88,17 +89,7 @@ START_TEST(virgl_init_egl_create_ctx_create_bind_res)
ret = virgl_renderer_context_create(1, strlen("test1"), "test1");
ck_assert_int_eq(ret, 0);
res.handle = 1;
res.target = 1;
res.format = 2;
res.width = 50;
res.height = 50;
res.depth = 1;
res.array_size = 1;
res.last_level = 0;
res.nr_samples = 0;
res.bind = 0;
res.flags = 0;
testvirgl_init_simple_1d_resource(&res, 1);
ret = virgl_renderer_resource_create(&res, NULL, 0);
ck_assert_int_eq(ret, 0);
@ -124,17 +115,7 @@ START_TEST(virgl_init_egl_create_ctx_create_bind_res_leak)
ret = virgl_renderer_context_create(1, strlen("test1"), "test1");
ck_assert_int_eq(ret, 0);
res.handle = 1;
res.target = 1;
res.format = 2;
res.width = 50;
res.height = 50;
res.depth = 1;
res.array_size = 1;
res.last_level = 0;
res.nr_samples = 0;
res.bind = 0;
res.flags = 0;
testvirgl_init_simple_1d_resource(&res, 1);
ret = virgl_renderer_resource_create(&res, NULL, 0);
ck_assert_int_eq(ret, 0);

@ -0,0 +1,21 @@
/* helper functions for testing purposes */
#include "pipe/p_defines.h"
#include "pipe/p_format.h"
#include "testvirgl.h"
#include "virglrenderer.h"
void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_args *res, int handle)
{
res->handle = handle;
res->target = PIPE_TEXTURE_1D;
res->format = PIPE_FORMAT_B8G8R8X8_UNORM;
res->width = 50;
res->height = 50;
res->depth = 1;
res->array_size = 1;
res->last_level = 0;
res->nr_samples = 0;
res->bind = PIPE_BIND_SAMPLER_VIEW;
res->flags = 0;
}

@ -0,0 +1,8 @@
#ifndef TESTVIRGL_H
#define TESTVIRGL_H
#include "virglrenderer.h"
void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_args *args, int handle);
#endif
Loading…
Cancel
Save