diff --git a/tests/unit/deps/test_vtk.cc b/tests/unit/deps/test_vtk.cc index 96f465264..9de91c316 100644 --- a/tests/unit/deps/test_vtk.cc +++ b/tests/unit/deps/test_vtk.cc @@ -116,7 +116,7 @@ TEST_F(VtkTest, test_vtk_screenshot_example) { w2i->SetMagnification(2); // image quality #endif w2i->SetInputBufferTypeToRGBA(); // also record the alpha - // (transparency) channel + // (transparency) channel w2i->ReadFrontBufferOff(); // read from the back buffer w2i->Update(); @@ -126,4 +126,4 @@ TEST_F(VtkTest, test_vtk_screenshot_example) { writer->SetInputConnection(windowToImageFilter->GetOutputPort()); } -} // namespace vt::tv::tests::unit::deps \ No newline at end of file +} // namespace vt::tv::tests::unit::deps diff --git a/tests/unit/main.cc b/tests/unit/main.cc index f9d2e6f5d..960fb6e20 100644 --- a/tests/unit/main.cc +++ b/tests/unit/main.cc @@ -55,5 +55,6 @@ void __asan_on_error() { int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS();; + return RUN_ALL_TESTS(); + ; } diff --git a/tests/unit/render/test_render.cc b/tests/unit/render/test_render.cc index b85222162..361b44eab 100644 --- a/tests/unit/render/test_render.cc +++ b/tests/unit/render/test_render.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// test_render.cc +// test_parse_render.cc // DARMA/vt-tv => Virtual Transport -- Task Visualizer // // Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC @@ -43,90 +43,73 @@ #include +#include + +#include + #include #include #include #include #include -#include -#include -#include - -#include -#include - #include "../generator.h" #include "../util.h" namespace vt::tv::tests::unit::render { +using ParseRender = vt::tv::utility::ParseRender; using Util = vt::tv::tests::unit::Util; /** - * Provides unit tests for the vt::tv::render::Render class to test with config file input - * Note: PNG output is turned off for these tests. + * Provides unit tests for the vt::tv::utility::ParseRender class to test with config file input */ -class RenderTest :public ::testing::TestWithParam { - -protected: - Render createRender(YAML::Node config, Info info, std::string& output_dir) { - // change output directory to use specific one for these tests - output_dir = Util::resolveDir(SRC_DIR, "output/tests/render", true); - - return Render( - {config["viz"]["rank_qoi"].as(), "", - config["viz"]["object_qoi"].as()}, - config["viz"]["force_continuous_object_qoi"].as(), info, - {config["viz"]["x_ranks"].as(), - config["viz"]["y_ranks"].as(), - config["viz"]["z_ranks"].as()}, - config["viz"]["object_jitter"].as(), output_dir, - config["output"]["file_stem"].as(), 1.0, - config["viz"]["save_meshes"].as(), false, - std::numeric_limits::max()); - } -}; +class ParseRenderTest : public ::testing::TestWithParam { }; /** - * Test Render:generate correcty run the different configuration files and generates mesh files (.vtp) + * Test ParseRender:parseAndRender correcty run the different configuration files */ -TEST_P(RenderTest, test_render_from_config_with_png) { - std::string const & config_file = GetParam(); - YAML::Node config = YAML::LoadFile(fmt::format("{}/tests/config/{}", SRC_DIR, config_file)); +TEST_P(ParseRenderTest, test_parse_config_and_render_no_png) { + std::string const& config_file = GetParam(); + auto parse_render = + ParseRender(fmt::format("{}/tests/config/{}", SRC_DIR, config_file)); + YAML::Node config = + YAML::LoadFile(fmt::format("{}/tests/config/{}", SRC_DIR, config_file)); Info info = Generator::loadInfoFromConfig(config); - uint64_t win_size = 2000; - uint64_t font_size = 50; - - std::string output_dir; - std::string output_file_stem = config["output"]["file_stem"].as(); - - // Render - Render render = createRender(config, info, output_dir); + auto output_dir = Util::resolveDir( + SRC_DIR, config["output"]["directory"].as(), true); std::filesystem::create_directories(output_dir); - render.generate(font_size, win_size); + auto output_file_stem = config["output"]["file_stem"].as(); + + // generate file containing object jitter dimensions for output trace and input usage + // this is needed for image and mesh tests + ASSERT_NO_THROW(parse_render.parseAndRender()); - // Check: that number of generated mesh files (*.vtp) correspond to the number of phases - std::string output_file_stem = - config["output"]["file_stem"].as(); for (uint64_t i = 0; i < info.getNumPhases(); i++) { auto rank_mesh_file = fmt::format("{}{}_rank_mesh_{}.vtp", output_dir, output_file_stem, i); auto object_mesh_file = fmt::format("{}{}_object_mesh_{}.vtp", output_dir, output_file_stem, i); + auto png_file = fmt::format("{}{}{}.png", output_dir, output_file_stem, i); + + fmt::print("----- Test phase {} -----\n", i); + // 1. test files exist: rank mesh, object mesh, png ASSERT_TRUE(std::filesystem::exists(rank_mesh_file)) - << fmt::format("Error: rank mesh not generated at {}", object_mesh_file); + << fmt::format("Error: rank mesh not generated at {}", rank_mesh_file); ASSERT_TRUE(std::filesystem::exists(object_mesh_file)) << fmt::format( "Error: object mesh not generated at {}", object_mesh_file); - } + ASSERT_FALSE(std::filesystem::exists(png_file)) + << fmt::format("Error: PNG image not generated at {}", png_file); + + } // end phases loop } /* Run with different configuration files */ INSTANTIATE_TEST_SUITE_P( - RenderTests, RenderTest, - ::testing::Values("conf.yaml", "ccm-example.yaml"), + ParseRenderTests, ParseRenderTest, + ::testing::Values("conf-no-png.yaml", "ccm-example-no-png.yaml"), [](const ::testing::TestParamInfo& in_info) { // test suffix as slug auto suffix = std::regex_replace(in_info.param, std::regex("\\.yaml"), ""); @@ -134,33 +117,4 @@ INSTANTIATE_TEST_SUITE_P( return suffix; }); -TEST_F(RenderTest, test_render_construct_from_info) { - // old example2 now as a test - using namespace vt; - using namespace tv; - // Read JSON file and input data - - std::filesystem::path p = std::filesystem::path(SRC_DIR) / "data/lb_test_data/"; - std::string path = std::filesystem::absolute(p).string(); - - NodeType n_ranks = 4; - - std::unique_ptr info = std::make_unique(); - - for (NodeType rank = 0; rank < n_ranks; rank++) { - utility::JSONReader reader{rank}; - reader.readFile(path + "/data." + std::to_string(rank) + ".json"); - auto tmpInfo = reader.parse(); - info->addInfo(tmpInfo->getObjectInfo(), tmpInfo->getRank(rank)); - } - - fmt::print("Num ranks={}\n", info->getNumRanks()); - - // Instantiate render - auto r = Render(*info); - r.generate(); - - SUCCEED(); -} - -} // namespace vt::tv::tests::unit::render +} // namespace vt::tv::tests::unit::render \ No newline at end of file diff --git a/tests/unit/render/test_standalone_app.cc b/tests/unit/render/test_standalone_app.cc index 5997fc15f..f9a1f0f72 100644 --- a/tests/unit/render/test_standalone_app.cc +++ b/tests/unit/render/test_standalone_app.cc @@ -60,7 +60,8 @@ struct StandaloneAppTest return; // Make the output directory for these tests - std::filesystem::create_directories(fmt::format("{}/output/tests", SRC_DIR)); + std::filesystem::create_directories( + fmt::format("{}/output/tests", SRC_DIR)); } }; diff --git a/tests/unit/utility/test_json_reader.cc b/tests/unit/utility/test_json_reader.cc index 387be7578..1935c9c1b 100644 --- a/tests/unit/utility/test_json_reader.cc +++ b/tests/unit/utility/test_json_reader.cc @@ -57,7 +57,8 @@ using JSONReader = vt::tv::utility::JSONReader; struct JSONReaderTest : public ::testing::Test { }; TEST_F(JSONReaderTest, test_json_reader_1) { - std::filesystem::path p = std::filesystem::path(SRC_DIR) / "data/lb_test_data" ; + std::filesystem::path p = + std::filesystem::path(SRC_DIR) / "data/lb_test_data"; std::string path = std::filesystem::absolute(p).string(); NodeType rank = 0; @@ -112,7 +113,8 @@ TEST_F(JSONReaderTest, test_json_reader_1) { } TEST_F(JSONReaderTest, test_json_reader_metadata_attributes) { - std::filesystem::path p = std::filesystem::path(SRC_DIR) / "data/lb_test_data" ; + std::filesystem::path p = + std::filesystem::path(SRC_DIR) / "data/lb_test_data"; std::string path = std::filesystem::absolute(p).string(); NodeType rank = 0; @@ -135,7 +137,8 @@ TEST_F(JSONReaderTest, test_json_reader_metadata_attributes) { } TEST_F(JSONReaderTest, test_json_reader_object_info_attributes) { - std::filesystem::path p = std::filesystem::path(SRC_DIR) / "data/lb_test_data" ; + std::filesystem::path p = + std::filesystem::path(SRC_DIR) / "data/lb_test_data"; std::string path = std::filesystem::absolute(p).string(); NodeType rank = 0; @@ -185,7 +188,8 @@ TEST_F(JSONReaderTest, test_json_reader_qoi_serializer) { } TEST_F(JSONReaderTest, test_json_reader_object_work_user_defined) { - std::filesystem::path p = std::filesystem::path(SRC_DIR) / "data/lb_test_data" ; + std::filesystem::path p = + std::filesystem::path(SRC_DIR) / "data/lb_test_data"; std::string path = std::filesystem::absolute(p).string(); NodeType rank = 0;