From 09fe7a16118c22fb10147b123dcb2889b7af0fa5 Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 13 Oct 2021 09:11:55 -0400 Subject: [PATCH 1/3] Fix output file name reuse in tests --- .../engine/bp/TestBPWriteReadBlockInfo.cpp | 2 +- .../engine/staging-common/TestThreads.cpp | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/testing/adios2/engine/bp/TestBPWriteReadBlockInfo.cpp b/testing/adios2/engine/bp/TestBPWriteReadBlockInfo.cpp index c1921cce7c..0eb15e0437 100644 --- a/testing/adios2/engine/bp/TestBPWriteReadBlockInfo.cpp +++ b/testing/adios2/engine/bp/TestBPWriteReadBlockInfo.cpp @@ -735,7 +735,7 @@ TEST_F(BPWriteReadBlockInfo, BPWriteReadBlockInfo1D8_C) { // Each process would write a 1x8 array and all processes would // form a mpiSize * Nx 1D array - const std::string fname("BPWriteReadblockInfo1D8.bp"); + const std::string fname("BPWriteReadblockInfo1D8_C.bp"); int mpiRank = 0, mpiSize = 1; // Number of rows diff --git a/testing/adios2/engine/staging-common/TestThreads.cpp b/testing/adios2/engine/staging-common/TestThreads.cpp index d4d4af26a8..6d68e33eb3 100644 --- a/testing/adios2/engine/staging-common/TestThreads.cpp +++ b/testing/adios2/engine/staging-common/TestThreads.cpp @@ -16,7 +16,7 @@ int value_errors = 0; std::mutex StdOutMtx; -int Read(int ID) +int Read(std::string BaseName, int ID) { adios2::ADIOS adios; adios2::IO io = adios.DeclareIO("IO"); @@ -35,7 +35,7 @@ int Read(int ID) try { - std::string FName = "File" + std::to_string(ID); + std::string FName = BaseName + std::to_string(ID); adios2::Engine Reader = io.Open(FName, adios2::Mode::Read); { std::lock_guard guard(StdOutMtx); @@ -92,7 +92,7 @@ int Read(int ID) return true; } -bool Write(int ID) +bool Write(std::string BaseName, int ID) { adios2::ADIOS adios; adios2::IO io = adios.DeclareIO("IO"); @@ -110,7 +110,7 @@ bool Write(int ID) try { - std::string FName = "File" + std::to_string(ID); + std::string FName = BaseName + std::to_string(ID); adios2::Engine Writer = io.Open(FName, adios2::Mode::Write); { @@ -145,8 +145,10 @@ class TestThreads : public ::testing::Test TEST_F(TestThreads, Basic) { - auto read_fut = std::async(std::launch::async, Read, 0); - auto write_fut = std::async(std::launch::async, Write, 0); + using namespace std; + std::string BaseName = std::to_string(getpid()); + auto read_fut = std::async(std::launch::async, Read, BaseName, 0); + auto write_fut = std::async(std::launch::async, Write, BaseName, 0); bool reader_success = read_fut.get(); bool writer_success = write_fut.get(); EXPECT_TRUE(reader_success); @@ -163,11 +165,12 @@ TEST_F(TestThreads, Basic) // auto high_write_fut = std::async(std::launch::async, Write, 0); // for (int i = 0; i < 1024; i++) // { -// auto read_fut = std::async(std::launch::async, Read, i + 1); -// auto write_fut = std::async(std::launch::async, Write, i + 1); -// bool reader_success = read_fut.get(); -// bool writer_success = write_fut.get(); -// EXPECT_TRUE(reader_success); +// using namespace std; +// std::string BaseName = std::to_string(getpid()); +// auto read_fut = std::async(std::launch::async, Read, BaseName, i + +// 1); auto write_fut = std::async(std::launch::async, Write, BaseName, +// i + 1); bool reader_success = read_fut.get(); bool writer_success = +// write_fut.get(); EXPECT_TRUE(reader_success); // EXPECT_TRUE(writer_success); // EXPECT_EQ(value_errors, 0) // << "We got " << value_errors << " erroneous values at the From 1d470dadf152af550c26e4d9c52d2424283a9d8a Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 13 Oct 2021 10:34:21 -0400 Subject: [PATCH 2/3] more --- .../engine/bp/TestBPStepsInSituGlobalArray.cpp | 18 ++++++++++++------ .../engine/bp/TestBPStepsInSituLocalArray.cpp | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp b/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp index b1d4ec33bc..55a2a74332 100644 --- a/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp +++ b/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp @@ -130,6 +130,8 @@ TEST_P(BPStepsInSituGlobalArrayReaders, EveryStep) { const std::vector &schedule = GetSchedule(); const ReadMode readMode = GetReadMode(); + using namespace std; + std::string BaseName = std::to_string(getpid()); const std::string fname_prefix = "BPStepsInSituGlobalArray.EveryStep." + std::to_string(GetScheduleID()) + "." + ReadModeToString(readMode); @@ -148,10 +150,10 @@ TEST_P(BPStepsInSituGlobalArrayReaders, EveryStep) std::string fname; #if ADIOS2_USE_MPI adios2::ADIOS adios(MPI_COMM_WORLD); - fname = fname_prefix + ".MPI.bp"; + fname = fname_prefix + BaseName + ".MPI.bp"; #else adios2::ADIOS adios; - fname = fname_prefix + ".Serial.bp"; + fname = fname_prefix + BaseName + ".Serial.bp"; #endif if (!mpiRank) @@ -285,6 +287,8 @@ TEST_P(BPStepsInSituGlobalArrayReaders, NewVarPerStep) { const std::vector &schedule = GetSchedule(); const ReadMode readMode = GetReadMode(); + using namespace std; + std::string BaseName = std::to_string(getpid()); const std::string fname_prefix = "BPStepsInSituGlobalArray.NewVarPerStep." + std::to_string(GetScheduleID()) + "." + ReadModeToString(readMode); @@ -303,10 +307,10 @@ TEST_P(BPStepsInSituGlobalArrayReaders, NewVarPerStep) std::string fname; #if ADIOS2_USE_MPI adios2::ADIOS adios(MPI_COMM_WORLD); - fname = fname_prefix + ".MPI.bp"; + fname = fname_prefix + BaseName + ".MPI.bp"; #else adios2::ADIOS adios; - fname = fname_prefix + ".Serial.bp"; + fname = fname_prefix + BaseName + ".Serial.bp"; #endif auto lf_VarName = [](int step) -> std::string { @@ -475,6 +479,8 @@ TEST_P(BPStepsInSituGlobalArrayParameters, EveryOtherStep) const std::vector &schedule = GetSchedule(); const std::size_t Oddity = GetOddity(); const ReadMode readMode = GetReadMode(); + using namespace std; + std::string BaseName = std::to_string(getpid()); const std::string fname_prefix = "BPStepsInSituGlobalArray.EveryOtherStep.Schedule" + std::to_string(GetScheduleID()) + ".Oddity" + std::to_string(Oddity) + @@ -494,10 +500,10 @@ TEST_P(BPStepsInSituGlobalArrayParameters, EveryOtherStep) std::string fname; #if ADIOS2_USE_MPI adios2::ADIOS adios(MPI_COMM_WORLD); - fname = fname_prefix + ".MPI.bp"; + fname = fname_prefix + BaseName + ".MPI.bp"; #else adios2::ADIOS adios; - fname = fname_prefix + ".Serial.bp"; + fname = fname_prefix + BaseName + ".Serial.bp"; #endif diff --git a/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp b/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp index 88fafedbcb..292ec96dee 100644 --- a/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp +++ b/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp @@ -107,6 +107,8 @@ class BPStepsInSituLocalArrayReaders TEST_P(BPStepsInSituLocalArrayReaders, EveryStep) { const std::vector &schedule = GetSchedule(); + using namespace std; + std::string BaseName = std::to_string(getpid()); const std::string fname_prefix = "BPStepsInSituLocalArray.EveryStep." + std::to_string(GetScheduleID()); int mpiRank = 0, mpiSize = 1; @@ -124,10 +126,10 @@ TEST_P(BPStepsInSituLocalArrayReaders, EveryStep) std::string fname; #if ADIOS2_USE_MPI adios2::ADIOS adios(MPI_COMM_WORLD); - fname = fname_prefix + ".MPI.bp"; + fname = fname_prefix + BaseName + ".MPI.bp"; #else adios2::ADIOS adios; - fname = fname_prefix + ".Serial.bp"; + fname = fname_prefix + BaseName + ".Serial.bp"; #endif if (!mpiRank) { @@ -230,6 +232,8 @@ TEST_P(BPStepsInSituLocalArrayReaders, EveryStep) TEST_P(BPStepsInSituLocalArrayReaders, NewVarPerStep) { const std::vector &schedule = GetSchedule(); + using namespace std; + std::string BaseName = std::to_string(getpid()); const std::string fname_prefix = "BPStepsInSituLocalArray.NewVarPerStep." + std::to_string(GetScheduleID()); int mpiRank = 0, mpiSize = 1; @@ -247,10 +251,10 @@ TEST_P(BPStepsInSituLocalArrayReaders, NewVarPerStep) std::string fname; #if ADIOS2_USE_MPI adios2::ADIOS adios(MPI_COMM_WORLD); - fname = fname_prefix + ".MPI.bp"; + fname = fname_prefix + BaseName + ".MPI.bp"; #else adios2::ADIOS adios; - fname = fname_prefix + ".Serial.bp"; + fname = fname_prefix + BaseName + ".Serial.bp"; #endif auto lf_VarName = [](int step) -> std::string { @@ -380,6 +384,8 @@ TEST_P(BPStepsInSituLocalArrayParameters, EveryOtherStep) { const std::vector &schedule = GetSchedule(); const std::size_t Oddity = GetOddity(); + using namespace std; + std::string BaseName = std::to_string(getpid()); const std::string fname_prefix = "BPStepsInSituLocalArray.EveryOtherStep.Schedule" + std::to_string(GetScheduleID()) + ".Oddity" + std::to_string(Oddity); @@ -398,10 +404,10 @@ TEST_P(BPStepsInSituLocalArrayParameters, EveryOtherStep) std::string fname; #if ADIOS2_USE_MPI adios2::ADIOS adios(MPI_COMM_WORLD); - fname = fname_prefix + ".MPI.bp"; + fname = fname_prefix + BaseName + ".MPI.bp"; #else adios2::ADIOS adios; - fname = fname_prefix + ".Serial.bp"; + fname = fname_prefix + BaseName + ".Serial.bp"; #endif From 5dba863833db88dbc431281d3974042793c75b0b Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 13 Oct 2021 13:37:21 -0400 Subject: [PATCH 3/3] Don't use getpid --- testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp | 6 +++--- testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp | 6 +++--- testing/adios2/engine/staging-common/TestThreads.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp b/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp index 55a2a74332..b885f630a3 100644 --- a/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp +++ b/testing/adios2/engine/bp/TestBPStepsInSituGlobalArray.cpp @@ -131,7 +131,7 @@ TEST_P(BPStepsInSituGlobalArrayReaders, EveryStep) const std::vector &schedule = GetSchedule(); const ReadMode readMode = GetReadMode(); using namespace std; - std::string BaseName = std::to_string(getpid()); + std::string BaseName = engineName; const std::string fname_prefix = "BPStepsInSituGlobalArray.EveryStep." + std::to_string(GetScheduleID()) + "." + ReadModeToString(readMode); @@ -288,7 +288,7 @@ TEST_P(BPStepsInSituGlobalArrayReaders, NewVarPerStep) const std::vector &schedule = GetSchedule(); const ReadMode readMode = GetReadMode(); using namespace std; - std::string BaseName = std::to_string(getpid()); + std::string BaseName = engineName; const std::string fname_prefix = "BPStepsInSituGlobalArray.NewVarPerStep." + std::to_string(GetScheduleID()) + "." + ReadModeToString(readMode); @@ -480,7 +480,7 @@ TEST_P(BPStepsInSituGlobalArrayParameters, EveryOtherStep) const std::size_t Oddity = GetOddity(); const ReadMode readMode = GetReadMode(); using namespace std; - std::string BaseName = std::to_string(getpid()); + std::string BaseName = engineName; const std::string fname_prefix = "BPStepsInSituGlobalArray.EveryOtherStep.Schedule" + std::to_string(GetScheduleID()) + ".Oddity" + std::to_string(Oddity) + diff --git a/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp b/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp index 292ec96dee..2ee9c9148c 100644 --- a/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp +++ b/testing/adios2/engine/bp/TestBPStepsInSituLocalArray.cpp @@ -108,7 +108,7 @@ TEST_P(BPStepsInSituLocalArrayReaders, EveryStep) { const std::vector &schedule = GetSchedule(); using namespace std; - std::string BaseName = std::to_string(getpid()); + std::string BaseName = engineName; const std::string fname_prefix = "BPStepsInSituLocalArray.EveryStep." + std::to_string(GetScheduleID()); int mpiRank = 0, mpiSize = 1; @@ -233,7 +233,7 @@ TEST_P(BPStepsInSituLocalArrayReaders, NewVarPerStep) { const std::vector &schedule = GetSchedule(); using namespace std; - std::string BaseName = std::to_string(getpid()); + std::string BaseName = engineName; const std::string fname_prefix = "BPStepsInSituLocalArray.NewVarPerStep." + std::to_string(GetScheduleID()); int mpiRank = 0, mpiSize = 1; @@ -385,7 +385,7 @@ TEST_P(BPStepsInSituLocalArrayParameters, EveryOtherStep) const std::vector &schedule = GetSchedule(); const std::size_t Oddity = GetOddity(); using namespace std; - std::string BaseName = std::to_string(getpid()); + std::string BaseName = engineName; const std::string fname_prefix = "BPStepsInSituLocalArray.EveryOtherStep.Schedule" + std::to_string(GetScheduleID()) + ".Oddity" + std::to_string(Oddity); diff --git a/testing/adios2/engine/staging-common/TestThreads.cpp b/testing/adios2/engine/staging-common/TestThreads.cpp index 6d68e33eb3..511aafe83d 100644 --- a/testing/adios2/engine/staging-common/TestThreads.cpp +++ b/testing/adios2/engine/staging-common/TestThreads.cpp @@ -146,7 +146,7 @@ class TestThreads : public ::testing::Test TEST_F(TestThreads, Basic) { using namespace std; - std::string BaseName = std::to_string(getpid()); + std::string BaseName = engine; auto read_fut = std::async(std::launch::async, Read, BaseName, 0); auto write_fut = std::async(std::launch::async, Write, BaseName, 0); bool reader_success = read_fut.get(); @@ -166,7 +166,7 @@ TEST_F(TestThreads, Basic) // for (int i = 0; i < 1024; i++) // { // using namespace std; -// std::string BaseName = std::to_string(getpid()); +// std::string BaseName = std::to_string(_getpid()); // auto read_fut = std::async(std::launch::async, Read, BaseName, i + // 1); auto write_fut = std::async(std::launch::async, Write, BaseName, // i + 1); bool reader_success = read_fut.get(); bool writer_success =