Skip to content
Snippets Groups Projects
Commit b22363cf authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

corrections, renamed Standard reference files

parent d7f4ea2c
No related branches found
No related tags found
No related merge requests found
Showing
with 30 additions and 52 deletions
......@@ -16,6 +16,7 @@
#include "FileSystem.h"
#include "Exceptions.h"
#include <boost/filesystem.hpp>
#include <cassert>
std::string Utils::FileSystem::m_argv0_path = std::string();
std::string Utils::FileSystem::m_reference_data_dir = std::string();
......@@ -71,12 +72,14 @@ std::string Utils::FileSystem::GetFileExtension(const std::string& name)
bool Utils::FileSystem::CreateDirectory(const std::string &dir_name)
{
boost::filesystem::path dir(dir_name);
return boost::filesystem::create_directory(dir);
assert(dir_name!="");
return boost::filesystem::create_directory(dir_name);
}
std::string Utils::FileSystem::GetJoinPath(const std::string &spath1, const std::string &spath2)
{
assert(spath1!="");
assert(spath2!="");
boost::filesystem::path path1(spath1);
boost::filesystem::path path2(spath2);
boost::filesystem::path full_path = path1 / path2;
......
......@@ -5,6 +5,9 @@
set(BUILD_REF_DIR ${CMAKE_BINARY_DIR}/ref)
file(MAKE_DIRECTORY ${BUILD_REF_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_BIN_DIR=\\\"${BUILD_BIN_DIR}\\\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_LIB_DIR=\\\"${BUILD_LIB_DIR}\\\"")
add_subdirectory(TestMachinery)
add_subdirectory(Core)
add_subdirectory(Fit)
......
......@@ -6,6 +6,11 @@ set(CORE_STD_OUT_DIR ${BUILD_REF_DIR}/StandardSuite)
set(CORE_STD_REF_DIR ${REFERENCE_DIR}/StandardSuite)
set(CORE_SPECIAL_OUT_DIR ${BUILD_REF_DIR}/Special)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCORE_STD_TMP_DIR=\\\"${CORE_STD_TMP_DIR}\\\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCORE_STD_REF_DIR=\\\"${CORE_STD_REF_DIR}\\\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCORE_SPECIAL_REF_DIR=\\\"${CORE_SPECIAL_REF_DIR}\\\"")
# CoreStandardTest cases:
set(test_cases
ApproximationDA
......
......@@ -18,9 +18,7 @@
#include "GISASSimulation.h"
#include "IntensityDataFunctions.h"
#include "IntensityDataIOFactory.h"
#include "TestConfig.h"
#include "Utils.h"
#include <cassert>
CoreTest::CoreTest(
const std::string& name, const std::string& description, GISASSimulation* simulation,
......@@ -29,8 +27,7 @@ CoreTest::CoreTest(
, m_simulation(simulation)
, m_threshold(threshold)
, m_difference(0)
{
}
{}
CoreTest::~CoreTest()
{
......@@ -44,7 +41,7 @@ void CoreTest::runTest()
m_simulation->runSimulation();
assert(CORE_STD_REF_DIR!="");
m_ref_filename = CORE_STD_REF_DIR + "/" + getName() + ".int.gz";
m_ref_filename = Utils::FileSystem::GetJoinPath(CORE_STD_REF_DIR, getName() + ".int.gz");
try {
m_reference = IntensityDataIOFactory::readOutputData( m_ref_filename );
} catch(const std::exception& ex) {
......
......@@ -2,12 +2,13 @@
#include "IntensityDataFunctions.h"
#include "IntensityDataIOFactory.h"
#include "SimulationFactory.h"
#include "TestConfig.h"
#include "FileSystem.h"
#include <memory>
int main(int, char**)
{
const std::string trunc = CORE_SPECIAL_REF_DIR + "/polmagcylinders2_reference_";
const std::string trunc = Utils::FileSystem::GetJoinPath(CORE_SPECIAL_REF_DIR,
"/polmagcylinders2_reference_");
const std::unique_ptr<OutputData<double> >
P_reference00(IntensityDataIOFactory::readOutputData(trunc + "00.int.gz"));
const std::unique_ptr<OutputData<double> >
......
......@@ -5,6 +5,8 @@
set(PYEXPORT_TMP_DIR ${BUILD_REF_DIR}/PyExport)
file(MAKE_DIRECTORY ${PYEXPORT_TMP_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPYEXPORT_TMP_DIR=\\\"${PYEXPORT_TMP_DIR}\\\"")
set(test_cases
ApproximationDA
ApproximationLMA
......
......@@ -21,7 +21,6 @@
#include "IntensityDataIOFactory.h"
#include "PythonFormatting.h"
#include "SimulationFactory.h"
#include "TestConfig.h"
#include "Utils.h"
#include <cstdio>
#include <cstdlib>
......@@ -47,7 +46,8 @@ PyExportTest::~PyExportTest()
void PyExportTest::runTest()
{
// Generate Python script
std::string pyscript_filename = PYEXPORT_TMP_DIR + "/" + getName() + ".py";
std::string pyscript_filename = Utils::FileSystem::GetJoinPath(PYEXPORT_TMP_DIR,
getName() + ".py");
std::ostringstream ostr;
ostr << "# Functional test settings, generated by PyExportTest::runTest():\n"
<< "import sys\n"
......@@ -62,7 +62,7 @@ void PyExportTest::runTest()
// the system calls 'remove' and 'system' may break the order of output lines.
// Run Python script
std::string output_name = PYEXPORT_TMP_DIR + "/" + getName();
std::string output_name = Utils::FileSystem::GetJoinPath(PYEXPORT_TMP_DIR, getName());
std::string output_path = output_name + ".int";
std::remove( output_path.c_str() );
std::cout << "Removed old data set " << output_path << "." << std::endl/*sic*/;
......@@ -79,7 +79,6 @@ void PyExportTest::runTest()
// Run direct simulation
std::cout <<
"Now going to directly run the simulation, and to compare with result from Py script.\n";
assert(m_reference_simulation);
m_reference_simulation->runSimulation();
const std::unique_ptr<OutputData<double> > P_reference_data(
m_reference_simulation->getDetectorIntensity());
......
############################################################################
# Tests/Functional/PyCore/suite/CMakeLists.txt
# Tests/Functional/PyCore/presistence/CMakeLists.txt
############################################################################
set(PYPERSIST_REF_DIR ${REFERENCE_DIR}/PyPersist)
set(PYPERSIST_TMP_DIR ${BUILD_REF_DIR}/PyPersist)
file(MAKE_DIRECTORY ${PYPERSIST_TMP_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPYPERSIST_TMP_DIR=\\\"${PYPERSIST_TMP_DIR}\\\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPYPERSIST_REF_DIR=\\\"${PYPERSIST_REF_DIR}\\\"")
file(GLOB PY_EXAMPLES "${PY_EXAMPLES_DIR}/simulation/ex*/*.py")
# for some reason these flags doesn't propagated here by SetUpWindows.cmake
......
......@@ -21,7 +21,6 @@
#include "IntensityDataIOFactory.h"
#include "PythonFormatting.h"
#include "SimulationFactory.h"
#include "TestConfig.h"
#include "TestUtils.h"
#include "Utils.h"
#include <cstdio>
......@@ -40,7 +39,7 @@ PyPersistenceTest::PyPersistenceTest(
void PyPersistenceTest::runTest()
{
// Set output data filename stem, and remove old output files
std::string dat_stem = PYPERSIST_TMP_DIR + "/" + getName();
std::string dat_stem = Utils::FileSystem::GetJoinPath(PYPERSIST_TMP_DIR, getName());
for (const std::string& fname: TestUtils::glob(dat_stem+".*.int")) {
std::remove( fname.c_str() );
std::cout << "Removed old result " << fname.c_str() << "." << std::endl/*sic*/;
......@@ -49,7 +48,7 @@ void PyPersistenceTest::runTest()
// Run Python script
std::string py_filename( m_directory + "/" + getName() + ".py" );
std::string command =
"PYTHONPATH=" + BUILD_LIB_DIR + " " +
std::string("PYTHONPATH=") + BUILD_LIB_DIR + " " +
BORNAGAIN_PYTHON_EXE + " " + py_filename + " " + dat_stem;
std::cout << "Now running command '" << command << "'." << std::endl/*sic*/;
int ret = std::system(command.c_str());
......@@ -73,7 +72,7 @@ void PyPersistenceTest::runTest()
// Read reference files
std::string ref_stem = PYPERSIST_REF_DIR + "/" + getName();
std::string ref_stem = Utils::FileSystem::GetJoinPath(PYPERSIST_REF_DIR, getName());
std::map<const std::string, const OutputData<double>*> ref;
for (const std::string& fname: TestUtils::glob(ref_stem+".*.int.gz"))
ref.insert(make_pair(Utils::String::split(fname,".")[1],
......
......@@ -9,8 +9,6 @@ if(POLICY CMP0042)
endif()
# --- source and include files ---------
configure_file(TestConfig.h.in ${BUILD_INC_DIR}/TestConfig.h @ONLY)
set(include_dirs ${BUILD_INC_DIR} ${CORE_SOURCE_DIRS} ${GSL_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/Fit/Parameters # for INamed.h
${CMAKE_SOURCE_DIR}/Fit/Utils
......
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file TestConfig.h.in
//! @brief Lets CMake define configuration variables for functional tests
//!
//! @homepage http://bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2015
//! @authors Scientific Computing Group at MLZ Garching
//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
#ifndef TEST_CONFIG_H
#define TEST_CONFIG_H
const std::string BUILD_LIB_DIR( "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" );
const std::string BUILD_BIN_DIR( "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@" );
const std::string CORE_STD_TMP_DIR( "@CORE_STD_TMP_DIR@" );
const std::string CORE_STD_REF_DIR( "@CORE_STD_REF_DIR@" );
const std::string CORE_SPECIAL_REF_DIR( "@CORE_SPECIAL_REF_DIR@" );
const std::string PYEXPORT_TMP_DIR( "@PYEXPORT_TMP_DIR@" );
const std::string PYPERSIST_TMP_DIR( "@PYPERSIST_TMP_DIR@" );
const std::string PYPERSIST_REF_DIR( "@PYPERSIST_REF_DIR@" );
#endif // TEST_CONFIG_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment