iPXE
Data Structures | Macros | Functions
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. More...
 
#define pixbuf_ok(test)   pixbuf_okx ( test, __FILE__, __LINE__ )
 Report pixel buffer test result. More...
 

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. More...
 

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 = { \
.name = #_name, \
.data = ( userptr_t ) ( _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, \
};
userptr_t data
Raw file image.
Definition: image.h:41
An executable image.
Definition: image.h:24
struct image_type * type
Image type.
Definition: pixbuf_test.h:14
size_t len
Length of pixel data.
Definition: pixbuf_test.h:20
unsigned int height
Height.
Definition: pixbuf_test.h:24
unsigned int uint32_t
Definition: stdint.h:12
#define REF_INIT(free_fn)
Initialise a static reference counter.
Definition: refcnt.h:77
void ref_no_free(struct refcnt *refcnt __unused)
Do not free reference-counted object.
Definition: refcnt.c:101
A pixel buffer test.
Definition: pixbuf_test.h:12
unsigned int width
Width.
Definition: pixbuf_test.h:22
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
struct refcnt refcnt
Reference count.
Definition: image.h:26

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.

◆ pixbuf_ok

#define pixbuf_ok (   test)    pixbuf_okx ( test, __FILE__, __LINE__ )

Report pixel buffer test result.

Parameters
testPixel buffer test

Definition at line 64 of file pixbuf_test.h.

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 
)

Report pixel buffer test result.

Parameters
testPixel buffer test
fileTest code file
lineTest code line

Definition at line 48 of file pixbuf_test.c.

49  {
50  struct pixel_buffer *pixbuf;
51  int rc;
52 
53  /* Sanity check */
54  assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
55  == test->len );
56 
57  /* Correct image data pointer */
58  test->image->data = virt_to_user ( ( void * ) test->image->data );
59 
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 );
63 
64  /* Check that a pixel buffer can be created from the image */
65  okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
66  if ( rc == 0 ) {
67 
68  /* Check pixel buffer dimensions */
69  okx ( pixbuf->width == test->width, file, line );
70  okx ( pixbuf->height == test->height, file, line );
71 
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 );
77 
78  pixbuf_put ( pixbuf );
79  }
80 
81  /* Unregister image */
82  unregister_image ( test->image );
83 }
int image_pixbuf(struct image *image, struct pixel_buffer **pixbuf)
Create pixel buffer from image.
Definition: pixbuf.c:97
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned int height
Height.
Definition: pixbuf.h:23
size_t len
Total length.
Definition: pixbuf.h:27
#define okx(success, file, line)
Report test result.
Definition: test.h:44
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
int register_image(struct image *image)
Register executable image.
Definition: image.c:210
A pixel buffer.
Definition: pixbuf.h:17
void unregister_image(struct image *image)
Unregister executable image.
Definition: image.c:252
int memcmp_user(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len)
Compare data between user buffers.
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
userptr_t data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
Definition: pixbuf.h:25
static int test
Definition: epic100.c:73
unsigned int width
Width.
Definition: pixbuf.h:21

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