Skip to content

Commit

Permalink
tests: psci: Introduce PSCI test
Browse files Browse the repository at this point in the history
Add a simple test to the the PSCI driver

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
  • Loading branch information
carlocaione committed Jan 6, 2021
1 parent ed12b1f commit 7b08351
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/arch/arm/arm_psci/CMakeLists.txt
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
)
2 changes: 2 additions & 0 deletions tests/arch/arm/arm_psci/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_TEST_USERSPACE=y
CONFIG_ZTEST=y
46 changes: 46 additions & 0 deletions tests/arch/arm/arm_psci/src/main.c
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);
}
5 changes: 5 additions & 0 deletions tests/arch/arm/arm_psci/testcase.yaml
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

0 comments on commit 7b08351

Please sign in to comment.