Salome HOME
- Changed tests to use Python (for portability)
authorbarate <barate>
Fri, 18 Jan 2013 15:55:51 +0000 (15:55 +0000)
committerbarate <barate>
Fri, 18 Jan 2013 15:55:51 +0000 (15:55 +0000)
- Remove deprecated tests

39 files changed:
src/Core/Test/SimpleParser.cxx
src/Core/Test/SimpleParser.hxx
src/Core/Test/Test_BatchManager.cxx
src/Core/Test/batchtest.conf
src/Core/Test/seta.py [new file with mode: 0644]
src/Core/Test/seta.sh [deleted file]
src/Core/Test/setb.py [new file with mode: 0644]
src/Core/Test/setb.sh [deleted file]
src/Core/Test/test-script.sh [deleted file]
src/Core/Test/test_script.py [new file with mode: 0755]
src/LSF/BatchManager_LSF.cxx
src/LoadLeveler/CMakeLists.txt
src/LoadLeveler/Test/CMakeLists.txt [deleted file]
src/LoadLeveler/Test/Test_LL.cxx [deleted file]
src/LoadLeveler/Test/seta.sh [deleted file]
src/LoadLeveler/Test/setb.sh [deleted file]
src/LoadLeveler/Test/test-script.sh [deleted file]
src/Local/BatchManager_Local.cxx
src/Local/CMakeLists.txt
src/Local/Test/CMakeLists.txt [deleted file]
src/Local/Test/Exec_Test.cxx [deleted file]
src/Local/Test/Test_Local_SH.cxx [deleted file]
src/Local/Test/Test_Local_config.h.in [deleted file]
src/Local/Test/seta.sh [deleted file]
src/Local/Test/setb.sh [deleted file]
src/Local/Test/test-script.sh [deleted file]
src/PBS/CMakeLists.txt
src/PBS/Test/CMakeLists.txt [deleted file]
src/PBS/Test/Test_PBS.cxx [deleted file]
src/PBS/Test/seta.sh [deleted file]
src/PBS/Test/setb.sh [deleted file]
src/PBS/Test/test-script.sh [deleted file]
src/Python/Test/CMakeLists.txt
src/Python/Test/Test_Python_Local_SH.py
src/Python/Test/config.py.in
src/Python/Test/seta.sh [deleted file]
src/Python/Test/setb.sh [deleted file]
src/Slurm/BatchManager_Slurm.cxx
src/Vishnu/BatchManager_Vishnu.cxx

index ac6a135945c8ade086d5144c1c9e393817419057..e40a56bf8c96035c1e18e1ff4d0a1300a33fa0c8 100644 (file)
@@ -128,9 +128,18 @@ 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)
+const string & SimpleParser::getTestValue(const string & bmType, const string & protocolStr,
+                                          const string & key) const throw(ParserException)
 {
-  string fullkey = string("TEST_") + bmType + "_" + key;
+  string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key;
+  try {
+    return getValue(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + bmType + "_" + key;
+  try {
+    return getValue(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + key;
   return getValue(fullkey);
 }
 
@@ -146,9 +155,18 @@ int SimpleParser::getValueAsInt(const string & key) const throw(ParserException)
   return res;
 }
 
-int SimpleParser::getTestValueAsInt(const string & bmType, const string & key) const throw(ParserException)
+int SimpleParser::getTestValueAsInt(const string & bmType, const string & protocolStr,
+                                    const string & key) const throw(ParserException)
 {
-  string fullkey = string("TEST_") + bmType + "_" + key;
+  string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key;
+  try {
+    return getValueAsInt(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + bmType + "_" + key;
+  try {
+    return getValueAsInt(fullkey);
+  } catch (const ParserException &) {}
+  fullkey = string("TEST_") + key;
   return getValueAsInt(fullkey);
 }
 
index 309799c6b597feb2f0bd98f7cc8d6a2f7dae6c88..43e8ec87874e210da97f22d4dafd4e96e697df2e 100644 (file)
@@ -54,9 +54,11 @@ 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);
+  const std::string & getTestValue(const std::string & bmType, const std::string & protocolStr,
+                                   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);
+  int getTestValueAsInt(const std::string & bmType, const std::string & protocolStr,
+                        const std::string & key) const throw(ParserException);
 
   friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) throw();
 
index feb093373f31408a94521c578ed0c16337d55b66..e1940cb2312a588bb0e887e011a7c3da856dbfe7 100644 (file)
@@ -60,12 +60,13 @@ int main(int argc, char** argv)
     return 1;
   }
   const char * bmType = argv[1];
+  const char * protocolStr = argv[2];
   CommunicationProtocolType protocol;
-  if (strcmp(argv[2], "SSH") == 0)
+  if (strcmp(protocolStr, "SSH") == 0)
     protocol = SSH;
-  else if (strcmp(argv[2], "RSH") == 0)
+  else if (strcmp(protocolStr, "RSH") == 0)
     protocol = RSH;
-  else if (strcmp(argv[2], "SH") == 0)
+  else if (strcmp(protocolStr, "SH") == 0)
     protocol = SH;
   else {
     print_usage();
@@ -74,7 +75,7 @@ int main(int argc, char** argv)
 
   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;
+  cout << "and the communication protocol \"" << protocolStr << "\"." << endl;
   if (protocol == RSH || protocol == SSH) {
     cout << "Passwordless authentication must be used for this test to pass." << endl;
     if (protocol == SSH) {
@@ -96,21 +97,24 @@ int main(int argc, char** argv)
     // 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");
+    const string & workdir = parser.getTestValue(bmType, protocolStr, "WORKDIR");
+    const string & host = parser.getTestValue(bmType, protocolStr, "HOST");
+    const string & user = parser.getTestValue(bmType, protocolStr, "USER");
+    int timeout = parser.getTestValueAsInt(bmType, protocolStr, "TIMEOUT");
 
     // Define the job...
     Job job;
     // ... and its parameters ...
     Parametre p;
-    p[EXECUTABLE]    = string(CMAKE_CURRENT_SOURCE_DIR) + "/test-script.sh";
+    p[EXECUTABLE]    = string(CMAKE_CURRENT_SOURCE_DIR) + "/test_script.py";
+    p[ARGUMENTS]     = "copied_seta.py";
+    p[ARGUMENTS]    += "copied_setb.py";
+    p[ARGUMENTS]    += "orig_result.txt";
     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[INFILE]        = Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/seta.py", "copied_seta.py");
+    p[INFILE]       += Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/setb.py", "copied_setb.py");
+    p[OUTFILE]       = Couple("result.txt", "orig_result.txt");
     p[NBPROC]        = 1;
     p[MAXWALLTIME]   = 1;
     p[MAXRAMSIZE]    = 50;
index 7ff4583eaa2145c653aade2082acf69665317953..f8cdcf304f5184cbe069ee37358a467caa41b022 100644 (file)
@@ -5,28 +5,16 @@
 # Note that BATCH_TEST_CONFIG_FILE is the default name for this environment variable. It can be
 # changed at compilation time by setting CMake option TEST_CONFIG_FILE_ENV_VAR.
 
+TEST_LOCAL_SH_HOST = "localhost"              # Not used
+TEST_LOCAL_SH_USER = "me"                     # Not used
 TEST_LOCAL_SH_WORK_DIR = "/tmp"               # Work directory for local SH Batch test
 TEST_LOCAL_SH_TIMEOUT = 2                     # Execution timeout (in seconds) for local SH Batch test
-TEST_LOCAL_SH_FINALIZATION_TIME = 2           # Finalization time (in seconds) for local SH Batch test
 
 TEST_LOCAL_HOST = "localhost"                 # Execution host for LOCAL Batch test
 TEST_LOCAL_USER = "username"                  # User name on the execution host for LOCAL Batch test
 TEST_LOCAL_WORKDIR = "/tmp"                   # Work directory for LOCAL Batch test
 TEST_LOCAL_TIMEOUT = 10                       # Execution timeout (in seconds) for LOCAL 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
-TEST_EPBS_QUEUE = "queuename"                 # Queue to submit test job on PBS server
-TEST_EPBS_TIMEOUT = 120                       # Execution timeout (in seconds) for PBS Batch test
-
-TEST_ELL_HOST = "localhost"                   # LoadLeveler server host
-TEST_ELL_USER = "username"                    # Login for the LoadLeveler server
-TEST_ELL_HOMEDIR = "/home/username"           # Home directory on LoadLeveler server
-TEST_ELL_QUEUE = "classname"                  # Class for the test job test job on LoadLeveler server
-TEST_ELL_JOBTYPE = "serial"                   # Job type for LoadLeveler
-TEST_ELL_TIMEOUT = 120                        # Execution timeout (in seconds) for LoadLeveler 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
diff --git a/src/Core/Test/seta.py b/src/Core/Test/seta.py
new file mode 100644 (file)
index 0000000..da718ba
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+
+a=4
diff --git a/src/Core/Test/seta.sh b/src/Core/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/Core/Test/setb.py b/src/Core/Test/setb.py
new file mode 100644 (file)
index 0000000..070121a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env python
+
+b=3
diff --git a/src/Core/Test/setb.sh b/src/Core/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/Core/Test/test-script.sh b/src/Core/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
diff --git a/src/Core/Test/test_script.py b/src/Core/Test/test_script.py
new file mode 100755 (executable)
index 0000000..f4073ce
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import sys
+import os
+
+if len(sys.argv) != 4:
+  print "Usage: test-script.py seta.py setb.py result.txt"
+
+execfile(sys.argv[1])
+execfile(sys.argv[2])
+
+c = a * b
+
+f = open(sys.argv[3], "w")
+f.write('MYENVVAR = "%s"\n' % os.getenv("MYENVVAR"))
+f.write("c = %d\n" % c)
index d35532e9e0d8e7c04e9a21f3dc4a950d0af93f2e..e9388fa05e157dee61c18b049885ab6edc8705ca 100644 (file)
@@ -234,7 +234,16 @@ namespace Batch {
     tempOutputFile << "export LIBBATCH_NODEFILE" << endl;
 
     // Launch the executable
-    tempOutputFile << "./" + fileNameToExecute << endl;
+    tempOutputFile << "./" + fileNameToExecute;
+    if (params.find(ARGUMENTS) != params.end()) {
+      Versatile V = params[ARGUMENTS];
+      for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) {
+        StringType argt = * static_cast<StringType *>(*it);
+        string     arg  = argt;
+        tempOutputFile << " " << arg;
+      }
+    }
+    tempOutputFile << endl;
 
     // Remove the node file
     tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl;
index c3e336a4df3d98afc4f580e7e7b6f7db1094b04f..a0634202bd38863defe56bc1f536a54e89e4b80c 100644 (file)
@@ -26,7 +26,3 @@ SET(CLASS_LIST LoadLeveler/BatchManager_LL
    )
 
 APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-
-IF (TEST_ENABLED)
-    add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
diff --git a/src/LoadLeveler/Test/CMakeLists.txt b/src/LoadLeveler/Test/CMakeLists.txt
deleted file mode 100644 (file)
index fc37b3e..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_LL Test_LL.cxx)
-target_link_libraries(Test_LL batch SimpleParser)
-
-IF (HAS_SSH)
-    ADD_TEST(LL_SSH Test_LL SSH)
-ENDIF (HAS_SSH)
-
-#IF (HAS_RSH)
-#    ADD_TEST(LL_RSH Test_LL RSH)
-#ENDIF (HAS_RSH)
diff --git a/src/LoadLeveler/Test/Test_LL.cxx b/src/LoadLeveler/Test/Test_LL.cxx
deleted file mode 100644 (file)
index 2bad912..0000000
+++ /dev/null
@@ -1,165 +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_PBS.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date   : April 2009
- *
- */
-
-#include <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Constants.hxx>
-#include <Job.hxx>
-#include <BatchManagerCatalog.hxx>
-#include <FactBatchManager.hxx>
-#include <FactBatchManager_LL.hxx>
-#include <BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-using namespace std;
-using namespace Batch;
-
-void print_usage()
-{
-  cout << "usage: Test_LL 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 LoadLeveler 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_ELL_HOMEDIR");
-    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...
-    Job job;
-    // ... and its parameters ...
-    Parametre p;
-    p[EXECUTABLE]    = "./test-script.sh";
-    p[NAME]          = string("Test_LL_") + 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[QUEUE]         = queue;
-    p[LL_JOBTYPE]    = jobType;
-    p[EXCLUSIVE]     = false;
-    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("LL");
-    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/LoadLeveler/Test/seta.sh b/src/LoadLeveler/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/LoadLeveler/Test/setb.sh b/src/LoadLeveler/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/LoadLeveler/Test/test-script.sh b/src/LoadLeveler/Test/test-script.sh
deleted file mode 100755 (executable)
index ae952c8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-source seta.sh
-source setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
index edf8182cc13342194cceb0f7aab699e0b8016f10..83530bcbed0a9b4136fd90999a67b949006101ba 100644 (file)
@@ -283,6 +283,11 @@ namespace Batch {
       _splitpath(workDir.c_str(), drive, NULL, NULL, NULL);
       if (strlen(drive) > 0) tempOutputFile << drive << endl;
       tempOutputFile << "cd " << Utils::fixPath(workDir) << endl;
+      // Define environment for the job
+      Environnement env = job.getEnvironnement();
+      for (Environnement::const_iterator iter = env.begin() ; iter != env.end() ; ++iter) {
+        tempOutputFile << "set " << iter->first << "=" << iter->second << endl;
+      }
       // Launch the executable
       tempOutputFile << fileNameToExecute;
       if (param.find(ARGUMENTS) != param.end()) {
index c2d091a9c9978f63502efe2fb49c1941f128d5cd..7d4d023d575d58df7fd7f28f2e17a8cd6b1a5e66 100644 (file)
@@ -30,5 +30,15 @@ SET(CLASS_LIST Local/BatchManager_Local
 APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
 
 IF (TEST_ENABLED)
-    add_subdirectory(Test)
+    IF (HAS_SH)
+        ADD_TEST(LOCAL_SH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SH)
+    ENDIF (HAS_SH)
+    
+    IF (HAS_SSH)
+        ADD_TEST(LOCAL_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SSH)
+    ENDIF (HAS_SSH)
+    
+    IF (HAS_RSH)
+        ADD_TEST(LOCAL_RSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL RSH)
+    ENDIF (HAS_RSH)
 ENDIF (TEST_ENABLED)
diff --git a/src/Local/Test/CMakeLists.txt b/src/Local/Test/CMakeLists.txt
deleted file mode 100644 (file)
index 9a919e1..0000000
+++ /dev/null
@@ -1,58 +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_BINARY_DIR})
-
-# Build the test programs and add the tests
-IF (HAS_SH)
-
-    # Build the executable to use for the local test program
-    add_executable(Exec_Test Exec_Test.cxx)
-    GET_TARGET_PROPERTY(EXEC_TEST_FULL_PATH_TEMP Exec_Test LOCATION)
-    GET_FILENAME_COMPONENT(EXEC_TEST_NAME_TEMP ${EXEC_TEST_FULL_PATH_TEMP} NAME)
-    SET(EXEC_TEST_FULL_PATH ${EXEC_TEST_FULL_PATH_TEMP} CACHE INTERNAL "")
-    SET(EXEC_TEST_NAME ${EXEC_TEST_NAME_TEMP} CACHE INTERNAL "")
-    
-    # Configure the config file for the test
-    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Local_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Test_Local_config.h)
-
-    add_executable(Test_Local_SH Test_Local_SH.cxx)
-    target_link_libraries(Test_Local_SH batch SimpleParser)
-    ADD_TEST(Local_SH Test_Local_SH)
-
-ENDIF (HAS_SH)
-
-IF (HAS_SSH)
-    ADD_TEST(LOCAL_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SSH)
-ENDIF (HAS_SSH)
-
-IF (HAS_RSH)
-    ADD_TEST(LOCAL_RSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL RSH)
-ENDIF (HAS_RSH)
diff --git a/src/Local/Test/Exec_Test.cxx b/src/Local/Test/Exec_Test.cxx
deleted file mode 100644 (file)
index 8ae8d65..0000000
+++ /dev/null
@@ -1,80 +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
-//
-/*
- * Exec_Test.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date   : May 2009
- *
- */
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <cstdlib>
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
-  if (argc != 4) {
-    cerr << "Exec_Test expects three parameters, usage: Exec_Test <scriptA> <scriptB> <result>" << endl;
-    return 1;
-  }
-
-  const char * scriptAFileName = argv[1];
-  const char * scriptBFileName = argv[2];
-  const char * resultFileName = argv[3];
-
-  ifstream scriptAStream(scriptAFileName);
-  std::string line;
-  int a = 0;
-  while (getline(scriptAStream, line)) {
-    if (line.compare(0, 2, string("a=")) == 0) {
-      a = strtol(line.substr(2).c_str(), NULL, 10);
-    }
-  }
-  scriptAStream.close();
-  if (a == 0) {
-    cerr << "Exec_Test couldn't parse value \"a\" in " << scriptAFileName << endl;
-    return 1;
-  }
-
-  ifstream scriptBStream(scriptBFileName);
-  int b = 0;
-  while (getline(scriptBStream, line)) {
-    if (line.compare(0, 2, string("b=")) == 0) {
-      b = strtol(line.substr(2).c_str(), NULL, 10);
-    }
-  }
-  scriptBStream.close();
-  if (b == 0) {
-    cerr << "Exec_Test couldn't parse value \"b\" in " << scriptBFileName << endl;
-    return 1;
-  }
-
-  int c = a * b;
-  ofstream resultStream(resultFileName);
-  resultStream << "c = " << c;
-  resultStream.close();
-  return 0;
-}
diff --git a/src/Local/Test/Test_Local_SH.cxx b/src/Local/Test/Test_Local_SH.cxx
deleted file mode 100644 (file)
index 943b34d..0000000
+++ /dev/null
@@ -1,132 +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_Local_SH.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date   : April 2009
- *
- */
-
-#include <iostream>
-#include <fstream>
-
-#include <Constants.hxx>
-#include <Job.hxx>
-#include <BatchManagerCatalog.hxx>
-#include <FactBatchManager.hxx>
-#include <BatchManager.hxx>
-
-#include <Test_Local_config.h>
-#include <SimpleParser.hxx>
-
-using namespace std;
-using namespace Batch;
-
-int main(int argc, char** argv)
-{
-  cout << "*******************************************************************************************" << endl;
-  cout << "This program tests the local batch submission based on SH. No specific configuration is" << endl;
-  cout << "needed for this test." << endl;
-  cout << "*******************************************************************************************" << endl;
-
-  // eventually remove any previous result
-  remove("result.txt");
-
-  try {
-    // Parse the test configuration file
-    SimpleParser parser;
-    parser.parseTestConfigFile();
-    const string & workdir = parser.getValue("TEST_LOCAL_SH_WORK_DIR");
-    int timeout = parser.getValueAsInt("TEST_LOCAL_SH_TIMEOUT");
-
-    // Define the job...
-    Job job;
-    // ... and its parameters ...
-    Parametre p;
-    p[EXECUTABLE] = EXEC_TEST_NAME;
-    p[ARGUMENTS]  = "copied-seta.sh";
-    p[ARGUMENTS] += "copied-setb.sh";
-    p[ARGUMENTS] += "orig-result.txt";
-    p[NAME]       = "Test_Local_SH";
-    p[WORKDIR]    = workdir;
-    p[INFILE]     = Couple("seta.sh", workdir + "/copied-seta.sh");
-    p[INFILE]    += Couple("setb.sh", workdir + "/copied-setb.sh");
-    p[OUTFILE]    = Couple("result.txt", workdir + "/orig-result.txt");
-    job.setParametre(p);
-    // ... and its environment
-    Environnement e;
-    job.setEnvironnement(e);
-    cout << job << endl;
-
-    // Get the catalog
-    BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
-
-    // Create a BatchManager of type Local_SH on localhost
-    FactBatchManager * fbm = c("LOCAL");
-    if (fbm == NULL) {
-      cerr << "Can't get SH batch manager factory" << endl;
-      return 1;
-    }
-    BatchManager * bm = (*fbm)("localhost", "", 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
-  string exp = "c = 12";
-  string res;
-  ifstream f("resultdir/seconddirname/result.txt");
-  getline(f, res);
-  f.close();
-
-  cout << "result found : " << res << ", expected : " << exp << endl;
-
-  if (res == exp)
-    return 0;
-  else
-    return 1;
-}
diff --git a/src/Local/Test/Test_Local_config.h.in b/src/Local/Test/Test_Local_config.h.in
deleted file mode 100644 (file)
index 4b32fe6..0000000
+++ /dev/null
@@ -1,23 +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
-//
-
-#define EXEC_TEST_NAME "${EXEC_TEST_NAME}"
diff --git a/src/Local/Test/seta.sh b/src/Local/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/Local/Test/setb.sh b/src/Local/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/Local/Test/test-script.sh b/src/Local/Test/test-script.sh
deleted file mode 100755 (executable)
index bc7704a..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-. ./copied-seta.sh
-. ./copied-setb.sh
-
-c=`expr $a "*" $b`
-
-echo "c = $c" > orig-result.txt
index e8d991ae931fcbdef3a95207da9ec0d6f4ea52fb..9fc2dde223ece514b2a41e12257d46e7b46244cf 100644 (file)
@@ -26,7 +26,3 @@ SET(CLASS_LIST PBS/BatchManager_PBS
    )
 
 APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-
-IF (TEST_ENABLED)
-    add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
diff --git a/src/PBS/Test/CMakeLists.txt b/src/PBS/Test/CMakeLists.txt
deleted file mode 100644 (file)
index 507ceda..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_PBS Test_PBS.cxx)
-target_link_libraries(Test_PBS batch SimpleParser)
-
-IF (HAS_SSH)
-    ADD_TEST(PBS_SSH Test_PBS SSH)
-ENDIF (HAS_SSH)
-
-IF (HAS_RSH)
-    ADD_TEST(PBS_RSH Test_PBS RSH)
-ENDIF (HAS_RSH)
diff --git a/src/PBS/Test/Test_PBS.cxx b/src/PBS/Test/Test_PBS.cxx
deleted file mode 100644 (file)
index 259fff2..0000000
+++ /dev/null
@@ -1,158 +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_PBS.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date   : April 2009
- *
- */
-
-#include <iostream>
-#include <fstream>
-#include <cstring>
-
-#include <Constants.hxx>
-#include <Job.hxx>
-#include <BatchManagerCatalog.hxx>
-#include <FactBatchManager.hxx>
-#include <BatchManager.hxx>
-
-#include <SimpleParser.hxx>
-
-using namespace std;
-using namespace Batch;
-
-void print_usage()
-{
-  cout << "usage: Test_PBS 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 PBS emulation. Passwordless authentication" << endl;
-  cout << "must be used for this test to pass. For SSH, this can be configured with ssh-agent for" << endl;
-  cout << "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_EPBS_HOMEDIR");
-    const string & host = parser.getValue("TEST_EPBS_HOST");
-    const string & user = parser.getValue("TEST_EPBS_USER");
-    const string & queue = parser.getValue("TEST_EPBS_QUEUE");
-    int timeout = parser.getValueAsInt("TEST_EPBS_TIMEOUT");
-
-    // Define the job...
-    Job job;
-    // ... and its parameters ...
-    Parametre p;
-    p[EXECUTABLE]    = "./test-script.sh";
-    p[NAME]          = string("Test_PBS_") + 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[NBPROCPERNODE] = 8;
-    p[MAXWALLTIME]   = 1;
-    p[MAXRAMSIZE]    = 128;
-    p[HOMEDIR]       = homedir;
-    p[QUEUE]         = queue;
-    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("PBS");
-    BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol, "nompi");
-
-    // 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 || state == FAILED) {
-      cout << "Job " << jobid.__repr__() << " is done" << endl;
-      bm->importOutputFiles(job, "resultdir/seconddirname");
-    } 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/PBS/Test/seta.sh b/src/PBS/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/PBS/Test/setb.sh b/src/PBS/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/PBS/Test/test-script.sh b/src/PBS/Test/test-script.sh
deleted file mode 100755 (executable)
index ae952c8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-source seta.sh
-source setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
index fe3d614d6b22fe70593c773dea01ca8d0c18a385..0119438725d565703ef31f14e8a19278153a3530 100644 (file)
@@ -24,9 +24,7 @@ IF (BUILD_LOCAL_SUBMISSION AND HAS_SH)
     # Configure the config file for the test script
     CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.py.in ${CMAKE_CURRENT_BINARY_DIR}/config.py)
     
-    # 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)
+    # Just copy the test script to the binary dir
     CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Python_Local_SH.py
                    ${CMAKE_CURRENT_BINARY_DIR}/Test_Python_Local_SH.py COPYONLY)
     
index 64a70af7f02914c7a2482e1ee4109cc66261671d..3a1e7422afaa5fd55dd6bc5b25282811ce62d375 100644 (file)
@@ -35,23 +35,24 @@ def work():
     print "*******************************************************************************************"
 
     # eventually remove any previous result
-    if (os.path.exists('result.txt')):
-        os.remove('result.txt')
+    if (os.path.exists("resultdir/seconddirname/result.txt")):
+        os.remove("resultdir/seconddirname/result.txt")
 
     # Define the job...
     job = Job()
     # ... and its parameters ...
     p = {}
-    p[EXECUTABLE] = config.EXEC_TEST_FULL_PATH
-    p[ARGUMENTS]  = ["copied-seta.sh", "copied-setb.sh", "orig-result.txt"];
+    p[EXECUTABLE] = config.TEST_SOURCE_DIR + "/test_script.py";
+    p[ARGUMENTS]  = ["copied_seta.py", "copied_setb.py", "orig_result.txt"];
     p[NAME] = 'Test_Python_Local_SH'
-    p[WORKDIR] = config.TEST_LOCAL_SH_WORK_DIR
-    p[INFILE] = [('seta.sh', p[WORKDIR] + '/copied-seta.sh'),
-                 ('setb.sh', p[WORKDIR] + '/copied-setb.sh')]
-    p[OUTFILE] = [('result.txt', p[WORKDIR] + '/orig-result.txt')]
+    p[WORKDIR] = config.TEST_LOCAL_SH_WORKDIR
+    p[INFILE] = [(config.TEST_SOURCE_DIR + '/seta.py', 'copied_seta.py'),
+                 (config.TEST_SOURCE_DIR + '/setb.py', 'copied_setb.py')]
+    p[OUTFILE] = [('result.txt', 'orig_result.txt')]
     job.setParametre(p)
     # ... and its environment
     e = {}
+    e["MYENVVAR"] = "MYVALUE";
     job.setEnvironnement(e)
     print job
 
@@ -88,15 +89,14 @@ def work():
         return 1;
 
     # test the result file
-    exp = "c = 12"
-    f = open('resultdir/seconddirname/result.txt')
-    res = f.read().strip()
-    print "result found : %s, expected : %s" % (res, exp)
-
-    if (res == exp):
-        return 0
+    res = {}
+    execfile('resultdir/seconddirname/result.txt', res)
+    if (res["c"] == 12 and res["MYENVVAR"] == "MYVALUE"):
+      print "OK, Expected result found."
+      return 0
     else:
-        return 1
+      print "result found : %s, expected : %s" % (res, 'res["c"] == 12 and res["MYENVVAR"] == "MYVALUE"')
+      return 1
 
 if __name__ == "__main__":
     retcode = work()
index 64c79270b553c311be94dd8426d4e1e12a5fa864..af5d3b4c7deee8e47c533ff1658a8bd9b2dc3fe0 100644 (file)
@@ -24,8 +24,6 @@ import sys
 import os
 sys.path.append('${CMAKE_CURRENT_BINARY_DIR}/..')
 
-EXEC_TEST_FULL_PATH = "${EXEC_TEST_FULL_PATH}"
-EXEC_TEST_NAME = "${EXEC_TEST_NAME}"
-
 configfile = os.environ["${TEST_CONFIG_FILE_ENV_VAR}"]
 execfile(configfile)
+TEST_SOURCE_DIR = "${CMAKE_SOURCE_DIR}/src/Core/Test"
diff --git a/src/Python/Test/seta.sh b/src/Python/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/Python/Test/setb.sh b/src/Python/Test/setb.sh
deleted file mode 100644 (file)
index 8969060..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-b=3
index e74f82c38b9b6c3d6355b49da4666c1be2e39c62..dfce7cd0063d0b41e20d8c4b4f4235a1ef2c5a86 100644 (file)
@@ -163,7 +163,16 @@ namespace Batch {
 
     // Launch the executable
     tempOutputFile << "cd " << workDir << endl;
-    tempOutputFile << "./" + fileNameToExecute << endl;
+    tempOutputFile << "./" + fileNameToExecute;
+    if (params.find(ARGUMENTS) != params.end()) {
+      Versatile V = params[ARGUMENTS];
+      for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) {
+        StringType argt = * static_cast<StringType *>(*it);
+        string     arg  = argt;
+        tempOutputFile << " " << arg;
+      }
+    }
+    tempOutputFile << endl;
 
     // Remove the node file
     tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl;
index 16d116f84bfbfcfbbe12c8485d61080ac0d7e89d..291f0961787a6462b9649ba9b21ad2ec64a0059d 100644 (file)
@@ -223,7 +223,16 @@ namespace Batch {
 
     // Launch the executable
     tempOutputFile << "cd " << workDir << endl;
-    tempOutputFile << "./" + fileNameToExecute << endl;
+    tempOutputFile << "./" + fileNameToExecute;
+    if (params.find(ARGUMENTS) != params.end()) {
+      Versatile V = params[ARGUMENTS];
+      for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) {
+        StringType argt = * static_cast<StringType *>(*it);
+        string     arg  = argt;
+        tempOutputFile << " " << arg;
+      }
+    }
+    tempOutputFile << endl;
 
     tempOutputFile.flush();
     tempOutputFile.close();