Back to index

salome-kernel  6.5.0
BatchTest.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "BatchTest.hxx"
00024 #include "Launcher.hxx"
00025 
00026 #ifdef WITH_LIBBATCH
00027 #include <Batch/Batch_Date.hxx>
00028 #include <Batch/Batch_MpiImpl.hxx>
00029 #endif
00030 
00031 #include "utilities.h"
00032 
00033 #include <sys/stat.h>
00034 #include <iostream>
00035 #include <fstream>
00036 #ifdef WIN32
00037 # include <io.h>
00038 #endif
00039 BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr) 
00040 {
00041 #ifdef WITH_LIBBATCH
00042   _batch_descr = batch_descr;
00043 
00044   // Getting date
00045   Batch::Date date = Batch::Date(time(0));
00046   _date = date.str();
00047   int lend = _date.size() ;
00048   int i = 0 ;
00049   while (i < lend) 
00050   {
00051     if (_date[i] == '/' || _date[i] == '-' || _date[i] == ':' ) 
00052     {
00053       _date[i] = '_' ;
00054     }
00055     i++ ;
00056   }
00057   
00058   // Creating test temporary file
00059   _test_filename =  "/tmp/";
00060   _test_filename +=  _date + "_test_cluster_file_";
00061   _test_filename += _batch_descr.hostname.in();
00062   _base_filename = _date + "_test_cluster_file_" + _batch_descr.hostname.in();
00063 #endif
00064 }
00065 
00066 BatchTest::~BatchTest() {}
00067 
00068 bool
00069 BatchTest::test()
00070 {
00071   bool rtn = false;
00072   INFOS(std::endl 
00073         << "--- Testing batch Machine :" << std::endl
00074         << "--- Name       : " << _batch_descr.hostname << std::endl
00075         << "--- hostname      : " << _batch_descr.hostname << std::endl
00076         << "--- Protocol   : " << _batch_descr.protocol << std::endl
00077         << "--- User Name  : " << _batch_descr.username << std::endl
00078         << "--- Batch Type : " << _batch_descr.batch << std::endl
00079         << "--- MPI Impl   : " << _batch_descr.mpiImpl << std::endl
00080         << "--- Appli Path : " << _batch_descr.applipath << std::endl
00081        );
00082 
00083   std::string result_connection("Not Tested");
00084   std::string result_filecopy("Not Tested");
00085   std::string result_getresult("Not Tested");
00086   std::string result_jobsubmit_simple("Not Tested");
00087   std::string result_jobsubmit_mpi("Not Tested");
00088   std::string result_appli("Not Tested");
00089 
00090   result_connection = test_connection();
00091   result_filecopy = test_filecopy();
00092   result_getresult = test_getresult();
00093   result_jobsubmit_simple = test_jobsubmit_simple();
00094   result_jobsubmit_mpi = test_jobsubmit_mpi();
00095   result_appli = test_appli();
00096 
00097   INFOS(std::endl
00098         << "--- Test results" << std::endl
00099         << "--- Connection          : " << result_connection << std::endl
00100         << "--- File copy           : " << result_filecopy << std::endl
00101         << "--- Get results         : " << result_getresult << std::endl
00102         << "--- Submit simple job   : " << result_jobsubmit_simple << std::endl
00103         << "--- Submit mpi job      : " << result_jobsubmit_mpi << std::endl
00104         << "--- Application         : " << result_appli << std::endl
00105        );
00106   
00107   if (result_connection == "OK"       && 
00108       result_filecopy == "OK"         &&
00109       result_getresult == "OK"        &&
00110       result_jobsubmit_simple == "OK" &&
00111       result_jobsubmit_mpi == "OK"    &&
00112       result_appli == "OK")
00113     rtn = true;
00114       
00115   return rtn;
00116 }
00117 
00118 // For this test we use : hostname, protocol, username
00119 std::string
00120 BatchTest::test_connection()
00121 {
00122   int status;
00123   std::string command;
00124   std::string result("Failed : ");
00125   std::string hostname = _batch_descr.hostname.in();
00126   std::string username = _batch_descr.username.in();
00127   std::string protocol = _batch_descr.protocol.in();
00128 
00129   // Basic tests
00130   if(hostname == "")
00131   {
00132     result += "hostname is empty !";
00133     return result;
00134   }
00135   if(username == "")
00136   {
00137     result += "username is empty !";
00138     return result;
00139   }
00140   if( protocol != "rsh" && protocol != "ssh")
00141   {
00142     result += "protocol unknown ! (" + protocol + ")";
00143     return result;
00144   }
00145 
00146   // Build command
00147   command += protocol
00148           + " "
00149           + username + "@" + hostname;
00150 
00151   // Test
00152   status = system(command.c_str());
00153   if(status) {
00154     std::ostringstream oss;
00155     oss << status;
00156     result += "Error of connection on remote host ! status = ";
00157     result += oss.str();
00158     return result;
00159   }
00160 
00161   result = "OK";
00162   return result;
00163 }
00164 
00165 // For this test we use : hostname, protocol, username
00166 std::string
00167 BatchTest::test_filecopy()
00168 {
00169   int status;
00170   std::string home;
00171   std::string command;
00172   std::string result("Failed : ");
00173   std::string hostname = _batch_descr.hostname.in();
00174   std::string username = _batch_descr.username.in();
00175   std::string protocol = _batch_descr.protocol.in();
00176 
00177   // Getting home directory
00178   std::string rst = get_home(&home);
00179   if(rst != "") {
00180     result += rst;
00181     return result;
00182   }
00183 
00184   // Writing into the tempory file
00185   command = "echo Hello > " +  _test_filename;
00186   status = system(command.c_str());
00187   if(status) {
00188     std::ostringstream oss;
00189     oss << status;
00190     result += "Error in creating tempory file ! status = ";
00191     result += oss.str();
00192     return result;
00193   }
00194 
00195   // Build command
00196   command = "scp";
00197   if(protocol == "rsh")
00198     command = "rcp";
00199   command += " " + _test_filename + " "
00200           + username + "@" + hostname + ":" + home;
00201 
00202   // Test
00203   status = system(command.c_str());
00204   if(status) {
00205     std::ostringstream oss;
00206     oss << status;
00207     result += "Error in copy file on remote host ! status = ";
00208     result += oss.str();
00209     return result;
00210   }
00211 
00212   result = "OK";
00213   return result;
00214 }
00215 
00216 // For this test we use : hostname, protocol, username
00217 std::string
00218 BatchTest::test_getresult()
00219 {
00220   int status;
00221   std::string home;
00222   std::string command;
00223   std::string result("Failed : ");
00224   std::string hostname = _batch_descr.hostname.in();
00225   std::string username = _batch_descr.username.in();
00226   std::string protocol = _batch_descr.protocol.in();
00227 
00228   // Getting home directory
00229   std::string rst = get_home(&home);
00230   if(rst != "") {
00231     result += rst;
00232     return result;
00233   }
00234 
00235   // Build command
00236   command = "scp";
00237   if(protocol == "rsh")
00238     command = "rcp";
00239   command += " " + username + "@" + hostname + ":" + home 
00240           + "/" + _base_filename + " " + _test_filename + "_copy";
00241 
00242   // Test
00243   status = system(command.c_str());
00244   if(status) {
00245     std::ostringstream oss;
00246     oss << status;
00247     result += "Error in copy file from remote host ! status = ";
00248     result += oss.str();
00249     return result;
00250   }
00251   
00252   // Compare files
00253   std::ifstream src_file(_test_filename.c_str());
00254   if (!src_file)
00255   {
00256     result += "Error in reading temporary file ! filename = " + _test_filename;
00257     return result;
00258   }
00259   std::string cp_filename = _test_filename + "_copy";
00260   std::ifstream cp_file(cp_filename.c_str());
00261   if (!cp_file)
00262   {
00263     result += "Error in reading temporary copy file ! filename = " + cp_filename;
00264     return result;
00265   }
00266   std::string src_firstline;
00267   std::string cp_firstline;
00268   std::getline(src_file, src_firstline);
00269   std::getline(cp_file, cp_firstline);
00270   src_file.close();
00271   cp_file.close();
00272   if (src_firstline != cp_firstline)
00273   {
00274     result += "Error source file and copy file are not equa ! source = " + src_firstline + " copy = " + cp_firstline;
00275     return result;
00276   }
00277 
00278   result = "OK";
00279   return result;
00280 }
00281 
00282 std::string 
00283 BatchTest::test_jobsubmit_simple() 
00284 {
00285   int status;
00286   std::string home;
00287   std::string command;
00288   std::string result("Failed : ");
00289   std::string hostname = _batch_descr.hostname.in();
00290   std::string username = _batch_descr.username.in();
00291   std::string protocol = _batch_descr.protocol.in();
00292   std::string batch_type = _batch_descr.batch.in();
00293 
00294   // Basic test
00295   if (batch_type == "lsf")
00296   {
00297     INFOS("test_jobsubmit_simple not yet implemented for lsf... return OK");
00298     result = "OK";
00299     return result;
00300   }
00301   if (batch_type == "ccc")
00302   {
00303     INFOS("test_jobsubmit_simple not yet implemented for ccc... return OK");
00304     result = "OK";
00305     return result;
00306   }
00307   if (batch_type == "slurm")
00308   {
00309     INFOS("test_jobsubmit_simple not yet implemented for slurm... return OK");
00310     result = "OK";
00311     return result;
00312   }
00313   if (batch_type == "sge")
00314   {
00315     INFOS("test_jobsubmit_simple not yet implemented for sge... return OK");
00316     result = "OK";
00317     return result;
00318   }
00319   if (batch_type != "pbs")
00320   {
00321     result += "Batch type unknown ! : " + batch_type;
00322     return result;
00323   }
00324 
00325   // Getting home directory
00326   std::string rst = get_home(&home);
00327   if(rst != "") {
00328     result += rst;
00329     return result;
00330   }
00331 
00332   // PBS test
00333   std::string _test_file_simple = _test_filename + "_simple";
00334   std::ofstream file;
00335   file.open(_test_file_simple.c_str(), std::ofstream::out);
00336   file << "#!/bin/bash\n"
00337        << "#PBS -l nodes=1\n"
00338        << "#PBS -l walltime=00:01:00\n"
00339        << "#PBS -o " + home + "/" + _date + "_simple_output.log\n"
00340        << "#PBS -e " + home + "/" + _date + "_simple_error.log\n"
00341        << "echo Bonjour\n"
00342        << "echo Error >&2\n";
00343   file.flush();
00344   file.close();
00345 
00346 
00347   // Build command for copy
00348   command = "scp";
00349   if(protocol == "rsh")
00350     command = "rcp";
00351   command += " " + _test_file_simple + " "
00352           + username + "@" + hostname + ":" + home;
00353   status = system(command.c_str());
00354   if(status) {
00355     std::ostringstream oss;
00356     oss << status;
00357     result += "Error in copy job file to remote host ! status = ";
00358     result += oss.str();
00359     return result;
00360   }
00361 
00362   // Build command for submit job
00363   std::string file_job_name = _test_filename + "_jobid";
00364   command = protocol + " " + username + "@" + hostname + " qsub " + _base_filename + "_simple > " + file_job_name;
00365   status = system(command.c_str());
00366   if(status) {
00367     std::ostringstream oss;
00368     oss << status;
00369     result += "Error in sending qsub to remote host ! status = ";
00370     result += oss.str();
00371     return result;
00372   }
00373   std::string jobid;
00374   std::ifstream file_job(file_job_name.c_str());
00375   if (!file_job)
00376   {
00377     result += "Error in reading temporary file ! filename = " + file_job_name;
00378     return result;
00379   }
00380   std::getline(file_job, jobid);
00381   file_job.close();
00382  
00383   // Wait the end of the job
00384   command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
00385   bool stop = false;
00386   while (!stop) 
00387   {
00388     status = system(command.c_str());
00389     if(status && status != 153 && status != 256*153)
00390     {
00391       std::ostringstream oss;
00392       oss << status;
00393       result += "Error in sending qstat to remote host ! status = ";
00394       result += oss.str();
00395       return result;
00396     }
00397 
00398     if(status == 153 || status == 256*153 )
00399       stop = true;
00400 #ifdef WIN32
00401     Sleep(1);
00402 #else
00403     sleep(1);
00404 #endif
00405   }
00406 
00407   // Build command for getting results
00408   command = "scp";
00409   if(protocol == "rsh")
00410     command = "rcp";
00411   command += " " 
00412           + username + "@" + hostname + ":" + home + "/" + _date + "_simple* /tmp";
00413   status = system(command.c_str());
00414   if(status) {
00415     std::ostringstream oss;
00416     oss << status;
00417     result += "error in getting file result of qsub simple to remote host ! status = ";
00418     result += oss.str();
00419     return result;
00420   }
00421   
00422   // Test results
00423   std::string normal_input;
00424   std::string file_normal_name = "/tmp/" + _date + "_simple_output.log";
00425   std::ifstream file_normal(file_normal_name.c_str());
00426   if (!file_normal)
00427   {
00428     result += "Error in reading temporary file ! filename = " + file_normal_name;
00429     return result;
00430   }
00431   std::getline(file_normal, normal_input);
00432   file_normal.close();
00433   if (normal_input != "Bonjour")
00434   {
00435     result += "error from simple ouput file ! waiting for Bonjour and get : " + normal_input;
00436     return result;
00437   }
00438   std::string error_input;
00439   std::string file_error_name = "/tmp/" + _date + "_simple_error.log";
00440   std::ifstream file_error(file_error_name.c_str());
00441   if (!file_error)
00442   {
00443     result += "Error in reading temporary file ! filename = " + file_error_name;
00444     return result;
00445   }
00446   std::getline(file_error, error_input);
00447   file_error.close();
00448   if (error_input != "Error")
00449   {
00450     result += "error from simple error file ! waiting for Error and get : " + error_input;
00451     return result;
00452   }
00453   result = "OK";
00454   return result;
00455 }
00456 
00457 std::string 
00458 BatchTest::test_jobsubmit_mpi() 
00459 {
00460 #ifdef WITH_LIBBATCH
00461   int status;
00462   std::string home;
00463   std::string command;
00464   MpiImpl * mpiImpl;
00465   std::string result("Failed : ");
00466   std::string hostname = _batch_descr.hostname.in();
00467   std::string username = _batch_descr.username.in();
00468   std::string protocol = _batch_descr.protocol.in();
00469   std::string batch_type = _batch_descr.batch.in();
00470   std::string mpi_type = _batch_descr.mpiImpl.in();
00471 
00472   // Basic test
00473   if(mpi_type == "lam")
00474     mpiImpl = new MpiImpl_LAM();
00475   else if(mpi_type == "mpich1")
00476     mpiImpl = new MpiImpl_MPICH1();
00477   else if(mpi_type == "mpich2")
00478     mpiImpl = new MpiImpl_MPICH2();
00479   else if(mpi_type == "openmpi")
00480     mpiImpl = new MpiImpl_OPENMPI();
00481   else if(mpi_type == "slurmmpi")
00482     mpiImpl = new MpiImpl_SLURM();
00483   else
00484   {
00485     result += "Error MPI impl not supported : " + mpi_type;
00486     return result;
00487   }
00488 
00489   // LSF et SGE not yet implemented...
00490   if (batch_type == "lsf")
00491   {
00492     INFOS("test_jobsubmit_simple not yet implemented for lsf... return OK");
00493     result = "OK";
00494     return result;
00495   }
00496 
00497   if (batch_type == "ccc")
00498   {
00499     INFOS("test_jobsubmit_simple not yet implemented for ccc... return OK");
00500     result = "OK";
00501     return result;
00502   }
00503 
00504   if (batch_type == "slurm")
00505   {
00506     INFOS("test_jobsubmit_simple not yet implemented for slurm... return OK");
00507     result = "OK";
00508     return result;
00509   }
00510 
00511   if (batch_type == "sge")
00512   {
00513     INFOS("test_jobsubmit_simple not yet implemented for sge... return OK");
00514     result = "OK";
00515     return result;
00516   }
00517 
00518   // Getting home directory
00519   std::string rst = get_home(&home);
00520   if(rst != "") {
00521     result += rst;
00522     return result;
00523   }
00524 
00525   // MPI test
00526   std::string _test_file_script = _test_filename + "_script";
00527   std::ofstream file_script;
00528   file_script.open(_test_file_script.c_str(), std::ofstream::out);
00529   file_script << "#!/bin/bash\n"
00530               << "echo HELLO MPI\n";
00531   file_script.flush();
00532   file_script.close();
00533 #ifdef WIN32
00534   _chmod
00535 #else
00536   chmod
00537 #endif
00538     (_test_file_script.c_str(), 0x1ED);
00539 
00540   std::string _test_file_mpi = _test_filename + "_mpi";
00541   std::ofstream file_mpi;
00542   file_mpi.open(_test_file_mpi.c_str(), std::ofstream::out);
00543   file_mpi << "#!/bin/bash\n"
00544            << "#PBS -l nodes=1\n"
00545            << "#PBS -l walltime=00:01:00\n"
00546            << "#PBS -o " << home << "/" << _date << "_mpi_output.log\n"
00547            << "#PBS -e " << home << "/" << _date << "_mpi_error.log\n"
00548            << mpiImpl->boot("${PBS_NODEFILE}", 1)
00549            << mpiImpl->run("${PBS_NODEFILE}", 1, _base_filename + "_script")
00550            << mpiImpl->halt();
00551   file_mpi.flush();
00552   file_mpi.close();
00553 
00554 
00555   // Build command for copy
00556   command = "scp";
00557   if(protocol == "rsh")
00558     command = "rcp";
00559   command += " " + _test_file_script + " "
00560           + username + "@" + hostname + ":" + home;
00561   status = system(command.c_str());
00562   if(status) {
00563     std::ostringstream oss;
00564     oss << status;
00565     result += "Error in copy job file to remote host ! status = ";
00566     result += oss.str();
00567     return result;
00568   }
00569   command = "scp";
00570   if(protocol == "rsh")
00571     command = "rcp";
00572   command += " " + _test_file_mpi + " "
00573           + username + "@" + hostname + ":" + home;
00574   status = system(command.c_str());
00575   if(status) {
00576     std::ostringstream oss;
00577     oss << status;
00578     result += "Error in copy job file to remote host ! status = ";
00579     result += oss.str();
00580     return result;
00581   }
00582 
00583   // Build command for submit job
00584   std::string file_job_name = _test_filename + "_jobid";
00585   command = protocol + " " + username + "@" + hostname + " qsub " + _base_filename + "_mpi > " + file_job_name;
00586   status = system(command.c_str());
00587   if(status) {
00588     std::ostringstream oss;
00589     oss << status;
00590     result += "Error in sending qsub to remote host ! status = ";
00591     result += oss.str();
00592     return result;
00593   }
00594   std::string jobid;
00595   std::ifstream file_job(file_job_name.c_str());
00596   if (!file_job)
00597   {
00598     result += "Error in reading temporary file ! filename = " + file_job_name;
00599     return result;
00600   }
00601   std::getline(file_job, jobid);
00602   file_job.close();
00603  
00604   // Wait the end of the job
00605   command = protocol + " " + username + "@" + hostname + " qstat -f " + jobid + " > " + file_job_name;
00606   bool stop = false;
00607   while (!stop) 
00608   {
00609     status = system(command.c_str());
00610     if(status && status != 153 && status != 256*153)
00611     {
00612       std::ostringstream oss;
00613       oss << status;
00614       result += "Error in sending qstat to remote host ! status = ";
00615       result += oss.str();
00616       return result;
00617     }
00618 
00619     if(status == 153 || status == 256*153 )
00620       stop = true;
00621 #ifdef WIN32
00622     Sleep(1);
00623 #else
00624     sleep(1);
00625 #endif
00626   }
00627 
00628   // Build command for getting results
00629   command = "scp";
00630   if(protocol == "rsh")
00631     command = "rcp";
00632   command += " " 
00633           + username + "@" + hostname + ":" + home + "/" + _date + "_mpi* /tmp";
00634   status = system(command.c_str());
00635   if(status) {
00636     std::ostringstream oss;
00637     oss << status;
00638     result += "error in getting file result of qsub mpi from remote host ! status = ";
00639     result += oss.str();
00640     return result;
00641   }
00642   
00643   // Test results
00644   std::string normal_input;
00645   std::string file_normal_name = "/tmp/" + _date + "_mpi_output.log";
00646   std::ifstream file_normal(file_normal_name.c_str());
00647   if (!file_normal)
00648   {
00649     result += "Error in reading temporary file ! filename = " + file_normal_name;
00650     return result;
00651   }
00652   bool test_ok = false;
00653   while (std::getline(file_normal, normal_input))
00654   {
00655     if (normal_input == "HELLO MPI")
00656       test_ok = true;
00657   }
00658   file_normal.close();
00659   if (!test_ok)
00660   {
00661     result += "error from mpi ouput file ! waiting for HELLO MPI please watch /tmp/" + _date + "_mpi_output.log file";
00662     return result;
00663   }
00664   result = "OK";
00665   return result;  
00666 #else
00667   throw LauncherException("Method BatchTest::test_jobsubmit_mpi is not available "
00668                           "(libBatch was not present at compilation time)");
00669 #endif
00670 }
00671 
00672 std::string 
00673 BatchTest::test_appli()
00674 {
00675   int status;
00676   std::string home;
00677   std::string command;
00678   std::string result("Failed : ");
00679   std::string hostname = _batch_descr.hostname.in();
00680   std::string username = _batch_descr.username.in();
00681   std::string protocol = _batch_descr.protocol.in();
00682   std::string applipath = _batch_descr.applipath.in();
00683   
00684   // Getting home directory
00685   std::string rst = get_home(&home);
00686   if(rst != "") {
00687     result += rst;
00688     return result;
00689   }
00690 
00691   std::string _test_file_appli = _test_filename + "_appli_test";
00692   std::ofstream file_appli;
00693   file_appli.open(_test_file_appli.c_str(), std::ofstream::out);
00694   file_appli << "#!/bin/bash\n"
00695              << "if [ -f " << applipath << "/runAppli ]\n"
00696              << "then\n"
00697              << "  echo OK\n"
00698              << "else\n"
00699              << "  echo NOK\n"
00700              << "fi\n";
00701   file_appli.flush();
00702   file_appli.close();
00703 
00704   // Build command for copy
00705   command = "scp";
00706   if(protocol == "rsh")
00707     command = "rcp";
00708   command += " " + _test_file_appli + " "
00709           + username + "@" + hostname + ":" + home;
00710   status = system(command.c_str());
00711   if(status) {
00712     std::ostringstream oss;
00713     oss << status;
00714     result += "Error in copy appli test file to remote host ! status = ";
00715     result += oss.str();
00716     return result;
00717   }
00718 
00719   // Launch test
00720   command = protocol + " " + username + "@" + hostname 
00721           + " sh " + home + "/" + _base_filename + "_appli_test > " 
00722           + _test_filename + "_appli_test_result";
00723 
00724   status = system(command.c_str());
00725   if(status) {
00726     std::ostringstream oss;
00727     oss << status;
00728     result += "Error in launching appli test on remote host ! status = ";
00729     result += oss.str();
00730     return result;
00731   }
00732 
00733   // Read test result
00734   std::string rst_appli;
00735   std::string file_appli_result_name = _test_filename + "_appli_test_result";
00736   std::ifstream file_appli_result(file_appli_result_name.c_str());
00737   if (!file_appli_result)
00738   {
00739     result += "Error in reading temporary file ! filename = " + file_appli_result_name;
00740     return result;
00741   }
00742   std::getline(file_appli_result, rst_appli);
00743   file_appli_result.close();
00744   
00745   if (rst_appli != "OK")
00746   {
00747     result += "Error checking application on remote host ! result = " + rst;
00748     return result;
00749   }
00750 
00751   result = "OK";
00752   return result;
00753 }
00754 
00755 // Useful methods
00756 std::string
00757 BatchTest::get_home(std::string * home)
00758 {
00759   int status;
00760   std::string result = "";
00761   std::string command;
00762   std::string hostname = _batch_descr.hostname.in();
00763   std::string username = _batch_descr.username.in();
00764   std::string protocol = _batch_descr.protocol.in();
00765   std::string file_home_name = _test_filename + "_home";
00766 
00767   command = protocol + " " + username + "@" + hostname + " 'echo $HOME' > " + file_home_name; 
00768   status = system(command.c_str());
00769   if(status) {
00770     std::ostringstream oss;
00771     oss << status;
00772     result += "Error in getting home directory ! status = ";
00773     result += oss.str();
00774     return result;
00775   }
00776 
00777   std::ifstream file_home(file_home_name.c_str());
00778   if (!file_home)
00779   {
00780     result += "Error in reading temporary file ! filename = " + file_home_name;
00781     return result;
00782   }
00783   std::getline(file_home, *home);
00784   file_home.close();
00785   return result;
00786 }