-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple test to the the PSCI driver Signed-off-by: Carlo Caione <ccaione@baylibre.com>
- Loading branch information
1 parent
57f7e31
commit 9efc7b6
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.13.1) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(arm_psci) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) | ||
target_include_directories(app PRIVATE | ||
${ARCH_DIR}/${ARCH}/include | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_TEST_USERSPACE=y | ||
CONFIG_ZTEST=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2020 Carlo Caione <ccaione@baylibre.com> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <ztest.h> | ||
#include <drivers/psci.h> | ||
|
||
#define PSCI_DEV_NAME "PSCI" | ||
|
||
void test_psci_func(void) | ||
{ | ||
const struct device *psci; | ||
uint32_t ver; | ||
int ret; | ||
|
||
psci = device_get_binding(PSCI_DEV_NAME); | ||
zassert_not_null(psci, "Could not get psci device"); | ||
|
||
/* This should return 2 for v0.2 */ | ||
ver = psci_get_version(psci); | ||
zassert_false((PSCI_VERSION_MAJOR(ver) == 0 && | ||
PSCI_VERSION_MINOR(ver) < 2), | ||
"Wrong PSCI firware version"); | ||
|
||
/* This should return 0: (one core in the affinity instance is ON) */ | ||
ret = psci_affinity_info(psci, 0, 0); | ||
zassert_true(ret == 0, "Wrong return code from psci_affinity_info"); | ||
|
||
/* This should return -PSCI_RET_ALREADY_ON that is mapped to -EINVAL */ | ||
ret = psci_cpu_on(psci, 0, 0); | ||
zassert_true(ret == -EINVAL, "Wrong return code from psci_cpu_on"); | ||
} | ||
|
||
void test_main(void) | ||
{ | ||
const struct device *psci = device_get_binding(PSCI_DEV_NAME); | ||
zassert_not_null(psci, "Could not get psci device"); | ||
|
||
k_object_access_grant(psci, k_current_get()); | ||
|
||
ztest_test_suite(psci_func, | ||
ztest_user_unit_test(test_psci_func)); | ||
ztest_run_test_suite(psci_func); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
tests: | ||
arch.arm64.psci: | ||
arch_allow: arm | ||
tags: arm psci drivers userspace | ||
filter: CONFIG_ARM_PSCI |