iPXE
pixbuf_test.h
Go to the documentation of this file.
00001 #ifndef _PIXBUF_TEST_H
00002 #define _PIXBUF_TEST_H
00003 
00004 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00005 
00006 #include <stdint.h>
00007 #include <ipxe/refcnt.h>
00008 #include <ipxe/image.h>
00009 #include <ipxe/test.h>
00010 
00011 /** A pixel buffer test */
00012 struct pixel_buffer_test {
00013         /** Image type */
00014         struct image_type *type;
00015         /** Source image */
00016         struct image *image;
00017         /** Pixel data */
00018         const uint32_t *data;
00019         /** Length of pixel data */
00020         size_t len;
00021         /** Width */
00022         unsigned int width;
00023         /** Height */
00024         unsigned int height;
00025 };
00026 
00027 /**
00028  * Define a pixel buffer test
00029  *
00030  * @v _name             Test name
00031  * @v _type             Test image file type
00032  * @v _file             Test image file data
00033  * @v _width            Expected pixel buffer width
00034  * @v _height           Expected pixel buffer height
00035  * @v _data             Expected pixel buffer data
00036  * @ret test            Pixel buffer test
00037  */
00038 #define PIX( _name, _type, _file, _width, _height, _data )              \
00039         static const char _name ## __file[] = _file;                    \
00040         static const uint32_t _name ## __data[] = _data;                \
00041         static struct image _name ## __image = {                        \
00042                 .refcnt = REF_INIT ( ref_no_free ),                     \
00043                 .name = #_name,                                         \
00044                 .data = ( userptr_t ) ( _name ## __file ),              \
00045                 .len = sizeof ( _name ## __file ),                      \
00046         };                                                              \
00047         static struct pixel_buffer_test _name = {                       \
00048                 .type = _type,                                          \
00049                 .image = & _name ## __image,                            \
00050                 .data = _name ## __data,                                \
00051                 .len = sizeof ( _name ## __data ),                      \
00052                 .width = _width,                                        \
00053                 .height = _height,                                      \
00054         };
00055 
00056 extern void pixbuf_okx ( struct pixel_buffer_test *test, const char *file,
00057                          unsigned int line );
00058 
00059 /**
00060  * Report pixel buffer test result
00061  *
00062  * @v test              Pixel buffer test
00063  */
00064 #define pixbuf_ok( test ) pixbuf_okx ( test, __FILE__, __LINE__ )
00065 
00066 #endif /* _PIXBUF_TEST_H */