From: Ovidiu Mircescu Date: Wed, 7 Jul 2021 08:26:25 +0000 (+0200) Subject: Fixed some tests. X-Git-Tag: V9_8_0rc1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b95975a65b0214d4949d7e625ad41a17d3e6cc25;p=tools%2Fydefx.git Fixed some tests. --- diff --git a/src/cpp/Test/StudyGeneralTest.cxx b/src/cpp/Test/StudyGeneralTest.cxx index d7f2be2..67f5cee 100644 --- a/src/cpp/Test/StudyGeneralTest.cxx +++ b/src/cpp/Test/StudyGeneralTest.cxx @@ -19,6 +19,9 @@ #include "StudyGeneralTest.hxx" #include "../Launcher.hxx" // possible conflict with KERNEL/Launcher/Launcher.hxx #include +#include +#include +#include void SampleTest::setUp() { @@ -39,7 +42,12 @@ void SampleTest::fullStudy() ydefx::JobParametersProxy jobParams; jobParams.configureResource("localhost"); - jobParams.work_directory(jobParams.work_directory() + "/GeneralTest"); + std::time_t t = std::time(nullptr); + std::tm tm = *std::localtime(&t); + std::stringstream ss; + ss << jobParams.work_directory() << "/GeneralTest" + << std::put_time(&tm, "%m%d%H%M%S"); + jobParams.work_directory(ss.str()); jobParams.createResultDirectory("/tmp"); std::string pyScript = "def _exec(a, b):\n" @@ -116,7 +124,12 @@ void SampleTest::genericStudy() ydefx::JobParametersProxy jobParams; jobParams.configureResource("localhost"); - jobParams.work_directory(jobParams.work_directory() + "/GenericTest"); + std::time_t t = std::time(nullptr); + std::tm tm = *std::localtime(&t); + std::stringstream ss; + ss << jobParams.work_directory() << "/GenericTest" + << std::put_time(&tm, "%m%d%H%M%S"); + jobParams.work_directory(ss.str()); jobParams.createResultDirectory("/tmp"); std::string pyScript = "def _exec(a, b):\n" diff --git a/src/cpp/Test/StudyRestartTest.cxx b/src/cpp/Test/StudyRestartTest.cxx index b8979a2..bbdd18e 100644 --- a/src/cpp/Test/StudyRestartTest.cxx +++ b/src/cpp/Test/StudyRestartTest.cxx @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include void SampleTest::setUp() { @@ -45,7 +48,12 @@ void SampleTest::studyTest() { ydefx::JobParametersProxy jobParams; jobParams.configureResource("localhost"); - jobParams.work_directory(jobParams.work_directory() + "/RestartTest"); + std::time_t t = std::time(nullptr); + std::tm tm = *std::localtime(&t); + std::stringstream ss; + ss << jobParams.work_directory() << "/RestartTest" + << std::put_time(&tm, "%m%d%H%M%S"); + jobParams.work_directory(ss.str()); jobParams.createResultDirectory("/tmp"); std::string pyScript = @@ -78,12 +86,17 @@ void SampleTest::studyTest() // ok means that the wait command succeeded. It is not the state of the job. CPPUNIT_ASSERT(ok); double progress = restoredJob->progress(); + int maxtries = 10; // We can check the progress in order to know if the job is done, but we // cannot detect if the job finished in error. - if(progress < 1.0) - std::this_thread::sleep_for(std::chrono::seconds(10)); - double progress2 = restoredJob->progress(); - CPPUNIT_ASSERT(progress <= progress2); + while(progress < 1.0 && maxtries > 0) + { + // wait for the job to finish + std::this_thread::sleep_for(std::chrono::seconds(5)); + progress = restoredJob->progress(); + maxtries--; + } + CPPUNIT_ASSERT(progress >= 1.0 ); ok = restoredJob->fetch(); CPPUNIT_ASSERT(ok); std::vector expectedResult = {0.5, 0.5, 0.5, 0.5};