2022-01-13 13:50:51 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
2022-06-06 02:42:18 +00:00
|
|
|
#ifndef __USE_POSIX2
|
2022-01-13 13:50:51 +00:00
|
|
|
#define __USE_POSIX2
|
2022-06-06 02:42:18 +00:00
|
|
|
#endif
|
2022-01-13 13:50:51 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2022-01-14 07:16:26 +00:00
|
|
|
static const char output1[] =
|
|
|
|
"Multiboot 2 header\n"
|
|
|
|
" magic: 3897708758\n"
|
|
|
|
" arch: 4 (MIPS32)\n"
|
|
|
|
" size: 24\n"
|
|
|
|
" checksum: 397258510\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
|
|
|
" type: 0 (none)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 8\n";
|
|
|
|
|
|
|
|
static const char output2[] =
|
2022-01-13 14:55:24 +00:00
|
|
|
"Multiboot 2 header\n"
|
2022-01-14 05:40:51 +00:00
|
|
|
" magic: 3897708758\n"
|
2022-01-14 06:20:16 +00:00
|
|
|
" arch: 0 (i386)\n"
|
2022-01-14 04:46:46 +00:00
|
|
|
" size: 272\n"
|
2022-01-14 06:20:16 +00:00
|
|
|
" checksum: 397258266\n"
|
2022-01-14 04:10:41 +00:00
|
|
|
"Multiboot 2 header tag\n"
|
|
|
|
" type: 1 (information request)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 96\n"
|
2022-01-13 14:55:24 +00:00
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:17:11 +00:00
|
|
|
" type: 2 (address)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 24\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:21:02 +00:00
|
|
|
" type: 3 (entry address)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 12\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:27:55 +00:00
|
|
|
" type: 4 (flags)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 12\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:30:39 +00:00
|
|
|
" type: 5 (framebuffer)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 20\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:32:17 +00:00
|
|
|
" type: 6 (module alignment)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 8\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:33:49 +00:00
|
|
|
" type: 7 (EFI boot services)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 8\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:38:30 +00:00
|
|
|
" type: 8 (EFI i386 entry address)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 12\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
|
|
|
" type: 9 (EFI amd64 entry address)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 12\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-14 04:46:46 +00:00
|
|
|
" type: 10 (relocatable header)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 24\n"
|
|
|
|
"Multiboot 2 header tag\n"
|
2022-01-13 14:55:24 +00:00
|
|
|
" type: 0 (none)\n"
|
|
|
|
" flags: 0\n"
|
|
|
|
" size: 8\n";
|
2022-01-13 13:50:51 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
2022-06-10 05:23:03 +00:00
|
|
|
FILE *const fd = popen("./multiboot2_header_print1", "r");
|
2022-01-13 13:50:51 +00:00
|
|
|
assert(fd != NULL);
|
|
|
|
|
2022-01-14 07:16:26 +00:00
|
|
|
for (const char *ch = output1; *ch; ++ch) {
|
2022-01-13 13:50:51 +00:00
|
|
|
assert(fgetc(fd) == *ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
const int status = pclose(fd);
|
|
|
|
assert(status == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2022-06-10 05:23:03 +00:00
|
|
|
FILE *const fd = popen("./multiboot2_header_print2", "r");
|
2022-01-13 13:50:51 +00:00
|
|
|
assert(fd != NULL);
|
|
|
|
|
2022-01-14 07:16:26 +00:00
|
|
|
for (const char *ch = output2; *ch; ++ch) {
|
2022-01-13 13:50:51 +00:00
|
|
|
assert(fgetc(fd) == *ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
const int status = pclose(fd);
|
|
|
|
assert(status == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|