foxBMS - Unit Tests  1.6.0
The foxBMS Unit Tests API Documentation
test_bms.c File Reference

Tests for the bms driver implementation. More...

#include "unity.h"
#include "Mockafe.h"
#include "Mockbal.h"
#include "Mockbattery_system_cfg.h"
#include "Mockcontactor.h"
#include "Mockdatabase.h"
#include "Mockdiag.h"
#include "Mockfassert.h"
#include "Mockimd.h"
#include "Mockinterlock.h"
#include "Mockled.h"
#include "Mockmeas.h"
#include "Mockos.h"
#include "Mockplausibility.h"
#include "Mocksoa.h"
#include "sps_cfg.h"
#include "bms.h"
#include "foxmath.h"
#include "test_assert_helper.h"
#include <stdbool.h>
Include dependency graph for test_bms.c:

Go to the source code of this file.

Macros

#define NUM_PRECHARGE_TESTS   13
 

Functions

void setUp (void)
 
void tearDown (void)
 
STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback (void *pDataToReceiver, int num_calls)
 
void testCheckPrechargeIterateStub (void)
 Iterate over a callback that supplies various scenarios and check if they work as expected. More...
 
void testBMS_GetCurrentFlowDirectionWithTypicalValues (void)
 
void testCheckCurrentValueDirectionWithCurrentZeroMaxAndMin (void)
 
void testBMS_CheckPrechargeInvalidStringNumber (void)
 

Variables

DIAG_ID_CFG_s diag_diagnosisIdConfiguration [] = {0}
 
DIAG_DEV_s diag_device
 
BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge [BS_NR_OF_STRINGS]
 
CONT_CONTACTOR_STATE_s cont_contactorStates []
 
STD_RETURN_TYPE_e prechargeExpectedResults [BS_NR_OF_STRINGS][NUM_PRECHARGE_TESTS] = {0}
 

Detailed Description

Tests for the bms driver implementation.

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2020-04-01 (date of creation)
Updated
2023-10-12 (date of last update)
Version
v1.6.0
Prefix
TEST

Definition in file test_bms.c.

Macro Definition Documentation

◆ NUM_PRECHARGE_TESTS

#define NUM_PRECHARGE_TESTS   13

Definition at line 144 of file test_bms.c.

Function Documentation

◆ MockDATA_ReadBlock_Callback()

STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback ( void *  pDataToReceiver,
int  num_calls 
)

Definition at line 149 of file test_bms.c.

◆ setUp()

void setUp ( void  )

Definition at line 137 of file test_bms.c.

◆ tearDown()

void tearDown ( void  )

Definition at line 140 of file test_bms.c.

◆ testBMS_CheckPrechargeInvalidStringNumber()

void testBMS_CheckPrechargeInvalidStringNumber ( void  )

check that invalid values to BMS_CheckPrecharge trip an assertion

invalid values are all those that do not fall into 0 <= stringNumber < BS_NR_OF_STRINGS

Definition at line 364 of file test_bms.c.

Here is the call graph for this function:

◆ testBMS_GetCurrentFlowDirectionWithTypicalValues()

void testBMS_GetCurrentFlowDirectionWithTypicalValues ( void  )

Definition at line 297 of file test_bms.c.

Here is the call graph for this function:

◆ testCheckCurrentValueDirectionWithCurrentZeroMaxAndMin()

void testCheckCurrentValueDirectionWithCurrentZeroMaxAndMin ( void  )

Definition at line 340 of file test_bms.c.

Here is the call graph for this function:

◆ testCheckPrechargeIterateStub()

void testCheckPrechargeIterateStub ( void  )

Iterate over a callback that supplies various scenarios and check if they work as expected.

This function uses the callback MockDATA_ReadBlock_Callback() in order to inject current tables and voltage tables into the returned database tables. The array prechargeExpectedResults contains prepared return values against which the output of TEST_BMS_CheckPrecharge() is compared.

Definition at line 278 of file test_bms.c.

Here is the call graph for this function:

Variable Documentation

◆ bs_stringsWithPrecharge

Initial value:

Defines whether a string can be used to precharge or not

Definition at line 106 of file test_bms.c.

◆ cont_contactorStates

CONT_CONTACTOR_STATE_s cont_contactorStates[]
Initial value:

central state registry of all contactors of the system

Definition at line 110 of file test_bms.c.

◆ diag_device

DIAG_DEV_s diag_device
Initial value:
= {
.nrOfConfiguredDiagnosisEntries = sizeof(diag_diagnosisIdConfiguration) / sizeof(DIAG_ID_CFG_s),
.pConfigurationOfDiagnosisEntries = &diag_diagnosisIdConfiguration[0],
.numberOfFatalErrors = 0u,
}
DIAG_ID_CFG_s diag_diagnosisIdConfiguration[]
Definition: test_bms.c:98

diag device configuration struct

Definition at line 100 of file test_bms.c.

◆ diag_diagnosisIdConfiguration

DIAG_ID_CFG_s diag_diagnosisIdConfiguration[] = {0}

variable tracking the state of the diag channels

Definition at line 98 of file test_bms.c.

◆ prechargeExpectedResults

STD_RETURN_TYPE_e prechargeExpectedResults[BS_NR_OF_STRINGS][NUM_PRECHARGE_TESTS] = {0}

Definition at line 145 of file test_bms.c.