![]() |
foxBMS - Unit Tests
1.6.0
The foxBMS Unit Tests API Documentation
|
Tests for the configuration validation functions and counter reset calculation in the the CAN driver. More...
#include "unity.h"
#include "MockHL_can.h"
#include "Mockcan_cfg.h"
#include "Mockdatabase.h"
#include "Mockdiag.h"
#include "Mockfoxmath.h"
#include "Mockftask.h"
#include "Mockimd.h"
#include "Mockio.h"
#include "Mockmcu.h"
#include "Mockos.h"
#include "Mockpex.h"
#include "Mockqueue.h"
#include "Mocktest_can_mpu_prototype_queue_create_stub.h"
#include "version_cfg.h"
#include "can.h"
#include "test_assert_helper.h"
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
Macros | |
#define | CANRX_NOT_PERIODIC (0u) |
#define | TEST_CANTX_ID_DUMMY (0x001) |
#define | TEST_CANTX_DUMMY_PERIOD_ms (51u) /* Period must be divisible by CAN Tick */ |
#define | TEST_CANTX_DUMMY_PHASE_ms (11u) /* Phase must be divisible by CAN Tick */ |
#define | TEST_CANTX_DUMMY_MESSAGE |
#define | TEST_CANTX_DUMMY_PERIOD_2_ms (30) |
#define | TEST_CANTX_DUMMY_PHASE_2_ms (0) |
#define | TEST_CANTX_DUMMY_MESSAGE_2 |
#define | TEST_CANTX_DUMMY_PERIOD_3_ms (70) |
#define | TEST_CANTX_DUMMY_PHASE_3_ms (0) |
#define | TEST_CANTX_DUMMY_MESSAGE_3 |
#define | TEST_CANRX_ID_DUMMY (0x002) |
#define | TEST_CANRX_DUMMY_MESSAGE |
Functions | |
static uint32_t | TEST_CANTX_DummyCallback (CAN_MESSAGE_PROPERTIES_s message, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim) |
static uint32_t | TEST_CANRX_DummyCallback (CAN_MESSAGE_PROPERTIES_s message, const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim) |
void | setUp (void) |
void | tearDown (void) |
void | testCAN_ValidateConfiguredTxMessagePeriod (void) |
void | testCAN_ValidateConfiguredTxMessagePhase (void) |
void | testCAN_CalculateCounterResetValue (void) |
Tests for the configuration validation functions and counter reset calculation in the the CAN driver.
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:
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 file implements the test of the validation functions for tx message configuration with the first invalid configuration of message period and phase in dummy message 1. Both functions are tested to assert an error with invalid configuration. Also the test for the CAN_CalculateCounterResetValue function is implemented here. It is tested to calculate the correct value for the given dummy messages.
Definition in file test_can_1.c.
#define CANRX_NOT_PERIODIC (0u) |
Definition at line 104 of file test_can_1.c.
#define TEST_CANRX_DUMMY_MESSAGE |
Definition at line 153 of file test_can_1.c.
#define TEST_CANRX_ID_DUMMY (0x002) |
Definition at line 151 of file test_can_1.c.
#define TEST_CANTX_DUMMY_MESSAGE |
Definition at line 111 of file test_can_1.c.
#define TEST_CANTX_DUMMY_MESSAGE_2 |
Definition at line 125 of file test_can_1.c.
#define TEST_CANTX_DUMMY_MESSAGE_3 |
Definition at line 139 of file test_can_1.c.
#define TEST_CANTX_DUMMY_PERIOD_2_ms (30) |
Definition at line 122 of file test_can_1.c.
#define TEST_CANTX_DUMMY_PERIOD_3_ms (70) |
Definition at line 136 of file test_can_1.c.
#define TEST_CANTX_DUMMY_PERIOD_ms (51u) /* Period must be divisible by CAN Tick */ |
Definition at line 108 of file test_can_1.c.
#define TEST_CANTX_DUMMY_PHASE_2_ms (0) |
Definition at line 123 of file test_can_1.c.
#define TEST_CANTX_DUMMY_PHASE_3_ms (0) |
Definition at line 137 of file test_can_1.c.
#define TEST_CANTX_DUMMY_PHASE_ms (11u) /* Phase must be divisible by CAN Tick */ |
Definition at line 109 of file test_can_1.c.
#define TEST_CANTX_ID_DUMMY (0x001) |
Definition at line 107 of file test_can_1.c.
void setUp | ( | void | ) |
Definition at line 228 of file test_can_1.c.
void tearDown | ( | void | ) |
Definition at line 231 of file test_can_1.c.
|
static |
Definition at line 199 of file test_can_1.c.
|
static |
Definition at line 191 of file test_can_1.c.
void testCAN_CalculateCounterResetValue | ( | void | ) |
void testCAN_ValidateConfiguredTxMessagePeriod | ( | void | ) |
void testCAN_ValidateConfiguredTxMessagePhase | ( | void | ) |
const CAN_SHIM_s can_kShim |
variable for storing and passing on the local database table handles
Definition at line 181 of file test_can_1.c.
const CAN_NODE_s can_node1 |
CAN node configurations for CAN1 and CAN2 (isolated)
Definition at line 164 of file test_can_1.c.
const CAN_NODE_s can_node2Isolated |
Definition at line 168 of file test_can_1.c.
const CAN_RX_MESSAGE_TYPE_s can_rxMessages[] |
registry of CAN RX messages
Definition at line 212 of file test_can_1.c.
const uint8_t can_rxMessagesLength = sizeof(can_rxMessages) / sizeof(can_rxMessages[0]) |
length of CAN message arrays
Definition at line 217 of file test_can_1.c.
|
static |
Definition at line 172 of file test_can_1.c.
|
static |
Definition at line 175 of file test_can_1.c.
|
static |
Definition at line 174 of file test_can_1.c.
|
static |
Definition at line 176 of file test_can_1.c.
|
static |
Definition at line 177 of file test_can_1.c.
|
static |
Definition at line 173 of file test_can_1.c.
const CAN_TX_MESSAGE_TYPE_s can_txMessages[] |
CAN RX and TX message configuration structs
registry of CAN TX messages
Definition at line 206 of file test_can_1.c.
const uint8_t can_txMessagesLength = sizeof(can_txMessages) / sizeof(can_txMessages[0]) |
array length for transmission CAN0 message definition
length of CAN message arrays
Definition at line 216 of file test_can_1.c.
CAN_STATE_s* canTestState = NULL_PTR |
Definition at line 219 of file test_can_1.c.
volatile bool ftsk_allQueuesCreated = false |
indicator whether the queues have successfully been initialized to be used in other parts of the software
Definition at line 225 of file test_can_1.c.
OS_QUEUE ftsk_canRxQueue = NULL_PTR |
CAN driver data queue for RX messages
Definition at line 223 of file test_can_1.c.
OS_QUEUE ftsk_canTxUnsentMessagesQueue = NULL_PTR |
CAN driver data queue for unsent TX messages
Definition at line 224 of file test_can_1.c.
OS_QUEUE ftsk_dataQueue = NULL_PTR |
Definition at line 221 of file test_can_1.c.
OS_QUEUE ftsk_imdCanDataQueue = NULL_PTR |
queue for CAN based IMD devices
Definition at line 222 of file test_can_1.c.
OS_QUEUE imd_canDataQueue = NULL_PTR |
Definition at line 179 of file test_can_1.c.