X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FLocal%2FTest%2FTest_Local_SSH.cxx;fp=src%2FLocal%2FTest%2FTest_Local_SSH.cxx;h=673a8946f0811b85c1287ffd60513b47b37ac356;hb=22e2a51eb83e8e1ff962a027f67f9e433d30389f;hp=b82740ea94968afca4295eab69ed1d56f66ded45;hpb=f9cfa27307e650551fd1f69d616cdec5f9ff2efd;p=tools%2Flibbatch.git diff --git a/src/Local/Test/Test_Local_SSH.cxx b/src/Local/Test/Test_Local_SSH.cxx index b82740e..673a894 100644 --- a/src/Local/Test/Test_Local_SSH.cxx +++ b/src/Local/Test/Test_Local_SSH.cxx @@ -65,14 +65,12 @@ int main(int argc, char** argv) Job job; // ... and its parameters ... Parametre p; - p[EXECUTABLE] = "source copied-test-script.sh"; + p[EXECUTABLE] = "test-script.sh"; p[NAME] = "Test_Local_SSH"; p[WORKDIR] = workdir; - 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[OUTFILE] = Couple("result.txt", "orig-result.txt"); - p[EXECUTIONHOST] = exechost; + 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"); p[USER] = user; job.setParametre(p); // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) @@ -86,12 +84,12 @@ int main(int argc, char** argv) BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); // Create a BatchManager of type Local_SSH on localhost - FactBatchManager * fbm = c("SSH"); + FactBatchManager * fbm = c("LOCAL"); if (fbm == NULL) { cerr << "Can't get SSH batch manager factory" << endl; return 1; } - BatchManager * bm = (*fbm)("localhost"); + BatchManager * bm = (*fbm)(exechost.c_str(), user.c_str(), SSH); // Submit the job to the BatchManager JobId jobid = bm->submitJob(job); @@ -100,13 +98,18 @@ int main(int argc, char** argv) // Wait for the end of the job string state = bm->waitForJobEnd(jobid, timeout); - if (state != FINISHED && state != FAILED) { - cerr << "Error: Job not finished after timeout" << endl; + 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; } - cout << "Job " << jobid.__repr__() << " is done" << endl; - } catch (GenericException e) { cerr << "Error: " << e << endl; return 1; @@ -118,7 +121,7 @@ int main(int argc, char** argv) // test the result file string exp = "c = 12"; string res; - ifstream f("result.txt"); + ifstream f("resultdir/seconddirname/result.txt"); getline(f, res); f.close();