-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit test fixes to support CAN mapping fixes (#44)
* Fix unit tests Update the test_vcu unit test to follow recent evolution of CAN and libopencm3 interface changes. Update the Makefile to reflect the current names of the CTRL_xxx defines and add the new GITHUB_RUN_NUMBER define. Ensure that the GitHub Action builds and runs the unit tests again. Tests: - Build and run the updated unit tests demuddle CI changes * Move the unit test stub CanHardware into its own module To allow more than one unit test that accesses the CAN hardware move the stub implementation into its own module. Tests: - Run the updated unit tests * Basic canmap test outline * Unit test CanMap transmit mapping For a wide variety of little/big-endian, offsets and lengths verify that mapping these into a CAN frame results in the expected contents. Tests: - Verify many failures are reported, clearly when running the current libopeninv - Verify no failures with the fixes in libopeninv PR#18 * Unit test CanMap receive mapping For a wide variety of little/big-endian, offsets and lengths verify that mapping a parameter from a CAN frame results in the expected contents. Tests: - Verify many failures are reported, clearly when running the current libopeninv - Verify no failures with the fixes in libopeninv PR#18 * Ensure unit test failure line numbers are shown in decimal When unit tests use std::hex to print failure information the line numbers printed by the ASSERT() macro are printed in hex as well. This is less than helpful so ensure they are always printed in decimal. * Unit test CAN map add validation Validate all of the different ways it is possible to incorrectly specify a can mapping through the "can tx" or "can rx" command with a unit test. Tests: - Verify many failures are reported, clearly when running the current libopeninv - Verify no failures with the fixes in libopeninv PR#18
- Loading branch information
1 parent
21f784f
commit 5847e01
Showing
8 changed files
with
1,028 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* This file is part of the stm32-sine project. | ||
* | ||
* Copyright (C) 2021 Johannes Huebner <[email protected]> | ||
* Copyright (C) 2024 David J. Fiddes <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "stub_canhardware.h" | ||
|
||
CanCallback* vcuCan = nullptr; | ||
uint32_t vcuCanId; | ||
|
||
CanHardware::CanHardware() | ||
{} | ||
|
||
bool CanHardware::AddCallback(CanCallback* cb) | ||
{ | ||
vcuCan = cb; | ||
return true; | ||
} | ||
|
||
bool CanHardware::RegisterUserMessage(uint32_t canId, uint32_t mask) | ||
{ | ||
vcuCanId = canId; | ||
return true; | ||
} | ||
|
||
void CanHardware::ClearUserMessages() {} | ||
|
||
void CanHardware::HandleRx(uint32_t canId, uint32_t data[2], uint8_t dlc) | ||
{ | ||
vcuCan->HandleRx(canId, data, dlc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* This file is part of the stm32-sine project. | ||
* | ||
* Copyright (C) 2021 Johannes Huebner <[email protected]> | ||
* Copyright (C) 2024 David J. Fiddes <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef TEST_CANHARDWARE_H | ||
#define TEST_CANHARDWARE_H | ||
|
||
#include "canhardware.h" | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <array> | ||
|
||
class CanStub: public CanHardware | ||
{ | ||
void SetBaudrate(enum baudrates baudrate) {} | ||
void Send(uint32_t canId, uint32_t data[2], uint8_t len) | ||
{ | ||
m_canId = canId; | ||
memcpy(&m_data[0], &data[0], sizeof(m_data)); | ||
m_len = len; | ||
} | ||
virtual void ConfigureFilters() {} | ||
|
||
public: | ||
std::array<uint8_t, 8> m_data; | ||
uint8_t m_len; | ||
uint32_t m_canId; | ||
}; | ||
|
||
extern CanCallback* vcuCan; | ||
extern uint32_t vcuCanId; | ||
|
||
#endif // TEST_CANHARDWARE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* This file is part of the stm32-sine project. | ||
* | ||
* Copyright (C) 2024 David J. Fiddes <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "stdint.h" | ||
|
||
void flash_unlock(void) | ||
{ | ||
} | ||
|
||
void flash_lock(void) | ||
{ | ||
} | ||
|
||
void flash_set_ws(uint32_t ws) | ||
{ | ||
} | ||
|
||
void flash_program_word(uint32_t address, uint32_t data) | ||
{ | ||
} | ||
|
||
void flash_erase_page(uint32_t page_address) | ||
{ | ||
} | ||
|
||
uint16_t desig_get_flash_size(void) | ||
{ | ||
return 8; | ||
} | ||
|
||
uint32_t crc_calculate(uint32_t data) | ||
{ | ||
return 0xaa55; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.