From 49aced7489723a773478849845df642d75569a7c Mon Sep 17 00:00:00 2001 From: DennisGlaeser <dennis.glaeser@iws.uni-stuttgart.de> Date: Thu, 7 Dec 2017 19:48:50 +0100 Subject: [PATCH] [test][comp] unify tests to use only one executable --- test/material/components/CMakeLists.txt | 94 +++++++++++----------- test/material/components/plotproperties.cc | 59 +++++++++++--- 2 files changed, 98 insertions(+), 55 deletions(-) diff --git a/test/material/components/CMakeLists.txt b/test/material/components/CMakeLists.txt index 00510c8216..71bd7c8ab6 100644 --- a/test/material/components/CMakeLists.txt +++ b/test/material/components/CMakeLists.txt @@ -1,74 +1,76 @@ +add_executable(plot_component plotproperties.cc) + dune_add_test(NAME plot_air - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::Air<double> - COMMAND ./plot_air) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "Air") dune_add_test(NAME plot_benzene - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::Benzene<double> - COMMAND ./plot_benzene false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "Benzene") dune_add_test(NAME plot_brine - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::Brine<double> - COMMAND ./plot_brine false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "Brine") dune_add_test(NAME plot_ch4 - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::CH4<double> - COMMAND ./plot_ch4 false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "CH4") -dune_add_test(NAME plot_dnapl - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::DNAPL<double> - COMMAND ./plot_dnapl false) +dune_add_test(NAME plot_dnapl_tce + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "DNAPL_TCE") dune_add_test(NAME plot_h2 - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::H2<double> - COMMAND ./plot_h2 false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "H2") dune_add_test(NAME plot_h2o - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::H2O<double> - COMMAND ./plot_h2o false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "H2O") dune_add_test(NAME plot_heavyoil - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::HeavyOil<double> - COMMAND ./plot_heavyoil false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "HeavyOil") dune_add_test(NAME plot_lnapl - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::LNAPL<double> - COMMAND ./plot_lnapl false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "LNAPL_oil") dune_add_test(NAME plot_mesitylene - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::Mesitylene<double> - COMMAND ./plot_mesitylene false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "Mesitylene") dune_add_test(NAME plot_n2 - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::N2<double> - COMMAND ./plot_n2 false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "N2") dune_add_test(NAME plot_o2 - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::O2<double> - COMMAND ./plot_o2 false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "O2") dune_add_test(NAME plot_simpleco2 - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::SimpleCO2<double> - COMMAND ./plot_simpleco2 false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "SimpleCO2") dune_add_test(NAME plot_simpleh2o - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::SimpleH2O<double> - COMMAND ./plot_simpleh2o false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "SimpleH2O") dune_add_test(NAME plot_xylene - SOURCES plotproperties.cc - COMPILE_DEFINITIONS COMPONENT=Dumux::Xylene<double> - COMMAND ./plot_xylene false) + TARGET plot_component + COMMAND ./plot_component + CMD_ARGS "Xylene") diff --git a/test/material/components/plotproperties.cc b/test/material/components/plotproperties.cc index c761c9ea4a..2cfc8b5b4a 100644 --- a/test/material/components/plotproperties.cc +++ b/test/material/components/plotproperties.cc @@ -46,15 +46,10 @@ #include <dumux/material/components/xylene.hh> using namespace std; -//////////////////////// -// the main function -//////////////////////// -int main(int argc, char *argv[]) -{ - bool openPlotWindow = true; - if (argc == 2 && (strcmp(argv[1], "0") || strcmp(argv[1], "false") || strcmp(argv[1], "False"))) - openPlotWindow = false; +template<class Component> +void plotStuff(bool openPlotWindow) +{ double pressure = 1e5; double TMin = 273.15; double TMax = 323.15; @@ -69,7 +64,6 @@ int main(int argc, char *argv[]) // components const unsigned int liquidPhaseIdx = 0; const unsigned int gasPhaseIdx = 1; - using Component = COMPONENT; const unsigned int numPhases = 2; array<string, numPhases> phaseNames; @@ -166,5 +160,52 @@ int main(int argc, char *argv[]) gnuplot.plot(Component::name() + "_" + phaseNames[phaseIdx] + "_" + propertyNames[propertyIdx]); } } +} + +//////////////////////// +// the main function +//////////////////////// +int main(int argc, char *argv[]) +{ + bool openPlotWindow = false; + if (argc == 3 && (strcmp(argv[2], "1") || strcmp(argv[2], "true") || strcmp(argv[2], "True"))) + openPlotWindow = true; + + if (argc < 2) + DUNE_THROW(Dune::InvalidStateException, "At least one argument (the component name) is required!"); + + const std::string compName = argv[1]; + if (compName == "Air") + plotStuff< Dumux::Air<double> >(openPlotWindow); + else if (compName == "Benzene") + plotStuff< Dumux::Benzene<double> >(openPlotWindow); + else if (compName == "Brine") + plotStuff< Dumux::Brine<double> >(openPlotWindow); + else if (compName == "CH4") + plotStuff< Dumux::CH4<double> >(openPlotWindow); + else if (compName == "DNAPL_TCE") + plotStuff< Dumux::DNAPL<double> >(openPlotWindow); + else if (compName == "H2") + plotStuff< Dumux::H2<double> >(openPlotWindow); + else if (compName == "H2O") + plotStuff< Dumux::H2O<double> >(openPlotWindow); + else if (compName == "HeavyOil") + plotStuff< Dumux::HeavyOil<double> >(openPlotWindow); + else if (compName == "LNAPL_oil") + plotStuff< Dumux::LNAPL<double> >(openPlotWindow); + else if (compName == "Mesitylene") + plotStuff< Dumux::Mesitylene<double> >(openPlotWindow); + else if (compName == "N2") + plotStuff< Dumux::N2<double> >(openPlotWindow); + else if (compName == "O2") + plotStuff< Dumux::O2<double> >(openPlotWindow); + else if (compName == "SimpleCO2") + plotStuff< Dumux::SimpleCO2<double> >(openPlotWindow); + else if (compName == "SimpleH2O") + plotStuff< Dumux::SimpleH2O<double> >(openPlotWindow); + else if (compName == "Xylene") + plotStuff< Dumux::Xylene<double> >(openPlotWindow); + else + DUNE_THROW(Dune::NotImplemented, "Test for component " << compName); } -- GitLab