57 #define DATA(...) { __VA_ARGS__ } 60 #define GZIP( name, COMPRESSED, EXPECTED ) \ 61 static const uint8_t name ## _compressed[] = COMPRESSED; \ 62 static const uint8_t name ## _expected[] = EXPECTED; \ 63 static struct gzip_test name = { \ 64 .compressed_name = #name ".gz", \ 65 .compressed = name ## _compressed, \ 66 .compressed_len = sizeof ( name ## _compressed ), \ 67 .expected_name = #name, \ 68 .expected = name ## _expected, \ 69 .expected_len = sizeof ( name ## _expected ), \ 74 DATA ( 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
75 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf, 0x2f, 0xca,
76 0x49, 0x01, 0x00, 0x52, 0x9e, 0xd6, 0x8b, 0x0b, 0x00, 0x00,
78 DATA ( 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c,
82 GZIP ( hello_filename,
83 DATA ( 0x1f, 0x8b, 0x08, 0x08, 0xeb, 0x5b, 0x96, 0x60, 0x00, 0x03,
84 0x68, 0x77, 0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3, 0x48, 0xcd,
85 0xc9, 0xc9, 0x57, 0x48, 0xcb, 0xcc, 0x49, 0xcd, 0x4b, 0xcc,
86 0x4d, 0x05, 0x00, 0x69, 0x37, 0x25, 0x3c, 0x0e, 0x00, 0x00,
88 DATA ( 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x66, 0x69, 0x6c, 0x65,
89 0x6e, 0x61, 0x6d, 0x65 ) );
93 DATA ( 0x1f, 0x8b, 0x08, 0x1c, 0x11, 0x5c, 0x96, 0x60, 0x00, 0x03,
94 0x05, 0x00, 0x41, 0x70, 0x01, 0x00, 0x0d, 0x68, 0x77, 0x2e,
95 0x74, 0x78, 0x74, 0x00, 0x2f, 0x2f, 0x77, 0x68, 0x79, 0x3f,
96 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x48, 0x2c, 0x2e,
97 0xce, 0x2f, 0x2a, 0x49, 0x4d, 0x51, 0xc8, 0x48, 0x4d, 0x4c,
98 0x49, 0x2d, 0x2a, 0x06, 0x00, 0x59, 0xa4, 0x19, 0x61, 0x16,
100 DATA ( 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x61, 0x73, 0x73, 0x6f,
101 0x72, 0x74, 0x65, 0x64, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65,
112 unsigned int line ) {
114 struct image *extracted;
119 test->compressed_len );
130 okx ( extracted->
len ==
test->expected_len, file, line );
133 test->expected_len ) == 0, file, line );
143 #define gzip_ok( test ) gzip_okx ( test, __FILE__, __LINE__ ) userptr_t data
Raw file image.
struct image_type * type
Image type, if known.
struct image * image_memory(const char *name, userptr_t data, size_t len)
Create registered image from block of memory.
Self-test infrastructure.
const char * name
Test set name.
struct self_test gzip_test __self_test
gzip self-test
const char * compressed_name
Compressed filename.
const void * compressed
Compressed data.
#define okx(success, file, line)
Report test result.
int image_extract(struct image *image, const char *name, struct image **extracted)
Extract archive image.
const void * expected
Expected uncompressed data.
size_t len
Length of raw file image.
static void gzip_test_exec(void)
Perform gzip self-test.
size_t compressed_len
Length of compressed data.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define GZIP(name, COMPRESSED, EXPECTED)
Define a gzip test.
void unregister_image(struct image *image)
Unregister executable image.
const char * expected_name
Expected uncompressed name.
int strcmp(const char *first, const char *second)
Compare strings.
#define DATA(...)
Define inline data.
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.
static void gzip_okx(struct gzip_test *test, const char *file, unsigned int line)
Report gzip test result.
#define NULL
NULL pointer (VOID *)
size_t expected_len
Length of expected uncompressed data.