Skip to content

Commit

Permalink
SerialIOTests: Windows compatibility
Browse files Browse the repository at this point in the history
Initialize Winsock API
  • Loading branch information
franzpoeschel committed Aug 18, 2023
1 parent 5c2a753 commit 3c692c2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include <unistd.h>
#endif

#ifdef _WIN32
#include <windows.h>
#else

using namespace openPMD;

struct BackendSelection
Expand Down Expand Up @@ -1512,6 +1516,10 @@ TEST_CASE("dtype_test", "[serial]")

inline void write_test(const std::string &backend)
{
#ifdef _WIN32
WSADATA wsaData;
WSAStartup(MAKEWORD(2,0), &wsaData);
#endif
Series o = Series(
"../samples/serial_write." + backend,
Access::CREATE,
Expand Down Expand Up @@ -1620,6 +1628,9 @@ inline void write_test(const std::string &backend)
REQUIRE(
(read.mpiRanksMetaInfo(/* collective = */ false) ==
chunk_assignment::RankMeta{{0, host_info::hostname()}}));
#ifdef _WIN32
WSACleanup();
#endif
}

TEST_CASE("write_test", "[serial]")
Expand Down Expand Up @@ -1774,6 +1785,10 @@ fileBased_add_EDpic(ParticleSpecies &e, uint64_t const num_particles)

inline void fileBased_write_test(const std::string &backend)
{
#ifdef _WIN32
WSADATA wsaData;
WSAStartup(MAKEWORD(2,0), &wsaData);
#endif
if (auxiliary::directory_exists("../samples/subdir"))
auxiliary::remove_directory("../samples/subdir");

Expand Down Expand Up @@ -2154,6 +2169,9 @@ inline void fileBased_write_test(const std::string &backend)
close(dirfd);
}
#endif // defined(__unix__)
#ifdef _WIN32
WSACleanup();
#endif
}

TEST_CASE("fileBased_write_test", "[serial]")
Expand Down

0 comments on commit 3c692c2

Please sign in to comment.