iPXE
pixbuf_test.h
Go to the documentation of this file.
1#ifndef _PIXBUF_TEST_H
2#define _PIXBUF_TEST_H
3
4FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
5
6#include <stdint.h>
7#include <ipxe/refcnt.h>
8#include <ipxe/image.h>
9#include <ipxe/test.h>
10
11/** A pixel buffer test */
13 /** Image type */
15 /** Source image */
16 struct image *image;
17 /** Pixel data */
18 const uint32_t *data;
19 /** Length of pixel data */
20 size_t len;
21 /** Width */
22 unsigned int width;
23 /** Height */
24 unsigned int height;
25};
26
27/**
28 * Define a pixel buffer test
29 *
30 * @v _name Test name
31 * @v _type Test image file type
32 * @v _file Test image file data
33 * @v _width Expected pixel buffer width
34 * @v _height Expected pixel buffer height
35 * @v _data Expected pixel buffer data
36 * @ret test Pixel buffer test
37 */
38#define PIX( _name, _type, _file, _width, _height, _data ) \
39 static const char _name ## __raw[] = _file; \
40 static const char _name ## __file \
41 [ sizeof ( _name ## __raw ) + 1 /* NUL */ ] = _file; \
42 static const uint32_t _name ## __data[] = _data; \
43 static struct image _name ## __image = { \
44 .refcnt = REF_INIT ( ref_no_free ), \
45 .name = #_name, \
46 .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \
47 .data = _name ## __file, \
48 .len = ( sizeof ( _name ## __file ) - 1 /* NUL */ ), \
49 }; \
50 static struct pixel_buffer_test _name = { \
51 .type = _type, \
52 .image = & _name ## __image, \
53 .data = _name ## __data, \
54 .len = sizeof ( _name ## __data ), \
55 .width = _width, \
56 .height = _height, \
57 };
58
59extern void pixbuf_okx ( struct pixel_buffer_test *test, const char *file,
60 unsigned int line );
61
62/**
63 * Report pixel buffer test result
64 *
65 * @v test Pixel buffer test
66 */
67#define pixbuf_ok( test ) pixbuf_okx ( test, __FILE__, __LINE__ )
68
69#endif /* _PIXBUF_TEST_H */
unsigned int uint32_t
Definition stdint.h:12
static int test
Definition epic100.c:73
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
Executable images.
void pixbuf_okx(struct pixel_buffer_test *test, const char *file, unsigned int line)
Report pixel buffer test result.
Definition pixbuf_test.c:49
Reference counting.
An executable image type.
Definition image.h:102
A pixel buffer test.
Definition pixbuf_test.h:12
struct image * image
Source image.
Definition pixbuf_test.h:16
unsigned int width
Width.
Definition pixbuf_test.h:22
const uint32_t * data
Pixel data.
Definition pixbuf_test.h:18
unsigned int height
Height.
Definition pixbuf_test.h:24
size_t len
Length of pixel data.
Definition pixbuf_test.h:20
struct image_type * type
Image type.
Definition pixbuf_test.h:14
Self-test infrastructure.