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);
}
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);
}
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();
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();
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) {
// 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;
# 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
--- /dev/null
+#!/usr/bin/env python
+
+a=4
+++ /dev/null
-#!/bin/sh
-
-a=4
--- /dev/null
+#!/usr/bin/env python
+
+b=3
+++ /dev/null
-#!/bin/sh
-
-b=3
+++ /dev/null
-#!/bin/sh
-
-. ./seta.sh
-. ./setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
--- /dev/null
+#!/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)
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;
)
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-
-IF (TEST_ENABLED)
- add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
+++ /dev/null
-# 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)
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-#!/bin/sh
-
-a=4
+++ /dev/null
-#!/bin/sh
-
-b=3
+++ /dev/null
-#!/bin/sh
-
-source seta.sh
-source setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
_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()) {
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)
+++ /dev/null
-# 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)
+++ /dev/null
-// 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;
-}
+++ /dev/null
-// 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;
-}
+++ /dev/null
-// 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}"
+++ /dev/null
-#!/bin/sh
-
-a=4
+++ /dev/null
-#!/bin/sh
-
-b=3
+++ /dev/null
-#!/bin/sh
-
-. ./copied-seta.sh
-. ./copied-setb.sh
-
-c=`expr $a "*" $b`
-
-echo "c = $c" > orig-result.txt
)
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
-
-IF (TEST_ENABLED)
- add_subdirectory(Test)
-ENDIF (TEST_ENABLED)
+++ /dev/null
-# 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)
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-#!/bin/sh
-
-a=4
+++ /dev/null
-#!/bin/sh
-
-b=3
+++ /dev/null
-#!/bin/sh
-
-source seta.sh
-source setb.sh
-
-c=`expr $a "*" $b`
-
-echo "MYENVVAR = $MYENVVAR" > result.txt
-echo "c = $c" >> result.txt
# 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)
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
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()
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"
+++ /dev/null
-#!/bin/sh
-
-a=4
+++ /dev/null
-#!/bin/sh
-
-b=3
// 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;
// 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();