diff options
author | Dave Airlie <airlied@redhat.com> | 2015-03-10 11:56:43 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2015-03-10 11:56:43 +1000 |
commit | 1f9ab04501669ba2f5adc7fd4a8e77cb0f97cd2f (patch) | |
tree | 5bedd840f916f8154f882288adfb6b1af8e35bf7 /tests | |
parent | 20e86f17714f423ae1440aca9ab4f1dc37f42dbb (diff) |
tests: do some tests for layer stride with bad texture types
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_virgl_transfer.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/test_virgl_transfer.c b/tests/test_virgl_transfer.c index 102f111..7fa6db1 100644 --- a/tests/test_virgl_transfer.c +++ b/tests/test_virgl_transfer.c @@ -372,6 +372,83 @@ START_TEST(virgl_test_transfer_1d_bad_iov_offset) } END_TEST +START_TEST(virgl_test_transfer_1d_bad_layer_stride) +{ + struct virgl_renderer_resource_create_args res; + unsigned char data[50*4]; + struct iovec iov = { .iov_base = data, .iov_len = sizeof(data) }; + int niovs = 1; + int ret; + struct virgl_box box = { .w = 50, .h = 1, .d = 1 }; + + testvirgl_init_simple_1d_resource(&res, 1); + res.target = PIPE_TEXTURE_1D; + res.depth = 1; + + ret = virgl_renderer_resource_create(&res, NULL, 0); + ck_assert_int_eq(ret, 0); + + virgl_renderer_ctx_attach_resource(1, res.handle); + + ret = virgl_renderer_transfer_write_iov(res.handle, 1, 0, 0, 50, &box, 0, &iov, niovs); + ck_assert_int_eq(ret, EINVAL); + + virgl_renderer_ctx_detach_resource(1, res.handle); + + virgl_renderer_resource_unref(1); +} +END_TEST + +START_TEST(virgl_test_transfer_2d_bad_layer_stride) +{ + struct virgl_renderer_resource_create_args res; + unsigned char data[50*4]; + struct iovec iov = { .iov_base = data, .iov_len = sizeof(data) }; + int niovs = 1; + int ret; + struct virgl_box box = { .w = 50, .h = 1, .d = 1 }; + + testvirgl_init_simple_2d_resource(&res, 1); + + ret = virgl_renderer_resource_create(&res, NULL, 0); + ck_assert_int_eq(ret, 0); + + virgl_renderer_ctx_attach_resource(1, res.handle); + + ret = virgl_renderer_transfer_write_iov(res.handle, 1, 0, 0, 50, &box, 0, &iov, niovs); + ck_assert_int_eq(ret, EINVAL); + + virgl_renderer_ctx_detach_resource(1, res.handle); + + virgl_renderer_resource_unref(1); +} +END_TEST + +START_TEST(virgl_test_transfer_buffer_bad_layer_stride) +{ + struct virgl_renderer_resource_create_args res; + unsigned char data[50*4]; + struct iovec iov = { .iov_base = data, .iov_len = sizeof(data) }; + int niovs = 1; + int ret; + struct virgl_box box = { .w = 50, .h = 1, .d = 1 }; + + testvirgl_init_simple_buffer(&res, 1); + + ret = virgl_renderer_resource_create(&res, NULL, 0); + ck_assert_int_eq(ret, 0); + + virgl_renderer_ctx_attach_resource(1, res.handle); + + ret = virgl_renderer_transfer_write_iov(res.handle, 1, 0, 0, 50, &box, 0, &iov, niovs); + ck_assert_int_eq(ret, EINVAL); + + virgl_renderer_ctx_detach_resource(1, res.handle); + + virgl_renderer_resource_unref(1); +} +END_TEST + /* for each texture type construct a valid and invalid transfer, invalid using a box outside the bounds of the transfer */ #define LARGE_FLAG_WIDTH (1 << 0) @@ -591,6 +668,9 @@ Suite *virgl_init_suite(void) tcase_add_test(tc_core, virgl_test_transfer_1d); tcase_add_test(tc_core, virgl_test_transfer_1d_bad_iov); tcase_add_test(tc_core, virgl_test_transfer_1d_bad_iov_offset); + tcase_add_test(tc_core, virgl_test_transfer_1d_bad_layer_stride); + tcase_add_test(tc_core, virgl_test_transfer_2d_bad_layer_stride); + tcase_add_test(tc_core, virgl_test_transfer_buffer_bad_layer_stride); tcase_add_loop_test(tc_core, virgl_test_transfer_res_read_valid, 0, PIPE_MAX_TEXTURE_TYPES); tcase_add_loop_test(tc_core, virgl_test_transfer_res_write_valid, 0, PIPE_MAX_TEXTURE_TYPES); |