From 7e3178ffe47e911555445450dd3f2eb340bebb6c Mon Sep 17 00:00:00 2001 From: James Date: Tue, 10 Dec 2019 13:56:31 -0500 Subject: [PATCH 01/17] Starting to add data directory to unit tests. --- CMake/testing/VTKmTestWrappers.cmake | 3 ++ .../testing/UnitTestMapperVolume.cxx | 41 ++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CMake/testing/VTKmTestWrappers.cmake b/CMake/testing/VTKmTestWrappers.cmake index 44770938f..3254cda10 100644 --- a/CMake/testing/VTKmTestWrappers.cmake +++ b/CMake/testing/VTKmTestWrappers.cmake @@ -102,6 +102,9 @@ function(vtkm_unit_tests) # For Testing Purposes, we will set the default logging level to INFO list(APPEND vtkm_default_test_log_level "-v" "INFO") + # Add the path to the data directory so tests can find and use data files for testing + list(APPEND VTKm_UT_TEST_ARGS "-path=${VTKm_SOURCE_DIR}/data") + if(VTKm_UT_MPI) # for MPI tests, suffix test name and add MPI_Init/MPI_Finalize calls. set(test_prog "${test_prog}_mpi") diff --git a/vtkm/rendering/testing/UnitTestMapperVolume.cxx b/vtkm/rendering/testing/UnitTestMapperVolume.cxx index 87f40d702..5572f6a35 100644 --- a/vtkm/rendering/testing/UnitTestMapperVolume.cxx +++ b/vtkm/rendering/testing/UnitTestMapperVolume.cxx @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -18,30 +19,60 @@ #include #include #include +#include namespace { +std::string get_working_path() +{ + char temp[1024]; + return (getcwd(temp, sizeof(temp)) ? std::string(temp) : std::string("")); +} + void RenderTests() { using M = vtkm::rendering::MapperVolume; using C = vtkm::rendering::CanvasRayTracer; using V3 = vtkm::rendering::View3D; - vtkm::cont::testing::MakeTestDataSet maker; vtkm::cont::ColorTable colorTable("inferno"); colorTable.AddPointAlpha(0.0, .01f); colorTable.AddPointAlpha(1.0, .01f); - vtkm::rendering::testing::Render( - maker.Make3DRegularDataSet0(), "pointvar", colorTable, "reg3D.pnm"); - vtkm::rendering::testing::Render( - maker.Make3DRectilinearDataSet0(), "pointvar", colorTable, "rect3D.pnm"); + vtkm::cont::DataSet ds; + const char* fname = "../data/magField.vtk"; + vtkm::io::reader::VTKDataSetReader reader(fname); + + try + { + ds = reader.ReadDataSet(); + } + catch (vtkm::io::ErrorIO& e) + { + std::string message("Error reading: "); + message += fname; + message += ", "; + message += e.GetMessage(); + + VTKM_TEST_FAIL(message.c_str()); + } + + + vtkm::rendering::testing::Render(ds, "vec_magnitude", colorTable, "reg3D.pnm"); + vtkm::rendering::testing::Render(ds, "vec_magnitude", colorTable, "rect3D.pnm"); } } //namespace int UnitTestMapperVolume(int argc, char* argv[]) { + std::cerr << "argc count: " << argc << std::endl; + + for (int i = 0; i < argc; i++) + { + printf("arg :: %s\n", argv[i]); + } + return vtkm::cont::testing::Testing::Run(RenderTests, argc, argv); } From b38fadc310c9d0dc213d4d4355a79a7a783e35ec Mon Sep 17 00:00:00 2001 From: James Date: Wed, 11 Dec 2019 14:38:16 -0500 Subject: [PATCH 02/17] Updates to get test data path. --- CMake/testing/VTKmTestWrappers.cmake | 2 +- vtkm/cont/testing/Testing.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMake/testing/VTKmTestWrappers.cmake b/CMake/testing/VTKmTestWrappers.cmake index 3254cda10..0c8f86530 100644 --- a/CMake/testing/VTKmTestWrappers.cmake +++ b/CMake/testing/VTKmTestWrappers.cmake @@ -103,7 +103,7 @@ function(vtkm_unit_tests) list(APPEND vtkm_default_test_log_level "-v" "INFO") # Add the path to the data directory so tests can find and use data files for testing - list(APPEND VTKm_UT_TEST_ARGS "-path=${VTKm_SOURCE_DIR}/data") + list(APPEND VTKm_UT_TEST_ARGS "--path=${VTKm_SOURCE_DIR}/data") if(VTKm_UT_MPI) # for MPI tests, suffix test name and add MPI_Init/MPI_Finalize calls. diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index 70cd509e7..a00a1fa69 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -38,7 +38,13 @@ public: template static VTKM_CONT int Run(Func function, int& argc, char* argv[]) { - vtkm::cont::Initialize(argc, argv, vtkm::cont::InitializeOptions::Strict); + vtkm::cont::Initialize(argc, argv); + + //Parse any remaining arguments that initialize did not recognize + for (int i = 0; i < argc; i++) + { + printf("after initialize arg :: %s\n", argv[i]); + } try { From 743094ffc908a5554009119cebc91ebfb998ad4c Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Dec 2019 11:07:47 -0500 Subject: [PATCH 03/17] Adding parser for arguments. --- CMake/testing/VTKmTestWrappers.cmake | 3 + vtkm/cont/testing/Testing.h | 134 ++++++++++++++++++ .../testing/UnitTestMapperVolume.cxx | 7 - 3 files changed, 137 insertions(+), 7 deletions(-) diff --git a/CMake/testing/VTKmTestWrappers.cmake b/CMake/testing/VTKmTestWrappers.cmake index 0c8f86530..2052197d4 100644 --- a/CMake/testing/VTKmTestWrappers.cmake +++ b/CMake/testing/VTKmTestWrappers.cmake @@ -105,6 +105,9 @@ function(vtkm_unit_tests) # Add the path to the data directory so tests can find and use data files for testing list(APPEND VTKm_UT_TEST_ARGS "--path=${VTKm_SOURCE_DIR}/data") + # Add the path to the location where regression test images are to be stored + list(APPEND VTKm_UT_TEST_ARGS "--images=${VTKm_SOURCE_DIR}") + if(VTKm_UT_MPI) # for MPI tests, suffix test name and add MPI_Init/MPI_Finalize calls. set(test_prog "${test_prog}_mpi") diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index a00a1fa69..132030cb1 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -25,6 +26,8 @@ #include +namespace opt = vtkm::cont::internal::option; + namespace vtkm { namespace cont @@ -32,6 +35,66 @@ namespace cont namespace testing { +enum TestOptionsIndex +{ + UNKNOWN, + DATADIR, // base dir containing test data files + IMGDIR // base dir for saving regression test images +}; + +struct VtkmArg : public opt::Arg +{ + static opt::ArgStatus Required(const opt::Option& option, bool msg) + { + if (option.arg == nullptr) + { + if (msg) + { + VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error, + "Missing argument after option '" + << std::string(option.name, static_cast(option.namelen)) + << "'.\n"); + } + return opt::ARG_ILLEGAL; + } + else + { + return opt::ARG_OK; + } + } + + // Method used for guessing whether an option that do not support (perhaps that calling + // program knows about it) has an option attached to it (which should also be ignored). + static opt::ArgStatus Unknown(const opt::Option& option, bool msg) + { + // If we don't have an arg, obviously we don't have an arg. + if (option.arg == nullptr) + { + return opt::ARG_NONE; + } + + // The opt::Arg::Optional method will return that the ARG is OK if and only if + // the argument is attached to the option (e.g. --foo=bar). If that is the case, + // then we definitely want to report that the argument is OK. + if (opt::Arg::Optional(option, msg) == opt::ARG_OK) + { + return opt::ARG_OK; + } + + // Now things get tricky. Maybe the next argument is an option or maybe it is an + // argument for this option. We will guess that if the next argument does not + // look like an option, we will treat it as such. + if (option.arg[0] == '-') + { + return opt::ARG_NONE; + } + else + { + return opt::ARG_OK; + } + } +}; + struct Testing { public: @@ -46,6 +109,77 @@ public: printf("after initialize arg :: %s\n", argv[i]); } + { // Parse test arguments + std::vector usage; + + usage.push_back( + { DATADIR, + 0, + "p", + "path", + VtkmArg::Required, + " --path, -p \tPath to the base data directory in the VTK-m src dir." }); + usage.push_back( + { IMGDIR, + 0, + "i", + "images", + VtkmArg::Required, + " --images, -i \tPath to the base dir for regression test images" }); + // Required to collect unknown arguments when help is off. + usage.push_back({ UNKNOWN, 0, "", "", VtkmArg::Unknown, "" }); + usage.push_back({ 0, 0, 0, 0, 0, 0 }); + + + // Remove argv[0] (executable name) if present: + int vtkmArgc = argc > 0 ? argc - 1 : 0; + char** vtkmArgv = vtkmArgc > 0 ? argv + 1 : argv; + + opt::Stats stats(usage.data(), vtkmArgc, vtkmArgv); + std::unique_ptr options{ new opt::Option[stats.options_max] }; + std::unique_ptr buffer{ new opt::Option[stats.buffer_max] }; + opt::Parser parse(usage.data(), vtkmArgc, vtkmArgv, options.get(), buffer.get()); + + if (parse.error()) + { + std::cerr << "Internal Initialize parser error" << std::endl; + exit(1); + } + + if (options[DATADIR]) + { + std::cerr << "found the data dir arg :: " << options[DATADIR].arg << std::endl; + } + + if (options[IMGDIR]) + { + std::cerr << "found the data image arg :: " << options[IMGDIR].arg << std::endl; + } + + for (const opt::Option* opt = options[UNKNOWN]; opt != nullptr; opt = opt->next()) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Info, + "Unknown option to internal Initialize: " << opt->name << "\n"); + if ((InitializeOptions::ErrorOnBadOption) != InitializeOptions::None) + { + std::cerr << "Unknown internal option: " << opt->name << std::endl; + exit(1); + } + } + + for (int nonOpt = 0; nonOpt < parse.nonOptionsCount(); ++nonOpt) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Info, + "Unknown argument to internal Initialize: " << parse.nonOption(nonOpt) << "\n"); + if ((InitializeOptions::ErrorOnBadArgument) != InitializeOptions::None) + { + std::cerr << "Unknown internal argument: " << parse.nonOption(nonOpt) << std::endl; + exit(1); + } + } + } + + try { function(); diff --git a/vtkm/rendering/testing/UnitTestMapperVolume.cxx b/vtkm/rendering/testing/UnitTestMapperVolume.cxx index 5572f6a35..35a4ff3b0 100644 --- a/vtkm/rendering/testing/UnitTestMapperVolume.cxx +++ b/vtkm/rendering/testing/UnitTestMapperVolume.cxx @@ -67,12 +67,5 @@ void RenderTests() int UnitTestMapperVolume(int argc, char* argv[]) { - std::cerr << "argc count: " << argc << std::endl; - - for (int i = 0; i < argc; i++) - { - printf("arg :: %s\n", argv[i]); - } - return vtkm::cont::testing::Testing::Run(RenderTests, argc, argv); } From 10d9f89258bc46d2a005d247092af215c1d70463 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 7 Jan 2020 15:56:00 -0500 Subject: [PATCH 04/17] Making the test data path available via a static function call. --- vtkm/cont/Initialize.cxx | 159 ++++++++++++++++++ vtkm/cont/Initialize.h | 24 +++ vtkm/cont/testing/Testing.h | 145 +--------------- vtkm/rendering/testing/RenderTest.h | 2 - .../testing/UnitTestMapperVolume.cxx | 25 +-- 5 files changed, 204 insertions(+), 151 deletions(-) diff --git a/vtkm/cont/Initialize.cxx b/vtkm/cont/Initialize.cxx index b0b12c851..a7e77306f 100644 --- a/vtkm/cont/Initialize.cxx +++ b/vtkm/cont/Initialize.cxx @@ -160,6 +160,68 @@ struct VtkmArg : public opt::Arg } }; + +enum TestOptionsIndex +{ + TEST_UNKNOWN, + DATADIR, // base dir containing test data files + IMGDIR // base dir for saving regression test images +}; + +struct TestVtkmArg : public opt::Arg +{ + static opt::ArgStatus Required(const opt::Option& option, bool msg) + { + if (option.arg == nullptr) + { + if (msg) + { + VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error, + "Missing argument after option '" + << std::string(option.name, static_cast(option.namelen)) + << "'.\n"); + } + return opt::ARG_ILLEGAL; + } + else + { + return opt::ARG_OK; + } + } + + // Method used for guessing whether an option that do not support (perhaps that calling + // program knows about it) has an option attached to it (which should also be ignored). + static opt::ArgStatus Unknown(const opt::Option& option, bool msg) + { + // If we don't have an arg, obviously we don't have an arg. + if (option.arg == nullptr) + { + return opt::ARG_NONE; + } + + // The opt::Arg::Optional method will return that the ARG is OK if and only if + // the argument is attached to the option (e.g. --foo=bar). If that is the case, + // then we definitely want to report that the argument is OK. + if (opt::Arg::Optional(option, msg) == opt::ARG_OK) + { + return opt::ARG_OK; + } + + // Now things get tricky. Maybe the next argument is an option or maybe it is an + // argument for this option. We will guess that if the next argument does not + // look like an option, we will treat it as such. + if (option.arg[0] == '-') + { + return opt::ARG_NONE; + } + else + { + return opt::ARG_OK; + } + } +}; + + } // end anon namespace namespace vtkm @@ -358,5 +420,102 @@ InitializeResult Initialize() vtkm::cont::InitLogging(); return InitializeResult{}; } + + +namespace // anonymous namespace to protect private testing variables +{ +std::string TestDataBasePath; +std::string RegressionTestImageBasePath; +} + +// Method to parse the extra arguments given to unit tests +VTKM_CONT +void ParseAdditionalTestArgs(int& argc, char* argv[]) +{ + { // Parse test arguments + std::vector usage; + + usage.push_back( + { DATADIR, + 0, + "p", + "path", + TestVtkmArg::Required, + " --path, -p \tPath to the base data directory in the VTK-m src dir." }); + usage.push_back({ IMGDIR, + 0, + "i", + "images", + TestVtkmArg::Required, + " --images, -i \tPath to the base dir for regression test images" }); + // Required to collect unknown arguments when help is off. + usage.push_back({ TEST_UNKNOWN, 0, "", "", TestVtkmArg::Unknown, "" }); + usage.push_back({ 0, 0, 0, 0, 0, 0 }); + + + // Remove argv[0] (executable name) if present: + int vtkmArgc = argc > 0 ? argc - 1 : 0; + char** vtkmArgv = vtkmArgc > 0 ? argv + 1 : argv; + + opt::Stats stats(usage.data(), vtkmArgc, vtkmArgv); + std::unique_ptr options{ new opt::Option[stats.options_max] }; + std::unique_ptr buffer{ new opt::Option[stats.buffer_max] }; + opt::Parser parse(usage.data(), vtkmArgc, vtkmArgv, options.get(), buffer.get()); + + if (parse.error()) + { + std::cerr << "Internal Initialize parser error" << std::endl; + exit(1); + } + + if (options[DATADIR]) + { + std::cerr << "found the data dir arg :: " << options[DATADIR].arg << std::endl; + TestDataBasePath = options[DATADIR].arg; + } + + if (options[IMGDIR]) + { + std::cerr << "found the data image arg :: " << options[IMGDIR].arg << std::endl; + RegressionTestImageBasePath = options[IMGDIR].arg; + } + + for (const opt::Option* opt = options[TEST_UNKNOWN]; opt != nullptr; opt = opt->next()) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Info, + "Unknown option to internal Initialize: " << opt->name << "\n"); + if ((InitializeOptions::ErrorOnBadOption) != InitializeOptions::None) + { + std::cerr << "Unknown internal option: " << opt->name << std::endl; + exit(1); + } + } + + for (int nonOpt = 0; nonOpt < parse.nonOptionsCount(); ++nonOpt) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Info, + "Unknown argument to internal Initialize: " << parse.nonOption(nonOpt) << "\n"); + if ((InitializeOptions::ErrorOnBadArgument) != InitializeOptions::None) + { + std::cerr << "Unknown internal argument: " << parse.nonOption(nonOpt) << std::endl; + exit(1); + } + } + } +} + +// method to access the path to the data directory in the VTK-M repository +VTKM_CONT +std::string getTestDataBasePath() +{ + return TestDataBasePath; +} + +// method to access the path to the directory where regression test images are stored +VTKM_CONT +std::string getRegressionTestImageBasePath() +{ + return RegressionTestImageBasePath; +} } } // end namespace vtkm::cont diff --git a/vtkm/cont/Initialize.h b/vtkm/cont/Initialize.h index 9fe0a056a..ea2388e36 100644 --- a/vtkm/cont/Initialize.h +++ b/vtkm/cont/Initialize.h @@ -102,6 +102,30 @@ VTKM_CONT_EXPORT VTKM_CONT InitializeResult Initialize(); /**@}*/ + + +/** + * Parses additional arguments that were not consumed by the Initialize function: + * - Sets the path to the data directory for consumption by the unit tests + * - Sets the path to the image directory for saving regression test images + * + * @note This method may call exit() on parse error. + * @{ + */ +VTKM_CONT_EXPORT +VTKM_CONT +void ParseAdditionalTestArgs(int& argc, char* argv[]); +/**@}*/ + +// method to access the path to the data directory in the VTK-M repository +VTKM_CONT_EXPORT +VTKM_CONT +std::string getTestDataBasePath(); + +// method to access the path to the directory where regression test images are stored +VTKM_CONT_EXPORT +VTKM_CONT +std::string getRegressionTestImageBasePath(); } } // end namespace vtkm::cont diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index 132030cb1..96bf12c0d 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -35,150 +35,21 @@ namespace cont namespace testing { -enum TestOptionsIndex -{ - UNKNOWN, - DATADIR, // base dir containing test data files - IMGDIR // base dir for saving regression test images -}; - -struct VtkmArg : public opt::Arg -{ - static opt::ArgStatus Required(const opt::Option& option, bool msg) - { - if (option.arg == nullptr) - { - if (msg) - { - VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error, - "Missing argument after option '" - << std::string(option.name, static_cast(option.namelen)) - << "'.\n"); - } - return opt::ARG_ILLEGAL; - } - else - { - return opt::ARG_OK; - } - } - - // Method used for guessing whether an option that do not support (perhaps that calling - // program knows about it) has an option attached to it (which should also be ignored). - static opt::ArgStatus Unknown(const opt::Option& option, bool msg) - { - // If we don't have an arg, obviously we don't have an arg. - if (option.arg == nullptr) - { - return opt::ARG_NONE; - } - - // The opt::Arg::Optional method will return that the ARG is OK if and only if - // the argument is attached to the option (e.g. --foo=bar). If that is the case, - // then we definitely want to report that the argument is OK. - if (opt::Arg::Optional(option, msg) == opt::ARG_OK) - { - return opt::ARG_OK; - } - - // Now things get tricky. Maybe the next argument is an option or maybe it is an - // argument for this option. We will guess that if the next argument does not - // look like an option, we will treat it as such. - if (option.arg[0] == '-') - { - return opt::ARG_NONE; - } - else - { - return opt::ARG_OK; - } - } -}; - struct Testing { public: + static VTKM_CONT const std::string GetTestDataPath() { return vtkm::cont::getTestDataBasePath(); } + + static VTKM_CONT const std::string GetRegressionTestImageBasePath() + { + return vtkm::cont::getRegressionTestImageBasePath(); + } + template static VTKM_CONT int Run(Func function, int& argc, char* argv[]) { vtkm::cont::Initialize(argc, argv); - - //Parse any remaining arguments that initialize did not recognize - for (int i = 0; i < argc; i++) - { - printf("after initialize arg :: %s\n", argv[i]); - } - - { // Parse test arguments - std::vector usage; - - usage.push_back( - { DATADIR, - 0, - "p", - "path", - VtkmArg::Required, - " --path, -p \tPath to the base data directory in the VTK-m src dir." }); - usage.push_back( - { IMGDIR, - 0, - "i", - "images", - VtkmArg::Required, - " --images, -i \tPath to the base dir for regression test images" }); - // Required to collect unknown arguments when help is off. - usage.push_back({ UNKNOWN, 0, "", "", VtkmArg::Unknown, "" }); - usage.push_back({ 0, 0, 0, 0, 0, 0 }); - - - // Remove argv[0] (executable name) if present: - int vtkmArgc = argc > 0 ? argc - 1 : 0; - char** vtkmArgv = vtkmArgc > 0 ? argv + 1 : argv; - - opt::Stats stats(usage.data(), vtkmArgc, vtkmArgv); - std::unique_ptr options{ new opt::Option[stats.options_max] }; - std::unique_ptr buffer{ new opt::Option[stats.buffer_max] }; - opt::Parser parse(usage.data(), vtkmArgc, vtkmArgv, options.get(), buffer.get()); - - if (parse.error()) - { - std::cerr << "Internal Initialize parser error" << std::endl; - exit(1); - } - - if (options[DATADIR]) - { - std::cerr << "found the data dir arg :: " << options[DATADIR].arg << std::endl; - } - - if (options[IMGDIR]) - { - std::cerr << "found the data image arg :: " << options[IMGDIR].arg << std::endl; - } - - for (const opt::Option* opt = options[UNKNOWN]; opt != nullptr; opt = opt->next()) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Info, - "Unknown option to internal Initialize: " << opt->name << "\n"); - if ((InitializeOptions::ErrorOnBadOption) != InitializeOptions::None) - { - std::cerr << "Unknown internal option: " << opt->name << std::endl; - exit(1); - } - } - - for (int nonOpt = 0; nonOpt < parse.nonOptionsCount(); ++nonOpt) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Info, - "Unknown argument to internal Initialize: " << parse.nonOption(nonOpt) << "\n"); - if ((InitializeOptions::ErrorOnBadArgument) != InitializeOptions::None) - { - std::cerr << "Unknown internal argument: " << parse.nonOption(nonOpt) << std::endl; - exit(1); - } - } - } - + vtkm::cont::ParseAdditionalTestArgs(argc, argv); try { diff --git a/vtkm/rendering/testing/RenderTest.h b/vtkm/rendering/testing/RenderTest.h index e3a40ab30..485ae40dc 100644 --- a/vtkm/rendering/testing/RenderTest.h +++ b/vtkm/rendering/testing/RenderTest.h @@ -48,8 +48,6 @@ inline void SetCamera(vtkm::rendering::Camera& camera, const vtkm::cont::Field&) { vtkm::Bounds b = coordBounds; - b.Z.Min = 0; - b.Z.Max = 4; camera = vtkm::rendering::Camera(); camera.ResetToBounds(b); camera.Azimuth(static_cast(45.0)); diff --git a/vtkm/rendering/testing/UnitTestMapperVolume.cxx b/vtkm/rendering/testing/UnitTestMapperVolume.cxx index 35a4ff3b0..68fc3980b 100644 --- a/vtkm/rendering/testing/UnitTestMapperVolume.cxx +++ b/vtkm/rendering/testing/UnitTestMapperVolume.cxx @@ -24,11 +24,6 @@ namespace { -std::string get_working_path() -{ - char temp[1024]; - return (getcwd(temp, sizeof(temp)) ? std::string(temp) : std::string("")); -} void RenderTests() { @@ -40,18 +35,24 @@ void RenderTests() colorTable.AddPointAlpha(0.0, .01f); colorTable.AddPointAlpha(1.0, .01f); - vtkm::cont::DataSet ds; - const char* fname = "../data/magField.vtk"; - vtkm::io::reader::VTKDataSetReader reader(fname); + vtkm::cont::DataSet rectDS, regDS; + std::string basePath = vtkm::cont::testing::Testing::GetTestDataPath(); + std::string rectfname = basePath + "/magField.vtk"; + std::string regfname = basePath + "/magField.vtk"; + vtkm::io::reader::VTKDataSetReader rectReader(rectfname); + vtkm::io::reader::VTKDataSetReader regReader(regfname); try { - ds = reader.ReadDataSet(); + rectDS = rectReader.ReadDataSet(); + regDS = regReader.ReadDataSet(); } catch (vtkm::io::ErrorIO& e) { std::string message("Error reading: "); - message += fname; + message += rectfname; + message += ", and "; + message += regfname; message += ", "; message += e.GetMessage(); @@ -59,8 +60,8 @@ void RenderTests() } - vtkm::rendering::testing::Render(ds, "vec_magnitude", colorTable, "reg3D.pnm"); - vtkm::rendering::testing::Render(ds, "vec_magnitude", colorTable, "rect3D.pnm"); + vtkm::rendering::testing::Render(regDS, "vec_magnitude", colorTable, "reg3D.pnm"); + vtkm::rendering::testing::Render(rectDS, "vec_magnitude", colorTable, "rect3D.pnm"); } } //namespace From 9d7fc3e6aa884947a969bc72c16491cdde61da19 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 8 Jan 2020 09:34:42 -0500 Subject: [PATCH 05/17] Merge branch 'Enhance-Testing-With-Data-From-Files' of https://gitlab.kitware.com/jameskress/vtk-m into Enhance-Testing-With-Data-From-Files --- vtkm/cont/Initialize.cxx | 2 -- vtkm/cont/testing/Testing.h | 1 + vtkm/rendering/testing/UnitTestMapperVolume.cxx | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/vtkm/cont/Initialize.cxx b/vtkm/cont/Initialize.cxx index a7e77306f..e3dc4004c 100644 --- a/vtkm/cont/Initialize.cxx +++ b/vtkm/cont/Initialize.cxx @@ -470,13 +470,11 @@ void ParseAdditionalTestArgs(int& argc, char* argv[]) if (options[DATADIR]) { - std::cerr << "found the data dir arg :: " << options[DATADIR].arg << std::endl; TestDataBasePath = options[DATADIR].arg; } if (options[IMGDIR]) { - std::cerr << "found the data image arg :: " << options[IMGDIR].arg << std::endl; RegressionTestImageBasePath = options[IMGDIR].arg; } diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index 96bf12c0d..9e2ff714e 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/vtkm/rendering/testing/UnitTestMapperVolume.cxx b/vtkm/rendering/testing/UnitTestMapperVolume.cxx index 68fc3980b..292ef5117 100644 --- a/vtkm/rendering/testing/UnitTestMapperVolume.cxx +++ b/vtkm/rendering/testing/UnitTestMapperVolume.cxx @@ -59,7 +59,6 @@ void RenderTests() VTKM_TEST_FAIL(message.c_str()); } - vtkm::rendering::testing::Render(regDS, "vec_magnitude", colorTable, "reg3D.pnm"); vtkm::rendering::testing::Render(rectDS, "vec_magnitude", colorTable, "rect3D.pnm"); } From 6162fdc591154eb275cc9503bd968896d807250c Mon Sep 17 00:00:00 2001 From: James Date: Wed, 8 Jan 2020 14:32:15 -0500 Subject: [PATCH 06/17] Moving new test code to the Testing.h header. --- CMake/testing/VTKmTestWrappers.cmake | 4 +- vtkm/cont/Initialize.cxx | 157 ----------------- vtkm/cont/Initialize.h | 24 --- vtkm/cont/testing/Testing.h | 166 +++++++++++++++++- .../testing/UnitTestMapperVolume.cxx | 2 +- 5 files changed, 166 insertions(+), 187 deletions(-) diff --git a/CMake/testing/VTKmTestWrappers.cmake b/CMake/testing/VTKmTestWrappers.cmake index 2052197d4..f63e00052 100644 --- a/CMake/testing/VTKmTestWrappers.cmake +++ b/CMake/testing/VTKmTestWrappers.cmake @@ -103,10 +103,10 @@ function(vtkm_unit_tests) list(APPEND vtkm_default_test_log_level "-v" "INFO") # Add the path to the data directory so tests can find and use data files for testing - list(APPEND VTKm_UT_TEST_ARGS "--path=${VTKm_SOURCE_DIR}/data") + list(APPEND VTKm_UT_TEST_ARGS "--data-dir=${VTKm_SOURCE_DIR}/data") # Add the path to the location where regression test images are to be stored - list(APPEND VTKm_UT_TEST_ARGS "--images=${VTKm_SOURCE_DIR}") + list(APPEND VTKm_UT_TEST_ARGS "--baseline-dir=${VTKm_SOURCE_DIR}") if(VTKm_UT_MPI) # for MPI tests, suffix test name and add MPI_Init/MPI_Finalize calls. diff --git a/vtkm/cont/Initialize.cxx b/vtkm/cont/Initialize.cxx index e3dc4004c..b0b12c851 100644 --- a/vtkm/cont/Initialize.cxx +++ b/vtkm/cont/Initialize.cxx @@ -160,68 +160,6 @@ struct VtkmArg : public opt::Arg } }; - -enum TestOptionsIndex -{ - TEST_UNKNOWN, - DATADIR, // base dir containing test data files - IMGDIR // base dir for saving regression test images -}; - -struct TestVtkmArg : public opt::Arg -{ - static opt::ArgStatus Required(const opt::Option& option, bool msg) - { - if (option.arg == nullptr) - { - if (msg) - { - VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error, - "Missing argument after option '" - << std::string(option.name, static_cast(option.namelen)) - << "'.\n"); - } - return opt::ARG_ILLEGAL; - } - else - { - return opt::ARG_OK; - } - } - - // Method used for guessing whether an option that do not support (perhaps that calling - // program knows about it) has an option attached to it (which should also be ignored). - static opt::ArgStatus Unknown(const opt::Option& option, bool msg) - { - // If we don't have an arg, obviously we don't have an arg. - if (option.arg == nullptr) - { - return opt::ARG_NONE; - } - - // The opt::Arg::Optional method will return that the ARG is OK if and only if - // the argument is attached to the option (e.g. --foo=bar). If that is the case, - // then we definitely want to report that the argument is OK. - if (opt::Arg::Optional(option, msg) == opt::ARG_OK) - { - return opt::ARG_OK; - } - - // Now things get tricky. Maybe the next argument is an option or maybe it is an - // argument for this option. We will guess that if the next argument does not - // look like an option, we will treat it as such. - if (option.arg[0] == '-') - { - return opt::ARG_NONE; - } - else - { - return opt::ARG_OK; - } - } -}; - - } // end anon namespace namespace vtkm @@ -420,100 +358,5 @@ InitializeResult Initialize() vtkm::cont::InitLogging(); return InitializeResult{}; } - - -namespace // anonymous namespace to protect private testing variables -{ -std::string TestDataBasePath; -std::string RegressionTestImageBasePath; -} - -// Method to parse the extra arguments given to unit tests -VTKM_CONT -void ParseAdditionalTestArgs(int& argc, char* argv[]) -{ - { // Parse test arguments - std::vector usage; - - usage.push_back( - { DATADIR, - 0, - "p", - "path", - TestVtkmArg::Required, - " --path, -p \tPath to the base data directory in the VTK-m src dir." }); - usage.push_back({ IMGDIR, - 0, - "i", - "images", - TestVtkmArg::Required, - " --images, -i \tPath to the base dir for regression test images" }); - // Required to collect unknown arguments when help is off. - usage.push_back({ TEST_UNKNOWN, 0, "", "", TestVtkmArg::Unknown, "" }); - usage.push_back({ 0, 0, 0, 0, 0, 0 }); - - - // Remove argv[0] (executable name) if present: - int vtkmArgc = argc > 0 ? argc - 1 : 0; - char** vtkmArgv = vtkmArgc > 0 ? argv + 1 : argv; - - opt::Stats stats(usage.data(), vtkmArgc, vtkmArgv); - std::unique_ptr options{ new opt::Option[stats.options_max] }; - std::unique_ptr buffer{ new opt::Option[stats.buffer_max] }; - opt::Parser parse(usage.data(), vtkmArgc, vtkmArgv, options.get(), buffer.get()); - - if (parse.error()) - { - std::cerr << "Internal Initialize parser error" << std::endl; - exit(1); - } - - if (options[DATADIR]) - { - TestDataBasePath = options[DATADIR].arg; - } - - if (options[IMGDIR]) - { - RegressionTestImageBasePath = options[IMGDIR].arg; - } - - for (const opt::Option* opt = options[TEST_UNKNOWN]; opt != nullptr; opt = opt->next()) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Info, - "Unknown option to internal Initialize: " << opt->name << "\n"); - if ((InitializeOptions::ErrorOnBadOption) != InitializeOptions::None) - { - std::cerr << "Unknown internal option: " << opt->name << std::endl; - exit(1); - } - } - - for (int nonOpt = 0; nonOpt < parse.nonOptionsCount(); ++nonOpt) - { - VTKM_LOG_S(vtkm::cont::LogLevel::Info, - "Unknown argument to internal Initialize: " << parse.nonOption(nonOpt) << "\n"); - if ((InitializeOptions::ErrorOnBadArgument) != InitializeOptions::None) - { - std::cerr << "Unknown internal argument: " << parse.nonOption(nonOpt) << std::endl; - exit(1); - } - } - } -} - -// method to access the path to the data directory in the VTK-M repository -VTKM_CONT -std::string getTestDataBasePath() -{ - return TestDataBasePath; -} - -// method to access the path to the directory where regression test images are stored -VTKM_CONT -std::string getRegressionTestImageBasePath() -{ - return RegressionTestImageBasePath; -} } } // end namespace vtkm::cont diff --git a/vtkm/cont/Initialize.h b/vtkm/cont/Initialize.h index ea2388e36..9fe0a056a 100644 --- a/vtkm/cont/Initialize.h +++ b/vtkm/cont/Initialize.h @@ -102,30 +102,6 @@ VTKM_CONT_EXPORT VTKM_CONT InitializeResult Initialize(); /**@}*/ - - -/** - * Parses additional arguments that were not consumed by the Initialize function: - * - Sets the path to the data directory for consumption by the unit tests - * - Sets the path to the image directory for saving regression test images - * - * @note This method may call exit() on parse error. - * @{ - */ -VTKM_CONT_EXPORT -VTKM_CONT -void ParseAdditionalTestArgs(int& argc, char* argv[]); -/**@}*/ - -// method to access the path to the data directory in the VTK-M repository -VTKM_CONT_EXPORT -VTKM_CONT -std::string getTestDataBasePath(); - -// method to access the path to the directory where regression test images are stored -VTKM_CONT_EXPORT -VTKM_CONT -std::string getRegressionTestImageBasePath(); } } // end namespace vtkm::cont diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index 9e2ff714e..522ecdf96 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -36,21 +36,81 @@ namespace cont namespace testing { +enum TestOptionsIndex +{ + TEST_UNKNOWN, + DATADIR, // base dir containing test data files + IMGDIR // base dir for saving regression test images +}; + +struct TestVtkmArg : public opt::Arg +{ + static opt::ArgStatus Required(const opt::Option& option, bool msg) + { + if (option.arg == nullptr) + { + if (msg) + { + VTKM_LOG_ALWAYS_S(vtkm::cont::LogLevel::Error, + "Missing argument after option '" + << std::string(option.name, static_cast(option.namelen)) + << "'.\n"); + } + return opt::ARG_ILLEGAL; + } + else + { + return opt::ARG_OK; + } + } + + // Method used for guessing whether an option that do not support (perhaps that calling + // program knows about it) has an option attached to it (which should also be ignored). + static opt::ArgStatus Unknown(const opt::Option& option, bool msg) + { + // If we don't have an arg, obviously we don't have an arg. + if (option.arg == nullptr) + { + return opt::ARG_NONE; + } + + // The opt::Arg::Optional method will return that the ARG is OK if and only if + // the argument is attached to the option (e.g. --foo=bar). If that is the case, + // then we definitely want to report that the argument is OK. + if (opt::Arg::Optional(option, msg) == opt::ARG_OK) + { + return opt::ARG_OK; + } + + // Now things get tricky. Maybe the next argument is an option or maybe it is an + // argument for this option. We will guess that if the next argument does not + // look like an option, we will treat it as such. + if (option.arg[0] == '-') + { + return opt::ARG_NONE; + } + else + { + return opt::ARG_OK; + } + } +}; + struct Testing { public: - static VTKM_CONT const std::string GetTestDataPath() { return vtkm::cont::getTestDataBasePath(); } + static VTKM_CONT const std::string GetTestDataBasePath() { return setAndGetTestDataBasePath(); } static VTKM_CONT const std::string GetRegressionTestImageBasePath() { - return vtkm::cont::getRegressionTestImageBasePath(); + return setAndGetRegressionImageBasePath(); } template static VTKM_CONT int Run(Func function, int& argc, char* argv[]) { vtkm::cont::Initialize(argc, argv); - vtkm::cont::ParseAdditionalTestArgs(argc, argv); + ParseAdditionalTestArgs(argc, argv); try { @@ -114,6 +174,106 @@ public: } return 0; } + +private: + static std::string& setAndGetTestDataBasePath(std::string path = "") + { + static std::string TestDataBasePath; + + if (path != "") + TestDataBasePath = path; + + return TestDataBasePath; + } + + static std::string& setAndGetRegressionImageBasePath(std::string path = "") + { + static std::string RegressionTestImageBasePath; + + if (path != "") + RegressionTestImageBasePath = path; + + return RegressionTestImageBasePath; + } + + // Method to parse the extra arguments given to unit tests + static VTKM_CONT void ParseAdditionalTestArgs(int& argc, char* argv[]) + { + { // Parse test arguments + std::vector usage; + + usage.push_back({ DATADIR, + 0, + "data", + "data-dir", + TestVtkmArg::Required, + " --data-dir, -data " + " \tPath to the " + "base data directory in the VTK-m " + "src dir." }); + usage.push_back({ IMGDIR, + 0, + "baseline", + "baseline-dir", + TestVtkmArg::Required, + " --baseline-dir, -b " + " " + "\tPath to the base dir " + "for regression test " + "images" }); + // Required to collect unknown arguments when help is off. + usage.push_back({ TEST_UNKNOWN, 0, "", "", TestVtkmArg::Unknown, "" }); + usage.push_back({ 0, 0, 0, 0, 0, 0 }); + + + // Remove argv[0] (executable name) if present: + int vtkmArgc = argc > 0 ? argc - 1 : 0; + char** vtkmArgv = vtkmArgc > 0 ? argv + 1 : argv; + + opt::Stats stats(usage.data(), vtkmArgc, vtkmArgv); + std::unique_ptr options{ new opt::Option[stats.options_max] }; + std::unique_ptr buffer{ new opt::Option[stats.buffer_max] }; + opt::Parser parse(usage.data(), vtkmArgc, vtkmArgv, options.get(), buffer.get()); + + if (parse.error()) + { + std::cerr << "Internal Initialize parser error" << std::endl; + exit(1); + } + + if (options[DATADIR]) + { + setAndGetTestDataBasePath(options[DATADIR].arg); + } + + if (options[IMGDIR]) + { + setAndGetRegressionImageBasePath(options[IMGDIR].arg); + } + + for (const opt::Option* opt = options[TEST_UNKNOWN]; opt != nullptr; opt = opt->next()) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Info, + "Unknown option to internal Initialize: " << opt->name << "\n"); + if ((InitializeOptions::ErrorOnBadOption) != InitializeOptions::None) + { + std::cerr << "Unknown internal option: " << opt->name << std::endl; + exit(1); + } + } + + for (int nonOpt = 0; nonOpt < parse.nonOptionsCount(); ++nonOpt) + { + VTKM_LOG_S(vtkm::cont::LogLevel::Info, + "Unknown argument to internal Initialize: " << parse.nonOption(nonOpt) << "\n"); + if ((InitializeOptions::ErrorOnBadArgument) != InitializeOptions::None) + { + std::cerr << "Unknown internal argument: " << parse.nonOption(nonOpt) << std::endl; + exit(1); + } + } + } + } }; struct Environment diff --git a/vtkm/rendering/testing/UnitTestMapperVolume.cxx b/vtkm/rendering/testing/UnitTestMapperVolume.cxx index 292ef5117..aa4b02fcc 100644 --- a/vtkm/rendering/testing/UnitTestMapperVolume.cxx +++ b/vtkm/rendering/testing/UnitTestMapperVolume.cxx @@ -36,7 +36,7 @@ void RenderTests() colorTable.AddPointAlpha(1.0, .01f); vtkm::cont::DataSet rectDS, regDS; - std::string basePath = vtkm::cont::testing::Testing::GetTestDataPath(); + std::string basePath = vtkm::cont::testing::Testing::GetTestDataBasePath(); std::string rectfname = basePath + "/magField.vtk"; std::string regfname = basePath + "/magField.vtk"; vtkm::io::reader::VTKDataSetReader rectReader(rectfname); From 3ef10a6cb41ad6cf96c3802e0673106eef081fc4 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 10 Jan 2020 08:07:11 -0500 Subject: [PATCH 07/17] Merge branch 'Enhance-Testing-With-Data-From-Files' of https://gitlab.kitware.com/jameskress/vtk-m into Enhance-Testing-With-Data-From-Files --- vtkm/cont/testing/Testing.h | 1 + 1 file changed, 1 insertion(+) diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index 522ecdf96..d771abae7 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include From 7a73b0f547435c7c81e6e14227b658f625a6b4d7 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 11 Mar 2020 13:37:52 -0400 Subject: [PATCH 08/17] Updating testing --- CMake/testing/VTKmTestWrappers.cmake | 4 +-- data/data.readme | 3 ++ .../rectilinear}/DoubleGyre_0.vtk | 0 .../rectilinear}/DoubleGyre_5.vtk | 0 data/{ => data/rectilinear}/magField.vtk | 0 data/data/rectilinear/noise.vtk | 3 ++ data/data/unstructured/ucd3d.vtk | 3 ++ data/sample.cosmotools | 3 -- data/tornado.vec | 3 -- vtkm/cont/testing/Testing.h | 34 ++++++------------- .../testing/UnitTestMapperVolume.cxx | 12 ++----- 11 files changed, 25 insertions(+), 40 deletions(-) create mode 100644 data/data.readme rename data/{temporal_datasets => data/rectilinear}/DoubleGyre_0.vtk (100%) rename data/{temporal_datasets => data/rectilinear}/DoubleGyre_5.vtk (100%) rename data/{ => data/rectilinear}/magField.vtk (100%) create mode 100644 data/data/rectilinear/noise.vtk create mode 100644 data/data/unstructured/ucd3d.vtk delete mode 100644 data/sample.cosmotools delete mode 100644 data/tornado.vec diff --git a/CMake/testing/VTKmTestWrappers.cmake b/CMake/testing/VTKmTestWrappers.cmake index f63e00052..b668ec610 100644 --- a/CMake/testing/VTKmTestWrappers.cmake +++ b/CMake/testing/VTKmTestWrappers.cmake @@ -103,10 +103,10 @@ function(vtkm_unit_tests) list(APPEND vtkm_default_test_log_level "-v" "INFO") # Add the path to the data directory so tests can find and use data files for testing - list(APPEND VTKm_UT_TEST_ARGS "--data-dir=${VTKm_SOURCE_DIR}/data") + list(APPEND VTKm_UT_TEST_ARGS "--data-dir=${VTKm_SOURCE_DIR}/data/data") # Add the path to the location where regression test images are to be stored - list(APPEND VTKm_UT_TEST_ARGS "--baseline-dir=${VTKm_SOURCE_DIR}") + list(APPEND VTKm_UT_TEST_ARGS "--baseline-dir=${VTKm_SOURCE_DIR}/data/baseline") if(VTKm_UT_MPI) # for MPI tests, suffix test name and add MPI_Init/MPI_Finalize calls. diff --git a/data/data.readme b/data/data.readme new file mode 100644 index 000000000..625be3a9b --- /dev/null +++ b/data/data.readme @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9fa8928893e3a34e24a6d675f66001df373c51657f9c5acb9606950e6e7f0b65 +size 456 diff --git a/data/temporal_datasets/DoubleGyre_0.vtk b/data/data/rectilinear/DoubleGyre_0.vtk similarity index 100% rename from data/temporal_datasets/DoubleGyre_0.vtk rename to data/data/rectilinear/DoubleGyre_0.vtk diff --git a/data/temporal_datasets/DoubleGyre_5.vtk b/data/data/rectilinear/DoubleGyre_5.vtk similarity index 100% rename from data/temporal_datasets/DoubleGyre_5.vtk rename to data/data/rectilinear/DoubleGyre_5.vtk diff --git a/data/magField.vtk b/data/data/rectilinear/magField.vtk similarity index 100% rename from data/magField.vtk rename to data/data/rectilinear/magField.vtk diff --git a/data/data/rectilinear/noise.vtk b/data/data/rectilinear/noise.vtk new file mode 100644 index 000000000..7f4eb0c53 --- /dev/null +++ b/data/data/rectilinear/noise.vtk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c23821f7436bce6d71593698e3cb0047752b4dd671513f8c4e961d4489f199f +size 12110311 diff --git a/data/data/unstructured/ucd3d.vtk b/data/data/unstructured/ucd3d.vtk new file mode 100644 index 000000000..e4ff7c88a --- /dev/null +++ b/data/data/unstructured/ucd3d.vtk @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a178b29073f2aa0d15375b07d0bdd28369422a352b5dcb5155cf67aebe54bbc +size 286099 diff --git a/data/sample.cosmotools b/data/sample.cosmotools deleted file mode 100644 index dc48f003c..000000000 --- a/data/sample.cosmotools +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9dc63465d864ec7a4546f1d006ca0153a5bb4c78fd4a42d16ad1177dabc70d75 -size 80263 diff --git a/data/tornado.vec b/data/tornado.vec deleted file mode 100644 index c4ad7a587..000000000 --- a/data/tornado.vec +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dca8105bf888e67a9fe476a563d69ac708925aec519814fb520c6057e5ca0a1f -size 1327116 diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index d771abae7..cb5d20b06 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include #include @@ -40,8 +38,8 @@ namespace testing enum TestOptionsIndex { TEST_UNKNOWN, - DATADIR, // base dir containing test data files - IMGDIR // base dir for saving regression test images + DATADIR, // base dir containing test data files + BASELINEDIR // base dir for regression test images }; struct TestVtkmArg : public opt::Arg @@ -100,11 +98,11 @@ struct TestVtkmArg : public opt::Arg struct Testing { public: - static VTKM_CONT const std::string GetTestDataBasePath() { return setAndGetTestDataBasePath(); } + static VTKM_CONT const std::string GetTestDataBasePath() { return SetAndGetTestDataBasePath(); } static VTKM_CONT const std::string GetRegressionTestImageBasePath() { - return setAndGetRegressionImageBasePath(); + return SetAndGetRegressionImageBasePath(); } template @@ -177,7 +175,7 @@ public: } private: - static std::string& setAndGetTestDataBasePath(std::string path = "") + static std::string& SetAndGetTestDataBasePath(std::string path = "") { static std::string TestDataBasePath; @@ -187,7 +185,7 @@ private: return TestDataBasePath; } - static std::string& setAndGetRegressionImageBasePath(std::string path = "") + static std::string& SetAndGetRegressionImageBasePath(std::string path = "") { static std::string RegressionTestImageBasePath; @@ -212,7 +210,7 @@ private: " \tPath to the " "base data directory in the VTK-m " "src dir." }); - usage.push_back({ IMGDIR, + usage.push_back({ BASELINEDIR, 0, "baseline", "baseline-dir", @@ -229,7 +227,7 @@ private: // Remove argv[0] (executable name) if present: int vtkmArgc = argc > 0 ? argc - 1 : 0; - char** vtkmArgv = vtkmArgc > 0 ? argv + 1 : argv; + char** vtkmArgv = argc > 0 ? argv + 1 : argv; opt::Stats stats(usage.data(), vtkmArgc, vtkmArgv); std::unique_ptr options{ new opt::Option[stats.options_max] }; @@ -244,34 +242,24 @@ private: if (options[DATADIR]) { - setAndGetTestDataBasePath(options[DATADIR].arg); + SetAndGetTestDataBasePath(options[DATADIR].arg); } - if (options[IMGDIR]) + if (options[BASELINEDIR]) { - setAndGetRegressionImageBasePath(options[IMGDIR].arg); + SetAndGetRegressionImageBasePath(options[BASELINEDIR].arg); } for (const opt::Option* opt = options[TEST_UNKNOWN]; opt != nullptr; opt = opt->next()) { VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Unknown option to internal Initialize: " << opt->name << "\n"); - if ((InitializeOptions::ErrorOnBadOption) != InitializeOptions::None) - { - std::cerr << "Unknown internal option: " << opt->name << std::endl; - exit(1); - } } for (int nonOpt = 0; nonOpt < parse.nonOptionsCount(); ++nonOpt) { VTKM_LOG_S(vtkm::cont::LogLevel::Info, "Unknown argument to internal Initialize: " << parse.nonOption(nonOpt) << "\n"); - if ((InitializeOptions::ErrorOnBadArgument) != InitializeOptions::None) - { - std::cerr << "Unknown internal argument: " << parse.nonOption(nonOpt) << std::endl; - exit(1); - } } } } diff --git a/vtkm/rendering/testing/UnitTestMapperVolume.cxx b/vtkm/rendering/testing/UnitTestMapperVolume.cxx index aa4b02fcc..0d6b5995d 100644 --- a/vtkm/rendering/testing/UnitTestMapperVolume.cxx +++ b/vtkm/rendering/testing/UnitTestMapperVolume.cxx @@ -35,32 +35,26 @@ void RenderTests() colorTable.AddPointAlpha(0.0, .01f); colorTable.AddPointAlpha(1.0, .01f); - vtkm::cont::DataSet rectDS, regDS; + vtkm::cont::DataSet rectDS, unsDS; std::string basePath = vtkm::cont::testing::Testing::GetTestDataBasePath(); - std::string rectfname = basePath + "/magField.vtk"; - std::string regfname = basePath + "/magField.vtk"; + std::string rectfname = basePath + "/rectilinear/noise.vtk"; vtkm::io::reader::VTKDataSetReader rectReader(rectfname); - vtkm::io::reader::VTKDataSetReader regReader(regfname); try { rectDS = rectReader.ReadDataSet(); - regDS = regReader.ReadDataSet(); } catch (vtkm::io::ErrorIO& e) { std::string message("Error reading: "); message += rectfname; - message += ", and "; - message += regfname; message += ", "; message += e.GetMessage(); VTKM_TEST_FAIL(message.c_str()); } - vtkm::rendering::testing::Render(regDS, "vec_magnitude", colorTable, "reg3D.pnm"); - vtkm::rendering::testing::Render(rectDS, "vec_magnitude", colorTable, "rect3D.pnm"); + vtkm::rendering::testing::Render(rectDS, "hardyglobal", colorTable, "rect3D.pnm"); } } //namespace From d14d6cb7e4e25ae8406f40316f2da063c157f1b1 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 11 Mar 2020 13:56:02 -0400 Subject: [PATCH 09/17] Updating short arguments. --- vtkm/cont/testing/Testing.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index cb5d20b06..341c00470 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -203,19 +203,19 @@ private: usage.push_back({ DATADIR, 0, - "data", + "D", "data-dir", TestVtkmArg::Required, - " --data-dir, -data " + " --data-dir, -D " " \tPath to the " "base data directory in the VTK-m " "src dir." }); usage.push_back({ BASELINEDIR, 0, - "baseline", + "B", "baseline-dir", TestVtkmArg::Required, - " --baseline-dir, -b " + " --baseline-dir, -B " " " "\tPath to the base dir " "for regression test " From adb73b360090d1d3faa895a1dd0cf9bc53b03aea Mon Sep 17 00:00:00 2001 From: James Date: Thu, 12 Mar 2020 10:50:42 -0400 Subject: [PATCH 10/17] Updating runondevice to use new args. --- vtkm/cont/testing/Testing.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtkm/cont/testing/Testing.h b/vtkm/cont/testing/Testing.h index b1b79d392..0be345992 100644 --- a/vtkm/cont/testing/Testing.h +++ b/vtkm/cont/testing/Testing.h @@ -142,9 +142,9 @@ public: template static VTKM_CONT int RunOnDevice(Func function, int argc, char* argv[]) { - auto opts = - vtkm::cont::InitializeOptions::RequireDevice | vtkm::cont::InitializeOptions::Strict; + auto opts = vtkm::cont::InitializeOptions::RequireDevice; auto config = vtkm::cont::Initialize(argc, argv, opts); + ParseAdditionalTestArgs(argc, argv); try { From 9e7ed6fde49438722234094ae35284cc13094193 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 13 Mar 2020 15:09:24 -0400 Subject: [PATCH 11/17] Checking for lfs in testing. --- CMakeLists.txt | 10 ++++++++++ data/data.readme | 4 ++-- data/sentinel-data | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 data/sentinel-data diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e24fd2a5..a249469b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,6 +159,16 @@ include(VTKmCompilerFlags) #----------------------------------------------------------------------------- +# We need to check and see if git lfs is installed so that test data will +# be available for use +file(READ "${VTKm_SOURCE_DIR}/data/sentinel-data" data) +if (NOT data STREQUAL "\n") + message(WARNING + "Testing is enabled, but the data is not available. Use git lfs in order " + " to obtain the testing data.") + set(VTKm_ENABLE_TESTING off) +endif() + # We include the wrappers unconditionally as VTK-m expects the function to # always exist (and early terminate when testing is disabled). include(testing/VTKmTestWrappers) diff --git a/data/data.readme b/data/data.readme index 625be3a9b..91daec721 100644 --- a/data/data.readme +++ b/data/data.readme @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9fa8928893e3a34e24a6d675f66001df373c51657f9c5acb9606950e6e7f0b65 -size 456 +oid sha256:f4c2b15c789037bb7721de8b40575c90dddb4a76920dba8b9488f9d3bac2b06f +size 624 diff --git a/data/sentinel-data b/data/sentinel-data new file mode 100644 index 000000000..fd481aab7 --- /dev/null +++ b/data/sentinel-data @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b +size 1 From 9ccd911644d28decc2b380db2cf14e000231fbf1 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 13 Mar 2020 15:11:33 -0400 Subject: [PATCH 12/17] Fixing file location. --- data/data.readme | 4 ++-- data/sentinel-data | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 data/sentinel-data diff --git a/data/data.readme b/data/data.readme index 91daec721..413fdd043 100644 --- a/data/data.readme +++ b/data/data.readme @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f4c2b15c789037bb7721de8b40575c90dddb4a76920dba8b9488f9d3bac2b06f -size 624 +oid sha256:4108a1c8a2fbf91c238ee9c00259e4d1f7f912236b811a450007c7995c6654a4 +size 634 diff --git a/data/sentinel-data b/data/sentinel-data deleted file mode 100644 index fd481aab7..000000000 --- a/data/sentinel-data +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b -size 1 From 41f64930ccfbeff760bcab63f0572b1ec140a26e Mon Sep 17 00:00:00 2001 From: James Date: Fri, 13 Mar 2020 15:11:58 -0400 Subject: [PATCH 13/17] Fixing file location. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a249469b7..a0e2b528b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,7 +161,7 @@ include(VTKmCompilerFlags) #----------------------------------------------------------------------------- # We need to check and see if git lfs is installed so that test data will # be available for use -file(READ "${VTKm_SOURCE_DIR}/data/sentinel-data" data) +file(READ "${VTKm_SOURCE_DIR}/data/data/sentinel-data" data) if (NOT data STREQUAL "\n") message(WARNING "Testing is enabled, but the data is not available. Use git lfs in order " From c03e84527565d2dfad1f325ac117ffb36f50fdb3 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 13 Mar 2020 15:13:53 -0400 Subject: [PATCH 14/17] File not added. --- data/data/sentinel-data | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 data/data/sentinel-data diff --git a/data/data/sentinel-data b/data/data/sentinel-data new file mode 100644 index 000000000..fd481aab7 --- /dev/null +++ b/data/data/sentinel-data @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b +size 1 From ad47be5a119c13032e1e2b0f8eabb8bd46efcfd3 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 17 Mar 2020 12:25:41 -0400 Subject: [PATCH 15/17] Adding ctest check. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0e2b528b..98266f86f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,6 +167,9 @@ if (NOT data STREQUAL "\n") "Testing is enabled, but the data is not available. Use git lfs in order " " to obtain the testing data.") set(VTKm_ENABLE_TESTING off) + if (CTEST_USE_LAUNCHERS) + set(CTEST_USE_LAUNCHERS OFF) + endif() endif() # We include the wrappers unconditionally as VTK-m expects the function to From f21f99b43c489d5dfe4faedfde41db520ee161df Mon Sep 17 00:00:00 2001 From: James Date: Tue, 24 Mar 2020 10:52:52 -0400 Subject: [PATCH 16/17] Fixing cmake case. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98266f86f..b04da1352 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,7 +168,7 @@ if (NOT data STREQUAL "\n") " to obtain the testing data.") set(VTKm_ENABLE_TESTING off) if (CTEST_USE_LAUNCHERS) - set(CTEST_USE_LAUNCHERS OFF) + set(CTEST_USE_LAUNCHERS off) endif() endif() From f8b425adbfb5fa9a3d2fad3bd741ca23624c2e6b Mon Sep 17 00:00:00 2001 From: James Date: Wed, 25 Mar 2020 09:14:56 -0400 Subject: [PATCH 17/17] Updating data README format and name. --- data/README.md | 3 +++ data/data.readme | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 data/README.md delete mode 100644 data/data.readme diff --git a/data/README.md b/data/README.md new file mode 100644 index 000000000..90655fb97 --- /dev/null +++ b/data/README.md @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b30a14a308f64c6fc2969e2b959d79dacdc5affda1d1c0e24f8e176304147146 +size 643 diff --git a/data/data.readme b/data/data.readme deleted file mode 100644 index 413fdd043..000000000 --- a/data/data.readme +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4108a1c8a2fbf91c238ee9c00259e4d1f7f912236b811a450007c7995c6654a4 -size 634