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

Commit

Permalink
mod_power_domain: Deny suspend requests if multiple cores remain active
Browse files Browse the repository at this point in the history
SCMI system suspend requests must be denied if multiple APs are active.
This patch enables this with a check in the mod_power_domain API call.

Signed-off-by: James McGregor <[email protected]>
Change-Id: I0845de0ba12cee66ac1a2d6e3efced7dd4417df6
  • Loading branch information
Jmc18134 committed Mar 26, 2024
1 parent aea5422 commit c2206b8
Show file tree
Hide file tree
Showing 9 changed files with 342 additions and 0 deletions.
9 changes: 9 additions & 0 deletions module/power_domain/include/internal/power_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ bool is_upwards_transition_propagation(
*/
bool is_allowed_by_parent_and_children(struct pd_ctx *pd, unsigned int state);

/*
* Check if a power domain is not in the given state or is
* awaiting any state changes or driver transitions.
*
* \param pd Description of the power domain to be checked.
* \param state Power state.
*/
bool is_state_in_transition(struct pd_ctx *pd, unsigned int state);

/*
* Auxiliary functions
*/
Expand Down
18 changes: 18 additions & 0 deletions module/power_domain/src/mod_power_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,28 @@ static int pd_get_state(fwk_id_t pd_id, unsigned int *state)

static int pd_system_suspend(unsigned int state)
{
unsigned int i, active_cores;
struct pd_ctx *pd;
struct fwk_event req;
struct pd_system_suspend_request *req_params =
(struct pd_system_suspend_request *)(&req.params);

/* System suspend is only supported if exactly one core remains active */
active_cores = 0u;
for (i = 0; i < mod_pd_ctx.pd_count; i++) {
pd = &mod_pd_ctx.pd_ctx_table[i];

if (pd->config->attributes.pd_type == MOD_PD_TYPE_CORE &&
is_state_in_transition(pd, (unsigned int)MOD_PD_STATE_OFF)) {
active_cores += 1;
}
}

if (active_cores > 1) {
FWK_LOG_ERR("[PD] Invalid system suspend request.");
return FWK_E_STATE;
}

req = (struct fwk_event){
.id = FWK_ID_EVENT(
FWK_MODULE_IDX_POWER_DOMAIN, PD_EVENT_IDX_SYSTEM_SUSPEND),
Expand Down
6 changes: 6 additions & 0 deletions module/power_domain/src/power_domain_state_checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,9 @@ bool is_allowed_by_parent_and_children(struct pd_ctx *pd, unsigned int state)

return true;
}

bool is_state_in_transition(struct pd_ctx *pd, unsigned int state)
{
return pd->requested_state != state || pd->current_state != state ||
pd->state_requested_to_driver != state;
}
3 changes: 3 additions & 0 deletions module/power_domain/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ 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 OTHER_MODULE_INC ${MODULE_ROOT}/system_power/include)

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

list(APPEND MOCK_REPLACEMENTS fwk_notification)

Expand Down
201 changes: 201 additions & 0 deletions module/power_domain/test/mocks/Mockmod_power_domain_extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ static const char* CMockString_is_allowed_by_children = "is_allowed_by_children"
static const char* CMockString_is_allowed_by_parent_and_children = "is_allowed_by_parent_and_children";
static const char* CMockString_is_deeper_state = "is_deeper_state";
static const char* CMockString_is_shallower_state = "is_shallower_state";
static const char* CMockString_is_state_in_transition = "is_state_in_transition";
static const char* CMockString_is_upwards_transition_propagation = "is_upwards_transition_propagation";
static const char* CMockString_is_valid_composite_state = "is_valid_composite_state";
static const char* CMockString_is_valid_state = "is_valid_state";
Expand Down Expand Up @@ -300,6 +301,22 @@ typedef struct _CMOCK_is_allowed_by_parent_and_children_CALL_INSTANCE

} CMOCK_is_allowed_by_parent_and_children_CALL_INSTANCE;

typedef struct _CMOCK_is_state_in_transition_CALL_INSTANCE
{
UNITY_LINE_TYPE LineNumber;
char ExpectAnyArgsBool;
bool ReturnVal;
struct pd_ctx* Expected_pd;
unsigned int Expected_state;
int Expected_pd_Depth;
char ReturnThruPtr_pd_Used;
struct pd_ctx* ReturnThruPtr_pd_Val;
size_t ReturnThruPtr_pd_Size;
char IgnoreArg_pd;
char IgnoreArg_state;

} CMOCK_is_state_in_transition_CALL_INSTANCE;

typedef struct _CMOCK_initiate_power_state_pre_transition_notification_CALL_INSTANCE
{
UNITY_LINE_TYPE LineNumber;
Expand Down Expand Up @@ -436,6 +453,12 @@ static struct Mockmod_power_domain_extraInstance
CMOCK_is_allowed_by_parent_and_children_CALLBACK is_allowed_by_parent_and_children_CallbackFunctionPointer;
int is_allowed_by_parent_and_children_CallbackCalls;
CMOCK_MEM_INDEX_TYPE is_allowed_by_parent_and_children_CallInstance;
char is_state_in_transition_IgnoreBool;
bool is_state_in_transition_FinalReturn;
char is_state_in_transition_CallbackBool;
CMOCK_is_state_in_transition_CALLBACK is_state_in_transition_CallbackFunctionPointer;
int is_state_in_transition_CallbackCalls;
CMOCK_MEM_INDEX_TYPE is_state_in_transition_CallInstance;
char initiate_power_state_pre_transition_notification_IgnoreBool;
bool initiate_power_state_pre_transition_notification_FinalReturn;
char initiate_power_state_pre_transition_notification_CallbackBool;
Expand Down Expand Up @@ -710,6 +733,19 @@ void Mockmod_power_domain_extra_Verify(void)
call_instance = CMOCK_GUTS_NONE;
(void)call_instance;
}
call_instance = Mock.is_state_in_transition_CallInstance;
if (Mock.is_state_in_transition_IgnoreBool)
call_instance = CMOCK_GUTS_NONE;
if (CMOCK_GUTS_NONE != call_instance)
{
UNITY_SET_DETAIL(CMockString_is_state_in_transition);
UNITY_TEST_FAIL(cmock_line, CMockStringCalledLess);
}
if (Mock.is_state_in_transition_CallbackFunctionPointer != NULL)
{
call_instance = CMOCK_GUTS_NONE;
(void)call_instance;
}
call_instance = Mock.initiate_power_state_pre_transition_notification_CallInstance;
if (Mock.initiate_power_state_pre_transition_notification_IgnoreBool)
call_instance = CMOCK_GUTS_NONE;
Expand Down Expand Up @@ -3597,6 +3633,171 @@ void is_allowed_by_parent_and_children_CMockIgnoreArg_state(UNITY_LINE_TYPE cmoc
cmock_call_instance->IgnoreArg_state = 1;
}

bool is_state_in_transition(struct pd_ctx* pd, unsigned int state)
{
UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance;
UNITY_SET_DETAIL(CMockString_is_state_in_transition);
cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.is_state_in_transition_CallInstance);
Mock.is_state_in_transition_CallInstance = CMock_Guts_MemNext(Mock.is_state_in_transition_CallInstance);
if (Mock.is_state_in_transition_IgnoreBool)
{
UNITY_CLR_DETAILS();
if (cmock_call_instance == NULL)
return Mock.is_state_in_transition_FinalReturn;
Mock.is_state_in_transition_FinalReturn = cmock_call_instance->ReturnVal;
return cmock_call_instance->ReturnVal;
}
if (!Mock.is_state_in_transition_CallbackBool &&
Mock.is_state_in_transition_CallbackFunctionPointer != NULL)
{
bool cmock_cb_ret = Mock.is_state_in_transition_CallbackFunctionPointer(pd, state, Mock.is_state_in_transition_CallbackCalls++);
UNITY_CLR_DETAILS();
return cmock_cb_ret;
}
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore);
cmock_line = cmock_call_instance->LineNumber;
if (!cmock_call_instance->ExpectAnyArgsBool)
{
if (!cmock_call_instance->IgnoreArg_pd)
{
UNITY_SET_DETAILS(CMockString_is_state_in_transition,CMockString_pd);
if (cmock_call_instance->Expected_pd == NULL)
{ UNITY_TEST_ASSERT_NULL(pd, cmock_line, CMockStringExpNULL); }
else
{ UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((void*)(cmock_call_instance->Expected_pd), (void*)(pd), sizeof(struct pd_ctx), cmock_call_instance->Expected_pd_Depth, cmock_line, CMockStringMismatch); }
}
if (!cmock_call_instance->IgnoreArg_state)
{
UNITY_SET_DETAILS(CMockString_is_state_in_transition,CMockString_state);
UNITY_TEST_ASSERT_EQUAL_HEX32(cmock_call_instance->Expected_state, state, cmock_line, CMockStringMismatch);
}
}
if (Mock.is_state_in_transition_CallbackFunctionPointer != NULL)
{
cmock_call_instance->ReturnVal = Mock.is_state_in_transition_CallbackFunctionPointer(pd, state, Mock.is_state_in_transition_CallbackCalls++);
}
if (cmock_call_instance->ReturnThruPtr_pd_Used)
{
UNITY_TEST_ASSERT_NOT_NULL(pd, cmock_line, CMockStringPtrIsNULL);
memcpy((void*)pd, (void*)cmock_call_instance->ReturnThruPtr_pd_Val,
cmock_call_instance->ReturnThruPtr_pd_Size);
}
UNITY_CLR_DETAILS();
return cmock_call_instance->ReturnVal;
}

void CMockExpectParameters_is_state_in_transition(CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance, struct pd_ctx* pd, int pd_Depth, unsigned int state);
void CMockExpectParameters_is_state_in_transition(CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance, struct pd_ctx* pd, int pd_Depth, unsigned int state)
{
cmock_call_instance->Expected_pd = pd;
cmock_call_instance->Expected_pd_Depth = pd_Depth;
cmock_call_instance->IgnoreArg_pd = 0;
cmock_call_instance->ReturnThruPtr_pd_Used = 0;
cmock_call_instance->Expected_state = state;
cmock_call_instance->IgnoreArg_state = 0;
}

void is_state_in_transition_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_is_state_in_transition_CALL_INSTANCE));
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);
memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));
Mock.is_state_in_transition_CallInstance = CMock_Guts_MemChain(Mock.is_state_in_transition_CallInstance, cmock_guts_index);
Mock.is_state_in_transition_IgnoreBool = (char)0;
cmock_call_instance->LineNumber = cmock_line;
cmock_call_instance->ExpectAnyArgsBool = (char)0;
cmock_call_instance->ReturnVal = cmock_to_return;
Mock.is_state_in_transition_IgnoreBool = (char)1;
}

void is_state_in_transition_CMockStopIgnore(void)
{
if(Mock.is_state_in_transition_IgnoreBool)
Mock.is_state_in_transition_CallInstance = CMock_Guts_MemNext(Mock.is_state_in_transition_CallInstance);
Mock.is_state_in_transition_IgnoreBool = (char)0;
}

void is_state_in_transition_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_is_state_in_transition_CALL_INSTANCE));
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);
memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));
Mock.is_state_in_transition_CallInstance = CMock_Guts_MemChain(Mock.is_state_in_transition_CallInstance, cmock_guts_index);
Mock.is_state_in_transition_IgnoreBool = (char)0;
cmock_call_instance->LineNumber = cmock_line;
cmock_call_instance->ExpectAnyArgsBool = (char)0;
cmock_call_instance->ReturnVal = cmock_to_return;
cmock_call_instance->ExpectAnyArgsBool = (char)1;
}

void is_state_in_transition_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, struct pd_ctx* pd, unsigned int state, bool cmock_to_return)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_is_state_in_transition_CALL_INSTANCE));
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);
memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));
Mock.is_state_in_transition_CallInstance = CMock_Guts_MemChain(Mock.is_state_in_transition_CallInstance, cmock_guts_index);
Mock.is_state_in_transition_IgnoreBool = (char)0;
cmock_call_instance->LineNumber = cmock_line;
cmock_call_instance->ExpectAnyArgsBool = (char)0;
CMockExpectParameters_is_state_in_transition(cmock_call_instance, pd, 1, state);
cmock_call_instance->ReturnVal = cmock_to_return;
}

void is_state_in_transition_AddCallback(CMOCK_is_state_in_transition_CALLBACK Callback)
{
Mock.is_state_in_transition_IgnoreBool = (char)0;
Mock.is_state_in_transition_CallbackBool = (char)1;
Mock.is_state_in_transition_CallbackFunctionPointer = Callback;
}

void is_state_in_transition_Stub(CMOCK_is_state_in_transition_CALLBACK Callback)
{
Mock.is_state_in_transition_IgnoreBool = (char)0;
Mock.is_state_in_transition_CallbackBool = (char)0;
Mock.is_state_in_transition_CallbackFunctionPointer = Callback;
}

void is_state_in_transition_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, struct pd_ctx* pd, int pd_Depth, unsigned int state, bool cmock_to_return)
{
CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_is_state_in_transition_CALL_INSTANCE));
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);
memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));
Mock.is_state_in_transition_CallInstance = CMock_Guts_MemChain(Mock.is_state_in_transition_CallInstance, cmock_guts_index);
Mock.is_state_in_transition_IgnoreBool = (char)0;
cmock_call_instance->LineNumber = cmock_line;
cmock_call_instance->ExpectAnyArgsBool = (char)0;
CMockExpectParameters_is_state_in_transition(cmock_call_instance, pd, pd_Depth, state);
cmock_call_instance->ReturnVal = cmock_to_return;
}

void is_state_in_transition_CMockReturnMemThruPtr_pd(UNITY_LINE_TYPE cmock_line, struct pd_ctx* pd, size_t cmock_size)
{
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.is_state_in_transition_CallInstance));
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringPtrPreExp);
cmock_call_instance->ReturnThruPtr_pd_Used = 1;
cmock_call_instance->ReturnThruPtr_pd_Val = pd;
cmock_call_instance->ReturnThruPtr_pd_Size = cmock_size;
}

void is_state_in_transition_CMockIgnoreArg_pd(UNITY_LINE_TYPE cmock_line)
{
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.is_state_in_transition_CallInstance));
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringIgnPreExp);
cmock_call_instance->IgnoreArg_pd = 1;
}

void is_state_in_transition_CMockIgnoreArg_state(UNITY_LINE_TYPE cmock_line)
{
CMOCK_is_state_in_transition_CALL_INSTANCE* cmock_call_instance = (CMOCK_is_state_in_transition_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.is_state_in_transition_CallInstance));
UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringIgnPreExp);
cmock_call_instance->IgnoreArg_state = 1;
}

bool initiate_power_state_pre_transition_notification(struct pd_ctx* pd)
{
UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;
Expand Down
22 changes: 22 additions & 0 deletions module/power_domain/test/mocks/Mockmod_power_domain_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,28 @@ void is_allowed_by_parent_and_children_CMockReturnMemThruPtr_pd(UNITY_LINE_TYPE
void is_allowed_by_parent_and_children_CMockIgnoreArg_pd(UNITY_LINE_TYPE cmock_line);
#define is_allowed_by_parent_and_children_IgnoreArg_state() is_allowed_by_parent_and_children_CMockIgnoreArg_state(__LINE__)
void is_allowed_by_parent_and_children_CMockIgnoreArg_state(UNITY_LINE_TYPE cmock_line);
#define is_state_in_transition_IgnoreAndReturn(cmock_retval) is_state_in_transition_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void is_state_in_transition_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define is_state_in_transition_StopIgnore() is_state_in_transition_CMockStopIgnore()
void is_state_in_transition_CMockStopIgnore(void);
#define is_state_in_transition_ExpectAnyArgsAndReturn(cmock_retval) is_state_in_transition_CMockExpectAnyArgsAndReturn(__LINE__, cmock_retval)
void is_state_in_transition_CMockExpectAnyArgsAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define is_state_in_transition_ExpectAndReturn(pd, state, cmock_retval) is_state_in_transition_CMockExpectAndReturn(__LINE__, pd, state, cmock_retval)
void is_state_in_transition_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, struct pd_ctx* pd, unsigned int state, bool cmock_to_return);
typedef bool (* CMOCK_is_state_in_transition_CALLBACK)(struct pd_ctx* pd, unsigned int state, int cmock_num_calls);
void is_state_in_transition_AddCallback(CMOCK_is_state_in_transition_CALLBACK Callback);
void is_state_in_transition_Stub(CMOCK_is_state_in_transition_CALLBACK Callback);
#define is_state_in_transition_StubWithCallback is_state_in_transition_Stub
#define is_state_in_transition_ExpectWithArrayAndReturn(pd, pd_Depth, state, cmock_retval) is_state_in_transition_CMockExpectWithArrayAndReturn(__LINE__, pd, pd_Depth, state, cmock_retval)
void is_state_in_transition_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, struct pd_ctx* pd, int pd_Depth, unsigned int state, bool cmock_to_return);
#define is_state_in_transition_ReturnThruPtr_pd(pd) is_state_in_transition_CMockReturnMemThruPtr_pd(__LINE__, pd, sizeof(struct pd_ctx))
#define is_state_in_transition_ReturnArrayThruPtr_pd(pd, cmock_len) is_state_in_transition_CMockReturnMemThruPtr_pd(__LINE__, pd, cmock_len * sizeof(*pd))
#define is_state_in_transition_ReturnMemThruPtr_pd(pd, cmock_size) is_state_in_transition_CMockReturnMemThruPtr_pd(__LINE__, pd, cmock_size)
void is_state_in_transition_CMockReturnMemThruPtr_pd(UNITY_LINE_TYPE cmock_line, struct pd_ctx* pd, size_t cmock_size);
#define is_state_in_transition_IgnoreArg_pd() is_state_in_transition_CMockIgnoreArg_pd(__LINE__)
void is_state_in_transition_CMockIgnoreArg_pd(UNITY_LINE_TYPE cmock_line);
#define is_state_in_transition_IgnoreArg_state() is_state_in_transition_CMockIgnoreArg_state(__LINE__)
void is_state_in_transition_CMockIgnoreArg_state(UNITY_LINE_TYPE cmock_line);
#define initiate_power_state_pre_transition_notification_IgnoreAndReturn(cmock_retval) initiate_power_state_pre_transition_notification_CMockIgnoreAndReturn(__LINE__, cmock_retval)
void initiate_power_state_pre_transition_notification_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, bool cmock_to_return);
#define initiate_power_state_pre_transition_notification_StopIgnore() initiate_power_state_pre_transition_notification_CMockStopIgnore()
Expand Down
2 changes: 2 additions & 0 deletions module/power_domain/test/mod_power_domain_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ bool is_upwards_transition_propagation(

bool is_allowed_by_parent_and_children(struct pd_ctx *pd, unsigned int state);

bool is_state_in_transition(struct pd_ctx *pd, unsigned int state);

bool initiate_power_state_pre_transition_notification(struct pd_ctx *pd);

#endif /* MOD_POWER_DOMAIN_EXTRA_H */
26 changes: 26 additions & 0 deletions module/power_domain/test/mod_power_domain_state_checks_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,32 @@ void test_retrieve_mapped_state_core(void)
TEST_ASSERT_EQUAL(MOD_PD_STATE_SLEEP, state);
}

void test_is_state_in_transition_valid(void)
{
bool valid;
struct pd_ctx pd;
pd.current_state = MOD_PD_STATE_OFF;
pd.requested_state = MOD_PD_STATE_OFF;
pd.state_requested_to_driver = MOD_PD_STATE_OFF;

valid = is_state_in_transition(&pd, MOD_PD_STATE_OFF);

TEST_ASSERT_EQUAL(false, valid);
}

void test_is_state_in_transition_invalid(void)
{
bool valid;
struct pd_ctx pd;
pd.current_state = MOD_PD_STATE_OFF;
pd.requested_state = MOD_PD_STATE_ON;
pd.state_requested_to_driver = MOD_PD_STATE_ON;

valid = is_state_in_transition(&pd, MOD_PD_STATE_OFF);

TEST_ASSERT_EQUAL(true, valid);
}

int power_domain_state_checks_test_main(void)
{
UNITY_BEGIN();
Expand Down
Loading

0 comments on commit c2206b8

Please sign in to comment.