1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-12-11 11:35:27 -05:00
libkernaux/tests/test_multiboot2_print.c

297 lines
7.3 KiB
C
Raw Normal View History

2020-12-06 23:47:53 -05:00
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
2020-11-28 16:24:50 -05:00
#include <assert.h>
#define __USE_POSIX2
#include <stdio.h>
2020-11-29 07:57:34 -05:00
static const char output1[] =
2020-11-28 16:24:50 -05:00
"Multiboot 2 info\n"
" size: 864\n"
" reserved1: 0\n"
"Multiboot 2 tag\n"
" type: 21 (image load base phys addr)\n"
" size: 12\n"
" load base addr: 4194304\n"
"Multiboot 2 tag\n"
" type: 1 (boot cmd line)\n"
" size: 21\n"
" cmdline: hello kernel\n"
"Multiboot 2 tag\n"
" type: 2 (boot loader name)\n"
" size: 30\n"
" name: GRUB 2.02-2ubuntu8.20\n"
"Multiboot 2 tag\n"
" type: 10 (APM table)\n"
" size: 28\n"
2020-11-28 17:06:25 -05:00
" version: 258\n"
" cseg: 61440\n"
" offset: 54479\n"
" cseg 16: 61440\n"
" dseg: 61440\n"
" flags: 3\n"
" cseg len: 65520\n"
" cseg 16 len: 65520\n"
" dseg len: 65520\n"
2020-11-28 16:24:50 -05:00
"Multiboot 2 tag\n"
" type: 3 (module)\n"
" size: 29\n"
" start: 1056768\n"
" end: 1061532\n"
" cmdline: hello module\n"
"Multiboot 2 tag\n"
" type: 3 (module)\n"
" size: 17\n"
" start: 1064960\n"
" end: 1069652\n"
" cmdline: \n"
"Multiboot 2 tag\n"
" type: 6 (memory map)\n"
" size: 160\n"
2020-11-28 18:24:14 -05:00
" entry size: 24\n"
" entry version: 0\n"
" entries:\n"
" entry 0\n"
" base addr: 0\n"
" length: 654336\n"
" type: 1\n"
" reserved1: 0\n"
" entry 1\n"
" base addr: 654336\n"
" length: 1024\n"
" type: 2\n"
" reserved1: 0\n"
" entry 2\n"
" base addr: 983040\n"
" length: 65536\n"
" type: 2\n"
" reserved1: 0\n"
" entry 3\n"
" base addr: 1048576\n"
" length: 133038080\n"
" type: 1\n"
" reserved1: 0\n"
" entry 4\n"
" base addr: 134086656\n"
" length: 131072\n"
" type: 2\n"
" reserved1: 0\n"
" entry 5\n"
" base addr: 4294705152\n"
" length: 262144\n"
" type: 2\n"
" reserved1: 0\n"
2020-11-28 16:24:50 -05:00
"Multiboot 2 tag\n"
" type: 9 (ELF symbols)\n"
" size: 420\n"
2020-11-29 09:25:35 -05:00
" num: 10\n"
" entsize: 0\n"
" shndx: 40\n"
" reserved1: 0\n"
2020-11-28 16:24:50 -05:00
"Multiboot 2 tag\n"
" type: 4 (basic memory info)\n"
" size: 16\n"
" mem lower: 639\n"
" mem upper: 129920\n"
"Multiboot 2 tag\n"
" type: 5 (BIOS boot device)\n"
" size: 20\n"
" bios dev: 224\n"
" partition: 4294967295\n"
" sub_partition: 4294967295\n"
"Multiboot 2 tag\n"
" type: 8 (framebuffer info)\n"
" size: 32\n"
" framebuffer addr: 753664\n"
" framebuffer pitch: 160\n"
" framebuffer width: 80\n"
" framebuffer height: 25\n"
" framebuffer bpp: 16\n"
" framebuffer type: 2\n"
2020-11-28 16:58:20 -05:00
" reserved1: 0\n"
2020-11-28 16:24:50 -05:00
"Multiboot 2 tag\n"
" type: 14 (ACPI old RSDP)\n"
" size: 28\n"
"Multiboot 2 tag\n"
" type: 0 (none)\n"
" size: 8\n";
2020-11-29 10:06:46 -05:00
static const char output2[] =
"Multiboot 2 info\n"
" size: 1816\n"
" reserved1: 0\n"
"Multiboot 2 tag\n"
" type: 1 (boot cmd line)\n"
" size: 23\n"
" cmdline: Hello, Kernel!\n"
"Multiboot 2 tag\n"
" type: 2 (boot loader name)\n"
" size: 30\n"
" name: GRUB 2.02-2ubuntu8.20\n"
"Multiboot 2 tag\n"
" type: 3 (module)\n"
" size: 33\n"
" start: 123\n"
" end: 456\n"
" cmdline: Hello, Module 1!\n"
"Multiboot 2 tag\n"
" type: 3 (module)\n"
" size: 33\n"
" start: 123\n"
" end: 456\n"
" cmdline: Hello, Module 2!\n"
"Multiboot 2 tag\n"
" type: 4 (basic memory info)\n"
" size: 16\n"
" mem lower: 123\n"
" mem upper: 456\n"
"Multiboot 2 tag\n"
" type: 5 (BIOS boot device)\n"
" size: 20\n"
" bios dev: 0\n"
" partition: 1\n"
" sub_partition: 2\n"
"Multiboot 2 tag\n"
" type: 6 (memory map)\n"
" size: 160\n"
" entry size: 24\n"
" entry version: 0\n"
" entries:\n"
" entry 0\n"
" base addr: 0\n"
" length: 654336\n"
" type: 1\n"
" reserved1: 0\n"
" entry 1\n"
" base addr: 654336\n"
" length: 1024\n"
" type: 2\n"
" reserved1: 0\n"
" entry 2\n"
" base addr: 983040\n"
" length: 65536\n"
" type: 2\n"
" reserved1: 0\n"
" entry 3\n"
" base addr: 1048576\n"
" length: 133038080\n"
" type: 1\n"
" reserved1: 0\n"
" entry 4\n"
" base addr: 134086656\n"
" length: 131072\n"
" type: 2\n"
" reserved1: 0\n"
" entry 5\n"
" base addr: 4294705152\n"
" length: 262144\n"
" type: 2\n"
" reserved1: 0\n"
"Multiboot 2 tag\n"
" type: 7 (VBE info)\n"
" size: 784\n"
" VBE mode: 0\n"
" VBE interface seg: 123\n"
" VBE interface off: 456\n"
" VBE interface len: 789\n"
"Multiboot 2 tag\n"
" type: 8 (framebuffer info)\n"
" size: 39\n"
" framebuffer addr: 123\n"
" framebuffer pitch: 456\n"
" framebuffer width: 123\n"
" framebuffer height: 456\n"
" framebuffer bpp: 8\n"
" framebuffer type: 1\n"
" reserved1: 0\n"
"Multiboot 2 tag\n"
" type: 9 (ELF symbols)\n"
" size: 420\n"
" num: 10\n"
" entsize: 0\n"
" shndx: 40\n"
" reserved1: 0\n"
"Multiboot 2 tag\n"
" type: 10 (APM table)\n"
" size: 28\n"
" version: 0\n"
" cseg: 123\n"
" offset: 456\n"
" cseg 16: 789\n"
" dseg: 123\n"
" flags: 1\n"
" cseg len: 456\n"
" cseg 16 len: 789\n"
" dseg len: 123\n"
"Multiboot 2 tag\n"
" type: 11 (EFI 32bit system table ptr)\n"
" size: 12\n"
"Multiboot 2 tag\n"
" type: 12 (EFI 64bit system table ptr)\n"
" size: 16\n"
"Multiboot 2 tag\n"
" type: 13 (SMBIOS tables)\n"
" size: 24\n"
" major: 1\n"
" minor: 2\n"
" reserved1: {0, 0, 0, 0, 0, 0}\n"
"Multiboot 2 tag\n"
" type: 14 (ACPI old RSDP)\n"
" size: 16\n"
"Multiboot 2 tag\n"
" type: 15 (ACPI new RSDP)\n"
" size: 16\n"
"Multiboot 2 tag\n"
" type: 16 (networking info)\n"
" size: 16\n"
"Multiboot 2 tag\n"
" type: 17 (EFI memory map)\n"
" size: 24\n"
"Multiboot 2 tag\n"
" type: 18 (EFI boot services not terminated)\n"
" size: 8\n"
"Multiboot 2 tag\n"
" type: 19 (EFI 32bit image handle ptr)\n"
" size: 12\n"
"Multiboot 2 tag\n"
" type: 20 (EFI 64bit image handle ptr)\n"
" size: 16\n"
"Multiboot 2 tag\n"
" type: 21 (image load base phys addr)\n"
" size: 12\n"
" load base addr: 123\n"
"Multiboot 2 tag\n"
" type: 0 (none)\n"
" size: 8\n";
2020-11-28 16:24:50 -05:00
int main()
{
2020-11-29 10:06:46 -05:00
{
FILE *const fd = popen("tests/multiboot2_print1", "r");
assert(fd != NULL);
for (const char *ch = output1; *ch; ++ch) {
assert(fgetc(fd) == *ch);
}
2020-11-28 16:24:50 -05:00
2020-11-29 10:06:46 -05:00
const int status = pclose(fd);
assert(status == 0);
2020-11-28 16:24:50 -05:00
}
2020-11-29 10:06:46 -05:00
{
FILE *const fd = popen("tests/multiboot2_print2", "r");
assert(fd != NULL);
for (const char *ch = output2; *ch; ++ch) {
assert(fgetc(fd) == *ch);
}
const int status = pclose(fd);
assert(status == 0);
}
2020-11-28 16:24:50 -05:00
return 0;
}