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
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
28 * Pixel buffer self-tests
32 /* Forcibly enable assertions */
36 #include <ipxe/image.h>
37 #include <ipxe/pixbuf.h>
38 #include <ipxe/test.h>
39 #include "pixbuf_test.h"
42 * Report pixel buffer test result
44 * @v test Pixel buffer test
45 * @v file Test code file
46 * @v line Test code line
48 void pixbuf_okx ( struct pixel_buffer_test *test, const char *file,
50 struct pixel_buffer *pixbuf;
54 assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
57 /* Correct image data pointer */
58 test->image->data = virt_to_user ( ( void * ) test->image->data );
60 /* Check that image is detected as correct type */
61 okx ( register_image ( test->image ) == 0, file, line );
62 okx ( test->image->type == test->type, file, line );
64 /* Check that a pixel buffer can be created from the image */
65 okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
68 /* Check pixel buffer dimensions */
69 okx ( pixbuf->width == test->width, file, line );
70 okx ( pixbuf->height == test->height, file, line );
72 /* Check pixel buffer data */
73 okx ( pixbuf->len == test->len, file, line );
74 okx ( memcmp_user ( pixbuf->data, 0,
75 virt_to_user ( test->data ), 0,
76 test->len ) == 0, file, line );
78 pixbuf_put ( pixbuf );
81 /* Unregister image */
82 unregister_image ( test->image );