|
@@ -243,36 +243,43 @@ PNM ( ppm_binary,
|
243
|
243
|
* Report PNM test result
|
244
|
244
|
*
|
245
|
245
|
* @v test PNM test
|
|
246
|
+ * @v file Test code file
|
|
247
|
+ * @v line Test code line
|
246
|
248
|
*/
|
247
|
|
-#define pnm_ok( test ) do { \
|
248
|
|
- struct pixel_buffer *pixbuf; \
|
249
|
|
- uint8_t data[ (test)->len ]; \
|
250
|
|
- int rc; \
|
251
|
|
- \
|
252
|
|
- /* Sanity check */ \
|
253
|
|
- assert ( ( (test)->width * (test)->height * \
|
254
|
|
- sizeof ( (test)->data[0] ) ) == (test)->len ); \
|
255
|
|
- \
|
256
|
|
- /* Correct image data pointer */ \
|
257
|
|
- (test)->image->data = \
|
258
|
|
- virt_to_user ( ( void * ) (test)->image->data ); \
|
259
|
|
- \
|
260
|
|
- /* Perform tests */ \
|
261
|
|
- ok ( image_probe ( (test)->image ) == 0 ); \
|
262
|
|
- ok ( (test)->image->type == &pnm_image_type ); \
|
263
|
|
- ok ( ( rc = image_pixbuf ( (test)->image, &pixbuf ) ) == 0 ); \
|
264
|
|
- if ( rc == 0 ) { \
|
265
|
|
- ok ( pixbuf->width == (test)->width ); \
|
266
|
|
- ok ( pixbuf->height == (test)->height ); \
|
267
|
|
- ok ( pixbuf->len == (test)->len ); \
|
268
|
|
- copy_from_user ( data, pixbuf->data, 0, \
|
269
|
|
- sizeof ( data ) ); \
|
270
|
|
- ok ( memcmp ( data, (test)->data, \
|
271
|
|
- sizeof ( data ) ) == 0 ); \
|
272
|
|
- DBGC_HDA ( (test)->image, 0, data, sizeof ( data ) ); \
|
273
|
|
- pixbuf_put ( pixbuf ); \
|
274
|
|
- } \
|
275
|
|
- } while ( 0 )
|
|
249
|
+static void pnm_okx ( struct pnm_test *test, const char *file,
|
|
250
|
+ unsigned int line ) {
|
|
251
|
+ struct pixel_buffer *pixbuf;
|
|
252
|
+ int rc;
|
|
253
|
+
|
|
254
|
+ /* Sanity check */
|
|
255
|
+ assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
|
|
256
|
+ == test->len );
|
|
257
|
+
|
|
258
|
+ /* Correct image data pointer */
|
|
259
|
+ test->image->data = virt_to_user ( ( void * ) test->image->data );
|
|
260
|
+
|
|
261
|
+ /* Check that image is detected as PNM */
|
|
262
|
+ okx ( image_probe ( test->image ) == 0, file, line );
|
|
263
|
+ okx ( test->image->type == &pnm_image_type, file, line );
|
|
264
|
+
|
|
265
|
+ /* Check that a pixel buffer can be created from the image */
|
|
266
|
+ okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
|
|
267
|
+ if ( rc == 0 ) {
|
|
268
|
+
|
|
269
|
+ /* Check pixel buffer dimensions */
|
|
270
|
+ okx ( pixbuf->width == test->width, file, line );
|
|
271
|
+ okx ( pixbuf->height == test->height, file, line );
|
|
272
|
+
|
|
273
|
+ /* Check pixel buffer data */
|
|
274
|
+ okx ( pixbuf->len == test->len, file, line );
|
|
275
|
+ okx ( memcmp_user ( pixbuf->data, 0,
|
|
276
|
+ virt_to_user ( test->data ), 0,
|
|
277
|
+ test->len ) == 0, file, line );
|
|
278
|
+
|
|
279
|
+ pixbuf_put ( pixbuf );
|
|
280
|
+ }
|
|
281
|
+}
|
|
282
|
+#define pnm_ok( test ) pnm_okx ( test, __FILE__, __LINE__ )
|
276
|
283
|
|
277
|
284
|
/**
|
278
|
285
|
* Perform PNM self-test
|