fsfw/unittests/osal/TestSemaphore.cpp

47 lines
1.6 KiB
C++
Raw Permalink Normal View History

2020-10-20 17:11:23 +02:00
#ifdef LINUX
/*
#include <fsfw/tasks/SemaphoreFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
2022-02-02 10:29:30 +01:00
#include "catch.hpp"
#include "core/CatchDefinitions.h"
2020-10-20 17:11:23 +02:00
TEST_CASE("Binary Semaphore Test" , "[BinSemaphore]") {
2022-02-02 10:29:30 +01:00
//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) ==
2022-08-24 17:25:45 +02:00
returnvalue::OK);
2022-02-02 10:29:30 +01:00
{
// 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);
2022-08-24 17:25:45 +02:00
REQUIRE(binSemaph->release() == returnvalue::OK);
2022-02-02 10:29:30 +01:00
}
SemaphoreFactory::instance()->deleteSemaphore(binSemaph);
// perform tear-down here
2020-10-20 17:11:23 +02:00
}
TEST_CASE("Counting Semaphore Test" , "[CountingSemaph]") {
2022-02-02 10:29:30 +01:00
SECTION("Simple Test") {
2020-10-20 17:11:23 +02:00
2022-02-02 10:29:30 +01:00
}
2020-10-20 17:11:23 +02:00
}
*/
#endif