Salome HOME
Added support for Microsoft Visual C++ (also experimental) V_1_0_0_RC2
authorbarate <barate>
Thu, 14 May 2009 14:44:31 +0000 (14:44 +0000)
committerbarate <barate>
Thu, 14 May 2009 14:44:31 +0000 (14:44 +0000)
23 files changed:
Batch_config.h.in
CMakeLists.txt
CMakeModules/FindLocal.cmake
CMakeModules/FindPThread.cmake [new file with mode: 0644]
CMakeModules/FindPython.cmake
INSTALL
src/CMakeLists.txt
src/Core/Batch_BatchManager_eClient.cxx
src/Local/Batch_BatchManager_Local.cxx
src/Local/Batch_BatchManager_Local.hxx
src/Local/Batch_BatchManager_Local_RSH.cxx
src/Local/Batch_BatchManager_Local_SH.cxx
src/Local/Batch_BatchManager_Local_SH.hxx
src/Local/Test/CMakeLists.txt
src/Local/Test/Exec_Test.cxx [new file with mode: 0644]
src/Local/Test/Test_Local_SH.cxx
src/Local/Test/Test_Local_config.h.in
src/PBS/Batch_BatchManager_ePBS.cxx
src/PBS/Test/Test_PBS_config.h.in
src/Python/Test/CMakeLists.txt
src/Python/Test/Test_Python_Local_SH.py
src/Python/Test/config.py.in
src/Python/Test/test-script.sh [deleted file]

index 4ad5d1e9779f90fd8f093bbc2618e4ace990f326..1901c2088ce7031e87ce333df3591a22f96d86e8 100644 (file)
 #ifndef BATCH_CONFIG_H
 #define BATCH_CONFIG_H
 
+/* Defines the compiler used on Windows */
+#cmakedefine MSVC
+#cmakedefine MINGW
+
 /* A path to a rcp-like command */
 #define RCP "@RCP@"
 
@@ -40,6 +44,7 @@
 
 /* A path to a sh-like command */
 #define SH "@SH@"
+#cmakedefine SH_COMMAND_IS_CMD
 
 /* A path to a ssh-like command */
 #define SSH "@SSH@"
index 25f49088139a4c17437290fd053c0a33a33dbad2..7142ff2ce87f833cada3282d698b309db3d5e4e8 100644 (file)
@@ -27,10 +27,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/)
 
 ENABLE_TESTING()
 
-find_package (Threads)
-IF (NOT CMAKE_USE_PTHREADS_INIT)
-    MESSAGE(FATAL_ERROR "Mandatory library pthread not found")
-ENDIF (NOT CMAKE_USE_PTHREADS_INIT)
+find_package (PThread REQUIRED)
 find_package (Makeinfo)
 
 SET (BUILD_LSF_INTERFACE TRUE CACHE BOOL "Build interface for LSF batch system")
@@ -63,7 +60,7 @@ IF (Makeinfo_FOUND)
 ENDIF (Makeinfo_FOUND)
 
 SET(CPACK_GENERATOR TGZ)
-SET(CPACK_SOURCE_GENERATOR TGZ)
+SET(CPACK_SOURCE_GENERATOR TGZ ZIP)
 SET(CPACK_PACKAGE_VERSION_MAJOR 1)
 SET(CPACK_PACKAGE_VERSION_MINOR 0)
 SET(CPACK_PACKAGE_VERSION_PATCH 0)
index a16ce90014e9cec4534937c0c3b826163510532f..bddeb896303352da9bc25fc4dc8148703605a0ba 100644 (file)
@@ -32,9 +32,51 @@ MACRO(FIND_LOCAL_COMMAND VAR COMMAND)
 ENDMACRO(FIND_LOCAL_COMMAND)
 
 MESSAGE(STATUS "Looking for commands needed for local submission...")
-FIND_LOCAL_COMMAND(RM rm)
-FIND_LOCAL_COMMAND(SH sh)
-FIND_LOCAL_COMMAND(CP cp)
+
+FIND_PROGRAM(RM rm)
+IF (RM)
+    MESSAGE(STATUS "rm found : ${RM}")
+ELSE (RM)
+    IF (WIN32)
+        MESSAGE(STATUS "using 'del' as rm command")
+        SET(RM del)
+    ELSE (WIN32)
+        MESSAGE(STATUS "rm not found, local submission might not work properly")
+        SET(RM /bin/false)
+    ENDIF (WIN32)
+ENDIF (RM)
+MARK_AS_ADVANCED(RM)
+
+FIND_PROGRAM(SH sh)
+IF (SH)
+    MESSAGE(STATUS "sh found : ${SH}")
+ELSE (SH)
+    FIND_PROGRAM(CMD cmd)
+    IF (CMD)
+        MESSAGE(STATUS "cmd found : ${CMD}")
+        SET(SH ${CMD})
+        SET(SH_COMMAND_IS_CMD TRUE)
+    ELSE (CMD)
+        MESSAGE(STATUS "sh not found, local submission might not work properly")
+        SET(SH /bin/false)
+    ENDIF (CMD)
+ENDIF (SH)
+MARK_AS_ADVANCED(CMD SH SH_COMMAND_IS_CMD)
+
+FIND_PROGRAM(CP cp)
+IF (CP)
+    MESSAGE(STATUS "cp found : ${CP}")
+ELSE (CP)
+    IF (WIN32)
+        MESSAGE(STATUS "using 'copy' as cp command")
+        SET(CP copy)
+    ELSE (WIN32)
+        MESSAGE(STATUS "cp not found, local submission might not work properly")
+        SET(CP /bin/false)
+    ENDIF (WIN32)
+ENDIF (CP)
+MARK_AS_ADVANCED(CP)
+
 FIND_LOCAL_COMMAND(RSH rsh)
 FIND_LOCAL_COMMAND(RCP rcp)
 FIND_LOCAL_COMMAND(SSH ssh plink)
diff --git a/CMakeModules/FindPThread.cmake b/CMakeModules/FindPThread.cmake
new file mode 100644 (file)
index 0000000..a144fcc
--- /dev/null
@@ -0,0 +1,52 @@
+#  Copyright (C) 2007-2008  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
+#
+
+IF (NOT PThread_FIND_QUIETLY)
+    MESSAGE(STATUS "Looking for PThread...")
+ENDIF (NOT PThread_FIND_QUIETLY)
+
+FIND_PATH(PTHREAD_INCLUDE_DIR pthread.h)
+FIND_LIBRARY(PTHREAD_LIBRARY NAMES pthread pthreadVC2) 
+
+IF (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+    SET(PThread_FOUND True)
+ENDIF (PTHREAD_INCLUDE_DIR AND PTHREAD_LIBRARY)
+
+IF (PThread_FOUND)
+
+    IF (NOT PThread_FIND_QUIETLY)
+        MESSAGE(STATUS "Found PThread:")
+        MESSAGE(STATUS "PThread include directory: ${PTHREAD_INCLUDE_DIR}")
+        MESSAGE(STATUS "PThread library: ${PTHREAD_LIBRARY}")
+    ENDIF (NOT PThread_FIND_QUIETLY)
+
+ELSE (PThread_FOUND)
+
+    IF (PThread_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "PThread not found")
+    ELSE (PThread_FIND_REQUIRED)
+        IF (NOT PThread_FIND_QUIETLY)
+            MESSAGE(STATUS "PThread not found")
+        ENDIF (NOT PThread_FIND_QUIETLY)
+    ENDIF (PThread_FIND_REQUIRED)
+
+ENDIF (PThread_FOUND)
index 78996b1b89d588cae83aaa2a1e1aa1ae3c3e6589..0a38e5520db8f1edb0b185ae5a0e94cdd46727c4 100644 (file)
@@ -35,7 +35,11 @@ ENDIF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
 IF (PYTHON_DEBUG)
     SET(PYTHON_EXECUTABLE ${PYTHON_DEBUG} CACHE STRING "Python interpreter")
 ELSE (PYTHON_DEBUG)
-    FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter")
+    IF(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
+        MESSAGE(STATUS "Warning! Python debug executable not found. To build Swig module, you will need to install it or compile in Release mode")
+    ELSE(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
+        FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter")
+    ENDIF(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
 ENDIF (PYTHON_DEBUG)
 
 IF (PYTHON_EXECUTABLE)
@@ -78,7 +82,10 @@ ENDIF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_PATH)
 IF (Python_FOUND)
 
     IF (NOT Python_FIND_QUIETLY)
-        MESSAGE(STATUS "Found Python: ${PYTHON_EXECUTABLE} (version ${PYTHON_VERSION})")
+        MESSAGE(STATUS "Found Python:")
+        MESSAGE(STATUS "Python executable: ${PYTHON_EXECUTABLE} (version ${PYTHON_VERSION})")
+        MESSAGE(STATUS "Python include directory: ${PYTHON_INCLUDE_PATH}")
+        MESSAGE(STATUS "Python library: ${PYTHON_LIBRARIES}")
     ENDIF (NOT Python_FIND_QUIETLY)
 
 ELSE (Python_FOUND)
diff --git a/INSTALL b/INSTALL
index faefda45d59cf1fe76fb122c93df352a2ddd92bc..24fdc8c1418ba08916682fa7f3a227ad9f2c6b35 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -147,8 +147,9 @@ First you will need to install a library providing pthread implementation. For
 this we tested Pthreads-win32 (http://sourceware.org/pthreads-win32/) but other
 implementations may exist.
 
-You will also need a compiler for Win32 platform. We tested MinGW and MSYS
-utilities (http://www.mingw.org/) but another compiler might also work.
+You will also need a compiler for Win32 platform. We tested MinGW with MSYS
+environment (http://www.mingw.org/), and Microsoft Visual C++ 2005 Express.
+Other compilers might also work but it is not guaranteed.
 
 Then you will have to install and run CMake, and you should be able to compile
 libBatch and run some basic examples.
index fae507a5c59d3d88ade01332f9ac1b57c01717c5..fe08a3caf0e6c02bae62a00155120e6dac0e66b4 100644 (file)
@@ -38,7 +38,11 @@ MACRO(APPEND_CLASSES_TO_HDR_FILES)
     ENDFOREACH(CLASS ${ARGV})
 ENDMACRO(APPEND_CLASSES_TO_HDR_FILES)
 
+IF (MSVC)
+  add_definitions(/wd4251 /wd4290)  # Disable annoying Visual C++ warnings
+ENDIF (MSVC)
 
+include_directories(${PTHREAD_INCLUDE_DIR})
 
 add_subdirectory (Core)
 
@@ -60,10 +64,8 @@ SET(HDR_FILES_BUILD CACHE INTERNAL "")
 
 add_library (Batch SHARED ${SRC_FILES})
 
-include_directories(${CMAKE_BINARY_DIR})
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core)
-
-target_link_libraries(Batch ${CMAKE_THREAD_LIBS_INIT})
+include_directories(${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Core)
+target_link_libraries(Batch ${PTHREAD_LIBRARY})
 
 IF (WIN32)
     target_link_libraries(Batch ws2_32)
index c0a8ae44c965b6102def2f81dfbf15c1e1fc9339..18082743e99c92dc809c7d61ea8c5a920353d0d2 100644 (file)
 #include "Batch_BatchManager_eClient.hxx"
 #include "Batch_RunTimeException.hxx"
 
+#include <ctime>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 
 #ifdef WIN32
 #include <direct.h>
+#include <io.h>
 #endif
 
 #include "Batch_config.h"
 
+#ifdef MSVC
+#define EXISTS(path) _access_s(path, 0) == 0
+#else
+#define EXISTS(path) access(path, F_OK) == 0
+#endif
+
 using namespace std;
 
 
@@ -273,7 +281,7 @@ namespace Batch {
     do {
       sprintf(randstr, "%06d", rand() % 1000000);
       fileName.replace(fileName.size()-6, 6, randstr);
-    } while (access(fileName.c_str(), F_OK) == 0);
+    } while (EXISTS(fileName.c_str()));
 
     return fileName;
   }
@@ -354,7 +362,7 @@ namespace Batch {
       do {
         sprintf(randstr, "%06d", rand() % 1000000);
         baseName.replace(baseName.size()-6, 6, randstr);
-      } while (access(baseName.c_str(), F_OK) == 0);
+      } while (EXISTS(baseName.c_str()));
       if (_mkdir(baseName.c_str()) != 0)
         throw RunTimeException(string("Can't create temporary directory ") + baseName);
       tmpDirName = baseName;
index 409e5eddc2204b0365de2d773e064a2a106464fd..22e5fb893b6343401a5422e50c210ac72e364cea 100644 (file)
@@ -890,15 +890,13 @@ namespace Batch {
       ZeroMemory( &pi, sizeof(pi) );
 
       // Copy the command to a non-const buffer
-      size_t str_size = exec_command.size();
-      char buffer[str_size+1];
-      exec_command.copy(buffer,str_size);
-      buffer[str_size]='\0';
+      char * buffer = strdup(exec_command.c_str());
 
       // launch the new process
       BOOL res = CreateProcess(NULL, buffer, NULL, NULL, FALSE,
-                               DETACHED_PROCESS, chNewEnv, NULL, &si, &pi);
+                               CREATE_NO_WINDOW, chNewEnv, NULL, &si, &pi);
 
+      if (buffer) free(buffer);
       if (!res) throw RunTimeException("Error while creating new process");
 
       CloseHandle(pi.hThread);
index a7e70de2ccb2665201c6d9f205ce76ecd4376666..5fac3d8f877b9d58cf2bef331f6dffdcc15b2e51 100644 (file)
 
 #include "Batch_Defines.hxx"
 
+#ifdef WIN32
+#include <Windows.h>
+#endif
+
 #include <list>
 #include <map>
 #include <queue>
index 0ca4e999aeede6047b42cab8f000ecfeb73a0734..d7276972c9e3ab44ff54c046aeeda9de485bd382 100644 (file)
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#  include <SALOMEconfig.h>
-#endif
-
 #include <iostream>
 #include <fstream>
 #include <sstream>
@@ -47,6 +43,7 @@
 #include <signal.h>
 #include <errno.h>
 #include <string.h>
+
 #include "Batch_IOMutex.hxx"
 #include "Batch_BatchManager_Local_RSH.hxx"
 
index db4e9cce61b6bf80954c3925f45a8d4f729dd704..10778e1e8fcaf94f02861819808b8b93ddd73960 100644 (file)
@@ -68,6 +68,18 @@ using namespace std;
 
 namespace Batch {
 
+  // Simple method to fix path strings depending on the platform. On Windows, it will replace
+  // forward slashes '/' by backslashes '\'. On Unix, the path is just copied without change.
+  string BatchManager_Local_SH::fixPath(const string & path) const
+  {
+    string fixedPath = path;
+#ifdef WIN32
+    for (int i=0 ; i<fixedPath.size() ; i++) {
+      if (fixedPath[i] == '/') fixedPath[i] = '\\';
+    }
+#endif
+    return fixedPath;
+  }
 
   // Constructeur
   BatchManager_Local_SH::BatchManager_Local_SH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host)
@@ -89,7 +101,11 @@ namespace Batch {
                                              const std::string & destination) const
   {
     ostringstream copy_cmd;
-    copy_cmd << "\"" << CP << "\" \"" << source << "\" \"" << destination << "\"";
+    if (strchr(CP, ' ') == NULL)
+      copy_cmd << CP;
+    else
+      copy_cmd << "\"" << CP << "\"";
+    copy_cmd << " \"" << fixPath(source) << "\" \"" << fixPath(destination) << "\"";
     return copy_cmd.str();
   }
 
@@ -100,7 +116,14 @@ namespace Batch {
 #ifdef WIN32
     exec_sub_cmd << "\"";
 #endif
+#ifdef SH_COMMAND_IS_CMD
+    char drive[_MAX_DRIVE];
+    _splitpath_s(fixPath(param[WORKDIR]).c_str(), drive, _MAX_DRIVE, NULL, 0, NULL, 0, NULL, 0);
+    if (strlen(drive) > 0) exec_sub_cmd << drive << " && ";
+    exec_sub_cmd << "cd " << fixPath(param[WORKDIR]) << " && " << fixPath(param[EXECUTABLE]);
+#else
     exec_sub_cmd << "cd " << param[WORKDIR] << " && " << param[EXECUTABLE];
+#endif
 
     if (param.find(ARGUMENTS) != param.end()) {
       Versatile V = param[ARGUMENTS];
@@ -114,10 +137,14 @@ namespace Batch {
     exec_sub_cmd << "\"";
 #endif
 
+#ifdef SH_COMMAND_IS_CMD
+    param[ARGUMENTS]  = "/c";
+#else
     param[ARGUMENTS]  = "-c";
+#endif
     param[ARGUMENTS] += exec_sub_cmd.str();
 
-    return SH;
+    return fixPath(SH);
   }
 
   // Methode qui renvoie la commande d'effacement du fichier
@@ -126,7 +153,12 @@ namespace Batch {
                                                const std::string & destination) const
   {
     ostringstream remove_cmd;
-    remove_cmd << "\"" << RM << "\" \"" << destination << "\"";
+    if (strchr(RM, ' ') == NULL)
+      remove_cmd << RM;
+    else
+      remove_cmd << "\"" << RM << "\"";
+
+    remove_cmd << " \"" << fixPath(destination) << "\"";
     return remove_cmd.str();
   }
 
index 34c02ec6ad56fd6ce2913fdc7c9002da7caa77d9..aee78d035605fee53a1470c3e9fcebfe927baf3a 100644 (file)
@@ -62,6 +62,8 @@ namespace Batch {
     virtual ~BatchManager_Local_SH();
 
   protected:
+    std::string fixPath(const std::string & path) const;
+
     // Methode qui renvoie la commande de copie du fichier source en destination
     virtual std::string copy_command( const std::string & user_source,
                                       const std::string & host_source,
index 72a332222aa37239a520a7987e34f1698d1efe32..0a8adfd9cb67070177449cbc006640d9f4bfc57b 100644 (file)
@@ -38,6 +38,13 @@ SET (TEST_LOCAL_SSH_USER $ENV{USER} CACHE STRING
 SET (TEST_LOCAL_SSH_WORK_DIR "/tmp" CACHE STRING
      "Work directory for SSH Batch test (only necessary for test target)")
 
+# 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 all the test scripts
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Local_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Test_Local_config.h)
 
diff --git a/src/Local/Test/Exec_Test.cxx b/src/Local/Test/Exec_Test.cxx
new file mode 100644 (file)
index 0000000..5f69726
--- /dev/null
@@ -0,0 +1,79 @@
+//  Copyright (C) 2007-2008  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>
+
+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;
+}
index 2cdcea98c25d1414b5818e9911f783c804835946..8e714bce7b5eee4fd94ba5edfc9311dc4a2431f9 100644 (file)
@@ -54,12 +54,15 @@ int main(int argc, char** argv)
     Job job;
     // ... and its parameters ...
     Parametre p;
-    p["EXECUTABLE"] = "./copied-test-script.sh";
+    p["EXECUTABLE"] = string("./copied-") + 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"]    = TEST_LOCAL_SH_WORK_DIR;
     p["INFILE"]     = Couple("seta.sh", "copied-seta.sh");
     p["INFILE"]    += Couple("setb.sh", "copied-setb.sh");
-    p["INFILE"]    += Couple("test-script.sh", "copied-test-script.sh");
+    p["INFILE"]    += Couple(EXEC_TEST_NAME, string("copied-") + EXEC_TEST_NAME);
     p["OUTFILE"]    = Couple("result.txt", "orig-result.txt");
     job.setParametre(p);
     // ... and its environment
index c1f9d6d9904065d547315ee8ef7ea56dbae07aea..724e5bd262b52ecdb4ad3241578070b041e18182 100644 (file)
@@ -20,6 +20,8 @@
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+#define EXEC_TEST_NAME "${EXEC_TEST_NAME}"
+
 #define TEST_LOCAL_SH_WORK_DIR "${TEST_LOCAL_SH_WORK_DIR}"
 
 #define TEST_LOCAL_RSH_EXECUTION_HOST "${TEST_LOCAL_RSH_EXECUTION_HOST}"
@@ -31,6 +33,7 @@
 #define TEST_LOCAL_SSH_WORK_DIR "${TEST_LOCAL_SSH_WORK_DIR}"
 
 #ifdef WIN32
+#include <Windows.h>
 #define sleep(seconds) Sleep((seconds)*1000)
 #define usleep(useconds) Sleep((useconds)/1000)
 #endif
index d96589767545d9a39a33429e3ab54d84b7fc4f9e..096aad0b76f4eeeb5d39251cdb82d85c9a9e7112 100644 (file)
 #include <fstream>
 #include <sstream>
 #include <sys/stat.h>
+
+#include "Batch_config.h"
+
+#ifdef MSVC
+#include <io.h>
+#else
 #include <libgen.h>
+#endif
 
 #include "Batch_BatchManager_ePBS.hxx"
-#include "Batch_config.h"
 
 using namespace std;
 
@@ -263,9 +269,19 @@ namespace Batch {
       string::size_type p1 = fileToExecute.find_last_of("/");
       string::size_type p2 = fileToExecute.find_last_of(".");
       rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+
+#ifdef MSVC
+      char fname[_MAX_FNAME];
+      char ext[_MAX_EXT];
+      _splitpath_s(fileToExecute.c_str(), NULL, 0, NULL, 0, fname, _MAX_FNAME, ext, _MAX_EXT);
+      string execBaseName = string(fname) + ext;
+#else
       char* basec=strdup(fileToExecute.c_str());
-      fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(basec));
+      string execBaseName = string(basename(basec));
       free(basec);
+#endif
+
+      fileNameToExecute = "~/" + dirForTmpFiles + "/" + execBaseName;
 
       int idx = dirForTmpFiles.find("Batch/");
       filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length());
index faf5a50308c575c4aeb0be5f8a9081202db49ed3..a31220503fe97390a843f75002663160f8ccf5eb 100644 (file)
@@ -26,6 +26,7 @@
 #define TEST_PBS_QUEUE "${TEST_PBS_QUEUE}"
 
 #ifdef WIN32
+#include <Windows.h>
 #define sleep(seconds) Sleep((seconds)*1000)
 #define usleep(useconds) Sleep((useconds)/1000)
 #endif
index 33339d84f6eed474739c83cd771d50c78d651b5c..af36dd482c93f55f301d3f7cc56968f0384512ab 100644 (file)
@@ -26,7 +26,6 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.py.in ${CMAKE_CURRENT_BINARY_D
 # 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)
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Python_Local_SH.py
                ${CMAKE_CURRENT_BINARY_DIR}/Test_Python_Local_SH.py COPYONLY)
 
index e5c2d0adcb68e69dc27621dbcc8c08cebeeeb0e9..4b684b042bbbae10ca377758c9f4834e5987b33d 100644 (file)
@@ -42,11 +42,12 @@ def work():
     job = Job()
     # ... and its parameters ...
     p = {}
-    p['EXECUTABLE'] = './copied-test-script.sh'
-    p['NAME'] = 'Test_Local_SH'
-    p['WORKDIR'] = '/tmp'
+    p['EXECUTABLE'] = './copied-' + config.EXEC_TEST_NAME
+    p["ARGUMENTS"]  = ["copied-seta.sh", "copied-setb.sh", "orig-result.txt"];
+    p['NAME'] = 'Test_Python_Local_SH'
+    p['WORKDIR'] = config.TEST_LOCAL_SH_WORK_DIR
     p['INFILE'] = [('seta.sh', 'copied-seta.sh'), ('setb.sh', 'copied-setb.sh'),
-                   ('test-script.sh', 'copied-test-script.sh')]
+                   (config.EXEC_TEST_FULL_PATH, 'copied-' + config.EXEC_TEST_NAME)]
     p['OUTFILE'] = [('result.txt', 'orig-result.txt')]
     job.setParametre(p)
     # ... and its environment
index 70e2f23eae78c0996e8d25260376260979ce86bc..a732320320143ff1b8607448796224bc9800e6f6 100644 (file)
@@ -22,3 +22,8 @@
 
 import sys
 sys.path.append('${CMAKE_CURRENT_BINARY_DIR}/..')
+
+EXEC_TEST_FULL_PATH = "${EXEC_TEST_FULL_PATH}"
+EXEC_TEST_NAME = "${EXEC_TEST_NAME}"
+
+TEST_LOCAL_SH_WORK_DIR = "${TEST_LOCAL_SH_WORK_DIR}"
diff --git a/src/Python/Test/test-script.sh b/src/Python/Test/test-script.sh
deleted file mode 100755 (executable)
index afd53de..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-source copied-seta.sh
-source copied-setb.sh
-
-c=`expr $a "*" $b`
-
-echo "c = $c" > orig-result.txt