Salome HOME
Merge class BatchManager_eClient into class BatchManager
[tools/libbatch.git] / src / LoadLeveler / Test / Test_eLL.cxx
index d3945259df2ff1be1424575b2f0bac2209307076..8f897cc2fe57c28ff4cbfc1fb6fa6226596ed31a 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #include <fstream>
 #include <cstring>
 
+#include <Batch_Constants.hxx>
 #include <Batch_Job.hxx>
 #include <Batch_BatchManagerCatalog.hxx>
 #include <Batch_FactBatchManager.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
+#include <Batch_FactBatchManager_eLL.hxx>
 #include <Batch_BatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
 
 #include <SimpleParser.hxx>
 
@@ -83,6 +83,7 @@ int main(int argc, char** argv)
     const string & host = parser.getValue("TEST_ELL_HOST");
     const string & user = parser.getValue("TEST_ELL_USER");
     const string & queue = parser.getValue("TEST_ELL_QUEUE");
+    const string & jobType = parser.getValue("TEST_ELL_JOBTYPE");
     int timeout = parser.getValueAsInt("TEST_ELL_TIMEOUT");
 
     // Define the job...
@@ -95,12 +96,13 @@ int main(int argc, char** argv)
     p[INFILE]        = Couple("seta.sh", "tmp/Batch/seta.sh");
     p[INFILE]       += Couple("setb.sh", "tmp/Batch/setb.sh");
     p[OUTFILE]       = Couple("result.txt", "tmp/Batch/result.txt");
-    p[TMPDIR]        = "tmp/Batch/";
     p[NBPROC]        = 1;
     p[MAXWALLTIME]   = 1;
-    p[MAXRAMSIZE]    = 1;
+    p[MAXRAMSIZE]    = 50;
     p[HOMEDIR]       = homedir;
     p[QUEUE]         = queue;
+    p[LL_JOBTYPE]    = jobType;
+    p[EXCLUSIVE]     = false;
     job.setParametre(p);
     // ... and its environment
     Environnement e;
@@ -112,8 +114,8 @@ int main(int argc, char** argv)
     BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
 
     // Create a BatchManager of type ePBS on localhost
-    FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eLL"));
-    BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
+    FactBatchManager * fbm = c("LL");
+    BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
 
     // Submit the job to the BatchManager
     JobId jobid = bm->submitJob(job);
@@ -122,9 +124,13 @@ int main(int argc, char** argv)
     // Wait for the end of the job
     string state = bm->waitForJobEnd(jobid, timeout);
 
-    if (state == FINISHED || state == FAILED) {
+    if (state == FINISHED) {
       cout << "Job " << jobid.__repr__() << " is done" << endl;
       bm->importOutputFiles(job, "resultdir/seconddirname");
+    } else if (state == FAILED) {
+      cerr << "Job " << jobid.__repr__() << " finished in error" << endl;
+      bm->importOutputFiles(job, "resultdir/seconddirname");
+      return 1;
     } else {
       cerr << "Timeout while executing job" << endl;
       return 1;