Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
TestingBase< T > Class Template Reference

Base class for all tests. More...

#include <TestingBase.hh>

Inheritance diagram for TestingBase< T >:
Collaboration diagram for TestingBase< T >:

Public Member Functions

 TestingBase ()=default
 Construct a new Testing Base object.
virtual ~TestingBase ()=default
 Destroy the Testing Base object.

Static Public Member Functions

static void SetCommandLineArgs (int argc, char **argv)
 Mutator for the Command Line Args private member.

Protected Member Functions

void RequiredSetup ()
 Required setup for all tests.
void RequiredTeardown ()
 Required teardown for all tests.
void SetupRoveComm ()
 Setup RoveComm for testing.
void TeardownRoveComm ()
 Teardown RoveComm for testing.
virtual void TestSetup ()
 User's setup method.
virtual void TestTeardown ()
 User's teardown method.

Private Member Functions

void SetUp () override
 Method to set up the test class.
void TearDown () override
 Method to tear down the test class.
void ParseArgc ()
 Method to parse the command line arguments.

Static Private Attributes

static int m_argc
static char ** m_argv
static std::string m_szTimestamp

Detailed Description

template<typename T>
class TestingBase< T >

Base class for all tests.

Template Parameters
T- Type of the test class.
Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09

Constructor & Destructor Documentation

◆ TestingBase()

template<typename T>
TestingBase< T >::TestingBase ( )
default

Construct a new Testing Base object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09

◆ ~TestingBase()

template<typename T>
virtual TestingBase< T >::~TestingBase ( )
virtualdefault

Destroy the Testing Base object.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09

Member Function Documentation

◆ SetCommandLineArgs()

template<typename T>
void TestingBase< T >::SetCommandLineArgs ( int argc,
char ** argv )
inlinestatic

Mutator for the Command Line Args private member.

Parameters
argc- The number of command line arguments
argv- The command line arguments
Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
61 {
62 m_argc = argc;
63 m_argv = argv;
64 }
Base class for all tests.
Definition TestingBase.hh:33
Here is the caller graph for this function:

◆ RequiredSetup()

template<typename T>
void TestingBase< T >::RequiredSetup ( )
inlineprotected

Required setup for all tests.

   This method initializes the loggers and RoveComm instances.
Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
76 {
77 // Parse the command line arguments.
78 ParseArgc();
79
80 // Initialize Loggers if they are not already initialized.
81 if (logging::g_qSharedLogger == nullptr)
82 {
84 }
85 }
void ParseArgc()
Method to parse the command line arguments.
Definition TestingBase.hh:229
void InitializeLoggers(std::string szLoggingOutputPath, std::string szProgramTimeLogsDir)
Logger Initializer - Sets Up all the logging handlers required for having the above loggers.
Definition AutonomyLogging.cpp:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RequiredTeardown()

template<typename T>
void TestingBase< T >::RequiredTeardown ( )
inlineprotected

Required teardown for all tests.

   This method stops the RoveComm instances and loggers.
Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
95{}
Here is the caller graph for this function:

◆ SetupRoveComm()

template<typename T>
void TestingBase< T >::SetupRoveComm ( )
inlineprotected

Setup RoveComm for testing.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-10
105 {
106 // Initialize RoveComm.
107 if (network::g_pRoveCommUDPNode == nullptr)
108 {
111 }
112
113 if (network::g_pRoveCommTCPNode == nullptr)
114 {
118 }
119
120 // Check if RoveComm was successfully initialized.
122 {
123 // Submit logger message.
125 "RoveComm did not initialize properly! UDPNode Status: {}, TCPNode Status: {}",
128
129 // Since RoveComm is crucial, skip the test.
130 GTEST_SKIP();
131 }
132 else
133 {
134 // Submit logger message.
135 LOG_INFO(logging::g_qSharedLogger, "RoveComm UDP and TCP nodes successfully initialized.");
136 }
137 }

◆ TeardownRoveComm()

template<typename T>
void TestingBase< T >::TeardownRoveComm ( )
inlineprotected

Teardown RoveComm for testing.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2025-02-10
147 {
148 // Stop RoveComm quill logging or quill will segfault if trying to output logs to RoveComm.
151
152 // Stop handlers.
153 if (network::g_pRoveCommUDPNode != nullptr)
154 {
155 network::g_pRoveCommUDPNode->CloseUDPSocket();
156 }
157 if (network::g_pRoveCommTCPNode != nullptr)
158 {
159 network::g_pRoveCommTCPNode->CloseTCPSocket();
160 }
161
162 // Delete dynamically allocated objects.
165
166 // Set dangling pointers to null.
169 }

◆ TestSetup()

◆ TestTeardown()

◆ SetUp()

template<typename T>
void TestingBase< T >::SetUp ( )
inlineoverrideprivate

Method to set up the test class.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
202 {
203 // Call the base setup method. This initializes the loggers and RoveComm instances.
205 // Call the user's setup method.
206 TestSetup();
207 }
virtual void TestSetup()
User's setup method.
Definition TestingBase.hh:178
void RequiredSetup()
Required setup for all tests.
Definition TestingBase.hh:75
Here is the call graph for this function:

◆ TearDown()

template<typename T>
void TestingBase< T >::TearDown ( )
inlineoverrideprivate

Method to tear down the test class.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
216 {
217 // Call the base teardown method. This stops the RoveComm instances and loggers.
219 // Call the user's teardown method.
220 TestTeardown();
221 }
void RequiredTeardown()
Required teardown for all tests.
Definition TestingBase.hh:95
virtual void TestTeardown()
User's teardown method.
Definition TestingBase.hh:187
Here is the call graph for this function:

◆ ParseArgc()

template<typename T>
void TestingBase< T >::ParseArgc ( )
inlineprivate

Method to parse the command line arguments.

Author
Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
Date
2025-01-09
230 {
231 // Set the current timestamp as the default timestamp.
233
234 // Check if the test being run is in the list of tests to skip setting up logging.
235 for (int i = 1; i < m_argc; ++i)
236 {
237 if (std::string(m_argv[i]).find("--timestamp=") != std::string::npos)
238 {
239 szTimestamp = std::string(m_argv[i]).substr(std::string(m_argv[i]).find("=") + 1);
240 break;
241 }
242 }
243
244 // Set the timestamp.
245 m_szTimestamp = szTimestamp;
246 }
std::string GetTimestamp(const std::string &szFormat="%Y%m%d-%H%M%S")
Accessor for getting the current time in a specified format.
Definition TimeOperations.hpp:42
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: