Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
scmi_power_domain: Add Unit Tests
Browse files Browse the repository at this point in the history
This patch includes unit tests to cover the changes for the incorrect
error handling fix when a set_sate fails and no response was being
generated.

Signed-off-by: Katherine Vincent <katherine.vincent@arm.com>
Change-Id: I4bf5ff420b01eb67b2b43c7c9252d43ad5bcdf9a
  • Loading branch information
katvin01 authored and mohamedasaker-arm committed May 3, 2024
1 parent 3b3c058 commit acd48f6
Show file tree
Hide file tree
Showing 9 changed files with 3,310 additions and 0 deletions.
27 changes: 27 additions & 0 deletions module/scmi_power_domain/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Arm SCP/MCP Software
# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#

set(TEST_SRC mod_scmi_power_domain)
set(TEST_FILE mod_scmi_power_domain)

set(UNIT_TEST_TARGET mod_${TEST_MODULE}_unit_test)

set(MODULE_SRC ${MODULE_ROOT}/${TEST_MODULE}/src)
set(MODULE_INC ${MODULE_ROOT}/${TEST_MODULE}/include)
list(APPEND OTHER_MODULE_INC ${MODULE_ROOT}/scmi/include)
list(APPEND OTHER_MODULE_INC ${MODULE_ROOT}/power_domain/include)
set(MODULE_UT_SRC ${CMAKE_CURRENT_LIST_DIR})
set(MODULE_UT_INC ${CMAKE_CURRENT_LIST_DIR})
set(MODULE_UT_MOCK_SRC ${CMAKE_CURRENT_LIST_DIR}/mocks)

list(APPEND MOCK_REPLACEMENTS fwk_module)
list(APPEND MOCK_REPLACEMENTS fwk_id)
list(APPEND MOCK_REPLACEMENTS fwk_core)

include(${SCP_ROOT}/unit_test/module_common.cmake)

target_compile_definitions(${UNIT_TEST_TARGET} PUBLIC "BUILD_HAS_MOD_POWER_DOMAIN")
35 changes: 35 additions & 0 deletions module/scmi_power_domain/test/config_scmi_power_domain_ut.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Arm SCP/MCP Software
* Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Description:
* SCMI System Power unit test configuration.
*/

#include <Mockmod_scmi_power_domain_extra.h>

#include <mod_power_domain.h>
#include <mod_scmi.h>
#include <mod_scmi_power_domain.h>

static struct mod_pd_restricted_api pd_api_ut = {
.get_domain_type = get_domain_type,
.get_domain_parent_id = get_domain_parent_id,
.set_state = set_state,
.get_state = get_state,
.reset = reset,
.system_suspend = system_suspend,
.system_shutdown = system_shutdown,
};

struct mod_scmi_from_protocol_api from_protocol_api = {
.get_agent_count = mod_scmi_from_protocol_api_get_agent_count,
.get_agent_id = mod_scmi_from_protocol_api_get_agent_id,
.get_agent_type = mod_scmi_from_protocol_api_get_agent_type,
.get_max_payload_size = mod_scmi_from_protocol_api_get_max_payload_size,
.write_payload = mod_scmi_from_protocol_api_write_payload,
.respond = mod_scmi_from_protocol_api_respond,
.notify = mod_scmi_from_protocol_api_notify,
};
29 changes: 29 additions & 0 deletions module/scmi_power_domain/test/fwk_module_idx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Arm SCP/MCP Software
* Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef TEST_FWK_MODULE_MODULE_IDX_H
#define TEST_FWK_MODULE_MODULE_IDX_H

#include <fwk_id.h>

enum fwk_module_idx {
FWK_MODULE_IDX_SCMI_POWER_DOMAIN,
FWK_MODULE_IDX_SCMI,
FWK_MODULE_IDX_POWER_DOMAIN,
FWK_MODULE_IDX_COUNT,
};

static const fwk_id_t fwk_module_id_scmi_power_domain =
FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SCMI_POWER_DOMAIN);

static const fwk_id_t fwk_module_id_scmi =
FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SCMI);

static const fwk_id_t fwk_module_id_power_domain =
FWK_ID_MODULE_INIT(FWK_MODULE_IDX_POWER_DOMAIN);

#endif /* TEST_FWK_MODULE_MODULE_IDX_H */
4 changes: 4 additions & 0 deletions module/scmi_power_domain/test/mocks/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"DisableFormat": true,
"SortIncludes": false,
}
Loading

0 comments on commit acd48f6

Please sign in to comment.