Commit afed84d5 authored by Andrew Bauer's avatar Andrew Bauer

Merge branch 'catalyst_regression_test' into 'master'

Adding in a test for the Catalyst slice output using the oscillator.

See merge request !61
parents 239b8126 e802d75e
......@@ -13,3 +13,7 @@ target_include_directories(util SYSTEM PUBLIC
add_executable(oscillator ${sources})
target_link_libraries(oscillator ${libs})
if (BUILD_TESTING)
add_subdirectory(testing)
endif (BUILD_TESTING)
if (BUILD_TESTING)
if (ENABLE_CATALYST)
add_test(NAME testCatalystSlice
COMMAND ${CMAKE_COMMAND}
-DCATALYST_TEST_DRIVER:FILEPATH=$<TARGET_FILE:oscillator>
-DIMAGE_TESTER:FILEPATH=$<TARGET_FILE:CompareImages>
-DCATALYST_TEST_DIR:PATH=${CMAKE_BINARY_DIR}/Testing
-DCATALYST_TEST_DATA=${CMAKE_CURRENT_SOURCE_DIR}
-DMPIEXEC:FILEPATH=${MPIEXEC}
-DMPIEXEC_NUMPROC_FLAG:STRING=${MPIEXEC_NUMPROC_FLAG}
-DMPIEXEC_NUMPROCS=2
-DMPIEXEC_PREFLAGS:STRING=${MPIEXEC_PREFLAGS}
-DVTK_MPI_POSTFLAGS:STRING=${VTK_MPI_POSTFLAGS}
-P ${CMAKE_CURRENT_SOURCE_DIR}/CatalystSlice.cmake)
endif()
endif()
# Catalyst test expects the following arguments to be passed to cmake using
# -DFoo=BAR arguments.
# CATALYST_TEST_DRIVER -- path to oscillator executable
# CATALYST_TEST_DIR -- path to temporary dir
# CATALYST_TEST_DATA -- path to where test input files are located
# IMAGE_TESTER -- path to ImagesTester executable
# CATALYST_DATA_DIR -- path to data dir for baselines
# MPIEXEC
# MPIEXEC_NUMPROC_FLAG
# MPIEXEC_NUMPROCS
# MPIEXEC_PREFLAGS
# VTK_MPI_POSTFLAGS
# remove result files generated by the test
file(REMOVE "${CATALYST_TEST_DIR}/slice-9.png" )
if(NOT EXISTS "${CATALYST_TEST_DRIVER}")
message(FATAL_ERROR "'${CATALYST_TEST_DRIVER}' does not exist")
endif()
message("Executing in ${CATALYST_TEST_DIR}:
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_NUMPROCS} ${MPIEXEC_PREFLAGS}
\"${CATALYST_TEST_DRIVER}\" -b 2 -t 1
-f \"${CATALYST_TEST_DATA}/oscillator-catalyst-slice.xml\"
\"${CATALYST_TEST_DATA}/oscillator-catalyst-slice.osc\""
)
execute_process(COMMAND
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_NUMPROCS} ${MPIEXEC_PREFLAGS}
${CATALYST_TEST_DRIVER} -b 2 -t 1
-f ${CATALYST_TEST_DATA}/oscillator-catalyst-slice.xml
${CATALYST_TEST_DATA}/oscillator-catalyst-slice.osc
WORKING_DIRECTORY ${CATALYST_TEST_DIR}
RESULT_VARIABLE rv)
if(NOT rv EQUAL 0)
message(FATAL_ERROR "Test executable return value was ${rv}")
endif()
if(NOT EXISTS "${CATALYST_TEST_DIR}/slice-9.png")
message(FATAL_ERROR "'${CATALYST_TEST_DIR}/slice-9.png' was not created")
endif()
message("Comparing test output ${CATALYST_TEST_DIR}/slice-9.png against ${CATALYST_TEST_DATA}/slice-9.png baseline.")
execute_process(COMMAND "${IMAGE_TESTER}"
"${CATALYST_TEST_DIR}/slice-9.png" 20 -V "${CATALYST_TEST_DATA}/slice-9.png" -T "${CATALYST_TEST_DIR}"
RESULT_VARIABLE failed)
if(failed)
message(FATAL_ERROR "slice-9.png image compare failed.")
endif()
# type center r omega0 zeta
periodic 512 512 512 256 3.14
periodic 512 512 1536 256 3.14
periodic 512 1536 512 256 3.14
periodic 512 1536 1536 256 3.14
periodic 1536 512 512 256 3.14
periodic 1536 512 1536 256 3.14
periodic 1536 1536 512 256 3.14
periodic 1536 1536 1536 256 3.14
<sensei>
<analysis type="catalyst" enabled="1"
pipeline="slice" array="data" association="cell"
image-filename="slice-%ts.png" image-width="1920" image-height="1080" />
</sensei>
......@@ -81,7 +81,8 @@ public:
if (this->EnableRendering())
{
this->RenderView = catalyst::CreateViewProxy("views", "RenderView");
vtkSMPropertyHelper(this->RenderView, "ShowAnnotation", true).Set(1);
// uncomment below if we want to see the frame rate and other annotation information
//vtkSMPropertyHelper(this->RenderView, "ShowAnnotation", true).Set(1);
vtkSMPropertyHelper(this->RenderView, "ViewTime").Set(time);
vtkSMPropertyHelper(this->RenderView, "ViewSize").Set(this->ImageSize, 2);
this->RenderView->UpdateVTKObjects();
......
......@@ -25,3 +25,4 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/opts"
add_subdirectory(pugixml)
add_subdirectory(timer)
add_subdirectory(ArrayIO)
add_subdirectory(ImageTester)
#------------------------------------------------------------------------------
# Generate the image compare tool.
include(vtk)
add_executable(CompareImages CompareImages.cxx)
target_link_libraries(CompareImages vtk vtkCommonDataModel)
/*=========================================================================
Program: ParaView
Module: CompareImages.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkImageData.h"
#include "vtkPNGReader.h"
#include "vtkSmartPointer.h"
#include "vtkTesting.h"
#include <vtksys/SystemTools.hxx>
// Checks to see if the file exists and that it is a png file.
// Returns 1 for a valid file and 0 for an invalid file.
int IsFileValid(const char* fileName)
{
if (vtksys::SystemTools::FileExists(fileName) == 0)
{
vtkGenericWarningMacro("Could not find file " << fileName);
return 0;
}
if (vtksys::SystemTools::GetFilenameLastExtension(fileName) != ".png")
{
vtkGenericWarningMacro("Wrong file type " << fileName);
return 0;
}
return 1;
}
int main(int argc, char* argv[])
{
if (argc != 7)
{
vtkGenericWarningMacro("Must specify files to compare.");
vtkGenericWarningMacro("<exe> TestImage.png <Threshold> -V BaselineImage.png -T TempDirectory");
return 1;
}
const char* baselineImage = argv[4];
const char* testImage = argv[1];
if (IsFileValid(baselineImage) == 0 || IsFileValid(testImage) == 0)
{
return 1;
}
vtkSmartPointer<vtkPNGReader> reader = vtkSmartPointer<vtkPNGReader>::New();
reader->SetFileName(testImage);
reader->Update();
vtkSmartPointer<vtkTesting> testing = vtkSmartPointer<vtkTesting>::New();
for (int cc = 1; cc < argc; cc++)
{
testing->AddArgument(argv[cc]);
}
double threshold = atof(argv[2]);
if (!testing->RegressionTest(reader, threshold))
{
return 1;
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment