2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2009-09-21 22:21:41 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2009-09-21 22:21:41 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2009-09-21 22:21:41 +04:00
|
|
|
|
2009-09-10 19:18:05 +04:00
|
|
|
#include "cmCTestBatchTestHandler.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCTest.h"
|
2009-09-10 19:18:05 +04:00
|
|
|
#include "cmProcess.h"
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
cmCTestBatchTestHandler::~cmCTestBatchTestHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestBatchTestHandler::RunTests()
|
|
|
|
{
|
|
|
|
this->WriteBatchScript();
|
2009-10-26 16:44:08 +03:00
|
|
|
this->SubmitBatchScript();
|
2009-09-10 19:18:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestBatchTestHandler::WriteBatchScript()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Script = this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt";
|
2014-10-05 00:19:13 +04:00
|
|
|
cmsys::ofstream fout;
|
|
|
|
fout.open(this->Script.c_str());
|
2009-09-21 22:21:41 +04:00
|
|
|
fout << "#!/bin/sh\n";
|
2009-09-10 19:18:05 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
|
|
|
|
++i) {
|
2009-09-10 19:18:05 +04:00
|
|
|
this->WriteSrunArgs(i->first, fout);
|
|
|
|
this->WriteTestCommand(i->first, fout);
|
2009-09-14 19:23:20 +04:00
|
|
|
fout << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-10 19:18:05 +04:00
|
|
|
fout.flush();
|
|
|
|
fout.close();
|
|
|
|
}
|
|
|
|
|
2014-10-05 00:19:13 +04:00
|
|
|
void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout)
|
2009-09-10 19:18:05 +04:00
|
|
|
{
|
|
|
|
cmCTestTestHandler::cmCTestTestProperties* properties =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Properties[test];
|
2009-09-10 19:18:05 +04:00
|
|
|
|
2009-09-21 23:29:34 +04:00
|
|
|
fout << "srun ";
|
2016-05-16 17:34:04 +03:00
|
|
|
// fout << "--jobid=" << test << " ";
|
2009-09-21 22:58:30 +04:00
|
|
|
fout << "-J=" << properties->Name << " ";
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// Write dependency information
|
2015-01-15 02:06:11 +03:00
|
|
|
/*if(!this->Tests[test].empty())
|
2009-09-10 19:18:05 +04:00
|
|
|
{
|
|
|
|
fout << "-P=afterany";
|
|
|
|
for(TestSet::iterator i = this->Tests[test].begin();
|
|
|
|
i != this->Tests[test].end(); ++i)
|
|
|
|
{
|
|
|
|
fout << ":" << *i;
|
|
|
|
}
|
|
|
|
fout << " ";
|
2009-09-21 23:29:34 +04:00
|
|
|
}*/
|
2016-05-16 17:34:04 +03:00
|
|
|
if (properties->RunSerial) {
|
2009-09-10 19:18:05 +04:00
|
|
|
fout << "--exclusive ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (properties->Processors > 1) {
|
2009-09-10 19:18:05 +04:00
|
|
|
fout << "-n" << properties->Processors << " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-10 19:18:05 +04:00
|
|
|
}
|
|
|
|
|
2014-10-05 00:19:13 +04:00
|
|
|
void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout)
|
2009-09-10 19:18:05 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> args = this->Properties[test]->Args;
|
|
|
|
std::vector<std::string> processArgs;
|
|
|
|
std::string command;
|
|
|
|
|
|
|
|
command = this->TestHandler->FindTheExecutable(args[1].c_str());
|
|
|
|
command = cmSystemTools::ConvertToOutputPath(command.c_str());
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
// Prepends memcheck args to our command string if this is a memcheck
|
2013-08-08 00:25:48 +04:00
|
|
|
this->TestHandler->GenerateTestCommand(processArgs, test);
|
2009-09-10 19:18:05 +04:00
|
|
|
processArgs.push_back(command);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator arg = processArgs.begin();
|
|
|
|
arg != processArgs.end(); ++arg) {
|
2009-09-10 19:18:05 +04:00
|
|
|
fout << *arg << " ";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-10 19:18:05 +04:00
|
|
|
|
|
|
|
std::vector<std::string>::iterator i = args.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
++i; // the test name
|
|
|
|
++i; // the executable (command)
|
|
|
|
if (args.size() > 2) {
|
2009-09-21 23:29:34 +04:00
|
|
|
fout << "'";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
while (i != args.end()) {
|
|
|
|
fout << "\"" << *i << "\""; // args to the test executable
|
2009-09-21 23:29:34 +04:00
|
|
|
++i;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == args.end() && args.size() > 2) {
|
2009-09-21 23:29:34 +04:00
|
|
|
fout << "'";
|
2009-09-10 19:18:05 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
fout << " ";
|
|
|
|
}
|
|
|
|
// TODO ZACH build TestResult.FullCommandLine
|
|
|
|
// this->TestResult.FullCommandLine = this->TestCommand;
|
2009-09-10 19:18:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestBatchTestHandler::SubmitBatchScript()
|
|
|
|
{
|
|
|
|
cmProcess sbatch;
|
|
|
|
std::vector<std::string> args;
|
|
|
|
args.push_back(this->Script);
|
|
|
|
args.push_back("-o");
|
2016-05-16 17:34:04 +03:00
|
|
|
args.push_back(this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt");
|
2009-09-10 19:18:05 +04:00
|
|
|
|
|
|
|
sbatch.SetCommand("sbatch");
|
|
|
|
sbatch.SetCommandArguments(args);
|
2009-10-26 16:44:08 +03:00
|
|
|
/*if(sbatch.StartProcess())
|
2009-09-10 19:18:05 +04:00
|
|
|
{
|
|
|
|
//success condition
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//fail condition
|
2009-10-26 16:44:08 +03:00
|
|
|
}*/
|
2009-09-10 19:18:05 +04:00
|
|
|
}
|