From ea542e18e7bc7e9d401aefd044bf0317676867ca Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 25 Nov 2024 07:35:35 +0100 Subject: tests: Only test initrd addresses on debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In initrd tests, and in general, we only need to check that the function did something. As in, that it set the entry addresses somewhere and did not leave them NULL. This is going to be performed from now on on CI and regular tests. And, just if you want to go the extra mile, we will run specific tests that check on memory addresses but that are not guaranteed to work. This is to be replaced in the future by having some proper debugging output. As in, having a message at kernel boot time specifying the addresses being used among other info. This needs a more complex printk utility, of course. Signed-off-by: Miquel Sabaté Solà --- .github/workflows/ci.yml | 2 +- Makefile | 2 +- test/test_initrd.c | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e278d5f..64d403e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,5 +25,5 @@ jobs: - name: Lint run: make lint V=1 - - name: Check that it builds + - name: Build and run unit tests run: make V=1 diff --git a/Makefile b/Makefile index b3642f0..03febb5 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ifeq ($(strip $(DEBUG)),) QEMU_FLAGS += -nographic else ASFLAGS += -g - CCFLAGS += -g + CCFLAGS += -g -D__DEBUG__ QEMU_FLAGS += -s -S endif diff --git a/test/test_initrd.c b/test/test_initrd.c index 7c23acc..314bd25 100644 --- a/test/test_initrd.c +++ b/test/test_initrd.c @@ -33,10 +33,17 @@ int main(void) extract_initrd(contents, (uint64_t)fsize, tasks); free(contents); - assert(((uintptr_t)tasks[0].entry_addr & 0xff) == 0xe8); - assert(((uintptr_t)tasks[1].entry_addr & 0xff) == 0xbc); - assert(((uintptr_t)tasks[2].entry_addr & 0xff) == 0xb4); - assert(((uintptr_t)tasks[3].entry_addr & 0xff) == 0x80); +#ifdef __DEBUG__ + assert(((uintptr_t)tasks[0].entry_addr & 0xfff) == 0xbe8); + assert(((uintptr_t)tasks[1].entry_addr & 0xfff) == 0x5bc); + assert(((uintptr_t)tasks[2].entry_addr & 0xfff) == 0x7b4); + assert(((uintptr_t)tasks[3].entry_addr & 0xfff) == 0x180); +#else + assert(tasks[0].entry_addr); + assert(tasks[1].entry_addr); + assert(tasks[2].entry_addr); + assert(tasks[3].entry_addr); +#endif exit(0); } -- cgit v1.2.3