iPXE
pixbuf_test.h File Reference
#include <stdint.h>
#include <ipxe/refcnt.h>
#include <ipxe/image.h>
#include <ipxe/test.h>

Go to the source code of this file.

Data Structures

struct  pixel_buffer_test
 A pixel buffer test. More...

Macros

#define PIX(_name, _type, _file, _width, _height, _data)
 Define a pixel buffer test.
#define pixbuf_ok(test)
 Report pixel buffer test result.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
void pixbuf_okx (struct pixel_buffer_test *test, const char *file, unsigned int line)
 Report pixel buffer test result.

Macro Definition Documentation

◆ PIX

#define PIX ( _name,
_type,
_file,
_width,
_height,
_data )
Value:
static const char _name ## __file[] = _file; \
static const uint32_t _name ## __data[] = _data; \
static struct image _name ## __image = { \
.refcnt = REF_INIT ( ref_no_free ), \
.name = #_name, \
.flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \
.data = _name ## __file, \
.len = sizeof ( _name ## __file ), \
}; \
static struct pixel_buffer_test _name = { \
.type = _type, \
.image = & _name ## __image, \
.data = _name ## __data, \
.len = sizeof ( _name ## __data ), \
.width = _width, \
.height = _height, \
};
unsigned int uint32_t
Definition stdint.h:12
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define IMAGE_STATIC_NAME
Image name is statically allocated.
Definition image.h:92
#define IMAGE_STATIC
Image is statically allocated.
Definition image.h:89
void ref_no_free(struct refcnt *refcnt __unused)
Do not free reference-counted object.
Definition refcnt.c:102
#define REF_INIT(free_fn)
Initialise a static reference counter.
Definition refcnt.h:78
An executable image.
Definition image.h:24
const void * data
Read-only data.
Definition image.h:51
A pixel buffer test.
Definition pixbuf_test.h:12
size_t len
Length of pixel data.
Definition pixbuf_test.h:20

Define a pixel buffer test.

Parameters
_nameTest name
_typeTest image file type
_fileTest image file data
_widthExpected pixel buffer width
_heightExpected pixel buffer height
_dataExpected pixel buffer data
Return values
testPixel buffer test

Definition at line 38 of file pixbuf_test.h.

38#define PIX( _name, _type, _file, _width, _height, _data ) \
39 static const char _name ## __file[] = _file; \
40 static const uint32_t _name ## __data[] = _data; \
41 static struct image _name ## __image = { \
42 .refcnt = REF_INIT ( ref_no_free ), \
43 .name = #_name, \
44 .flags = ( IMAGE_STATIC | IMAGE_STATIC_NAME ), \
45 .data = _name ## __file, \
46 .len = sizeof ( _name ## __file ), \
47 }; \
48 static struct pixel_buffer_test _name = { \
49 .type = _type, \
50 .image = & _name ## __image, \
51 .data = _name ## __data, \
52 .len = sizeof ( _name ## __data ), \
53 .width = _width, \
54 .height = _height, \
55 };

◆ pixbuf_ok

#define pixbuf_ok ( test)
Value:
pixbuf_okx ( test, __FILE__, __LINE__ )
static int test
Definition epic100.c:73
void pixbuf_okx(struct pixel_buffer_test *test, const char *file, unsigned int line)
Report pixel buffer test result.
Definition pixbuf_test.c:49

Report pixel buffer test result.

Parameters
testPixel buffer test

Definition at line 65 of file pixbuf_test.h.

Referenced by png_test_exec(), and pnm_test_exec().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ pixbuf_okx()

void pixbuf_okx ( struct pixel_buffer_test * test,
const char * file,
unsigned int line )
extern

Report pixel buffer test result.

Parameters
testPixel buffer test
fileTest code file
lineTest code line

Definition at line 49 of file pixbuf_test.c.

50 {
51 struct pixel_buffer *pixbuf;
52 int rc;
53
54 /* Sanity check */
55 assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
56 == test->len );
57
58 /* Check that image is detected as correct type */
59 okx ( register_image ( test->image ) == 0, file, line );
60 okx ( test->image->type == test->type, file, line );
61
62 /* Check that a pixel buffer can be created from the image */
63 okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
64 if ( rc == 0 ) {
65
66 /* Check pixel buffer dimensions */
67 okx ( pixbuf->width == test->width, file, line );
68 okx ( pixbuf->height == test->height, file, line );
69
70 /* Check pixel buffer data */
71 okx ( pixbuf->len == test->len, file, line );
72 okx ( memcmp ( pixbuf->data, test->data, test->len ) == 0,
73 file, line );
74
75 pixbuf_put ( pixbuf );
76 }
77
78 /* Unregister image */
79 unregister_image ( test->image );
80}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
void unregister_image(struct image *image)
Unregister executable image.
Definition image.c:358
int register_image(struct image *image)
Register executable image.
Definition image.c:315
int image_pixbuf(struct image *image, struct pixel_buffer **pixbuf)
Create pixel buffer from image.
Definition pixbuf.c:100
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition string.c:115
A pixel buffer.
Definition pixbuf.h:17
unsigned int height
Height.
Definition pixbuf.h:23
size_t len
Total length.
Definition pixbuf.h:29
unsigned int width
Width.
Definition pixbuf.h:21
uint32_t * data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
Definition pixbuf.h:25
#define okx(success, file, line)
Report test result.
Definition test.h:44

References assert, pixel_buffer::data, pixel_buffer::height, image_pixbuf(), pixel_buffer::len, memcmp(), okx, rc, register_image(), test, unregister_image(), and pixel_buffer::width.