Skip to content

Test that load_kernel actually loads the kernel into memory #25

Open
@fabianfreyer

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions