iPXE
mime_test.c File Reference

MIME image tests. More...

#include <ipxe/mime.h>
#include <ipxe/test.h>
#include "archive_test.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 ARCHIVE_TEST (hello_world, &mime_image_type, "hw.mime", NULL, "hw", TEXTFILE("Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"hw.ipxe\"\r\n" "\r\n" "IyFpcHhlCgplY2hvIEhlbGxvIHdvcmxkCnNoZWxsCg==\r\n"), TEXTFILE("#!ipxe\n" "\n" "echo Hello world\n" "shell\n"))
 "Hello world"
 ARCHIVE_TEST (multipart, &mime_image_type, "user-data", NULL, "user-data", TEXTFILE("Content-Type: multipart/mixed; " "boundary=\"===============5227682047807177400==\"\r\n" "MIME-Version: 1.0\r\n" "\r\n" "--===============5227682047807177400==\r\n" "Content-Type: text/cloud-config; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"conf.yml\"\r\n" "\r\n" "LS0tCmNvbmZpZzoKICB0aGluZ3M6CiAgICAtIG9uZQogICAgLSB0d2\r\n" "8KICBvdGhlcnRoaW5nOiAid29vaG9vIgo=\r\n" "\r\n" "--===============5227682047807177400==\r\n" "Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"hw.ipxe\"\r\n" "\r\n" "IyFpcHhlCgplY2hvIEhlbGxvIHdvcmxkCnNoZWxsCg==\r\n" "\r\n" "--===============5227682047807177400==--\r\n"), TEXTFILE("Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"hw.ipxe\"\r\n" "\r\n" "IyFpcHhlCgplY2hvIEhlbGxvIHdvcmxkCnNoZWxsCg==\r\n" "\r\n"))
 Multipart test.
 ARCHIVE_TEST (no_encoding, &mime_image_type, "noenc.mime", NULL, "noenc", TEXTFILE("Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "\r\n" "#!ipxe\r\n" "echo Default encoding\r\n"), TEXTFILE("#!ipxe\r\n" "echo Default encoding\r\n"))
 No explicit encoding.
static void mime_test_exec (void)
 Perform mime self-test.

Variables

struct self_test mime_test __self_test
 MIME self-test.

Detailed Description

MIME image tests.

Definition in file mime_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ ARCHIVE_TEST() [1/3]

ARCHIVE_TEST ( hello_world ,
& mime_image_type,
"hw.mime" ,
NULL ,
"hw" ,
TEXTFILE("Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"hw.ipxe\"\r\n" "\r\n" "IyFpcHhlCgplY2hvIEhlbGxvIHdvcmxkCnNoZWxsCg==\r\n") ,
TEXTFILE("#!ipxe\n" "\n" "echo Hello world\n" "shell\n")  )

"Hello world"

References NULL, and TEXTFILE.

◆ ARCHIVE_TEST() [2/3]

ARCHIVE_TEST ( multipart ,
& mime_image_type,
"user-data" ,
NULL ,
"user-data" ,
TEXTFILE("Content-Type: multipart/mixed; " "boundary=\"===============5227682047807177400==\"\r\n" "MIME-Version: 1.0\r\n" "\r\n" "--===============5227682047807177400==\r\n" "Content-Type: text/cloud-config; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"conf.yml\"\r\n" "\r\n" "LS0tCmNvbmZpZzoKICB0aGluZ3M6CiAgICAtIG9uZQogICAgLSB0d2\r\n" "8KICBvdGhlcnRoaW5nOiAid29vaG9vIgo=\r\n" "\r\n" "--===============5227682047807177400==\r\n" "Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"hw.ipxe\"\r\n" "\r\n" "IyFpcHhlCgplY2hvIEhlbGxvIHdvcmxkCnNoZWxsCg==\r\n" "\r\n" "--===============5227682047807177400==--\r\n") ,
TEXTFILE("Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "Content-Transfer-Encoding: base64\r\n" "Content-Disposition: attachment; filename=\"hw.ipxe\"\r\n" "\r\n" "IyFpcHhlCgplY2hvIEhlbGxvIHdvcmxkCnNoZWxsCg==\r\n" "\r\n")  )

Multipart test.

References NULL, and TEXTFILE.

◆ ARCHIVE_TEST() [3/3]

ARCHIVE_TEST ( no_encoding ,
& mime_image_type,
"noenc.mime" ,
NULL ,
"noenc" ,
TEXTFILE("Content-Type: text/x-ipxe; charset=\"utf-8\"\r\n" "MIME-Version: 1.0\r\n" "\r\n" "#!ipxe\r\n" "echo Default encoding\r\n") ,
TEXTFILE("#!ipxe\r\n" "echo Default encoding\r\n")  )

No explicit encoding.

References NULL, and TEXTFILE.

◆ mime_test_exec()

void mime_test_exec ( void )
static

Perform mime self-test.

Definition at line 98 of file mime_test.c.

98 {
99
100 archive_ok ( &hello_world );
101 archive_ok ( &multipart );
102 archive_ok ( &no_encoding );
103}
#define archive_ok(test)
Report an archive extraction test result.

References archive_ok.

Variable Documentation

◆ __self_test

struct self_test mime_test __self_test
Initial value:
= {
.name = "mime",
.exec = mime_test_exec,
}
static void mime_test_exec(void)
Perform mime self-test.
Definition mime_test.c:98

MIME self-test.

Definition at line 106 of file mime_test.c.

106 {
107 .name = "mime",
108 .exec = mime_test_exec,
109};