Skip to content
Permalink
Browse files

tests: userspace: cover missing/bad syscalls

We were missing code coverage for bad or unimplemented
system call IDs.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information...
andrewboie committed Jun 24, 2019
1 parent 31c4cc5 commit 777336ef38503eb672f6c158242b69dd1b93b5b1
@@ -762,15 +762,15 @@ static u32_t handler_bad_syscall(u32_t bad_id, u32_t arg2, u32_t arg3,
{
printk("Bad system call id %u invoked\n", bad_id);
z_arch_syscall_oops(ssf);
CODE_UNREACHABLE;
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}

static u32_t handler_no_syscall(u32_t arg1, u32_t arg2, u32_t arg3,
u32_t arg4, u32_t arg5, u32_t arg6, void *ssf)
{
printk("Unimplemented system call\n");
z_arch_syscall_oops(ssf);
CODE_UNREACHABLE;
CODE_UNREACHABLE; /* LCOV_EXCL_LINE */
}

#include <syscall_dispatch.c>
@@ -1085,6 +1085,29 @@ void test_stack_buffer(void)

}

void z_impl_missing_syscall(void)
{
/* Shouldn't ever get here; no handler function compiled */
k_panic();
}

void test_unimplemented_syscall(void)
{
expect_fault = true;
expected_reason = REASON_KERNEL_OOPS;

missing_syscall();
}

void test_bad_syscall(void)
{
expect_fault = true;
expected_reason = REASON_KERNEL_OOPS;

z_arch_syscall_invoke0(INT_MAX);

}

void test_main(void)
{
struct k_mem_partition *parts[] = {&part0, &part1,
@@ -1134,7 +1157,9 @@ void test_main(void)
ztest_unit_test(domain_add_part_context_switch),
ztest_unit_test(domain_remove_part_context_switch),
ztest_unit_test(domain_remove_thread_context_switch),
ztest_unit_test(test_stack_buffer)
ztest_unit_test(test_stack_buffer),
ztest_user_unit_test(test_unimplemented_syscall),
ztest_user_unit_test(test_bad_syscall)
);
ztest_run_test_suite(userspace);
}
@@ -9,6 +9,7 @@

__syscall void stack_info_get(u32_t *start_addr, u32_t *size);
__syscall int check_perms(void *addr, size_t size, int write);
__syscall void missing_syscall(void);

#include <syscalls/test_syscall.h>

0 comments on commit 777336e

Please sign in to comment.
You can’t perform that action at this time.