Skip to content

Commit

Permalink
#2074: Use getUniqueFilename for file name in offlinelb tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed Nov 29, 2023
1 parent 7390ebe commit 8a72a9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
7 changes: 4 additions & 3 deletions tests/unit/lb/test_lb_reader.nompi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@
#include <vt/vrt/collection/balance/read_lb.h>

#include "test_harness.h"
#include "test_helpers.h"

namespace vt { namespace tests { namespace unit {

using TestLBReader = TestHarness;

TEST_F(TestLBReader, test_lb_read_1) {

std::string file_name = "test_lb_read_1.txt";
std::string file_name = getUniqueFilename(".txt");
std::ofstream out(file_name);
out << ""
"0 NoLB\n"
Expand Down Expand Up @@ -105,7 +106,7 @@ TEST_F(TestLBReader, test_lb_read_1) {

TEST_F(TestLBReader, test_lb_read_2) {

std::string file_name = "test_lb_read_2.txt";
std::string file_name = getUniqueFilename(".txt");
std::ofstream out(file_name);
out << ""
"0 NoLB\n"
Expand Down Expand Up @@ -198,7 +199,7 @@ TEST_F(TestLBReader, test_lb_read_2) {
}

TEST_F(TestLBReader, test_lb_read_3_with_offline_lb) {
std::string file_name = "test_lb_read_3_with_offline_lb.txt";
std::string file_name = getUniqueFilename(".txt");
std::ofstream out(file_name);
out << ""
"0 NoLB\n"
Expand Down
21 changes: 9 additions & 12 deletions tests/unit/lb/test_offlinelb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <fstream>

#include "test_parallel_harness.h"
#include "test_helpers.h"

namespace vt { namespace tests { namespace unit { namespace lb {

Expand Down Expand Up @@ -78,7 +79,7 @@ struct SimCol : vt::Collection<SimCol, vt::Index1D> {
void sparseHandler(Msg* m){
auto const this_node = theContext()->getNode();
vt_debug_print(terse, lb, "sparseHandler: idx={}: elm={}\n", getIndex(), getElmID());
if (m->iter == 0 or m->iter == 1 or m->iter == 2 or m->iter == 3 or m->iter == 4 or m->iter == 5 or m->iter == 6) {
if (m->iter >= 0 and m->iter <= 6) {
EXPECT_EQ(getIndex().x() / 2, this_node);
}
}
Expand Down Expand Up @@ -208,20 +209,16 @@ TEST_F(TestOfflineLB, test_offlinelb_2) {
metadata["type"] = "LBDatafile";
metadata["phases"] = phasesMetadata;

auto w = std::make_unique<JSONAppender>(
auto appender = std::make_unique<JSONAppender>(
"phases", metadata, std::move(stream), true
);
for (PhaseType i = 0; i < num_phases; i++) {
// ignore skipped and identical phases
if(i != 1 && i != 2 && i != 3 && i != 5 && i != 6) {
auto j = dh.toJson(i);
w->addElm(*j);
}
}
stream = w->finish();
// Add phases 0 and 4
appender->addElm(*dh.toJson(0));
appender->addElm(*dh.toJson(4));
stream = appender->finish();

// Preapre configuration file
std::string file_name = "test_offlinelb_2.txt";
std::string file_name = getUniqueFilenameWithRanks(".txt");
std::ofstream out(file_name);
out << ""
"0 OfflineLB\n"
Expand All @@ -234,7 +231,7 @@ TEST_F(TestOfflineLB, test_offlinelb_2) {
out.close();

theConfig()->vt_lb = true;
theConfig()->vt_lb_file_name = "test_offlinelb_2.txt";
theConfig()->vt_lb_file_name = file_name;

auto up = LBDataRestartReader::construct();
curRT->theLBDataReader = up.get();
Expand Down

0 comments on commit 8a72a9f

Please sign in to comment.