Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge Python 3 porting: additional chnages.
[modules/kernel.git]
/
src
/
Launcher
/
BatchTest.cxx
diff --git
a/src/Launcher/BatchTest.cxx
b/src/Launcher/BatchTest.cxx
index 1ff5422fba02328af1a3386a77bbfc0c54528f59..d81ef8a04b07510118e60e94c5636ec773ea1bd0 100644
(file)
--- a/
src/Launcher/BatchTest.cxx
+++ b/
src/Launcher/BatchTest.cxx
@@
-1,4
+1,4
@@
-// Copyright (C) 2007-201
3
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-201
7
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
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-6,7
+6,7
@@
// 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
// 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.
+// version 2.1 of the License
, or (at your option) any later version
.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-22,6
+22,8
@@
#include "BatchTest.hxx"
#include "Launcher.hxx"
#include "BatchTest.hxx"
#include "Launcher.hxx"
+#include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
#ifdef WITH_LIBBATCH
#include <libbatch/MpiImpl.hxx>
#ifdef WITH_LIBBATCH
#include <libbatch/MpiImpl.hxx>
@@
-35,7
+37,7
@@
#ifdef WIN32
# include <io.h>
#endif
#ifdef WIN32
# include <io.h>
#endif
-BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr)
+BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr)
{
#ifdef WITH_LIBBATCH
_batch_descr = batch_descr;
{
#ifdef WITH_LIBBATCH
_batch_descr = batch_descr;
@@
-47,10
+49,8
@@
BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr)
strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime));
// Creating test temporary file
strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime));
// Creating test temporary file
- _test_filename = "/tmp/";
- _test_filename += std::string(date) + "_test_cluster_file_";
- _test_filename += _batch_descr.hostname.in();
_base_filename = std::string(date) + "_test_cluster_file_" + _batch_descr.hostname.in();
_base_filename = std::string(date) + "_test_cluster_file_" + _batch_descr.hostname.in();
+ _test_filename = Kernel_Utils::GetTmpDir() + _base_filename;
#endif
}
#endif
}
@@
-60,7
+60,7
@@
bool
BatchTest::test()
{
bool rtn = false;
BatchTest::test()
{
bool rtn = false;
- INFOS(std::endl
+ INFOS(std::endl
<< "--- Testing batch Machine :" << std::endl
<< "--- Name : " << _batch_descr.hostname << std::endl
<< "--- hostname : " << _batch_descr.hostname << std::endl
<< "--- Testing batch Machine :" << std::endl
<< "--- Name : " << _batch_descr.hostname << std::endl
<< "--- hostname : " << _batch_descr.hostname << std::endl
@@
-94,15
+94,15
@@
BatchTest::test()
<< "--- Submit mpi job : " << result_jobsubmit_mpi << std::endl
<< "--- Application : " << result_appli << std::endl
);
<< "--- Submit mpi job : " << result_jobsubmit_mpi << std::endl
<< "--- Application : " << result_appli << std::endl
);
-
- if (result_connection == "OK" &&
+
+ if (result_connection == "OK" &&
result_filecopy == "OK" &&
result_getresult == "OK" &&
result_jobsubmit_simple == "OK" &&
result_jobsubmit_mpi == "OK" &&
result_appli == "OK")
rtn = true;
result_filecopy == "OK" &&
result_getresult == "OK" &&
result_jobsubmit_simple == "OK" &&
result_jobsubmit_mpi == "OK" &&
result_appli == "OK")
rtn = true;
-
+
return rtn;
}
return rtn;
}
@@
-227,7
+227,7
@@
BatchTest::test_getresult()
command = "scp";
if(protocol == "rsh")
command = "rcp";
command = "scp";
if(protocol == "rsh")
command = "rcp";
- command += " " + username + "@" + hostname + ":" + home
+ command += " " + username + "@" + hostname + ":" + home
+ "/" + _base_filename + " " + _test_filename + "_copy";
// Test
+ "/" + _base_filename + " " + _test_filename + "_copy";
// Test
@@
-239,7
+239,7
@@
BatchTest::test_getresult()
result += oss.str();
return result;
}
result += oss.str();
return result;
}
-
+
// Compare files
std::ifstream src_file(_test_filename.c_str());
if (!src_file)
// Compare files
std::ifstream src_file(_test_filename.c_str());
if (!src_file)
@@
-270,8
+270,8
@@
BatchTest::test_getresult()
return result;
}
return result;
}
-std::string
-BatchTest::test_jobsubmit_simple()
+std::string
+BatchTest::test_jobsubmit_simple()
{
int status;
std::string home;
{
int status;
std::string home;
@@
-382,11
+382,11
@@
BatchTest::test_jobsubmit_simple()
}
std::getline(file_job, jobid);
file_job.close();
}
std::getline(file_job, jobid);
file_job.close();
-
+
// Wait the end of the job
command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
bool stop = false;
// Wait the end of the job
command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
bool stop = false;
- while (!stop)
+ while (!stop)
{
status = system(command.c_str());
if(status && status != 153 && status != 256*153)
{
status = system(command.c_str());
if(status && status != 153 && status != 256*153)
@@
-411,7
+411,7
@@
BatchTest::test_jobsubmit_simple()
command = "scp";
if(protocol == "rsh")
command = "rcp";
command = "scp";
if(protocol == "rsh")
command = "rcp";
- command += " "
+ command += " "
+ username + "@" + hostname + ":" + home + "/" + _date + "_simple* /tmp";
status = system(command.c_str());
if(status) {
+ username + "@" + hostname + ":" + home + "/" + _date + "_simple* /tmp";
status = system(command.c_str());
if(status) {
@@
-421,7
+421,7
@@
BatchTest::test_jobsubmit_simple()
result += oss.str();
return result;
}
result += oss.str();
return result;
}
-
+
// Test results
std::string normal_input;
std::string file_normal_name = "/tmp/" + _date + "_simple_output.log";
// Test results
std::string normal_input;
std::string file_normal_name = "/tmp/" + _date + "_simple_output.log";
@@
-457,8
+457,8
@@
BatchTest::test_jobsubmit_simple()
return result;
}
return result;
}
-std::string
-BatchTest::test_jobsubmit_mpi()
+std::string
+BatchTest::test_jobsubmit_mpi()
{
#ifdef WITH_LIBBATCH
int status;
{
#ifdef WITH_LIBBATCH
int status;
@@
-605,11
+605,11
@@
BatchTest::test_jobsubmit_mpi()
}
std::getline(file_job, jobid);
file_job.close();
}
std::getline(file_job, jobid);
file_job.close();
-
+
// Wait the end of the job
command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
bool stop = false;
// Wait the end of the job
command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
bool stop = false;
- while (!stop)
+ while (!stop)
{
status = system(command.c_str());
if(status && status != 153 && status != 256*153)
{
status = system(command.c_str());
if(status && status != 153 && status != 256*153)
@@
-634,7
+634,7
@@
BatchTest::test_jobsubmit_mpi()
command = "scp";
if(protocol == "rsh")
command = "rcp";
command = "scp";
if(protocol == "rsh")
command = "rcp";
- command += " "
+ command += " "
+ username + "@" + hostname + ":" + home + "/" + _date + "_mpi* /tmp";
status = system(command.c_str());
if(status) {
+ username + "@" + hostname + ":" + home + "/" + _date + "_mpi* /tmp";
status = system(command.c_str());
if(status) {
@@
-644,7
+644,7
@@
BatchTest::test_jobsubmit_mpi()
result += oss.str();
return result;
}
result += oss.str();
return result;
}
-
+
// Test results
std::string normal_input;
std::string file_normal_name = "/tmp/" + _date + "_mpi_output.log";
// Test results
std::string normal_input;
std::string file_normal_name = "/tmp/" + _date + "_mpi_output.log";
@@
-667,14
+667,14
@@
BatchTest::test_jobsubmit_mpi()
return result;
}
result = "OK";
return result;
}
result = "OK";
- return result;
+ return result;
#else
throw LauncherException("Method BatchTest::test_jobsubmit_mpi is not available "
"(libBatch was not present at compilation time)");
#endif
}
#else
throw LauncherException("Method BatchTest::test_jobsubmit_mpi is not available "
"(libBatch was not present at compilation time)");
#endif
}
-std::string
+std::string
BatchTest::test_appli()
{
int status;
BatchTest::test_appli()
{
int status;
@@
-685,7
+685,7
@@
BatchTest::test_appli()
std::string username = _batch_descr.username.in();
std::string protocol = _batch_descr.protocol.in();
std::string applipath = _batch_descr.applipath.in();
std::string username = _batch_descr.username.in();
std::string protocol = _batch_descr.protocol.in();
std::string applipath = _batch_descr.applipath.in();
-
+
// Getting home directory
std::string rst = get_home(&home);
if(rst != "") {
// Getting home directory
std::string rst = get_home(&home);
if(rst != "") {
@@
-697,7
+697,7
@@
BatchTest::test_appli()
std::ofstream file_appli;
file_appli.open(_test_file_appli.c_str(), std::ofstream::out);
file_appli << "#!/bin/bash\n"
std::ofstream file_appli;
file_appli.open(_test_file_appli.c_str(), std::ofstream::out);
file_appli << "#!/bin/bash\n"
- << "if [ -f " << applipath << "/
runAppli
]\n"
+ << "if [ -f " << applipath << "/
salome
]\n"
<< "then\n"
<< " echo OK\n"
<< "else\n"
<< "then\n"
<< " echo OK\n"
<< "else\n"
@@
-722,8
+722,8
@@
BatchTest::test_appli()
}
// Launch test
}
// Launch test
- command = protocol + " " + username + "@" + hostname
- + " sh " + home + "/" + _base_filename + "_appli_test > "
+ command = protocol + " " + username + "@" + hostname
+ + " sh " + home + "/" + _base_filename + "_appli_test > "
+ _test_filename + "_appli_test_result";
status = system(command.c_str());
+ _test_filename + "_appli_test_result";
status = system(command.c_str());
@@
-746,7
+746,7
@@
BatchTest::test_appli()
}
std::getline(file_appli_result, rst_appli);
file_appli_result.close();
}
std::getline(file_appli_result, rst_appli);
file_appli_result.close();
-
+
if (rst_appli != "OK")
{
result += "Error checking application on remote host ! result = " + rst;
if (rst_appli != "OK")
{
result += "Error checking application on remote host ! result = " + rst;
@@
-769,7
+769,7
@@
BatchTest::get_home(std::string * home)
std::string protocol = _batch_descr.protocol.in();
std::string file_home_name = _test_filename + "_home";
std::string protocol = _batch_descr.protocol.in();
std::string file_home_name = _test_filename + "_home";
- command = protocol + " " + username + "@" + hostname + " 'echo $HOME' > " + file_home_name;
+ command = protocol + " " + username + "@" + hostname + " 'echo $HOME' > " + file_home_name;
status = system(command.c_str());
if(status) {
std::ostringstream oss;
status = system(command.c_str());
if(status) {
std::ostringstream oss;