Skip to content
Snippets Groups Projects
Commit f3262d97 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for BuildInfo

parent 8b1c2965
No related branches found
No related tags found
1 merge request!63Feature/utils coverage
...@@ -45,6 +45,7 @@ add_executable (unit_tests ...@@ -45,6 +45,7 @@ add_executable (unit_tests
test_BinaryExpressionProcessor_equality.cpp test_BinaryExpressionProcessor_equality.cpp
test_BinaryExpressionProcessor_logic.cpp test_BinaryExpressionProcessor_logic.cpp
test_BiCGStab.cpp test_BiCGStab.cpp
test_BuildInfo.cpp
test_BuiltinFunctionEmbedder.cpp test_BuiltinFunctionEmbedder.cpp
test_BuiltinFunctionEmbedderTable.cpp test_BuiltinFunctionEmbedderTable.cpp
test_BuiltinFunctionProcessor.cpp test_BuiltinFunctionProcessor.cpp
......
#ifndef TEST_BUILD_INFO_HPP
#define TEST_BUILD_INFO_HPP
#include <catch2/catch.hpp>
#include <utils/BuildInfo.hpp>
#include <utils/pugs_build_info.hpp>
#include <utils/pugs_config.hpp>
#include <sstream>
#ifdef PUGS_HAS_MPI
#include <mpi.h>
#endif // PUGS_HAS_MPI
#ifdef PUGS_HAS_PETSC
#include <petsc.h>
#endif // PUGS_HAS_PETSC
// clazy:excludeall=non-pod-global-static
TEST_CASE("BuildInfo", "[utils]")
{
SECTION("type")
{
REQUIRE(BuildInfo::type() == PUGS_BUILD_TYPE);
}
SECTION("compiler")
{
std::stringstream compiler_info;
compiler_info << PUGS_BUILD_COMPILER << " (" << PUGS_BUILD_COMPILER_VERSION << ")" << std::ends;
REQUIRE(BuildInfo::compiler() == compiler_info.str());
}
SECTION("kokkos")
{
REQUIRE(BuildInfo::kokkosDevices() == PUGS_BUILD_KOKKOS_DEVICES);
}
SECTION("mpi")
{
#ifdef PUGS_HAS_MPI
const std::string mpi_library = []() {
int length;
char mpi_version[MPI_MAX_LIBRARY_VERSION_STRING];
MPI_Get_library_version(mpi_version, &length);
return std::string(mpi_version);
}();
REQUIRE(BuildInfo::mpiLibrary() == mpi_library);
#else
REQUIRE(BuildInfo::mpiLibrary() == "none");
#endif // PUGS_HAS_MPI
}
SECTION("petsc")
{
#ifdef PUGS_HAS_PETSC
const std::string petsc_library = std::to_string(PETSC_VERSION_MAJOR) + "." + std::to_string(PETSC_VERSION_MINOR) +
"." + std::to_string(PETSC_VERSION_SUBMINOR);
REQUIRE(BuildInfo::petscLibrary() == petsc_library);
#else
REQUIRE(BuildInfo::petscLibrary() == "none");
#endif // PUGS_HAS_PETSC
}
}
#endif // TEST_BUILD_INFO_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment