Skip to content

Commit

Permalink
test: Fix test on initrd
Browse files Browse the repository at this point in the history
This was broken since I first introduced the test on initrd on
40ffc51 ("Initial parsing of the provided initrd file") but it
always was as a work in progress test.

Now that the initrd parsing has separation of concerns with the global
'tasks' variable since f4986da ("Accept tasks as a parameter on
initrd extraction"), we can have a proper test written for this.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Nov 24, 2024
1 parent f4986da commit 4228cfe
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/test_initrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#include <fbos/sched.h>
#include <fbos/mm.h>

unsigned long init_stack[4][THREAD_SIZE / sizeof(unsigned long)];
unsigned long stack[4][THREAD_SIZE / sizeof(unsigned long)];

struct task_struct tasks[4] = {
[0] = { .stack = init_stack[0] },
[1] = { .stack = init_stack[1] },
[2] = { .stack = init_stack[2] },
[3] = { .stack = init_stack[3] },
[TASK_INIT] = { .stack = stack[0], .entry_addr = NULL, },
[TASK_FIZZ] = { .stack = stack[1], .entry_addr = NULL, },
[TASK_BUZZ] = { .stack = stack[2], .entry_addr = NULL, },
[TASK_FIZZBUZZ] = { .stack = stack[3], .entry_addr = NULL, },
};

int main(void)
Expand All @@ -33,7 +33,10 @@ int main(void)
extract_initrd(contents, (uint64_t)fsize, tasks);
free(contents);

// TODO
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);

exit(0);
}

0 comments on commit 4228cfe

Please sign in to comment.