From 159dafe1a1e225ee6783f1bc1cca2fd8f8dadd28 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 4 Feb 2015 14:21:37 +1000 Subject: [PATCH] tests: add some tests for illegal attach/detach --- tests/test_virgl_init.c | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/test_virgl_init.c b/tests/test_virgl_init.c index 0949105..e1b7a81 100644 --- a/tests/test_virgl_init.c +++ b/tests/test_virgl_init.c @@ -135,6 +135,55 @@ START_TEST(virgl_init_egl_create_ctx_create_bind_res) } END_TEST +START_TEST(virgl_init_egl_create_ctx_create_bind_res_illegal_ctx) +{ + int ret; + struct virgl_renderer_resource_create_args res; + + test_cbs.version = 1; + ret = virgl_renderer_init(&mystruct, VIRGL_RENDERER_USE_EGL, &test_cbs); + ck_assert_int_eq(ret, 0); + ret = virgl_renderer_context_create(1, strlen("test1"), "test1"); + ck_assert_int_eq(ret, 0); + + testvirgl_init_simple_1d_resource(&res, 1); + + ret = virgl_renderer_resource_create(&res, NULL, 0); + ck_assert_int_eq(ret, 0); + + virgl_renderer_ctx_attach_resource(2, res.handle); + + virgl_renderer_resource_unref(1); + virgl_renderer_context_destroy(1); + virgl_renderer_cleanup(&mystruct); +} +END_TEST + + +START_TEST(virgl_init_egl_create_ctx_create_bind_res_illegal_res) +{ + int ret; + struct virgl_renderer_resource_create_args res; + + test_cbs.version = 1; + ret = virgl_renderer_init(&mystruct, VIRGL_RENDERER_USE_EGL, &test_cbs); + ck_assert_int_eq(ret, 0); + ret = virgl_renderer_context_create(1, strlen("test1"), "test1"); + ck_assert_int_eq(ret, 0); + + testvirgl_init_simple_1d_resource(&res, 1); + + ret = virgl_renderer_resource_create(&res, NULL, 0); + ck_assert_int_eq(ret, 0); + + virgl_renderer_ctx_attach_resource(1, 2); + + virgl_renderer_resource_unref(1); + virgl_renderer_context_destroy(1); + virgl_renderer_cleanup(&mystruct); +} +END_TEST + START_TEST(virgl_init_egl_create_ctx_create_unbind_no_bind) { int ret; @@ -159,6 +208,31 @@ START_TEST(virgl_init_egl_create_ctx_create_unbind_no_bind) } END_TEST +START_TEST(virgl_init_egl_create_ctx_create_unbind_illegal_ctx) +{ + int ret; + struct virgl_renderer_resource_create_args res; + + test_cbs.version = 1; + ret = virgl_renderer_init(&mystruct, VIRGL_RENDERER_USE_EGL, &test_cbs); + ck_assert_int_eq(ret, 0); + ret = virgl_renderer_context_create(1, strlen("test1"), "test1"); + ck_assert_int_eq(ret, 0); + + testvirgl_init_simple_1d_resource(&res, 1); + + ret = virgl_renderer_resource_create(&res, NULL, 0); + ck_assert_int_eq(ret, 0); + + virgl_renderer_ctx_detach_resource(2, res.handle); + + virgl_renderer_resource_unref(1); + virgl_renderer_context_destroy(1); + virgl_renderer_cleanup(&mystruct); +} +END_TEST + + START_TEST(virgl_init_egl_create_ctx_create_bind_res_leak) { int ret; @@ -340,7 +414,10 @@ Suite *virgl_init_suite(void) tcase_add_test(tc_core, virgl_init_egl_create_ctx); tcase_add_test(tc_core, virgl_init_egl_create_ctx_leak); tcase_add_test(tc_core, virgl_init_egl_create_ctx_create_bind_res); + tcase_add_test(tc_core, virgl_init_egl_create_ctx_create_bind_res_illegal_ctx); + tcase_add_test(tc_core, virgl_init_egl_create_ctx_create_bind_res_illegal_res); tcase_add_test(tc_core, virgl_init_egl_create_ctx_create_unbind_no_bind); + tcase_add_test(tc_core, virgl_init_egl_create_ctx_create_unbind_illegal_ctx); tcase_add_test(tc_core, virgl_init_egl_create_ctx_create_bind_res_leak); tcase_add_test(tc_core, virgl_init_egl_create_ctx_reset); tcase_add_test(tc_core, virgl_init_get_caps_set0);