2 * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 FILE_LICENCE ( GPL2_OR_LATER );
24 * Pixel buffer self-tests
28 /* Forcibly enable assertions */
32 #include <ipxe/image.h>
33 #include <ipxe/pixbuf.h>
34 #include <ipxe/test.h>
35 #include "pixbuf_test.h"
38 * Report pixel buffer test result
40 * @v test Pixel buffer test
41 * @v file Test code file
42 * @v line Test code line
44 void pixbuf_okx ( struct pixel_buffer_test *test, const char *file,
46 struct pixel_buffer *pixbuf;
50 assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
53 /* Correct image data pointer */
54 test->image->data = virt_to_user ( ( void * ) test->image->data );
56 /* Check that image is detected as PNM */
57 okx ( image_probe ( test->image ) == 0, file, line );
58 okx ( test->image->type == test->type, file, line );
60 /* Check that a pixel buffer can be created from the image */
61 okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
64 /* Check pixel buffer dimensions */
65 okx ( pixbuf->width == test->width, file, line );
66 okx ( pixbuf->height == test->height, file, line );
68 /* Check pixel buffer data */
69 okx ( pixbuf->len == test->len, file, line );
70 okx ( memcmp_user ( pixbuf->data, 0,
71 virt_to_user ( test->data ), 0,
72 test->len ) == 0, file, line );
74 pixbuf_put ( pixbuf );