Commit 06fc1aae authored by John Stultz's avatar John Stultz Committed by Shuah Khan

kselftests: dmabuf-heaps: Cleanup test output

Cleanup the test output so it is a bit easier to read

Cc: Shuah Khan <shuah@kernel.org>
Cc: Brian Starkey <brian.starkey@arm.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Laura Abbott <labbott@kernel.org>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sandeep Patil <sspatil@google.com>
Cc: Daniel Mentz <danielmentz@google.com>
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kselftest@vger.kernel.org
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 1b50e10e
...@@ -148,16 +148,14 @@ static int test_alloc_and_import(char *heap_name) ...@@ -148,16 +148,14 @@ static int test_alloc_and_import(char *heap_name)
void *p = NULL; void *p = NULL;
int ret; int ret;
printf("Testing heap: %s\n", heap_name);
heap_fd = dmabuf_heap_open(heap_name); heap_fd = dmabuf_heap_open(heap_name);
if (heap_fd < 0) if (heap_fd < 0)
return -1; return -1;
printf("Allocating 1 MEG\n"); printf(" Testing allocation and importing: ");
ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0, &dmabuf_fd); ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0, &dmabuf_fd);
if (ret) { if (ret) {
printf("Allocation Failed!\n"); printf("FAIL (Allocation Failed!)\n");
ret = -1; ret = -1;
goto out; goto out;
} }
...@@ -169,11 +167,10 @@ static int test_alloc_and_import(char *heap_name) ...@@ -169,11 +167,10 @@ static int test_alloc_and_import(char *heap_name)
dmabuf_fd, dmabuf_fd,
0); 0);
if (p == MAP_FAILED) { if (p == MAP_FAILED) {
printf("mmap() failed: %m\n"); printf("FAIL (mmap() failed)\n");
ret = -1; ret = -1;
goto out; goto out;
} }
printf("mmap passed\n");
dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
memset(p, 1, ONE_MEG / 2); memset(p, 1, ONE_MEG / 2);
...@@ -183,33 +180,31 @@ static int test_alloc_and_import(char *heap_name) ...@@ -183,33 +180,31 @@ static int test_alloc_and_import(char *heap_name)
importer_fd = open_vgem(); importer_fd = open_vgem();
if (importer_fd < 0) { if (importer_fd < 0) {
ret = importer_fd; ret = importer_fd;
printf("Failed to open vgem\n"); printf("(Could not open vgem - skipping): ");
} else { } else {
ret = import_vgem_fd(importer_fd, dmabuf_fd, &handle); ret = import_vgem_fd(importer_fd, dmabuf_fd, &handle);
if (ret < 0) { if (ret < 0) {
printf("Failed to import buffer\n"); printf("FAIL (Failed to import buffer)\n");
goto out; goto out;
} }
printf("import passed\n");
} }
ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
if (ret < 0) { if (ret < 0) {
printf("Sync start failed!\n"); printf("FAIL (DMA_BUF_SYNC_START failed!)\n");
goto out; goto out;
} }
memset(p, 0xff, ONE_MEG); memset(p, 0xff, ONE_MEG);
ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END); ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END);
if (ret < 0) { if (ret < 0) {
printf("Sync end failed!\n"); printf("FAIL (DMA_BUF_SYNC_END failed!)\n");
goto out; goto out;
} }
printf("syncs passed\n");
close_handle(importer_fd, handle); close_handle(importer_fd, handle);
ret = 0; ret = 0;
printf(" OK\n");
out: out:
if (p) if (p)
munmap(p, ONE_MEG); munmap(p, ONE_MEG);
...@@ -297,23 +292,24 @@ static int test_alloc_compat(char *heap_name) ...@@ -297,23 +292,24 @@ static int test_alloc_compat(char *heap_name)
if (heap_fd < 0) if (heap_fd < 0)
return -1; return -1;
printf("Testing (theoretical)older alloc compat\n"); printf(" Testing (theoretical)older alloc compat: ");
ret = dmabuf_heap_alloc_older(heap_fd, ONE_MEG, 0, &dmabuf_fd); ret = dmabuf_heap_alloc_older(heap_fd, ONE_MEG, 0, &dmabuf_fd);
if (ret) { if (ret) {
printf("Older compat allocation failed!\n"); printf("FAIL (Older compat allocation failed!)\n");
ret = -1; ret = -1;
goto out; goto out;
} }
close(dmabuf_fd); close(dmabuf_fd);
printf("OK\n");
printf("Testing (theoretical)newer alloc compat\n"); printf(" Testing (theoretical)newer alloc compat: ");
ret = dmabuf_heap_alloc_newer(heap_fd, ONE_MEG, 0, &dmabuf_fd); ret = dmabuf_heap_alloc_newer(heap_fd, ONE_MEG, 0, &dmabuf_fd);
if (ret) { if (ret) {
printf("Newer compat allocation failed!\n"); printf("FAIL (Newer compat allocation failed!)\n");
ret = -1; ret = -1;
goto out; goto out;
} }
printf("Ioctl compatibility tests passed\n"); printf("OK\n");
out: out:
if (dmabuf_fd >= 0) if (dmabuf_fd >= 0)
close(dmabuf_fd); close(dmabuf_fd);
...@@ -332,17 +328,17 @@ static int test_alloc_errors(char *heap_name) ...@@ -332,17 +328,17 @@ static int test_alloc_errors(char *heap_name)
if (heap_fd < 0) if (heap_fd < 0)
return -1; return -1;
printf("Testing expected error cases\n"); printf(" Testing expected error cases: ");
ret = dmabuf_heap_alloc(0, ONE_MEG, 0x111111, &dmabuf_fd); ret = dmabuf_heap_alloc(0, ONE_MEG, 0x111111, &dmabuf_fd);
if (!ret) { if (!ret) {
printf("Did not see expected error (invalid fd)!\n"); printf("FAIL (Did not see expected error (invalid fd)!)\n");
ret = -1; ret = -1;
goto out; goto out;
} }
ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0x111111, &dmabuf_fd); ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0x111111, &dmabuf_fd);
if (!ret) { if (!ret) {
printf("Did not see expected error (invalid heap flags)!\n"); printf("FAIL (Did not see expected error (invalid heap flags)!)\n");
ret = -1; ret = -1;
goto out; goto out;
} }
...@@ -350,12 +346,12 @@ static int test_alloc_errors(char *heap_name) ...@@ -350,12 +346,12 @@ static int test_alloc_errors(char *heap_name)
ret = dmabuf_heap_alloc_fdflags(heap_fd, ONE_MEG, ret = dmabuf_heap_alloc_fdflags(heap_fd, ONE_MEG,
~(O_RDWR | O_CLOEXEC), 0, &dmabuf_fd); ~(O_RDWR | O_CLOEXEC), 0, &dmabuf_fd);
if (!ret) { if (!ret) {
printf("Did not see expected error (invalid fd flags)!\n"); printf("FAIL (Did not see expected error (invalid fd flags)!)\n");
ret = -1; ret = -1;
goto out; goto out;
} }
printf("Expected error checking passed\n"); printf("OK\n");
ret = 0; ret = 0;
out: out:
if (dmabuf_fd >= 0) if (dmabuf_fd >= 0)
...@@ -384,6 +380,8 @@ int main(void) ...@@ -384,6 +380,8 @@ int main(void)
if (!strncmp(dir->d_name, "..", 3)) if (!strncmp(dir->d_name, "..", 3))
continue; continue;
printf("Testing heap: %s\n", dir->d_name);
printf("=======================================\n");
ret = test_alloc_and_import(dir->d_name); ret = test_alloc_and_import(dir->d_name);
if (ret) if (ret)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment