Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that load_kernel actually loads the kernel into memory #25

Open
2 tasks
fabianfreyer opened this issue Feb 20, 2018 · 0 comments
Open
2 tasks

Test that load_kernel actually loads the kernel into memory #25

fabianfreyer opened this issue Feb 20, 2018 · 0 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed tests
Milestone

Comments

@fabianfreyer
Copy link
Contributor

The tests load_aout_direct and load_elf_direct only check the return values of the load functions:

/* Load a kernel with a valid a.out kludge */
ATF_CHECK(fread(random_buffer, 128*kiB, 1, urandom));
mbh = (struct multiboot_header* )(random_buffer + 2*kiB);
mbh->magic = MULTIBOOT1_MAGIC;
mbh->flags = 0 | MULTIBOOT_AOUT_KLUDGE;
mbh->checksum = (uint32_t) 0U-MULTIBOOT1_MAGIC-(mbh->flags);
mbh->header_addr = 1*MiB;
mbh->load_addr = 1*MiB;
mbh->load_end_addr = 1*MiB + 0x100;
mbh->bss_end_addr = 1*MiB + 0x200;
mbh->entry_addr = 1*MiB + sizeof(struct multiboot_header);
mb = mb_scan(random_buffer, 128*kiB);
error = multiboot_load_aout(random_buffer, 128*kiB, mbh);
ATF_CHECK_EQ_MSG(0, error, "multiboot_load_aout failed");

mb = mb_scan(kernel, kernsz);
mbh = mb->info.mb.header;
multiboot_load_type(kernel, kernsz, &kernelf, mbh);
error = multiboot_load_elf(kernel, kernsz, kernelf);
ATF_CHECK_EQ_MSG(0, error, "multiboot_load_elf failed");

Instead they should also verify that copyin actually copied something. Probably the best idea is to

  • implement a function to get the lowmem_buffer and highmem_buffer pointers from mock_bhyveload.c
  • then use memcmp() to verify that the appropriate parts were actually loaded
@fabianfreyer fabianfreyer added help wanted Extra attention is needed good first issue Good for newcomers tests labels Feb 20, 2018
@fabianfreyer fabianfreyer added this to the v0.1 milestone Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed tests
Projects
None yet
Development

No branches or pull requests

2 participants