From 8e11ab41923d0d45740c0530a8158edd354cf510 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 7 Aug 2013 18:12:20 +0200 Subject: tests/prime_self_import: Add a flink/dma-buf self-import test This checks that we really always fill the dma-buf export cache. Which sometimes we don't. Signed-off-by: Daniel Vetter --- tests/prime_self_import.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/prime_self_import.c') diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c index b8b91e72..59b550d2 100644 --- a/tests/prime_self_import.c +++ b/tests/prime_self_import.c @@ -143,6 +143,31 @@ static void test_with_two_bos(void) close(fd2); } +static void test_with_one_bo_two_files(void) +{ + int fd1, fd2; + uint32_t handle_import, handle_open, handle_orig, flink_name; + int dma_buf_fd; + + fd1 = drm_open_any(); + fd2 = drm_open_any(); + + handle_orig = gem_create(fd1, BO_SIZE); + + flink_name = gem_flink(fd1, handle_orig); + handle_open = gem_open(fd2, flink_name); + + dma_buf_fd = prime_handle_to_fd(fd2, handle_open); + handle_import = prime_fd_to_handle(fd1, dma_buf_fd); + + /* dma-buf selfimporting an flink bo should give the same handle */ + assert(handle_import == handle_open); + + close(fd1); + close(fd2); + close(dma_buf_fd); +} + static void test_with_one_bo(void) { int fd1, fd2; @@ -348,6 +373,7 @@ int main(int argc, char **argv) void (*fn)(void); } tests[] = { { "with_one_bo", test_with_one_bo }, + { "with_one_bo_two_files", test_with_one_bo_two_files }, { "with_two_bos", test_with_two_bos }, { "with_fd_dup", test_with_fd_dup }, { "export-vs-gem_close-race", test_export_close_race }, -- cgit v1.2.3