From 731bf24573a076365593f7ef857255086b7b5183 Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Tue, 30 Mar 2021 00:02:52 +0200 Subject: [PATCH] [UnitTest] Add shmem unit-tests to windows Signed-off-by: Vitalii Koshura --- tests/unit-tests/lib/test_shmem.cpp | 22 ++++++++++++++++------ win_build/unittests_vs2019.vcxproj | 6 +++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/unit-tests/lib/test_shmem.cpp b/tests/unit-tests/lib/test_shmem.cpp index 1ee67cc8d9..714a2268de 100644 --- a/tests/unit-tests/lib/test_shmem.cpp +++ b/tests/unit-tests/lib/test_shmem.cpp @@ -17,14 +17,12 @@ #include "gtest/gtest.h" -#if defined(_WIN32) +#ifdef _WIN32 #include "boinc_win.h" #endif #include "shmem.h" -#define KEY 0xbeefcafe - using namespace std; namespace test_shmem { @@ -60,14 +58,26 @@ namespace test_shmem { // Objects declared here can be used by all tests in the test case for Foo. }; - // Test shmem functions for Unix/Linux/Mac V5 applications + // Test shmem functions for Windows/Unix/Linux/Mac V5 applications TEST_F(test_shmem, shmem) { void* p; + +#ifdef _WIN32 + const std::string KEY("0xbeefcafe"); + + HANDLE handle = create_shmem(reinterpret_cast(KEY.c_str()), 100, &p); + EXPECT_NE(handle, INVALID_HANDLE_VALUE); + HANDLE handle2 = attach_shmem(reinterpret_cast(KEY.c_str()), &p); + EXPECT_NE(handle2, INVALID_HANDLE_VALUE); + EXPECT_EQ(detach_shmem(handle, &p), 0); + EXPECT_EQ(detach_shmem(handle2, &p), 0); +#else +#define KEY 0xbeefcafe + EXPECT_EQ(create_shmem(KEY, 100, false, &p), 0); - EXPECT_EQ(attach_shmem(KEY, &p), 0); - EXPECT_EQ(destroy_shmem(KEY), 0); +#endif } } // namespace diff --git a/win_build/unittests_vs2019.vcxproj b/win_build/unittests_vs2019.vcxproj index 73129ddd10..b8c2ca562d 100644 --- a/win_build/unittests_vs2019.vcxproj +++ b/win_build/unittests_vs2019.vcxproj @@ -23,14 +23,14 @@ Application true v142 - Unicode + MultiByte Application false v142 true - Unicode + MultiByte @@ -107,4 +107,4 @@ - + \ No newline at end of file