Compare commits
5 Commits
Examplar-1
...
Examplar-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b2225f3e4 | ||
|
|
6af1082852 | ||
|
|
9d5af160c5 | ||
|
|
da50f152f2 | ||
|
|
7404f07dc5 |
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(ftests)
|
||||
project(examplar)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++1z -O0 -DDEBUG=1")
|
||||
set(SOURCE_FILES examplar.cpp src/loaders/loaders.cpp src/loaders/loaders.h src/json/jsoncpp.cpp src/loaders/JSON_Loader.cpp src/loaders/JSON_Loader.h src/loaders/helpers.cpp src/loaders/helpers.h src/loaders/Suite.cpp src/loaders/Suite.h src/loaders/Plan.cpp src/loaders/Plan.h src/loaders/Conf.cpp src/loaders/Conf.h src/loaders/Unit.cpp src/loaders/Unit.h src/loaders/Task.cpp src/loaders/Task.h src/sproc/Sproc.cpp src/sproc/Sproc.h)
|
||||
|
||||
add_executable(ftests ${SOURCE_FILES})
|
||||
add_executable(examplar ${SOURCE_FILES})
|
||||
20
conf/units/dependent_tests.units
Normal file
20
conf/units/dependent_tests.units
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"units": [
|
||||
{
|
||||
"name": "A DEFINITION THAT IS NOT USED",
|
||||
"target": "/usr/bin/dialog --yesno test 50 50",
|
||||
"rectifier": "/usr/bin/false",
|
||||
"active": true,
|
||||
"required": true,
|
||||
"rectify": true
|
||||
},
|
||||
{
|
||||
"name": "dependent test",
|
||||
"target": "/usr/bin/false",
|
||||
"rectifier": "/usr/bin/true",
|
||||
"active": true,
|
||||
"required": true,
|
||||
"rectify": true
|
||||
}
|
||||
]
|
||||
}
|
||||
56
examplar.cpp
56
examplar.cpp
@@ -21,20 +21,61 @@
|
||||
#include <iostream>
|
||||
#include "src/json/json.h"
|
||||
#include "src/loaders/loaders.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
/*
|
||||
* TODO Logging -- Pump to syslog with clone to STDOUT
|
||||
* TODO Unit Files Directory instead of a single Unit File (optional to user)
|
||||
* TODO Commandline switches
|
||||
*/
|
||||
|
||||
|
||||
int main( )
|
||||
void print_usage()
|
||||
{
|
||||
bool verbose = true;
|
||||
printf("examplar [ -h ] [ -v ] [ -c CONFIG_PATH ]");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main( int argc, char * argv[] )
|
||||
{
|
||||
int flags, opt;
|
||||
bool verbose = false;
|
||||
bool show_help = false;
|
||||
std::string config_path = "/etc/Examplar/config.json";
|
||||
|
||||
// commandline switches:
|
||||
// -h help
|
||||
// -v verbose
|
||||
// -c CONFIG_FILE_PATH -- defaults to '/etc/Examplar/config.json'
|
||||
|
||||
while ( ( opt = getopt( argc, argv, "hvc:" ) ) != -1 )
|
||||
{
|
||||
switch(opt)
|
||||
{
|
||||
case 'h':
|
||||
show_help = true;
|
||||
case 'v':
|
||||
verbose = true;
|
||||
break;
|
||||
case 'c':
|
||||
config_path = std::string(optarg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( show_help == true )
|
||||
{
|
||||
print_usage();
|
||||
}
|
||||
|
||||
setlogmask( LOG_UPTO( LOG_INFO ) );
|
||||
|
||||
openlog( "Examplar", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_PERROR | LOG_LOCAL1 );
|
||||
|
||||
// A Plan is made up of Tasks, and a Suite is made up of Units.
|
||||
// A Plan declares what units are executed and a Suite declares the definitions of those units.
|
||||
Conf configuration = Conf("/home/phanes/development/internal/Examplar/conf/config.json", verbose );
|
||||
Conf configuration = Conf(config_path, verbose );
|
||||
|
||||
// load the configuration file which contains filepaths to definitions of a plan and definitions of units.
|
||||
std::string definitions_file = configuration.get_units_path();
|
||||
@@ -58,8 +99,11 @@ int main( )
|
||||
catch ( std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
syslog( LOG_ERR, e.what() );
|
||||
closelog();
|
||||
return 1;
|
||||
}
|
||||
|
||||
closelog();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user