.idea
automation
cmake
contrib
docs
misc
scripts
src
unittests
action
cfdp
container
datapoollocal
devicehandler
globalfunctions
hal
internalerror
mocks
osal
CMakeLists.txt
TestClock.cpp
TestSemaphore.cpp
testMq.cpp
power
pus
serialize
storagemanager
tcdistributor
testcfg
testtemplate
timemanager
tmtcpacket
tmtcservices
util
CMakeLists.txt
CatchDefinitions.cpp
CatchDefinitions.h
CatchFactory.cpp
CatchFactory.h
CatchRunner.cpp
CatchRunner.h
CatchSetup.cpp
lcov_epilog.html
printChar.cpp
printChar.h
testVersion.cpp
.clang-format
.gitignore
.gitmodules
CHANGELOG.md
CMakeLists.txt
FSFWVersion.h.in
LICENSE
NOTICE
README.md
33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
#include <fsfw/osal/osal.h>
|
|
#include <fsfw/tasks/SemaphoreFactory.h>
|
|
#include <fsfw/timemanager/Stopwatch.h>
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
|
|
TEST_CASE("Binary Semaphore Test", "[BinSemaphore]") {
|
|
// perform set-up here
|
|
SemaphoreIF* binSemaph = SemaphoreFactory::instance()->createBinarySemaphore();
|
|
REQUIRE(binSemaph != nullptr);
|
|
SECTION("Simple Test") {
|
|
// set-up is run for each section
|
|
REQUIRE(binSemaph->getSemaphoreCounter() == 1);
|
|
REQUIRE(binSemaph->release() == static_cast<int>(SemaphoreIF::SEMAPHORE_NOT_OWNED));
|
|
REQUIRE(binSemaph->acquire(SemaphoreIF::POLLING) == returnvalue::OK);
|
|
{
|
|
// not precise enough on linux.. should use clock instead..
|
|
// Stopwatch stopwatch(false);
|
|
// REQUIRE(binSemaph->acquire(SemaphoreIF::TimeoutType::WAITING, 5) ==
|
|
// SemaphoreIF::SEMAPHORE_TIMEOUT);
|
|
// dur_millis_t time = stopwatch.stop();
|
|
// CHECK(time == 5);
|
|
}
|
|
REQUIRE(binSemaph->getSemaphoreCounter() == 0);
|
|
REQUIRE(binSemaph->release() == returnvalue::OK);
|
|
}
|
|
SemaphoreFactory::instance()->deleteSemaphore(binSemaph);
|
|
// perform tear-down here
|
|
}
|
|
|
|
TEST_CASE("Counting Semaphore Test", "[CountingSemaph]") {
|
|
SECTION("Simple Test") {}
|
|
} |