1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00

Test Multiboot 2 printing

This commit is contained in:
Alex Kotov 2020-11-29 02:24:50 +05:00
parent 27729540d5
commit 7e83431095
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 161 additions and 1 deletions

2
.gitignore vendored
View file

@ -24,4 +24,6 @@
/tests/test*.log
/tests/test*.trs
/tests/multiboot2_print
/tests/test_multiboot2_print
/tests/test_multiboot2_validation

View file

@ -5,9 +5,12 @@ AM_CFLAGS = -std=c99 -I$(top_srcdir)/include
lib_LIBRARIES = libkernaux.a
TESTS = \
tests/test_multiboot2_print \
tests/test_multiboot2_validation
noinst_PROGRAMS = $(TESTS)
noinst_PROGRAMS = \
$(TESTS) \
tests/multiboot2_print
libkernaux_a_SOURCES = \
src/arch/i386.S \
@ -15,6 +18,14 @@ libkernaux_a_SOURCES = \
src/multiboot2/print.c \
src/pfa.c
tests_multiboot2_print_SOURCES = \
$(libkernaux_a_SOURCES) \
tests/multiboot2_print.c
tests_test_multiboot2_print_SOURCES = \
$(libkernaux_a_SOURCES) \
tests/test_multiboot2_print.c
tests_test_multiboot2_validation_SOURCES = \
$(libkernaux_a_SOURCES) \
tests/test_multiboot2_validation.c

70
tests/multiboot2_print.c Normal file
View file

@ -0,0 +1,70 @@
#include <kernaux/multiboot2.h>
#include <stdio.h>
static const unsigned char multiboot2_example[864] = {
96, 3, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 12, 0, 0, 0,
0, 0, 64, 0, 0, 0, 232, 133, 1, 0, 0, 0, 21, 0, 0, 0,
104, 101, 108, 108, 111, 32, 107, 101, 114, 110, 101, 108, 0, 139, 69, 228,
2, 0, 0, 0, 30, 0, 0, 0, 71, 82, 85, 66, 32, 50, 46, 48,
50, 45, 50, 117, 98, 117, 110, 116, 117, 56, 46, 50, 48, 0, 0, 0,
10, 0, 0, 0, 28, 0, 0, 0, 2, 1, 0, 240, 207, 212, 0,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, 0, 0, 255, 255, 255, 255,
255, 255, 255, 255, 208, 137, 69, 212, 8, 0, 0, 0, 32, 0, 0, 0,
0, 128, 11, 0, 0, 0, 0, 0, 160, 0, 0, 0, 80, 0, 0, 0,
25, 0, 0, 0, 16, 2, 0, 0, 14, 0, 0, 0, 28, 0, 0, 0,
82, 83, 68, 32, 80, 84, 82, 32, 60, 66, 79, 67, 72, 83, 32, 0,
252, 21, 254, 7, 236, 0, 0, 235, 0, 0, 0, 0, 8, 0, 0, 0,
};
int main()
{
KernAux_Multiboot2_print(
(struct KernAux_Multiboot2*)multiboot2_example,
(void (*)(const char *format, ...))printf
);
return 0;
}

View file

@ -0,0 +1,77 @@
#include <assert.h>
#define __USE_POSIX2
#include <stdio.h>
static const char output[] =
"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"
"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"
"Multiboot 2 tag\n"
" type: 9 (ELF symbols)\n"
" size: 420\n"
"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"
"Multiboot 2 tag\n"
" type: 14 (ACPI old RSDP)\n"
" size: 28\n"
"Multiboot 2 tag\n"
" type: 0 (none)\n"
" size: 8\n";
int main()
{
FILE *const fd = popen("tests/multiboot2_print", "r");
assert(fd != NULL);
for (const char *ch = output; *ch; ++ch) {
assert(fgetc(fd) == *ch);
}
const int status = pclose(fd);
assert(status == 0);
return 0;
}