From fbfd178f590f402c2ca95d164e3a6a83d32c614b Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 19 Dec 2021 08:40:23 +0500 Subject: [PATCH] Add test "arch_i386_paging" --- .gitignore | 1 + Makefile.am | 5 +++++ tests/test_arch_i386_paging.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/test_arch_i386_paging.c diff --git a/.gitignore b/.gitignore index 02515a1..3cd28c5 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ /tests/multiboot2_print1 /tests/multiboot2_print2 +/tests/test_arch_i386_paging /tests/test_cmdline /tests/test_elf /tests/test_itoa diff --git a/Makefile.am b/Makefile.am index a4e47f3..0c66f6d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ if ARCH_I386 libkernaux_a_SOURCES += src/arch/i386/asm.S endif libkernaux_a_SOURCES += src/arch/i386/paging.c +TESTS += tests/test_arch_i386_paging endif if WITH_ARCH_X86_64 @@ -111,6 +112,10 @@ examples_units_human_SOURCES = \ $(libkernaux_a_SOURCES) \ examples/units_human.c +tests_test_arch_i386_paging_SOURCES = \ + $(libkernaux_a_SOURCES) \ + tests/test_arch_i386_paging.c + tests_multiboot2_print1_SOURCES = \ $(libkernaux_a_SOURCES) \ tests/multiboot2_print1.c diff --git a/tests/test_arch_i386_paging.c b/tests/test_arch_i386_paging.c new file mode 100644 index 0000000..a572831 --- /dev/null +++ b/tests/test_arch_i386_paging.c @@ -0,0 +1,32 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +// TODO: There are some static asserts just for example. + +__attribute__((unused)) +static const int assert0[ + sizeof(struct KernAux_Arch_I386_PDE) == sizeof(uint32_t) ? 1 : -1 +]; + +__attribute__((unused)) +static const int assert1[ + sizeof(struct KernAux_Arch_I386_PTE) == sizeof(uint32_t) ? 1 : -1 +]; + +__attribute__((unused)) +static const int assert1[ + sizeof(struct KernAux_Arch_I386_PageDir) == 1024 * sizeof(uint32_t) ? 1 : -1 +]; + +__attribute__((unused)) +static const int assert1[ + sizeof(struct KernAux_Arch_I386_PageTable) == 1024 * sizeof(uint32_t) ? 1 : -1 +]; + +int main() +{ + return 0; +}