mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge topic 'Enhance-Testing-From-File'
46d7d1865 Merge remote-tracking branch 'upstream/master' into Enhance-Testing-From-File f8b425adb Updating data README format and name. 95ba497bb Merge remote-tracking branch 'upstream/master' into Enhance-Testing-From-File f21f99b43 Fixing cmake case. ad47be5a1 Adding ctest check. c03e84527 File not added. 41f64930c Fixing file location. 9ccd91164 Fixing file location. ... Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <kmorel@sandia.gov> Merge-request: !1986
This commit is contained in:
commit
9eaaadb1bd
@ -103,6 +103,12 @@ 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 "--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}/data/baseline")
|
||||
|
||||
if(VTKm_UT_MPI)
|
||||
# for MPI tests, suffix test name and add MPI_Init/MPI_Finalize calls.
|
||||
set(test_prog "${test_prog}_mpi")
|
||||
|
@ -159,6 +159,19 @@ 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/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)
|
||||
if (CTEST_USE_LAUNCHERS)
|
||||
set(CTEST_USE_LAUNCHERS off)
|
||||
endif()
|
||||
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)
|
||||
|
3
data/README.md
Normal file
3
data/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b30a14a308f64c6fc2969e2b959d79dacdc5affda1d1c0e24f8e176304147146
|
||||
size 643
|
3
data/data/rectilinear/noise.vtk
Normal file
3
data/data/rectilinear/noise.vtk
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8c23821f7436bce6d71593698e3cb0047752b4dd671513f8c4e961d4489f199f
|
||||
size 12110311
|
3
data/data/sentinel-data
Normal file
3
data/data/sentinel-data
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b
|
||||
size 1
|
3
data/data/unstructured/ucd3d.vtk
Normal file
3
data/data/unstructured/ucd3d.vtk
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9a178b29073f2aa0d15375b07d0bdd28369422a352b5dcb5155cf67aebe54bbc
|
||||
size 286099
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9dc63465d864ec7a4546f1d006ca0153a5bb4c78fd4a42d16ad1177dabc70d75
|
||||
size 80263
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dca8105bf888e67a9fe476a563d69ac708925aec519814fb520c6057e5ca0a1f
|
||||
size 1327116
|
@ -13,6 +13,7 @@
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/Error.h>
|
||||
#include <vtkm/cont/Initialize.h>
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
#include <vtkm/testing/Testing.h>
|
||||
#include <vtkm/thirdparty/diy/Configure.h>
|
||||
|
||||
@ -25,6 +26,8 @@
|
||||
|
||||
#include <vtkm/thirdparty/diy/serialization.h>
|
||||
|
||||
namespace opt = vtkm::cont::internal::option;
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
@ -32,13 +35,81 @@ namespace cont
|
||||
namespace testing
|
||||
{
|
||||
|
||||
enum TestOptionsIndex
|
||||
{
|
||||
TEST_UNKNOWN,
|
||||
DATADIR, // base dir containing test data files
|
||||
BASELINEDIR // base dir for 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<size_t>(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 GetTestDataBasePath() { return SetAndGetTestDataBasePath(); }
|
||||
|
||||
static VTKM_CONT const std::string GetRegressionTestImageBasePath()
|
||||
{
|
||||
return SetAndGetRegressionImageBasePath();
|
||||
}
|
||||
|
||||
template <class Func>
|
||||
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);
|
||||
ParseAdditionalTestArgs(argc, argv);
|
||||
|
||||
try
|
||||
{
|
||||
@ -71,9 +142,9 @@ public:
|
||||
template <class Func>
|
||||
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
|
||||
{
|
||||
@ -102,6 +173,96 @@ 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<opt::Descriptor> usage;
|
||||
|
||||
usage.push_back({ DATADIR,
|
||||
0,
|
||||
"D",
|
||||
"data-dir",
|
||||
TestVtkmArg::Required,
|
||||
" --data-dir, -D "
|
||||
"<data-dir-path> \tPath to the "
|
||||
"base data directory in the VTK-m "
|
||||
"src dir." });
|
||||
usage.push_back({ BASELINEDIR,
|
||||
0,
|
||||
"B",
|
||||
"baseline-dir",
|
||||
TestVtkmArg::Required,
|
||||
" --baseline-dir, -B "
|
||||
"<baseline-dir-path> "
|
||||
"\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 = argc > 0 ? argv + 1 : argv;
|
||||
|
||||
opt::Stats stats(usage.data(), vtkmArgc, vtkmArgv);
|
||||
std::unique_ptr<opt::Option[]> options{ new opt::Option[stats.options_max] };
|
||||
std::unique_ptr<opt::Option[]> 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[BASELINEDIR])
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
for (int nonOpt = 0; nonOpt < parse.nonOptionsCount(); ++nonOpt)
|
||||
{
|
||||
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
|
||||
"Unknown argument to internal Initialize: " << parse.nonOption(nonOpt) << "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct Environment
|
||||
|
@ -48,8 +48,6 @@ inline void SetCamera<vtkm::rendering::View3D>(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<vtkm::Float32>(45.0));
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/io/reader/VTKDataSetReader.h>
|
||||
#include <vtkm/rendering/Actor.h>
|
||||
#include <vtkm/rendering/Canvas.h>
|
||||
#include <vtkm/rendering/CanvasRayTracer.h>
|
||||
@ -18,25 +19,42 @@
|
||||
#include <vtkm/rendering/Scene.h>
|
||||
#include <vtkm/rendering/View3D.h>
|
||||
#include <vtkm/rendering/testing/RenderTest.h>
|
||||
#include <vtkm/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
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<M, C, V3>(
|
||||
maker.Make3DRegularDataSet0(), "pointvar", colorTable, "reg3D.pnm");
|
||||
vtkm::rendering::testing::Render<M, C, V3>(
|
||||
maker.Make3DRectilinearDataSet0(), "pointvar", colorTable, "rect3D.pnm");
|
||||
vtkm::cont::DataSet rectDS, unsDS;
|
||||
std::string basePath = vtkm::cont::testing::Testing::GetTestDataBasePath();
|
||||
std::string rectfname = basePath + "/rectilinear/noise.vtk";
|
||||
vtkm::io::reader::VTKDataSetReader rectReader(rectfname);
|
||||
|
||||
try
|
||||
{
|
||||
rectDS = rectReader.ReadDataSet();
|
||||
}
|
||||
catch (vtkm::io::ErrorIO& e)
|
||||
{
|
||||
std::string message("Error reading: ");
|
||||
message += rectfname;
|
||||
message += ", ";
|
||||
message += e.GetMessage();
|
||||
|
||||
VTKM_TEST_FAIL(message.c_str());
|
||||
}
|
||||
|
||||
vtkm::rendering::testing::Render<M, C, V3>(rectDS, "hardyglobal", colorTable, "rect3D.pnm");
|
||||
}
|
||||
|
||||
} //namespace
|
||||
|
Loading…
Reference in New Issue
Block a user