iPXE
Functions
pixbuf_test.c File Reference

Pixel buffer self-tests. More...

#include <assert.h>
#include <ipxe/image.h>
#include <ipxe/pixbuf.h>
#include <ipxe/test.h>
#include "pixbuf_test.h"

Go to the source code of this file.

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.

Detailed Description

Pixel buffer self-tests.

Definition in file pixbuf_test.c.


Function Documentation

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.

Parameters:
testPixel buffer test
fileTest code file
lineTest code line

Definition at line 48 of file pixbuf_test.c.

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

                                      {
        struct pixel_buffer *pixbuf;
        int rc;

        /* Sanity check */
        assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
                 == test->len );

        /* Correct image data pointer */
        test->image->data = virt_to_user ( ( void * ) test->image->data );

        /* Check that image is detected as correct type */
        okx ( register_image ( test->image ) == 0, file, line );
        okx ( test->image->type == test->type, file, line );

        /* Check that a pixel buffer can be created from the image */
        okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
        if ( rc == 0 ) {

                /* Check pixel buffer dimensions */
                okx ( pixbuf->width == test->width, file, line );
                okx ( pixbuf->height == test->height, file, line );

                /* Check pixel buffer data */
                okx ( pixbuf->len == test->len, file, line );
                okx ( memcmp_user ( pixbuf->data, 0,
                                    virt_to_user ( test->data ), 0,
                                    test->len ) == 0, file, line );

                pixbuf_put ( pixbuf );
        }

        /* Unregister image */
        unregister_image ( test->image );
}