diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-07-23 10:06:25 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-07-23 10:06:25 +0200 |
commit | 5d9e22366b37b725358d22dbee47e094f7157974 (patch) | |
tree | 3d0b4aa58c93fc727de70768ef6b17ab28158ae5 | |
parent | 796f6193c9697e0ae57970a8c48cc9bb3a69877d (diff) |
tests/prime: more paranoia
- check the old contents first in check_bo
- drop all GEM handles for the re-import test
-rw-r--r-- | tests/prime_self_import.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c index 20b2ada9..36514363 100644 --- a/tests/prime_self_import.c +++ b/tests/prime_self_import.c @@ -53,19 +53,26 @@ check_bo(int fd1, uint32_t handle1, int fd2, uint32_t handle2) { char *ptr1, *ptr2; static char counter = 0; + int i; ptr1 = gem_mmap(fd1, handle1, BO_SIZE, PROT_READ | PROT_WRITE); ptr2 = gem_mmap(fd2, handle2, BO_SIZE, PROT_READ | PROT_WRITE); assert(ptr1); + /* check whether it's still our old object first. */ + for (i = 0; i < BO_SIZE; i++) { + assert(ptr1[i] == 0); + assert(ptr2[i] == 0); + } + + counter++; + memset(ptr1, counter, BO_SIZE); assert(memcmp(ptr1, ptr2, BO_SIZE) == 0); munmap(ptr1, BO_SIZE); munmap(ptr2, BO_SIZE); - - counter++; } int main(int argc, char **argv) @@ -102,7 +109,10 @@ int main(int argc, char **argv) /* re-import into old exporter */ dma_buf_fd = prime_handle_to_fd(fd2, handle_import1); + /* but drop all references to the obj in between */ + gem_close(fd2, handle_import1); handle = prime_fd_to_handle(fd1, dma_buf_fd); + handle_import1 = prime_fd_to_handle(fd2, dma_buf_fd); check_bo(fd1, handle, fd2, handle_import1); /* Completely rip out exporting fd. */ |