tests: add framework to create a context with a command buffer.

macos/master
Dave Airlie 10 years ago
parent 688017b73f
commit 94946a6ea6
  1. 32
      tests/testvirgl.c
  2. 3
      tests/testvirgl.h

@ -24,8 +24,10 @@
/* helper functions for testing purposes */
#include <check.h>
#include <errno.h>
#include "pipe/p_defines.h"
#include "pipe/p_format.h"
#include "util/u_memory.h"
#include "testvirgl.h"
#include "virglrenderer.h"
@ -109,3 +111,33 @@ void testvirgl_fini_single_ctx(void)
virgl_renderer_context_destroy(1);
virgl_renderer_cleanup(&mystruct);
}
int testvirgl_init_ctx_cmdbuf(struct virgl_context *ctx)
{
int ret;
ret = testvirgl_init_single_ctx();
if (ret)
return ret;
ctx->ctx_id = 1;
ctx->cbuf = CALLOC_STRUCT(virgl_cmd_buf);
if (!ctx->cbuf) {
testvirgl_fini_single_ctx();
return ENOMEM;
}
ctx->cbuf->buf = CALLOC(1, VIRGL_MAX_CMDBUF_DWORDS);
if (!ctx->cbuf->buf) {
FREE(ctx->cbuf);
testvirgl_fini_single_ctx();
return ENOMEM;
}
return 0;
}
void testvirgl_fini_ctx_cmdbuf(struct virgl_context *ctx)
{
FREE(ctx->cbuf->buf);
FREE(ctx->cbuf);
testvirgl_fini_single_ctx();
}

@ -37,6 +37,7 @@ struct virgl_cmd_buf {
struct virgl_context {
struct virgl_cmd_buf *cbuf;
int ctx_id;
};
struct virgl_so_target {
@ -59,4 +60,6 @@ int testvirgl_init_single_ctx(void);
void testvirgl_init_single_ctx_nr(void);
void testvirgl_fini_single_ctx(void);
int testvirgl_init_ctx_cmdbuf(struct virgl_context *ctx);
void testvirgl_fini_ctx_cmdbuf(struct virgl_context *ctx);
#endif

Loading…
Cancel
Save