@@ -148,16 +148,14 @@ static int test_alloc_and_import(char *heap_name)
148
148
void * p = NULL ;
149
149
int ret ;
150
150
151
- printf ("Testing heap: %s\n" , heap_name );
152
-
153
151
heap_fd = dmabuf_heap_open (heap_name );
154
152
if (heap_fd < 0 )
155
153
return -1 ;
156
154
157
- printf ("Allocating 1 MEG\n " );
155
+ printf (" Testing allocation and importing: " );
158
156
ret = dmabuf_heap_alloc (heap_fd , ONE_MEG , 0 , & dmabuf_fd );
159
157
if (ret ) {
160
- printf ("Allocation Failed!\n" );
158
+ printf ("FAIL ( Allocation Failed!) \n" );
161
159
ret = -1 ;
162
160
goto out ;
163
161
}
@@ -169,11 +167,10 @@ static int test_alloc_and_import(char *heap_name)
169
167
dmabuf_fd ,
170
168
0 );
171
169
if (p == MAP_FAILED ) {
172
- printf ("mmap() failed: %m \n" );
170
+ printf ("FAIL ( mmap() failed) \n" );
173
171
ret = -1 ;
174
172
goto out ;
175
173
}
176
- printf ("mmap passed\n" );
177
174
178
175
dmabuf_sync (dmabuf_fd , DMA_BUF_SYNC_START );
179
176
memset (p , 1 , ONE_MEG / 2 );
@@ -183,33 +180,31 @@ static int test_alloc_and_import(char *heap_name)
183
180
importer_fd = open_vgem ();
184
181
if (importer_fd < 0 ) {
185
182
ret = importer_fd ;
186
- printf ("Failed to open vgem\n " );
183
+ printf ("(Could not open vgem - skipping): " );
187
184
} else {
188
185
ret = import_vgem_fd (importer_fd , dmabuf_fd , & handle );
189
186
if (ret < 0 ) {
190
- printf ("Failed to import buffer\n" );
187
+ printf ("FAIL ( Failed to import buffer) \n" );
191
188
goto out ;
192
189
}
193
- printf ("import passed\n" );
194
190
}
195
191
196
192
ret = dmabuf_sync (dmabuf_fd , DMA_BUF_SYNC_START );
197
193
if (ret < 0 ) {
198
- printf ("Sync start failed!\n" );
194
+ printf ("FAIL (DMA_BUF_SYNC_START failed!) \n" );
199
195
goto out ;
200
196
}
201
197
202
198
memset (p , 0xff , ONE_MEG );
203
199
ret = dmabuf_sync (dmabuf_fd , DMA_BUF_SYNC_END );
204
200
if (ret < 0 ) {
205
- printf ("Sync end failed!\n" );
201
+ printf ("FAIL (DMA_BUF_SYNC_END failed!) \n" );
206
202
goto out ;
207
203
}
208
- printf ("syncs passed\n" );
209
204
210
205
close_handle (importer_fd , handle );
211
206
ret = 0 ;
212
-
207
+ printf ( " OK\n" );
213
208
out :
214
209
if (p )
215
210
munmap (p , ONE_MEG );
@@ -297,23 +292,24 @@ static int test_alloc_compat(char *heap_name)
297
292
if (heap_fd < 0 )
298
293
return -1 ;
299
294
300
- printf ("Testing (theoretical)older alloc compat\n " );
295
+ printf (" Testing (theoretical)older alloc compat: " );
301
296
ret = dmabuf_heap_alloc_older (heap_fd , ONE_MEG , 0 , & dmabuf_fd );
302
297
if (ret ) {
303
- printf ("Older compat allocation failed!\n" );
298
+ printf ("FAIL ( Older compat allocation failed!) \n" );
304
299
ret = -1 ;
305
300
goto out ;
306
301
}
307
302
close (dmabuf_fd );
303
+ printf ("OK\n" );
308
304
309
- printf ("Testing (theoretical)newer alloc compat\n " );
305
+ printf (" Testing (theoretical)newer alloc compat: " );
310
306
ret = dmabuf_heap_alloc_newer (heap_fd , ONE_MEG , 0 , & dmabuf_fd );
311
307
if (ret ) {
312
- printf ("Newer compat allocation failed!\n" );
308
+ printf ("FAIL ( Newer compat allocation failed!) \n" );
313
309
ret = -1 ;
314
310
goto out ;
315
311
}
316
- printf ("Ioctl compatibility tests passed \n" );
312
+ printf ("OK \n" );
317
313
out :
318
314
if (dmabuf_fd >= 0 )
319
315
close (dmabuf_fd );
@@ -332,30 +328,30 @@ static int test_alloc_errors(char *heap_name)
332
328
if (heap_fd < 0 )
333
329
return -1 ;
334
330
335
- printf ("Testing expected error cases\n " );
331
+ printf (" Testing expected error cases: " );
336
332
ret = dmabuf_heap_alloc (0 , ONE_MEG , 0x111111 , & dmabuf_fd );
337
333
if (!ret ) {
338
- printf ("Did not see expected error (invalid fd)!\n" );
334
+ printf ("FAIL ( Did not see expected error (invalid fd)!) \n" );
339
335
ret = -1 ;
340
336
goto out ;
341
337
}
342
338
343
339
ret = dmabuf_heap_alloc (heap_fd , ONE_MEG , 0x111111 , & dmabuf_fd );
344
340
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" );
346
342
ret = -1 ;
347
343
goto out ;
348
344
}
349
345
350
346
ret = dmabuf_heap_alloc_fdflags (heap_fd , ONE_MEG ,
351
347
~(O_RDWR | O_CLOEXEC ), 0 , & dmabuf_fd );
352
348
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" );
354
350
ret = -1 ;
355
351
goto out ;
356
352
}
357
353
358
- printf ("Expected error checking passed \n" );
354
+ printf ("OK \n" );
359
355
ret = 0 ;
360
356
out :
361
357
if (dmabuf_fd >= 0 )
@@ -384,6 +380,8 @@ int main(void)
384
380
if (!strncmp (dir -> d_name , ".." , 3 ))
385
381
continue ;
386
382
383
+ printf ("Testing heap: %s\n" , dir -> d_name );
384
+ printf ("=======================================\n" );
387
385
ret = test_alloc_and_import (dir -> d_name );
388
386
if (ret )
389
387
break ;
0 commit comments