Skip to content

Commit 06fc1aa

Browse files
johnstultz-workshuahkh
authored andcommitted
kselftests: dmabuf-heaps: Cleanup test output
Cleanup the test output so it is a bit easier to read Cc: Shuah Khan <[email protected]> Cc: Brian Starkey <[email protected]> Cc: Sumit Semwal <[email protected]> Cc: Laura Abbott <[email protected]> Cc: Hridya Valsaraju <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Sandeep Patil <[email protected]> Cc: Daniel Mentz <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: John Stultz <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 1b50e10 commit 06fc1aa

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,14 @@ static int test_alloc_and_import(char *heap_name)
148148
void *p = NULL;
149149
int ret;
150150

151-
printf("Testing heap: %s\n", heap_name);
152-
153151
heap_fd = dmabuf_heap_open(heap_name);
154152
if (heap_fd < 0)
155153
return -1;
156154

157-
printf("Allocating 1 MEG\n");
155+
printf(" Testing allocation and importing: ");
158156
ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0, &dmabuf_fd);
159157
if (ret) {
160-
printf("Allocation Failed!\n");
158+
printf("FAIL (Allocation Failed!)\n");
161159
ret = -1;
162160
goto out;
163161
}
@@ -169,11 +167,10 @@ static int test_alloc_and_import(char *heap_name)
169167
dmabuf_fd,
170168
0);
171169
if (p == MAP_FAILED) {
172-
printf("mmap() failed: %m\n");
170+
printf("FAIL (mmap() failed)\n");
173171
ret = -1;
174172
goto out;
175173
}
176-
printf("mmap passed\n");
177174

178175
dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
179176
memset(p, 1, ONE_MEG / 2);
@@ -183,33 +180,31 @@ static int test_alloc_and_import(char *heap_name)
183180
importer_fd = open_vgem();
184181
if (importer_fd < 0) {
185182
ret = importer_fd;
186-
printf("Failed to open vgem\n");
183+
printf("(Could not open vgem - skipping): ");
187184
} else {
188185
ret = import_vgem_fd(importer_fd, dmabuf_fd, &handle);
189186
if (ret < 0) {
190-
printf("Failed to import buffer\n");
187+
printf("FAIL (Failed to import buffer)\n");
191188
goto out;
192189
}
193-
printf("import passed\n");
194190
}
195191

196192
ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START);
197193
if (ret < 0) {
198-
printf("Sync start failed!\n");
194+
printf("FAIL (DMA_BUF_SYNC_START failed!)\n");
199195
goto out;
200196
}
201197

202198
memset(p, 0xff, ONE_MEG);
203199
ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END);
204200
if (ret < 0) {
205-
printf("Sync end failed!\n");
201+
printf("FAIL (DMA_BUF_SYNC_END failed!)\n");
206202
goto out;
207203
}
208-
printf("syncs passed\n");
209204

210205
close_handle(importer_fd, handle);
211206
ret = 0;
212-
207+
printf(" OK\n");
213208
out:
214209
if (p)
215210
munmap(p, ONE_MEG);
@@ -297,23 +292,24 @@ static int test_alloc_compat(char *heap_name)
297292
if (heap_fd < 0)
298293
return -1;
299294

300-
printf("Testing (theoretical)older alloc compat\n");
295+
printf(" Testing (theoretical)older alloc compat: ");
301296
ret = dmabuf_heap_alloc_older(heap_fd, ONE_MEG, 0, &dmabuf_fd);
302297
if (ret) {
303-
printf("Older compat allocation failed!\n");
298+
printf("FAIL (Older compat allocation failed!)\n");
304299
ret = -1;
305300
goto out;
306301
}
307302
close(dmabuf_fd);
303+
printf("OK\n");
308304

309-
printf("Testing (theoretical)newer alloc compat\n");
305+
printf(" Testing (theoretical)newer alloc compat: ");
310306
ret = dmabuf_heap_alloc_newer(heap_fd, ONE_MEG, 0, &dmabuf_fd);
311307
if (ret) {
312-
printf("Newer compat allocation failed!\n");
308+
printf("FAIL (Newer compat allocation failed!)\n");
313309
ret = -1;
314310
goto out;
315311
}
316-
printf("Ioctl compatibility tests passed\n");
312+
printf("OK\n");
317313
out:
318314
if (dmabuf_fd >= 0)
319315
close(dmabuf_fd);
@@ -332,30 +328,30 @@ static int test_alloc_errors(char *heap_name)
332328
if (heap_fd < 0)
333329
return -1;
334330

335-
printf("Testing expected error cases\n");
331+
printf(" Testing expected error cases: ");
336332
ret = dmabuf_heap_alloc(0, ONE_MEG, 0x111111, &dmabuf_fd);
337333
if (!ret) {
338-
printf("Did not see expected error (invalid fd)!\n");
334+
printf("FAIL (Did not see expected error (invalid fd)!)\n");
339335
ret = -1;
340336
goto out;
341337
}
342338

343339
ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0x111111, &dmabuf_fd);
344340
if (!ret) {
345-
printf("Did not see expected error (invalid heap flags)!\n");
341+
printf("FAIL (Did not see expected error (invalid heap flags)!)\n");
346342
ret = -1;
347343
goto out;
348344
}
349345

350346
ret = dmabuf_heap_alloc_fdflags(heap_fd, ONE_MEG,
351347
~(O_RDWR | O_CLOEXEC), 0, &dmabuf_fd);
352348
if (!ret) {
353-
printf("Did not see expected error (invalid fd flags)!\n");
349+
printf("FAIL (Did not see expected error (invalid fd flags)!)\n");
354350
ret = -1;
355351
goto out;
356352
}
357353

358-
printf("Expected error checking passed\n");
354+
printf("OK\n");
359355
ret = 0;
360356
out:
361357
if (dmabuf_fd >= 0)
@@ -384,6 +380,8 @@ int main(void)
384380
if (!strncmp(dir->d_name, "..", 3))
385381
continue;
386382

383+
printf("Testing heap: %s\n", dir->d_name);
384+
printf("=======================================\n");
387385
ret = test_alloc_and_import(dir->d_name);
388386
if (ret)
389387
break;

0 commit comments

Comments
 (0)