2#include "../../../../tests/catch2/catch.hpp"
4#include <mx/sys/timeUtils.hpp>
8#undef app_telemeter_hpp
10#define XWCTEST_NAMESPACE XWCTEST_TELEMETER_LOGSTART_ns
11#define XWCTEST_TELEMETER_LOGSTART
13#undef XWCTEST_NAMESPACE
14#undef XWCTEST_TELEMETER_LOGSTART
28TEST_CASE(
"Test telemeter Configuration",
"[dev::telemeter]" )
30 SECTION(
"a config file with no [telemeter] section, loading defaults" )
33 mx::app::writeConfigFile(
"/tmp/telemeter_test.conf", {
"none" }, {
"nada" }, {
"0" } );
35 mx::app::appConfigurator config;
43 config.readConfig(
"/tmp/telemeter_test.conf" );
48 REQUIRE( pdt.m_tel.logPath().find(
"telem" ) != std::string::npos );
49 REQUIRE( pdt.m_tel.logExt() ==
"bintel" );
50 REQUIRE( pdt.m_tel.logName() == pdt.
configName() );
51 REQUIRE( pdt.m_maxInterval == 10.0 );
54 SECTION(
"a config file with a [telemeter] section changing everything" )
57 mx::app::writeConfigFile(
"/tmp/telemeter_test.conf",
58 {
"telemeter",
"telemeter",
"telemeter" },
59 {
"logDir",
"logExt",
"maxInterval" },
60 {
"/new/log/path",
"txt",
"25" } );
62 mx::app::appConfigurator config;
70 config.readConfig(
"/tmp/telemeter_test.conf" );
75 REQUIRE( pdt.m_tel.logPath() ==
"/new/log/path" );
76 REQUIRE( pdt.m_tel.logExt() ==
"txt" );
77 REQUIRE( pdt.m_maxInterval == 25 );
80 #ifdef XWCTEST_DOX_REF
90TEST_CASE(
"Test telemeter app logic",
"[dev::telemeter]" )
92 SECTION(
"no errors" )
95 mx::app::writeConfigFile(
"/tmp/telemeter_test.conf", {
"none" }, {
"nada" }, {
"0" } );
97 mx::app::appConfigurator config;
105 config.readConfig(
"/tmp/telemeter_test.conf" );
110 pdt.m_tel.logPath(
"/tmp/telems" );
122 SECTION(
"log thread shutsdown" )
125 mx::app::writeConfigFile(
"/tmp/telemeter_test.conf", {
"none" }, {
"nada" }, {
"0" } );
127 mx::app::appConfigurator config;
135 config.readConfig(
"/tmp/telemeter_test.conf" );
140 pdt.m_tel.logPath(
"/tmp/telems" );
148 pdt.m_tel.logShutdown(
true );
158 #ifdef XWCTEST_DOX_REF
171TEST_CASE(
"Test telemeter telem-logger fails to start",
"[dev::telemeter]" )
174 mx::app::writeConfigFile(
"/tmp/telemeter_test.conf", {
"none" }, {
"nada" }, {
"0" } );
176 mx::app::appConfigurator config;
178 telemeter_tests::XWCTEST_TELEMETER_LOGSTART_ns::telemeterTest pdt(
"xx",
false );
181 rv = pdt.setupConfig( config );
184 config.readConfig(
"/tmp/telemeter_test.conf" );
186 rv = pdt.loadConfig( config );
189 pdt.m_tel.logPath(
"/tmp/telems" );
191 rv = pdt.appStartup();
194 #ifdef XWCTEST_DOX_REF
std::string configName()
Get the config name.
TEST_CASE("Test telemeter Configuration", "[dev::telemeter]")
Test telemeter Configuration.
int appShutdown()
Perform telemeter application shutdown.
int loadConfig(appConfigurator &config)
Load the device section from an application configurator.
int appLogic()
Perform telemeter application logic.
int setupConfig(appConfigurator &config)
Setup an application configurator for the device section.
int appStartup()
Starts the telemetry log thread.
Test harness for dev::telemeter.
int setupConfig(mx::app::appConfigurator &config)
int appStartup()
Any tasks to perform prior to the main event loop go here.
int appShutdown()
Any tasks to perform after main loop exit go here.
int loadConfig(mx::app::appConfigurator &config)
int appLogic()
This is where derived applications implement their main FSM logic.