]> SALOME platform Git repositories - tools/ydefx.git/commitdiff
Salome HOME
Fixed some tests. V9_8_0 V9_8_0a1 V9_8_0a2 V9_8_0b1 V9_8_0rc1
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 7 Jul 2021 08:26:25 +0000 (10:26 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Wed, 7 Jul 2021 08:26:25 +0000 (10:26 +0200)
src/cpp/Test/StudyGeneralTest.cxx
src/cpp/Test/StudyRestartTest.cxx

index d7f2be2f261bc8bec0fe9c3e7459a13174158cfe..67f5ceedbdc6c598b927ea5dc93654407847d6eb 100644 (file)
@@ -19,6 +19,9 @@
 #include "StudyGeneralTest.hxx"
 #include "../Launcher.hxx" // possible conflict with KERNEL/Launcher/Launcher.hxx
 #include <algorithm>
+#include <ctime>
+#include <iomanip>
+#include <sstream>
 
 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"
index b8979a230d319674890a1f57f6dae46529a8b5dd..bbdd18e52a16596810d86134bd8d480fcb0cdd8e 100644 (file)
@@ -21,6 +21,9 @@
 #include <algorithm>
 #include <thread>
 #include <chrono>
+#include <ctime>
+#include <iomanip>
+#include <sstream>
 
 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<double> expectedResult = {0.5, 0.5, 0.5, 0.5};