From: barate Date: Fri, 18 Jan 2013 15:55:51 +0000 (+0000) Subject: - Changed tests to use Python (for portability) X-Git-Url: http://git.salome-platform.org/gitweb/?p=tools%2Flibbatch.git;a=commitdiff_plain;h=622761a8f65df4949f82a611d32d1a09ce07bab9 - Changed tests to use Python (for portability) - Remove deprecated tests --- diff --git a/src/Core/Test/SimpleParser.cxx b/src/Core/Test/SimpleParser.cxx index ac6a135..e40a56b 100644 --- a/src/Core/Test/SimpleParser.cxx +++ b/src/Core/Test/SimpleParser.cxx @@ -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); } diff --git a/src/Core/Test/SimpleParser.hxx b/src/Core/Test/SimpleParser.hxx index 309799c..43e8ec8 100644 --- a/src/Core/Test/SimpleParser.hxx +++ b/src/Core/Test/SimpleParser.hxx @@ -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(); diff --git a/src/Core/Test/Test_BatchManager.cxx b/src/Core/Test/Test_BatchManager.cxx index feb0933..e1940cb 100644 --- a/src/Core/Test/Test_BatchManager.cxx +++ b/src/Core/Test/Test_BatchManager.cxx @@ -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; diff --git a/src/Core/Test/batchtest.conf b/src/Core/Test/batchtest.conf index 7ff4583..f8cdcf3 100644 --- a/src/Core/Test/batchtest.conf +++ b/src/Core/Test/batchtest.conf @@ -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 index 0000000..da718ba --- /dev/null +++ b/src/Core/Test/seta.py @@ -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 index 42d1e38..0000000 --- a/src/Core/Test/seta.sh +++ /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 index 0000000..070121a --- /dev/null +++ b/src/Core/Test/setb.py @@ -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 index 8969060..0000000 --- a/src/Core/Test/setb.sh +++ /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 index 1d56247..0000000 --- a/src/Core/Test/test-script.sh +++ /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 index 0000000..f4073ce --- /dev/null +++ b/src/Core/Test/test_script.py @@ -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) diff --git a/src/LSF/BatchManager_LSF.cxx b/src/LSF/BatchManager_LSF.cxx index d35532e..e9388fa 100644 --- a/src/LSF/BatchManager_LSF.cxx +++ b/src/LSF/BatchManager_LSF.cxx @@ -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(*it); + string arg = argt; + tempOutputFile << " " << arg; + } + } + tempOutputFile << endl; // Remove the node file tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl; diff --git a/src/LoadLeveler/CMakeLists.txt b/src/LoadLeveler/CMakeLists.txt index c3e336a..a063420 100644 --- a/src/LoadLeveler/CMakeLists.txt +++ b/src/LoadLeveler/CMakeLists.txt @@ -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 index fc37b3e..0000000 --- a/src/LoadLeveler/Test/CMakeLists.txt +++ /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 index 2bad912..0000000 --- a/src/LoadLeveler/Test/Test_LL.cxx +++ /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 -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -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 index 42d1e38..0000000 --- a/src/LoadLeveler/Test/seta.sh +++ /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 index 8969060..0000000 --- a/src/LoadLeveler/Test/setb.sh +++ /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 index ae952c8..0000000 --- a/src/LoadLeveler/Test/test-script.sh +++ /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 diff --git a/src/Local/BatchManager_Local.cxx b/src/Local/BatchManager_Local.cxx index edf8182..83530bc 100644 --- a/src/Local/BatchManager_Local.cxx +++ b/src/Local/BatchManager_Local.cxx @@ -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()) { diff --git a/src/Local/CMakeLists.txt b/src/Local/CMakeLists.txt index c2d091a..7d4d023 100644 --- a/src/Local/CMakeLists.txt +++ b/src/Local/CMakeLists.txt @@ -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 index 9a919e1..0000000 --- a/src/Local/Test/CMakeLists.txt +++ /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 index 8ae8d65..0000000 --- a/src/Local/Test/Exec_Test.cxx +++ /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 -#include -#include -#include - -using namespace std; - -int main(int argc, char** argv) -{ - if (argc != 4) { - cerr << "Exec_Test expects three parameters, usage: Exec_Test " << 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 index 943b34d..0000000 --- a/src/Local/Test/Test_Local_SH.cxx +++ /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 -#include - -#include -#include -#include -#include -#include - -#include -#include - -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 index 4b32fe6..0000000 --- a/src/Local/Test/Test_Local_config.h.in +++ /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 index 42d1e38..0000000 --- a/src/Local/Test/seta.sh +++ /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 index 8969060..0000000 --- a/src/Local/Test/setb.sh +++ /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 index bc7704a..0000000 --- a/src/Local/Test/test-script.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -. ./copied-seta.sh -. ./copied-setb.sh - -c=`expr $a "*" $b` - -echo "c = $c" > orig-result.txt diff --git a/src/PBS/CMakeLists.txt b/src/PBS/CMakeLists.txt index e8d991a..9fc2dde 100644 --- a/src/PBS/CMakeLists.txt +++ b/src/PBS/CMakeLists.txt @@ -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 index 507ceda..0000000 --- a/src/PBS/Test/CMakeLists.txt +++ /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 index 259fff2..0000000 --- a/src/PBS/Test/Test_PBS.cxx +++ /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 -#include -#include - -#include -#include -#include -#include -#include - -#include - -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 index 42d1e38..0000000 --- a/src/PBS/Test/seta.sh +++ /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 index 8969060..0000000 --- a/src/PBS/Test/setb.sh +++ /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 index ae952c8..0000000 --- a/src/PBS/Test/test-script.sh +++ /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 diff --git a/src/Python/Test/CMakeLists.txt b/src/Python/Test/CMakeLists.txt index fe3d614..0119438 100644 --- a/src/Python/Test/CMakeLists.txt +++ b/src/Python/Test/CMakeLists.txt @@ -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) diff --git a/src/Python/Test/Test_Python_Local_SH.py b/src/Python/Test/Test_Python_Local_SH.py index 64a70af..3a1e742 100644 --- a/src/Python/Test/Test_Python_Local_SH.py +++ b/src/Python/Test/Test_Python_Local_SH.py @@ -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() diff --git a/src/Python/Test/config.py.in b/src/Python/Test/config.py.in index 64c7927..af5d3b4 100644 --- a/src/Python/Test/config.py.in +++ b/src/Python/Test/config.py.in @@ -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 index 42d1e38..0000000 --- a/src/Python/Test/seta.sh +++ /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 index 8969060..0000000 --- a/src/Python/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/Slurm/BatchManager_Slurm.cxx b/src/Slurm/BatchManager_Slurm.cxx index e74f82c..dfce7cd 100644 --- a/src/Slurm/BatchManager_Slurm.cxx +++ b/src/Slurm/BatchManager_Slurm.cxx @@ -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(*it); + string arg = argt; + tempOutputFile << " " << arg; + } + } + tempOutputFile << endl; // Remove the node file tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl; diff --git a/src/Vishnu/BatchManager_Vishnu.cxx b/src/Vishnu/BatchManager_Vishnu.cxx index 16d116f..291f096 100644 --- a/src/Vishnu/BatchManager_Vishnu.cxx +++ b/src/Vishnu/BatchManager_Vishnu.cxx @@ -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(*it); + string arg = argt; + tempOutputFile << " " << arg; + } + } + tempOutputFile << endl; tempOutputFile.flush(); tempOutputFile.close();