Salome HOME
Fix remote directories in file transfer and merge some tests
authorbarate <barate>
Wed, 16 Jan 2013 15:56:06 +0000 (15:56 +0000)
committerbarate <barate>
Wed, 16 Jan 2013 15:56:06 +0000 (15:56 +0000)
28 files changed:
src/Core/Batch_BatchManager.cxx
src/Core/Test/CMakeLists.txt
src/Core/Test/SimpleParser.cxx
src/Core/Test/SimpleParser.hxx
src/Core/Test/Test_BatchManager.cxx [new file with mode: 0644]
src/Core/Test/Test_config.h.in
src/Core/Test/batchtest.conf
src/Core/Test/seta.sh [new file with mode: 0644]
src/Core/Test/setb.sh [new file with mode: 0644]
src/Core/Test/test-script.sh [new file with mode: 0755]
src/LSF/CMakeLists.txt
src/LSF/Test/CMakeLists.txt [deleted file]
src/LSF/Test/Test_eLSF.cxx [deleted file]
src/LSF/Test/seta.sh [deleted file]
src/LSF/Test/setb.sh [deleted file]
src/LSF/Test/test-script.sh [deleted file]
src/Slurm/CMakeLists.txt
src/Slurm/Test/CMakeLists.txt [deleted file]
src/Slurm/Test/Test_eSlurm.cxx [deleted file]
src/Slurm/Test/seta.sh [deleted file]
src/Slurm/Test/setb.sh [deleted file]
src/Slurm/Test/test-script.sh [deleted file]
src/Vishnu/CMakeLists.txt
src/Vishnu/Test/CMakeLists.txt [deleted file]
src/Vishnu/Test/Test_eVishnu.cxx [deleted file]
src/Vishnu/Test/seta.sh [deleted file]
src/Vishnu/Test/setb.sh [deleted file]
src/Vishnu/Test/test-script.sh [deleted file]

index 2585f7f23076cb93cfc672013820b20699d331b6..1af2bec3e2edc2e743a4f671b60738e610de0650 100644 (file)
@@ -236,8 +236,12 @@ namespace Batch {
     for (Vit=V.begin() ; Vit!=V.end() ; Vit++) {
       CoupleType cpt = *static_cast< CoupleType * >(*Vit);
       Couple inputFile = cpt;
+      string remotePath = inputFile.getRemote();
+      if (!Utils::isAbsolutePath(remotePath)) {
+        remotePath = params[WORKDIR].str() + "/" + remotePath;
+      }
       status = _protocol.copyFile(inputFile.getLocal(), "", "",
-                                  inputFile.getRemote(), _hostname, _username);
+                                  remotePath, _hostname, _username);
       if (status) {
         std::ostringstream oss;
         oss << "Cannot copy file " << inputFile.getLocal() << " on host " << _hostname;
@@ -267,11 +271,15 @@ namespace Batch {
     for(Vit=V.begin(); Vit!=V.end(); Vit++) {
       CoupleType cpt  = *static_cast< CoupleType * >(*Vit);
       Couple outputFile = cpt;
+      string remotePath = outputFile.getRemote();
+      if (!Utils::isAbsolutePath(remotePath)) {
+        remotePath = params[WORKDIR].str() + "/" + remotePath;
+      }
       string localPath = outputFile.getLocal();
       if (!Utils::isAbsolutePath(localPath)) {
         localPath = directory + "/" + localPath;
       }
-      status = _protocol.copyFile(outputFile.getRemote(), _hostname, _username,
+      status = _protocol.copyFile(remotePath, _hostname, _username,
                                   localPath, "", "");
       if (status) {
         // Try to get what we can (logs files)
index a2e81ccef0b3d27ef00bff33ec4a808db1270d72..b2244cbb701e8155370cbbea5c2adde319acbf64 100644 (file)
@@ -29,13 +29,18 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_config.h.in ${CMAKE_CURRENT_BINA
 
 # Set the include directories
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CMAKE_SOURCE_DIR}/src/Core)
 
 # Build SimpleParser library
 add_library (SimpleParser STATIC SimpleParser.cxx)
 
-# Build the test program
+# Build the test program for SimpleParser
 add_executable(Test_SimpleParser Test_SimpleParser.cxx)
 target_link_libraries(Test_SimpleParser SimpleParser)
 
 # Add the test itself
 ADD_TEST(SimpleParser Test_SimpleParser)
+
+# Build the test program for the batch managers
+add_executable(Test_BatchManager Test_BatchManager.cxx)
+target_link_libraries(Test_BatchManager batch SimpleParser)
index f20eb275bcc7ca2ddde39e556ec229d72549fb56..ac6a135945c8ade086d5144c1c9e393817419057 100644 (file)
@@ -128,6 +128,12 @@ const string & SimpleParser::getValue(const string & key) const throw(ParserExce
   return iter->second;
 }
 
+const string & SimpleParser::getTestValue(const string & bmType, const string & key) const throw(ParserException)
+{
+  string fullkey = string("TEST_") + bmType + "_" + key;
+  return getValue(fullkey);
+}
+
 int SimpleParser::getValueAsInt(const string & key) const throw(ParserException)
 {
   const string & valueStr = getValue(key);
@@ -140,6 +146,12 @@ int SimpleParser::getValueAsInt(const string & key) const throw(ParserException)
   return res;
 }
 
+int SimpleParser::getTestValueAsInt(const string & bmType, const string & key) const throw(ParserException)
+{
+  string fullkey = string("TEST_") + bmType + "_" + key;
+  return getValueAsInt(fullkey);
+}
+
 ostream & operator <<(ostream & os, const SimpleParser & parser) throw()
 {
   if (parser._configmap.empty()) {
index cccee1f33c9665a0fcbf64d36256a56746e7e356..309799c6b597feb2f0bd98f7cc8d6a2f7dae6c88 100644 (file)
@@ -54,7 +54,9 @@ public:
   void parse(const std::string & filename) throw(ParserException);
   void parseTestConfigFile() throw(ParserException);
   const std::string & getValue(const std::string & key) const throw(ParserException);
+  const std::string & getTestValue(const std::string & bmType, const std::string & key) const throw(ParserException);
   int getValueAsInt(const std::string & key) const throw(ParserException);
+  int getTestValueAsInt(const std::string & bmType, const std::string & key) const throw(ParserException);
 
   friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) throw();
 
diff --git a/src/Core/Test/Test_BatchManager.cxx b/src/Core/Test/Test_BatchManager.cxx
new file mode 100644 (file)
index 0000000..2bac0b3
--- /dev/null
@@ -0,0 +1,172 @@
+//  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
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * Test_BatchManager.cxx :
+ *
+ * Author : Renaud BARATE - EDF R&D
+ * Date   : Jan 2013
+ *
+ */
+
+#include <iostream>
+#include <fstream>
+#include <cstring>
+
+#include <Batch_Constants.hxx>
+#include <Batch_Job.hxx>
+#include <Batch_BatchManagerCatalog.hxx>
+#include <Batch_FactBatchManager.hxx>
+#include <Batch_BatchManager.hxx>
+
+#include "SimpleParser.hxx"
+
+#include <Test_config.h>
+
+using namespace std;
+using namespace Batch;
+
+void print_usage()
+{
+  cout << "usage: Test_BatchManager BATCH_MANAGER PROTOCOL" << endl;
+  cout << "    BATCH_MANAGER \"CCC\", \"LL\", \"LOCAL\", \"LSF\", \"PBS\", " <<
+          "\"SGE\", \"SLURM\" or \"VISHNU\"" << endl;
+  cout << "    PROTOCOL      \"SH\", \"SSH\" or \"RSH\"" << endl;
+}
+
+int main(int argc, char** argv)
+{
+  // Parse argument
+  if (argc != 3) {
+    print_usage();
+    return 1;
+  }
+  const char * bmType = argv[1];
+  CommunicationProtocolType protocol;
+  if (strcmp(argv[2], "SSH") == 0)
+    protocol = SSH;
+  else if (strcmp(argv[2], "RSH") == 0)
+    protocol = RSH;
+  else if (strcmp(argv[2], "SH") == 0)
+    protocol = SH;
+  else {
+    print_usage();
+    return 1;
+  }
+
+  cout << "*******************************************************************************************" << endl;
+  cout << "This program tests the batch submission of a job using the batch manager \"" << bmType << "\"" << endl;
+  cout << "and the communication protocol \"" << argv[2] << "\"." << endl;
+  if (protocol == RSH || protocol == SSH) {
+    cout << "Passwordless authentication must be used for this test to pass." << endl;
+    if (protocol == SSH) {
+      cout << "This can be configured with ssh-agent for instance." << endl;
+    } else if (protocol == RSH) {
+      cout << "This can be configured with the .rhosts file." << endl;
+    }
+  }
+  cout << "*******************************************************************************************" << endl;
+
+  // eventually remove any previous result
+  remove("resultdir/seconddirname/result.txt");
+
+  try {
+    // Get the catalog and the BatchManager factory
+    BatchManagerCatalog& cata = BatchManagerCatalog::getInstance();
+    FactBatchManager * fbm = cata(bmType);
+
+    // Parse the test configuration file
+    SimpleParser parser;
+    parser.parseTestConfigFile();
+    const string & workdir = parser.getTestValue(bmType, "WORKDIR");
+    const string & host = parser.getTestValue(bmType, "HOST");
+    const string & user = parser.getTestValue(bmType, "USER");
+    int timeout = parser.getTestValueAsInt(bmType, "TIMEOUT");
+
+    // Define the job...
+    Job job;
+    // ... and its parameters ...
+    Parametre p;
+    p[EXECUTABLE]    = string(CMAKE_CURRENT_SOURCE_DIR) + "/test-script.sh";
+    p[NAME]          = string("Test ") + bmType + " " + argv[2];
+    p[WORKDIR]       = workdir;
+    p[INFILE]        = Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/seta.sh", "seta.sh");
+    p[INFILE]       += Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/setb.sh", "setb.sh");
+    p[OUTFILE]       = Couple("result.txt", "result.txt");
+    p[NBPROC]        = 1;
+    p[MAXWALLTIME]   = 1;
+    p[MAXRAMSIZE]    = 50;
+    job.setParametre(p);
+    // ... and its environment
+    Environnement e;
+    e["MYENVVAR"] = "MYVALUE";
+    job.setEnvironnement(e);
+    cout << job << endl;
+
+    // Create the BatchManager
+    BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
+
+    // Submit the job to the BatchManager
+    JobId jobid = bm->submitJob(job);
+    cout << jobid.__repr__() << endl;
+
+    // Wait for the end of the job
+    string state = bm->waitForJobEnd(jobid, timeout);
+
+    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;
+    }
+
+  } catch (const GenericException & e) {
+    cerr << "Error: " << e << endl;
+    return 1;
+  } catch (const ParserException & e) {
+    cerr << "Parser error: " << e.what() << endl;
+    return 1;
+  }
+
+  // test the result file
+  try {
+    SimpleParser resultParser;
+    resultParser.parse("resultdir/seconddirname/result.txt");
+    cout << "Result:" << endl << resultParser;
+    const string & envvar = resultParser.getValue("MYENVVAR");
+    int result = resultParser.getValueAsInt("c");
+    if (envvar == "MYVALUE" && result == 12) {
+      cout << "OK, Expected result found." << endl;
+      return 0;
+    } else {
+      cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl;
+      return 1;
+    }
+  } catch (const ParserException & e) {
+    cerr << "Parser error on result file: " << e.what() << endl;
+    return 1;
+  }
+}
index 8e5ab001496994d4eba2396f133f9672f0a9404b..a11641295b4e1b4f3e762a280fb981c26e86dde6 100644 (file)
@@ -20,4 +20,8 @@
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+/* Environment variable containing the path of the test configuration file */
 #define TEST_CONFIG_FILE_ENV_VAR "${TEST_CONFIG_FILE_ENV_VAR}"
+
+/* Current source directory */
+#define CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
index 2d30ca9bd7ef7522f144a34c8c7ca6bcbc77e214..9deb2de8a884d8e62f9a7cd1bba4d64cad86a8e6 100644 (file)
@@ -21,11 +21,6 @@ TEST_LOCAL_SSH_WORK_DIR = "/tmp"              # Work directory for SSH Batch tes
 TEST_LOCAL_SSH_TIMEOUT = 10                   # Execution timeout (in seconds) for local SSH Batch test
 TEST_LOCAL_SSH_FINALIZATION_TIME = 5          # Finalization time (in seconds) for local SSH Batch test
 
-TEST_PBS_HOST = "localhost"                   # PBS server host
-TEST_PBS_USER = "username"                    # Login for the PBS server
-TEST_PBS_QUEUE = "queuename"                  # Queue to submit test job on PBS server
-TEST_PBS_TIMEOUT = 120                        # Execution timeout (in seconds) for PBS Batch test
-
 TEST_EPBS_HOST = "localhost"                  # PBS server host
 TEST_EPBS_USER = "username"                   # Login for the PBS server
 TEST_EPBS_HOMEDIR = "/home/username"          # Home directory on PBS server
@@ -39,12 +34,17 @@ TEST_ELL_QUEUE = "classname"                  # Class for the test job test job
 TEST_ELL_JOBTYPE = "serial"                   # Job type for LoadLeveler
 TEST_ELL_TIMEOUT = 120                        # Execution timeout (in seconds) for LoadLeveler Batch test
 
-TEST_ESLURM_HOST = "localhost"                # Slurm server host
-TEST_ESLURM_USER = "username"                 # Login for the Slurm server
-TEST_ESLURM_HOMEDIR = "/home/username"        # Home directory on Slurm server
-TEST_ESLURM_TIMEOUT = 120                     # Execution timeout (in seconds) for Slurm Batch test
+TEST_LSF_HOST = "localhost"                   # LSF server host
+TEST_LSF_USER = "username"                    # Login for the LSF server
+TEST_LSF_WORKDIR = "/home/username/wrk"       # Work directory on LSF server
+TEST_LSF_TIMEOUT = 120                        # Execution timeout (in seconds) for LSF Batch test
+
+TEST_SLURM_HOST = "localhost"                 # Slurm server host
+TEST_SLURM_USER = "username"                  # Login for the Slurm server
+TEST_SLURM_WORKDIR = "/home/username/wrk"     # Work directory on Slurm server
+TEST_SLURM_TIMEOUT = 120                      # Execution timeout (in seconds) for Slurm Batch test
 
-TEST_EVISHNU_HOST = "localhost"               # Machine ID of the target cluster
-TEST_EVISHNU_USER = "username"                # Vishnu login (unused)
-TEST_EVISHNU_HOMEDIR = "/home/username"       # Home directory on the target cluster
-TEST_EVISHNU_TIMEOUT = 120                    # Execution timeout (in seconds) for Vishnu Batch test
+TEST_VISHNU_HOST = "localhost"                # Machine ID of the target cluster
+TEST_VISHNU_USER = "username"                 # Vishnu login (unused)
+TEST_VISHNU_WORKDIR = "/home/username/wrk"    # Work directory on the target cluster
+TEST_VISHNU_TIMEOUT = 120                     # Execution timeout (in seconds) for Vishnu Batch test
diff --git a/src/Core/Test/seta.sh b/src/Core/Test/seta.sh
new file mode 100644 (file)
index 0000000..42d1e38
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+a=4
diff --git a/src/Core/Test/setb.sh b/src/Core/Test/setb.sh
new file mode 100644 (file)
index 0000000..8969060
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+b=3
diff --git a/src/Core/Test/test-script.sh b/src/Core/Test/test-script.sh
new file mode 100755 (executable)
index 0000000..1d56247
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. ./seta.sh
+. ./setb.sh
+
+c=`expr $a "*" $b`
+
+echo "MYENVVAR = $MYENVVAR" > result.txt
+echo "c = $c" >> result.txt
index 107d8f9f9187cc0f30e6a0480b77d94e7184de50..7a1d7f5511c045d72a3e6b5ffb422e0072cc8c1f 100644 (file)
@@ -27,6 +27,6 @@ SET(CLASS_LIST LSF/Batch_BatchManager_eLSF
 
 APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
 
-IF (TEST_ENABLED)
-    add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
+IF (TEST_ENABLED AND HAS_SSH)
+    ADD_TEST(LSF_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LSF SSH)
+ENDIF (TEST_ENABLED AND HAS_SSH)
diff --git a/src/LSF/Test/CMakeLists.txt b/src/LSF/Test/CMakeLists.txt
deleted file mode 100644 (file)
index 2794feb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#  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
-#
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
-#
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-# Just copy the test scripts to the binary dir
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY)
-
-# set the include directories
-include_directories(${CMAKE_SOURCE_DIR}/src/Core)
-include_directories(${CMAKE_SOURCE_DIR}/src/Core/Test)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Build the test programs and add the tests
-add_executable(Test_eLSF Test_eLSF.cxx)
-target_link_libraries(Test_eLSF batch SimpleParser)
-
-IF (HAS_SSH)
-    ADD_TEST(eLSF_SSH Test_eLSF SSH)
-ENDIF (HAS_SSH)
-
-#IF (HAS_RSH)
-#    ADD_TEST(eLSF_RSH Test_eLSF RSH)
-#ENDIF (HAS_RSH)
diff --git a/src/LSF/Test/Test_eLSF.cxx b/src/LSF/Test/Test_eLSF.cxx
deleted file mode 100644 (file)
index 98aa060..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-//  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
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * Test_eLSF.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date   : September 2011
- *
- */
-
-#include <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Batch_Constants.hxx>
-#include <Batch_Job.hxx>
-#include <Batch_BatchManagerCatalog.hxx>
-#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-using namespace std;
-using namespace Batch;
-
-void print_usage()
-{
-  cout << "usage: Test_eLSF PROTOCOL" << endl;
-  cout << "    PROTOCOL      \"SSH\" or \"RSH\"" << endl;
-}
-
-int main(int argc, char** argv)
-{
-  // Parse argument
-  if (argc != 2) {
-    print_usage();
-    return 1;
-  }
-  CommunicationProtocolType protocol;
-  if (strcmp(argv[1], "SSH") == 0)
-    protocol = SSH;
-  else if (strcmp(argv[1], "RSH") == 0)
-    protocol = RSH;
-  else {
-    print_usage();
-    return 1;
-  }
-
-  cout << "*******************************************************************************************" << endl;
-  cout << "This program tests the batch submission based on LSF emulation. Passwordless" << endl;
-  cout << "authentication must be used for this test to pass. For SSH, this can be configured with" << endl;
-  cout << "ssh-agent for instance. For RSH, this can be configured with the .rhosts file." << endl;
-  cout << "*******************************************************************************************" << endl;
-
-  // eventually remove any previous result
-  remove("result.txt");
-
-  try {
-    // Parse the test configuration file
-    SimpleParser parser;
-    parser.parseTestConfigFile();
-    const string & homedir = parser.getValue("TEST_ELSF_HOMEDIR");
-    const string & host = parser.getValue("TEST_ELSF_HOST");
-    const string & user = parser.getValue("TEST_ELSF_USER");
-    int timeout = parser.getValueAsInt("TEST_ELSF_TIMEOUT");
-
-    // Define the job...
-    Job job;
-    // ... and its parameters ...
-    Parametre p;
-    p[EXECUTABLE]    = "./test-script.sh";
-    p[NAME]          = string("Test_eLSF_") + argv[1];
-    p[WORKDIR]       = homedir + "/tmp/Batch";
-    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[NBPROC]        = 1;
-    p[MAXWALLTIME]   = 1;
-    p[MAXRAMSIZE]    = 128;
-    p[HOMEDIR]       = homedir;
-    p[EXCLUSIVE]     = true;
-    job.setParametre(p);
-    // ... and its environment
-    Environnement e;
-    e["MYENVVAR"] = "MYVALUE";
-    job.setEnvironnement(e);
-    cout << job << endl;
-
-    // Get the catalog
-    BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
-
-    // Create a BatchManager of type ePBS on localhost
-    FactBatchManager * fbm = c("LSF");
-    BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
-
-    // Submit the job to the BatchManager
-    JobId jobid = bm->submitJob(job);
-    cout << jobid.__repr__() << endl;
-
-    // Wait for the end of the job
-    string state = bm->waitForJobEnd(jobid, timeout);
-
-    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;
-    }
-
-  } catch (GenericException e) {
-    cerr << "Error: " << e << endl;
-    return 1;
-  } catch (ParserException e) {
-    cerr << "Parser error: " << e.what() << endl;
-    return 1;
-  }
-
-  // test the result file
-  try {
-    SimpleParser resultParser;
-    resultParser.parse("resultdir/seconddirname/result.txt");
-    cout << "Result:" << endl << resultParser;
-    const string & envvar = resultParser.getValue("MYENVVAR");
-    int result = resultParser.getValueAsInt("c");
-    if (envvar == "MYVALUE" && result == 12) {
-      cout << "OK, Expected result found." << endl;
-      return 0;
-    } else {
-      cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl;
-      return 1;
-    }
-  } catch (ParserException e) {
-    cerr << "Parser error on result file: " << e.what() << endl;
-    return 1;
-  }
-}
diff --git a/src/LSF/Test/seta.sh b/src/LSF/Test/seta.sh
deleted file mode 100644 (file)
index 42d1e38..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-a=4
diff --git a/src/LSF/Test/setb.sh b/src/LSF/Test/setb.sh
deleted file mode 100644 (file)
index 8969060..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-b=3
diff --git a/src/LSF/Test/test-script.sh b/src/LSF/Test/test-script.sh
deleted file mode 100755 (executable)
index 1d56247..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-. ./seta.sh
-. ./setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
index 5a1c43250293a04701316e3328855c34061cb94e..175559a9183ddaeb80dd78b69114d0558c08d5ee 100644 (file)
@@ -27,6 +27,6 @@ SET(CLASS_LIST Slurm/Batch_BatchManager_eSlurm
 
 APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
 
-IF (TEST_ENABLED)
-    add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
+IF (TEST_ENABLED AND HAS_SSH)
+    ADD_TEST(SLURM_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager SLURM SSH)
+ENDIF (TEST_ENABLED AND HAS_SSH)
diff --git a/src/Slurm/Test/CMakeLists.txt b/src/Slurm/Test/CMakeLists.txt
deleted file mode 100644 (file)
index be028f6..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#  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
-#
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
-#
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-# Just copy the test scripts to the binary dir
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY)
-
-# set the include directories
-include_directories(${CMAKE_SOURCE_DIR}/src/Core)
-include_directories(${CMAKE_SOURCE_DIR}/src/Core/Test)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Build the test programs and add the tests
-add_executable(Test_eSlurm Test_eSlurm.cxx)
-target_link_libraries(Test_eSlurm batch SimpleParser)
-
-IF (HAS_SSH)
-    ADD_TEST(eSlurm_SSH Test_eSlurm SSH)
-ENDIF (HAS_SSH)
-
-#IF (HAS_RSH)
-#    ADD_TEST(eSlurm_RSH Test_eSlurm RSH)
-#ENDIF (HAS_RSH)
diff --git a/src/Slurm/Test/Test_eSlurm.cxx b/src/Slurm/Test/Test_eSlurm.cxx
deleted file mode 100644 (file)
index 41e2e46..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-//  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
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * Test_eSlurm.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date   : May 2011
- *
- */
-
-#include <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Batch_Constants.hxx>
-#include <Batch_Job.hxx>
-#include <Batch_BatchManagerCatalog.hxx>
-#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-using namespace std;
-using namespace Batch;
-
-void print_usage()
-{
-  cout << "usage: Test_eSlurm PROTOCOL" << endl;
-  cout << "    PROTOCOL      \"SSH\" or \"RSH\"" << endl;
-}
-
-int main(int argc, char** argv)
-{
-  // Parse argument
-  if (argc != 2) {
-    print_usage();
-    return 1;
-  }
-  CommunicationProtocolType protocol;
-  if (strcmp(argv[1], "SSH") == 0)
-    protocol = SSH;
-  else if (strcmp(argv[1], "RSH") == 0)
-    protocol = RSH;
-  else {
-    print_usage();
-    return 1;
-  }
-
-  cout << "*******************************************************************************************" << endl;
-  cout << "This program tests the batch submission based on Slurm emulation. Passwordless" << endl;
-  cout << "authentication must be used for this test to pass. For SSH, this can be configured with" << endl;
-  cout << "ssh-agent for instance. For RSH, this can be configured with the .rhosts file." << endl;
-  cout << "*******************************************************************************************" << endl;
-
-  // eventually remove any previous result
-  remove("result.txt");
-
-  try {
-    // Parse the test configuration file
-    SimpleParser parser;
-    parser.parseTestConfigFile();
-    const string & homedir = parser.getValue("TEST_ESLURM_HOMEDIR");
-    const string & host = parser.getValue("TEST_ESLURM_HOST");
-    const string & user = parser.getValue("TEST_ESLURM_USER");
-    int timeout = parser.getValueAsInt("TEST_ESLURM_TIMEOUT");
-
-    // Define the job...
-    Job job;
-    // ... and its parameters ...
-    Parametre p;
-    p[EXECUTABLE]    = "./test-script.sh";
-    p[NAME]          = string("Test eSLURM ") + argv[1];
-    p[WORKDIR]       = homedir + "/tmp/Batch";
-    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[NBPROC]        = 1;
-    p[MAXWALLTIME]   = 1;
-    p[MAXRAMSIZE]    = 50;
-    p[HOMEDIR]       = homedir;
-    p[EXCLUSIVE]     = true;
-    job.setParametre(p);
-    // ... and its environment
-    Environnement e;
-    e["MYENVVAR"] = "MYVALUE";
-    job.setEnvironnement(e);
-    cout << job << endl;
-
-    // Get the catalog
-    BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
-
-    // Create a BatchManager of type ePBS on localhost
-    FactBatchManager * fbm = c("SLURM");
-    BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
-
-    // Submit the job to the BatchManager
-    JobId jobid = bm->submitJob(job);
-    cout << jobid.__repr__() << endl;
-
-    // Wait for the end of the job
-    string state = bm->waitForJobEnd(jobid, timeout);
-
-    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;
-    }
-
-  } catch (GenericException e) {
-    cerr << "Error: " << e << endl;
-    return 1;
-  } catch (ParserException e) {
-    cerr << "Parser error: " << e.what() << endl;
-    return 1;
-  }
-
-  // test the result file
-  try {
-    SimpleParser resultParser;
-    resultParser.parse("resultdir/seconddirname/result.txt");
-    cout << "Result:" << endl << resultParser;
-    const string & envvar = resultParser.getValue("MYENVVAR");
-    int result = resultParser.getValueAsInt("c");
-    if (envvar == "MYVALUE" && result == 12) {
-      cout << "OK, Expected result found." << endl;
-      return 0;
-    } else {
-      cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl;
-      return 1;
-    }
-  } catch (ParserException e) {
-    cerr << "Parser error on result file: " << e.what() << endl;
-    return 1;
-  }
-}
diff --git a/src/Slurm/Test/seta.sh b/src/Slurm/Test/seta.sh
deleted file mode 100644 (file)
index 42d1e38..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-a=4
diff --git a/src/Slurm/Test/setb.sh b/src/Slurm/Test/setb.sh
deleted file mode 100644 (file)
index 8969060..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-b=3
diff --git a/src/Slurm/Test/test-script.sh b/src/Slurm/Test/test-script.sh
deleted file mode 100755 (executable)
index 1d56247..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-. ./seta.sh
-. ./setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
index 31ab7a2a93b48814553d31e37af55dd757e5a594..1a0d084b84bec9dff5065ae73e241b64919f8cd3 100644 (file)
@@ -28,5 +28,5 @@ SET(CLASS_LIST Vishnu/Batch_BatchManager_eVishnu
 APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
 
 IF (TEST_ENABLED)
-    add_subdirectory(Test)
+    ADD_TEST(VISHNU ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager VISHNU SH)
 ENDIF (TEST_ENABLED)
diff --git a/src/Vishnu/Test/CMakeLists.txt b/src/Vishnu/Test/CMakeLists.txt
deleted file mode 100644 (file)
index 9e66fb2..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#  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
-#
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
-#
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-# Just copy the test scripts to the binary dir
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY)
-
-# set the include directories
-include_directories(${CMAKE_SOURCE_DIR}/src/Core)
-include_directories(${CMAKE_SOURCE_DIR}/src/Core/Test)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Build the test programs and add the tests
-add_executable(Test_eVishnu Test_eVishnu.cxx)
-target_link_libraries(Test_eVishnu batch SimpleParser)
-
-IF (HAS_SSH)
-    ADD_TEST(eVishnu_SSH Test_eVishnu SSH)
-ENDIF (HAS_SSH)
-
-#IF (HAS_RSH)
-#    ADD_TEST(eVishnu_RSH Test_eVishnu RSH)
-#ENDIF (HAS_RSH)
diff --git a/src/Vishnu/Test/Test_eVishnu.cxx b/src/Vishnu/Test/Test_eVishnu.cxx
deleted file mode 100644 (file)
index 0ef9d12..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-//  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
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * Test_eVishnu.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date   : June 2011
- *
- */
-
-#include <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Batch_Constants.hxx>
-#include <Batch_Job.hxx>
-#include <Batch_BatchManagerCatalog.hxx>
-#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-using namespace std;
-using namespace Batch;
-
-int main(int argc, char** argv)
-{
-  cout << "*******************************************************************************************" << endl;
-  cout << "This program tests the batch submission based on Vishnu commands." << endl;
-  cout << "*******************************************************************************************" << endl;
-
-  // eventually remove any previous result
-  remove("result.txt");
-
-  try {
-    // Parse the test configuration file
-    SimpleParser parser;
-    parser.parseTestConfigFile();
-    const string & homedir = parser.getValue("TEST_EVISHNU_HOMEDIR");
-    const string & host = parser.getValue("TEST_EVISHNU_HOST");
-    const string & user = parser.getValue("TEST_EVISHNU_USER");
-    int timeout = parser.getValueAsInt("TEST_EVISHNU_TIMEOUT");
-
-    // Define the job...
-    Job job;
-    // ... and its parameters ...
-    Parametre p;
-    p[EXECUTABLE]    = "./test-script.sh";
-    p[NAME]          = "Test_eVISHNU";
-    p[WORKDIR]       = homedir + "/tmp/Batch";
-    p[INFILE]        = Couple("seta.sh", "seta.sh");
-    p[INFILE]       += Couple("setb.sh", "setb.sh");
-    p[OUTFILE]       = Couple("result.txt", "result.txt");
-    p[NBPROC]        = 1;
-    p[MAXWALLTIME]   = 1;
-    p[MAXRAMSIZE]    = 50;
-    job.setParametre(p);
-    // ... and its environment
-    Environnement e;
-    e["MYENVVAR"] = "MYVALUE";
-    job.setEnvironnement(e);
-    cout << job << endl;
-
-    // Get the catalog
-    BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
-
-    // Create a BatchManager of type ePBS on localhost
-    FactBatchManager * fbm = c("VISHNU");
-    BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), SH);
-
-    // Submit the job to the BatchManager
-    JobId jobid = bm->submitJob(job);
-    cout << jobid.__repr__() << endl;
-
-    // Wait for the end of the job
-    string state = bm->waitForJobEnd(jobid, timeout);
-
-    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;
-    }
-
-  } catch (GenericException e) {
-    cerr << "Error: " << e << endl;
-    return 1;
-  } catch (ParserException e) {
-    cerr << "Parser error: " << e.what() << endl;
-    return 1;
-  }
-
-  // test the result file
-  try {
-    SimpleParser resultParser;
-    resultParser.parse("resultdir/seconddirname/result.txt");
-    cout << "Result:" << endl << resultParser;
-    const string & envvar = resultParser.getValue("MYENVVAR");
-    int result = resultParser.getValueAsInt("c");
-    if (envvar == "MYVALUE" && result == 12) {
-      cout << "OK, Expected result found." << endl;
-      return 0;
-    } else {
-      cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl;
-      return 1;
-    }
-  } catch (ParserException e) {
-    cerr << "Parser error on result file: " << e.what() << endl;
-    return 1;
-  }
-}
diff --git a/src/Vishnu/Test/seta.sh b/src/Vishnu/Test/seta.sh
deleted file mode 100644 (file)
index 42d1e38..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-a=4
diff --git a/src/Vishnu/Test/setb.sh b/src/Vishnu/Test/setb.sh
deleted file mode 100644 (file)
index 8969060..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-b=3
diff --git a/src/Vishnu/Test/test-script.sh b/src/Vishnu/Test/test-script.sh
deleted file mode 100755 (executable)
index 1d56247..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-. ./seta.sh
-. ./setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt