iPXE
gzip_test.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
26/** @file
27 *
28 * gzip image tests
29 *
30 */
31
32/* Forcibly enable assertions */
33#undef NDEBUG
34
35#include <ipxe/gzip.h>
36#include <ipxe/test.h>
37#include "archive_test.h"
38
39/** "Hello world" */
40ARCHIVE_TEST ( hello_world, &gzip_image_type, "hw.gz", NULL, "hw",
41 BINFILE ( 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
42 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x28, 0xcf, 0x2f, 0xca,
43 0x49, 0x01, 0x00, 0x52, 0x9e, 0xd6, 0x8b, 0x0b, 0x00, 0x00,
44 0x00 ),
45 TEXTFILE ( "Hello world" ) );
46
47/** "Hello filename" */
48ARCHIVE_TEST ( hello_filename, &gzip_image_type, "hwname.gz", NULL, "hwname",
49 BINFILE ( 0x1f, 0x8b, 0x08, 0x08, 0xeb, 0x5b, 0x96, 0x60, 0x00, 0x03,
50 0x68, 0x77, 0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3, 0x48, 0xcd,
51 0xc9, 0xc9, 0x57, 0x48, 0xcb, 0xcc, 0x49, 0xcd, 0x4b, 0xcc,
52 0x4d, 0x05, 0x00, 0x69, 0x37, 0x25, 0x3c, 0x0e, 0x00, 0x00,
53 0x00 ),
54 TEXTFILE ( "Hello filename" ) );
55
56/** "Hello assorted headers" */
57ARCHIVE_TEST ( hello_headers, &gzip_image_type, "hwhdrs.gz", NULL, "hwhdrs",
58 BINFILE ( 0x1f, 0x8b, 0x08, 0x1c, 0x11, 0x5c, 0x96, 0x60, 0x00, 0x03,
59 0x05, 0x00, 0x41, 0x70, 0x01, 0x00, 0x0d, 0x68, 0x77, 0x2e,
60 0x74, 0x78, 0x74, 0x00, 0x2f, 0x2f, 0x77, 0x68, 0x79, 0x3f,
61 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x48, 0x2c, 0x2e,
62 0xce, 0x2f, 0x2a, 0x49, 0x4d, 0x51, 0xc8, 0x48, 0x4d, 0x4c,
63 0x49, 0x2d, 0x2a, 0x06, 0x00, 0x59, 0xa4, 0x19, 0x61, 0x16,
64 0x00, 0x00, 0x00 ),
65 TEXTFILE ( "Hello assorted headers" ) );
66
67/**
68 * Perform gzip self-test
69 *
70 */
71static void gzip_test_exec ( void ) {
72
73 archive_ok ( &hello_world );
74 archive_ok ( &hello_filename );
75 archive_ok ( &hello_headers );
76}
77
78/** gzip self-test */
79struct self_test gzip_test __self_test = {
80 .name = "gzip",
81 .exec = gzip_test_exec,
82};
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
#define archive_ok(test)
Report an archive extraction test result.
#define ARCHIVE_TEST(name, TYPE, ARCHIVE_NAME, EXTRACT_NAME, EXPECTED_NAME, ARCHIVE, EXPECTED)
Define an archive extraction test.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
gzip compressed images
static void gzip_test_exec(void)
Perform gzip self-test.
Definition gzip_test.c:71
A self-test set.
Definition test.h:15
Self-test infrastructure.
#define __self_test
Declare a self-test.
Definition test.h:32
#define BINFILE(...)
Define inline binary file content.
Definition test.h:50
#define TEXTFILE(text)
Define inline text file content.
Definition test.h:53