diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-07 18:12:20 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-07 18:13:48 +0200 |
commit | 8e11ab41923d0d45740c0530a8158edd354cf510 (patch) | |
tree | 4fd9efc542433edc40d98bc4f7081b3f3b20bd5e /tests/prime_self_import.c | |
parent | e7c4fde8c1827783e8cd1ff17945c710f44b8723 (diff) |
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 <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/prime_self_import.c')
-rw-r--r-- | tests/prime_self_import.c | 26 |
1 files changed, 26 insertions, 0 deletions
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 }, |