Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutex BasicLockable #1441

Merged
merged 2 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/test/ut/OsTaskTest.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/OsFileSystemTest.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/OsSystemResourcesTest.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/OsMutexBasicLockableTest.cpp"
)
register_fprime_ut()

Expand Down
1 change: 1 addition & 0 deletions Os/Mutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Os {

void lock(); //!< lock the mutex
void unLock(); //!< unlock the mutex
void unlock() { this->unLock(); } //!< alias for unLock to meet BasicLockable requirements

private:

Expand Down
26 changes: 26 additions & 0 deletions Os/test/ut/OsMutexBasicLockableTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <gtest/gtest.h>

#include <Os/Mutex.hpp>
#include <Fw/Types/Assert.hpp>

#include <mutex>


// This is exclusively a compile-time check
void testMutexBasicLockableTest() {
Os::Mutex mux;

{
std::lock_guard<Os::Mutex> lock(mux);
}

ASSERT_TRUE(true); // if runs will pass
}

extern "C" {
void mutexBasicLockableTest();
}

void mutexBasicLockableTest() {
testMutexBasicLockableTest();
}
6 changes: 5 additions & 1 deletion Os/test/ut/TestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ extern "C" {
void intervalTimerTest();
void fileSystemTest();
void validateFileTest(const char* filename);
void systemResourcesTest(void);
void systemResourcesTest();
void mutexBasicLockableTest();
}
const char* filename;
TEST(Nominal, StartTestTask) {
Expand Down Expand Up @@ -56,6 +57,9 @@ TEST(Nominal, ValidateFileTest) {
TEST(Nominal, SystemResourcesTest) {
systemResourcesTest();
}
TEST(Nominal, MutexBasicLockableTest) {
mutexBasicLockableTest();
}

int main(int argc, char* argv[]) {
filename = argv[0];
Expand Down