From 7d12ccca1bde073e5405a864eb5e7f7ed2f4ced3 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Mon, 18 Dec 2017 10:35:39 +0100 Subject: [PATCH] Pre process command is now a script. --- idl/SALOME_Launcher.idl | 4 ++-- src/Launcher/CMakeLists.txt | 6 +++++- src/Launcher/Launcher_Job.cxx | 11 ++++++++++- src/Launcher/Test/CTestTestfileInstall.cmake | 2 +- src/Launcher/Test/test_launcher.py | 8 +++++++- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl index b3619363c..ca8a0248c 100644 --- a/idl/SALOME_Launcher.idl +++ b/idl/SALOME_Launcher.idl @@ -66,8 +66,8 @@ struct JobParameters */ string job_file; - //! Pre processing command. - /*! This command is called on the remote resource, from #work_directory, after + //! Pre processing script. + /*! This script is called on the remote resource, from #work_directory, after the copy of #in_files and before submiting the job. */ string pre_command; diff --git a/src/Launcher/CMakeLists.txt b/src/Launcher/CMakeLists.txt index e85ee37b1..4c8560db3 100755 --- a/src/Launcher/CMakeLists.txt +++ b/src/Launcher/CMakeLists.txt @@ -40,7 +40,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_BINARY_DIR}/idl ) -ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${OMNIORB_DEFINITIONS}) +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${BOOST_DEFINITIONS} ${OMNIORB_DEFINITIONS}) IF(SALOME_USE_LIBBATCH) ADD_DEFINITIONS(-DWITH_LIBBATCH) ENDIF(SALOME_USE_LIBBATCH) @@ -56,6 +56,8 @@ SET(COMMON_LIBS SALOMELocalTrace SALOMEBasics SalomeIDLKernel + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_SYSTEM_LIBRARY} ${LIBBATCH_LIBRARIES} ${OMNIORB_LIBRARIES} ${LIBXML2_LIBRARIES} @@ -83,6 +85,8 @@ SET(TestLauncher_LIBS ResourcesManager Launcher ${LIBBATCH_LIBRARIES} + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_SYSTEM_LIBRARY} ) # TestLauncher needs only (and must need only) libxml, libbatch, ResourceManager and Launcher libraries! diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index e3a2fc615..e98e0f204 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -22,6 +22,7 @@ //#define _DEBUG_ #include "Launcher_Job.hxx" #include "Launcher.hxx" +#include #ifdef WITH_LIBBATCH #include @@ -617,7 +618,13 @@ Launcher::Job::common_job_params() } } params[Batch::WORKDIR] = _work_directory; - params[Batch::PREPROCESS] = _pre_command; + std::string libbatch_pre_command(""); + if(!_pre_command.empty()) + { + boost::filesystem::path pre_command_path(_pre_command); + libbatch_pre_command += "./" + pre_command_path.filename().string(); + } + params[Batch::PREPROCESS] = libbatch_pre_command; // Parameters for COORM params[Batch::LAUNCHER_FILE] = _launcher_file; @@ -632,6 +639,8 @@ Launcher::Job::common_job_params() in_files.push_back(_job_file); if (_env_file != "") in_files.push_back(_env_file); + if(!_pre_command.empty()) + in_files.push_back(_pre_command); for(std::list::iterator it = in_files.begin(); it != in_files.end(); it++) { std::string file = *it; diff --git a/src/Launcher/Test/CTestTestfileInstall.cmake b/src/Launcher/Test/CTestTestfileInstall.cmake index 664c74c99..3d4df3a2d 100644 --- a/src/Launcher/Test/CTestTestfileInstall.cmake +++ b/src/Launcher/Test/CTestTestfileInstall.cmake @@ -19,7 +19,7 @@ IF(NOT WIN32) SET(TEST_NAME ${COMPONENT_NAME}_Launcher) - ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} test_launcher.py) + ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} 2000 test_launcher.py) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" # TIMEOUT 500 ) diff --git a/src/Launcher/Test/test_launcher.py b/src/Launcher/Test/test_launcher.py index b0bee509d..991c05599 100755 --- a/src/Launcher/Test/test_launcher.py +++ b/src/Launcher/Test/test_launcher.py @@ -466,7 +466,13 @@ f.close() mkdir_p(case_test_dir) # command to be run before the job - pre_command = "echo 'it works!' > in.txt" + pre_command = "pre_command.sh" + pre_command_text = "echo 'it works!' > in.txt" + abs_pre_command_file = os.path.join(case_test_dir, pre_command) + f = open(abs_pre_command_file, "w") + f.write(pre_command_text) + f.close() + os.chmod(abs_pre_command_file, 0o755) # job script script_file = "myTestScript.py" -- 2.39.2