move HAL and tests folder
This commit is contained in:
hal
src
CMakeLists.txt
fsfw_hal
CMakeLists.txt
common
devicehandlers
CMakeLists.txtGyroL3GD20Handler.cppGyroL3GD20Handler.hMgmLIS3MDLHandler.cppMgmLIS3MDLHandler.hMgmRM3100Handler.cppMgmRM3100Handler.h
devicedefinitions
host
linux
CMakeLists.txtCommandExecutor.cppCommandExecutor.hUnixFileGuard.cppUnixFileGuard.h
gpio
i2c
rpi
spi
uart
uio
utility.cpputility.hstm32h7
fsfw_tests
CMakeLists.txt
integration
CMakeLists.txt
assemblies
controller
devices
CMakeLists.txtTestCookie.cppTestCookie.hTestDeviceHandler.cppTestDeviceHandler.hTestEchoComIF.cppTestEchoComIF.h
devicedefinitions
task
internal
CMakeLists.txtInternalUnitTester.cppInternalUnitTester.hUnittDefinitions.cppUnittDefinitions.h
globalfunctions
osal
serialize
unit
CMakeLists.txtCatchDefinitions.cppCatchDefinitions.hCatchFactory.cppCatchFactory.hCatchRunner.cppCatchRunner.hCatchSetup.cpp
action
cfdp
CMakeLists.txttestAckPdu.cpptestCfdp.cpptestEofPdu.cpptestFileData.cpptestFinishedPdu.cpptestKeepAlivePdu.cpptestMetadataPdu.cpptestNakPdu.cpptestPromptPdu.cpptestTlvsLvs.cpp
container
CMakeLists.txtRingBufferTest.cppTestArrayList.cppTestDynamicFifo.cppTestFifo.cppTestFixedArrayList.cppTestFixedMap.cppTestFixedOrderedMultimap.cppTestPlacementFactory.cpp
datapoollocal
CMakeLists.txtDataSetTest.cppLocalPoolManagerTest.cppLocalPoolOwnerBase.cppLocalPoolOwnerBase.hLocalPoolVariableTest.cppLocalPoolVectorTest.cpp
devicehandler
CMakeLists.txtComIFMock.cppComIFMock.hCookieIFMock.cppCookieIFMock.hDeviceFdirMock.cppDeviceFdirMock.hDeviceHandlerCommander.cppDeviceHandlerCommander.hDeviceHandlerMock.cppDeviceHandlerMock.hTestDeviceHandlerBase.cpp
globalfunctions
CMakeLists.txttestBitutil.cpptestCRC.cpptestDleEncoder.cpptestOpDivider.cpptestTimevalOperations.cpp
hal
internalerror
mocks
CMakeLists.txtHkReceiverMock.hMessageQueueMockBase.hPeriodicTaskIFMock.hPowerSwitcherMock.cppPowerSwitcherMock.h
osal
power
printChar.cppprintChar.hserialize
CMakeLists.txtTestSerialBufferAdapter.cppTestSerialLinkedPacket.cppTestSerialLinkedPacket.hTestSerialization.cpp
storagemanager
testcfg
CMakeLists.txtFSFWConfig.h.inOBSWConfig.h.inTestsConfig.h.in
devices
events
ipc
objects
pollingsequence
returnvalues
tmtc
testtemplate
timemanager
tmtcpacket
version.cpptests
71
src/fsfw_tests/unit/power/testPowerSwitcher.cpp
Normal file
71
src/fsfw_tests/unit/power/testPowerSwitcher.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
#include <fsfw/power/DummyPowerSwitcher.h>
|
||||
#include <fsfw/power/PowerSwitcher.h>
|
||||
#include <fsfw_tests/unit/mocks/PowerSwitcherMock.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "objects/systemObjectList.h"
|
||||
|
||||
TEST_CASE("Power Switcher", "[power-switcher]") {
|
||||
PowerSwitcherMock mock;
|
||||
PowerSwitcher switcher(&mock, 1);
|
||||
DummyPowerSwitcher dummySwitcher(objects::DUMMY_POWER_SWITCHER, 5, 5, false);
|
||||
PowerSwitcher switcherUsingDummy(&dummySwitcher, 1);
|
||||
SwitchInfo switchInfo;
|
||||
mock.initSwitch(1);
|
||||
|
||||
SECTION("Basic Tests") {
|
||||
REQUIRE(switcher.getFirstSwitch() == 1);
|
||||
REQUIRE(switcher.getSecondSwitch() == power::NO_SWITCH);
|
||||
// Default start state
|
||||
REQUIRE(switcher.getState() == PowerSwitcher::SWITCH_IS_OFF);
|
||||
switcher.turnOn(true);
|
||||
REQUIRE(mock.getAmountSwitchStatWasRequested() == 1);
|
||||
REQUIRE(switcher.getState() == PowerSwitcher::WAIT_ON);
|
||||
REQUIRE(switcher.checkSwitchState() == PowerSwitcher::IN_POWER_TRANSITION);
|
||||
REQUIRE(switcher.active());
|
||||
switcher.doStateMachine();
|
||||
REQUIRE(switcher.getState() == PowerSwitcher::SWITCH_IS_ON);
|
||||
mock.getSwitchInfo(1, switchInfo);
|
||||
REQUIRE(switchInfo.timesCalledOn == 1);
|
||||
REQUIRE(not switcher.active());
|
||||
REQUIRE(mock.getAmountSwitchStatWasRequested() == 2);
|
||||
REQUIRE(switcher.checkSwitchState() == HasReturnvaluesIF::RETURN_OK);
|
||||
REQUIRE(mock.getAmountSwitchStatWasRequested() == 3);
|
||||
switcher.turnOff(false);
|
||||
REQUIRE(mock.getAmountSwitchStatWasRequested() == 3);
|
||||
REQUIRE(switcher.getState() == PowerSwitcher::WAIT_OFF);
|
||||
REQUIRE(switcher.active());
|
||||
REQUIRE(switcher.getState() == PowerSwitcher::WAIT_OFF);
|
||||
switcher.doStateMachine();
|
||||
mock.getSwitchInfo(1, switchInfo);
|
||||
REQUIRE(switcher.getState() == PowerSwitcher::SWITCH_IS_OFF);
|
||||
REQUIRE(switchInfo.timesCalledOn == 1);
|
||||
REQUIRE(switchInfo.timesCalledOff == 1);
|
||||
REQUIRE(not switcher.active());
|
||||
REQUIRE(mock.getAmountSwitchStatWasRequested() == 4);
|
||||
}
|
||||
|
||||
SECTION("Dummy Test") {
|
||||
// Same tests, but we can't really check the dummy
|
||||
REQUIRE(switcherUsingDummy.getFirstSwitch() == 1);
|
||||
REQUIRE(switcherUsingDummy.getSecondSwitch() == power::NO_SWITCH);
|
||||
REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::SWITCH_IS_OFF);
|
||||
switcherUsingDummy.turnOn(true);
|
||||
REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::WAIT_ON);
|
||||
REQUIRE(switcherUsingDummy.active());
|
||||
switcherUsingDummy.doStateMachine();
|
||||
REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::SWITCH_IS_ON);
|
||||
REQUIRE(not switcherUsingDummy.active());
|
||||
|
||||
switcherUsingDummy.turnOff(false);
|
||||
REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::WAIT_OFF);
|
||||
REQUIRE(switcherUsingDummy.active());
|
||||
REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::WAIT_OFF);
|
||||
switcherUsingDummy.doStateMachine();
|
||||
REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::SWITCH_IS_OFF);
|
||||
REQUIRE(not switcherUsingDummy.active());
|
||||
}
|
||||
|
||||
SECTION("More Dummy Tests") {}
|
||||
}
|
Reference in New Issue
Block a user