tests/kernel: Simple test for multiprocessor start API
Starts the second CPU and verifies that it can set a variable while we spin on the first. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
e717267abf
commit
86ff14824d
4 changed files with 56 additions and 0 deletions
4
tests/kernel/mp/CMakeLists.txt
Normal file
4
tests/kernel/mp/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
project(NONE)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
1
tests/kernel/mp/prj.conf
Normal file
1
tests/kernel/mp/prj.conf
Normal file
|
@ -0,0 +1 @@
|
|||
CONFIG_ZTEST=y
|
48
tests/kernel/mp/src/main.c
Normal file
48
tests/kernel/mp/src/main.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <tc_util.h>
|
||||
#include <ztest.h>
|
||||
#include <kernel.h>
|
||||
|
||||
#define CPU1_STACK_SIZE 1024
|
||||
|
||||
K_THREAD_STACK_DEFINE(cpu1_stack, CPU1_STACK_SIZE);
|
||||
|
||||
int cpu_arg;
|
||||
|
||||
volatile int cpu_running;
|
||||
|
||||
void cpu1_fn(int key, void *arg)
|
||||
{
|
||||
zassert_true(key, "bad irq key");
|
||||
zassert_true(arg == &cpu_arg && *(int *)arg == 12345, "wrong arg");
|
||||
|
||||
cpu_running = 1;
|
||||
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
void test_mp_start(void)
|
||||
{
|
||||
cpu_arg = 12345;
|
||||
|
||||
_arch_start_cpu(1, cpu1_stack, CPU1_STACK_SIZE, cpu1_fn, &cpu_arg);
|
||||
|
||||
while (!cpu_running) {
|
||||
}
|
||||
|
||||
zassert_true(cpu_running, "cpu1 didn't start");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(test_mp,
|
||||
ztest_unit_test(test_mp_start));
|
||||
ztest_run_test_suite(test_mp);
|
||||
}
|
3
tests/kernel/mp/testcase.yaml
Normal file
3
tests/kernel/mp/testcase.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
tests:
|
||||
test:
|
||||
platform_whitelist: esp32
|
Loading…
Add table
Add a link
Reference in a new issue