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

Add tests for stop function

parent fc82cae0
No related branches found
No related tags found
1 merge request!199Integrate checkpointing
...@@ -30,6 +30,7 @@ stop() ...@@ -30,6 +30,7 @@ stop()
} }
#ifdef PUGS_HAS_SLURM #ifdef PUGS_HAS_SLURM
// LCOV_EXCL_START
char* env = getenv("SLURM_JOB_ID"); char* env = getenv("SLURM_JOB_ID");
if (env != nullptr) { if (env != nullptr) {
slurm_init(nullptr); slurm_init(nullptr);
...@@ -41,6 +42,7 @@ stop() ...@@ -41,6 +42,7 @@ stop()
slurm_fini(); slurm_fini();
} }
// LCOV_EXCL_STOP
#endif // PUGS_HAS_SLURM #endif // PUGS_HAS_SLURM
} }
......
...@@ -147,6 +147,7 @@ add_executable (unit_tests ...@@ -147,6 +147,7 @@ add_executable (unit_tests
test_SourceLocation.cpp test_SourceLocation.cpp
test_SquareGaussQuadrature.cpp test_SquareGaussQuadrature.cpp
test_SquareTransformation.cpp test_SquareTransformation.cpp
test_Stop.cpp
test_SymbolTable.cpp test_SymbolTable.cpp
test_Table.cpp test_Table.cpp
test_TetrahedronGaussQuadrature.cpp test_TetrahedronGaussQuadrature.cpp
......
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_all.hpp>
#include <utils/ExecutionStatManager.hpp>
#include <utils/Stop.hpp>
#include <chrono>
#include <filesystem>
#include <fstream>
// clazy:excludeall=non-pod-global-static
TEST_CASE("Stop", "[utils]")
{
ExecutionStatManager::create();
auto stop_file = std::filesystem::current_path() / "stop";
std::filesystem::remove(stop_file);
REQUIRE(not std::filesystem::exists(stop_file));
REQUIRE(not stop());
std::ofstream{stop_file.c_str()}.put('a');
REQUIRE(std::filesystem::exists(stop_file));
std::filesystem::file_time_type ftime = std::filesystem::last_write_time(stop_file);
using namespace std::chrono_literals;
std::filesystem::last_write_time(stop_file, ftime - 1h);
REQUIRE(not stop());
std::filesystem::last_write_time(stop_file, ftime);
REQUIRE(stop());
ExecutionStatManager::destroy();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment