removed output checks from data model and from implementation.
prepared to implement STD{IN,OUT,ERR} piping for subprocess execution. Hoping to maintain compatibility with curses dialogs.master
parent
3bc8908d65
commit
8545264a92
|
@ -2,36 +2,32 @@
|
||||||
"units": [
|
"units": [
|
||||||
{
|
{
|
||||||
"name": "independent test 1",
|
"name": "independent test 1",
|
||||||
"target": "/bin/pwd",
|
"target": "/usr/bin/true",
|
||||||
"output": "pass",
|
"rectifier": "/usr/bin/true",
|
||||||
"rectifier": "/bin/pwd",
|
|
||||||
"active": true,
|
"active": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"rectify": true
|
"rectify": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "independent test 2",
|
"name": "independent test 2",
|
||||||
"target": "/bin/pwd",
|
"target": "/usr/bin/false",
|
||||||
"output": "pass",
|
"rectifier": "/usr/bin/true",
|
||||||
"rectifier": "/bin/pwd",
|
|
||||||
"active": true,
|
"active": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"rectify": true
|
"rectify": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "A DEFINITION THAT IS NOT USED",
|
"name": "A DEFINITION THAT IS NOT USED",
|
||||||
"target": "/bin/pwd",
|
"target": "/usr/bin/false",
|
||||||
"output": "pass",
|
"rectifier": "/usr/bin/true",
|
||||||
"rectifier": "/bin/pwd",
|
|
||||||
"active": true,
|
"active": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"rectify": true
|
"rectify": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dependent test",
|
"name": "dependent test",
|
||||||
"target": "/home/phanes/tests/test-script-pass.sh",
|
"target": "/usr/bin/false",
|
||||||
"output": "pass",
|
"rectifier": "/usr/bin/true",
|
||||||
"rectifier": "/home/phanes/tests/test-script-rectifier.sh",
|
|
||||||
"active": true,
|
"active": true,
|
||||||
"required": true,
|
"required": true,
|
||||||
"rectify": false
|
"rectify": false
|
||||||
|
|
|
@ -97,15 +97,22 @@ void Task::execute( bool verbose )
|
||||||
std::cout << "\t Executing target \"" << this->definition.get_target() << "\"." << std::endl;
|
std::cout << "\t Executing target \"" << this->definition.get_target() << "\"." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionInput execIn;
|
std::string executionString = this->definition.get_target();
|
||||||
Execution Result;
|
std::string rectifierString = this->definition.get_rectifier();
|
||||||
|
|
||||||
execIn.executionString = this->definition.get_target();
|
int return_code = Sproc::execute( executionString );
|
||||||
|
|
||||||
int execution_status = Sproc::execute( execIn, Result );
|
if ( return_code )
|
||||||
|
|
||||||
if ( execution_status )
|
|
||||||
{
|
{
|
||||||
std::cout << std::endl << "STDOUT:" << std::endl<< Result.STDOUT << std::endl;
|
std::cout << "Process failed with exit code " << return_code << "." << std::endl;
|
||||||
|
|
||||||
|
std::cout << "Performing rectification: " << rectifierString << "." << std::endl;
|
||||||
|
int rectifier_error = Sproc::execute( rectifierString );
|
||||||
|
|
||||||
|
if ( rectifier_error )
|
||||||
|
{
|
||||||
|
std::cout << "Designated rectification script failed with error " << rectifier_error << "." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,9 +48,6 @@ int Unit::load_root(Json::Value loader_root)
|
||||||
if ( loader_root.isMember("target") )
|
if ( loader_root.isMember("target") )
|
||||||
{ this->target = loader_root.get("target", errmsg).asString(); } else throw Unit_DataStructureException();
|
{ this->target = loader_root.get("target", errmsg).asString(); } else throw Unit_DataStructureException();
|
||||||
|
|
||||||
if ( loader_root.isMember("output") )
|
|
||||||
{ this->output = loader_root.get("output", errmsg).asString(); } else throw Unit_DataStructureException();
|
|
||||||
|
|
||||||
if ( loader_root.isMember("rectifier") )
|
if ( loader_root.isMember("rectifier") )
|
||||||
{ this->rectifier = loader_root.get("rectifier", errmsg).asString(); } else throw Unit_DataStructureException();
|
{ this->rectifier = loader_root.get("rectifier", errmsg).asString(); } else throw Unit_DataStructureException();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#include "Sproc.h"
|
#include "Sproc.h"
|
||||||
|
|
||||||
int Sproc::execute(ExecutionInput input, Execution &output)
|
|
||||||
|
|
||||||
|
int Sproc::execute( std::string input )
|
||||||
{
|
{
|
||||||
output.STDOUT = "it worked";
|
std::cout << std::endl << "made it to subprocess execution but not implemented yet" << std::endl << std::endl;
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,32 +1,15 @@
|
||||||
#ifndef FTESTS_SPROC_H
|
#ifndef FTESTS_SPROC_H
|
||||||
#define FTESTS_SPROC_H
|
#define FTESTS_SPROC_H
|
||||||
|
|
||||||
#include "string"
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
struct ExecutionInput {
|
|
||||||
std::string executionString;
|
|
||||||
// std::string STDIN;
|
|
||||||
// std::vector<KeyValuePair> EnvironmentVariables;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Execution {
|
|
||||||
//input
|
|
||||||
ExecutionInput input;
|
|
||||||
|
|
||||||
// output
|
|
||||||
int return_code;
|
|
||||||
|
|
||||||
std::string STDOUT;
|
|
||||||
std::string STDERR;
|
|
||||||
};
|
|
||||||
|
|
||||||
// executes a subprocess and captures STDOUT, STDERR, and return code.
|
// executes a subprocess and captures STDOUT, STDERR, and return code.
|
||||||
// should be able to recieve path of binary to be executed as well as any parameters
|
// should be able to recieve path of binary to be executed as well as any parameters
|
||||||
class Sproc {
|
class Sproc {
|
||||||
public:
|
public:
|
||||||
// call the object. returnvalue is enum representing external execution attempt not binary exit code
|
// call the object. returnvalue is enum representing external execution attempt not binary exit code
|
||||||
static int execute( ExecutionInput input, Execution & output );
|
static int execute( std::string input );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //FTESTS_SPROC_H
|
#endif //FTESTS_SPROC_H
|
||||||
|
|
Loading…
Reference in New Issue