david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[test] Rewrite pnm_ok() using okx()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2014-01-06 18:58:46 +01:00
parent fffd98bd37
commit da7224f9b6
1 changed files with 36 additions and 29 deletions

View File

@ -243,36 +243,43 @@ PNM ( ppm_binary,
* Report PNM test result * Report PNM test result
* *
* @v test PNM test * @v test PNM test
* @v file Test code file
* @v line Test code line
*/ */
#define pnm_ok( test ) do { \ static void pnm_okx ( struct pnm_test *test, const char *file,
struct pixel_buffer *pixbuf; \ unsigned int line ) {
uint8_t data[ (test)->len ]; \ struct pixel_buffer *pixbuf;
int rc; \ int rc;
\
/* Sanity check */ \ /* Sanity check */
assert ( ( (test)->width * (test)->height * \ assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
sizeof ( (test)->data[0] ) ) == (test)->len ); \ == test->len );
\
/* Correct image data pointer */ \ /* Correct image data pointer */
(test)->image->data = \ test->image->data = virt_to_user ( ( void * ) test->image->data );
virt_to_user ( ( void * ) (test)->image->data ); \
\ /* Check that image is detected as PNM */
/* Perform tests */ \ okx ( image_probe ( test->image ) == 0, file, line );
ok ( image_probe ( (test)->image ) == 0 ); \ okx ( test->image->type == &pnm_image_type, file, line );
ok ( (test)->image->type == &pnm_image_type ); \
ok ( ( rc = image_pixbuf ( (test)->image, &pixbuf ) ) == 0 ); \ /* Check that a pixel buffer can be created from the image */
if ( rc == 0 ) { \ okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
ok ( pixbuf->width == (test)->width ); \ if ( rc == 0 ) {
ok ( pixbuf->height == (test)->height ); \
ok ( pixbuf->len == (test)->len ); \ /* Check pixel buffer dimensions */
copy_from_user ( data, pixbuf->data, 0, \ okx ( pixbuf->width == test->width, file, line );
sizeof ( data ) ); \ okx ( pixbuf->height == test->height, file, line );
ok ( memcmp ( data, (test)->data, \
sizeof ( data ) ) == 0 ); \ /* Check pixel buffer data */
DBGC_HDA ( (test)->image, 0, data, sizeof ( data ) ); \ okx ( pixbuf->len == test->len, file, line );
pixbuf_put ( pixbuf ); \ okx ( memcmp_user ( pixbuf->data, 0,
} \ virt_to_user ( test->data ), 0,
} while ( 0 ) test->len ) == 0, file, line );
pixbuf_put ( pixbuf );
}
}
#define pnm_ok( test ) pnm_okx ( test, __FILE__, __LINE__ )
/** /**
* Perform PNM self-test * Perform PNM self-test