|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
The test runner (process-wide singleton). More...
#include <UnitTestFramework.h>
Public Member Functions | |
| void | registerTest (const char *name, UnitTestFunc func, const char *description="", const char *category="", bool inDefaultRun=true) |
| Register a test with the runner. | |
| void | setVerbose (bool v) |
| Enable/disable verbose diagnostics (unittest::detail output). | |
| void | setCompareFile (const char *path) |
| Set a previous perf JSON file to compare metrics against. | |
| void | setOutputFile (const char *path) |
| Set an explicit perf JSON output path (overrides the timestamped default). | |
| void | setOutputDir (const char *dir) |
| Set the directory for the default (timestamped + latest) output files. | |
| void | setWriteJSON (bool v) |
| Enable/disable writing the perf JSON file at all. | |
| void | setForkPerTest (bool v) |
| Run each test in its own process (default: on where supported) so crashes/hangs are isolated. | |
| bool | hasTest (const char *name) const |
| std::vector< std::string > | testNames () const |
| void | listTests () const |
| Print the registered tests (name, category, description) to stdout. | |
| bool | runAll () |
Run every test marked inDefaultRun. | |
| bool | runOne (const char *name) |
| Run a single named test in isolation. | |
| void | hookProgress (int percent, const char *action) |
| Hook behind unittest::progress()/progressf() for the current test. | |
| void | hookMetric (const char *name, double value, const char *unit, bool higherIsBetter) |
| Hook behind unittest::metric() for the current test. | |
| void | hookDetail (const char *text) |
| Hook behind unittest::detail() for the current test. | |
| void | hookFail (const char *text) |
| Hook behind unittest::fail() for the current test. | |
| bool | hookVerbose () const |
| Hook behind unittest::verbose(). | |
Static Public Member Functions | |
| static UnitTestRunner & | instance () |
| Access the singleton (created on first use). | |
The test runner (process-wide singleton).
Holds the registry of tests, executes them (optionally each in a forked child process so a crash or hang cannot take down the suite), renders the console output, writes the perf JSON and computes compare-mode deltas.
Definition at line 175 of file UnitTestFramework.h.
| bool cmlabs::UnitTestRunner::hasTest | ( | const char * | name | ) | const |
Definition at line 183 of file UnitTestFramework.cpp.
References stricmp.
Referenced by cmlabs::IsCMSDKTest().
| void cmlabs::UnitTestRunner::hookDetail | ( | const char * | text | ) |
Hook behind unittest::detail() for the current test.
Definition at line 269 of file UnitTestFramework.cpp.
References UT_INDENT.
Referenced by cmlabs::unittest::detail().
| void cmlabs::UnitTestRunner::hookFail | ( | const char * | text | ) |
Hook behind unittest::fail() for the current test.
Definition at line 276 of file UnitTestFramework.cpp.
References UT_INDENT.
Referenced by cmlabs::unittest::fail().
| void cmlabs::UnitTestRunner::hookMetric | ( | const char * | name, |
| double | value, | ||
| const char * | unit, | ||
| bool | higherIsBetter ) |
Hook behind unittest::metric() for the current test.
Definition at line 257 of file UnitTestFramework.cpp.
References cmlabs::UnitTestMetric::higherIsBetter, cmlabs::UnitTestMetric::name, cmlabs::UnitTestMetric::unit, and cmlabs::UnitTestMetric::value.
Referenced by cmlabs::unittest::metric().
| void cmlabs::UnitTestRunner::hookProgress | ( | int | percent, |
| const char * | action ) |
Hook behind unittest::progress()/progressf() for the current test.
Definition at line 214 of file UnitTestFramework.cpp.
References UT_NAME_WIDTH.
Referenced by cmlabs::unittest::progress(), and cmlabs::unittest::progressf().
| bool cmlabs::UnitTestRunner::hookVerbose | ( | ) | const |
Hook behind unittest::verbose().
Definition at line 212 of file UnitTestFramework.cpp.
Referenced by cmlabs::unittest::verbose().
|
static |
Access the singleton (created on first use).
Definition at line 138 of file UnitTestFramework.cpp.
Referenced by cmlabs::unittest::detail(), cmlabs::unittest::fail(), cmlabs::IsCMSDKTest(), cmlabs::unittest::metric(), cmlabs::unittest::progress(), cmlabs::unittest::progressf(), cmlabs::Register_Base64_Tests(), cmlabs::Register_Bitmap_Tests(), cmlabs::Register_ComponentData_Tests(), cmlabs::Register_ComponentMemory_Tests(), cmlabs::Register_ControlMessage_Tests(), cmlabs::Register_DataMessage_Tests(), cmlabs::Register_Hash_Tests(), cmlabs::Register_HTML_Tests(), cmlabs::Register_MathClasses_Tests(), cmlabs::Register_MemoryManager_Tests(), cmlabs::Register_MemoryRequestServer_Tests(), cmlabs::Register_MessageIndex_Tests(), cmlabs::Register_MovingAverage_Tests(), cmlabs::Register_NetworkManager_Tests(), cmlabs::Register_NetworkProtocols_Tests(), cmlabs::Register_Observations_Tests(), cmlabs::Register_ProcessMemory_Tests(), cmlabs::Register_PsyTime_Tests(), cmlabs::Register_RequestClient_Tests(), cmlabs::Register_RequestGateway_Tests(), cmlabs::Register_RESTParser_Tests(), cmlabs::Register_Stats_Tests(), cmlabs::Register_Subscriptions_Tests(), cmlabs::Register_TemporalMemory_Tests(), cmlabs::Register_ThreadManager_Tests(), cmlabs::Register_Utils_Tests(), cmlabs::Register_VantagePoints_Tests(), cmlabs::RunCMSDKTests(), and cmlabs::unittest::verbose().
| void cmlabs::UnitTestRunner::listTests | ( | ) | const |
Print the registered tests (name, category, description) to stdout.
Definition at line 196 of file UnitTestFramework.cpp.
Referenced by cmlabs::RunCMSDKTests(), and runOne().
| void cmlabs::UnitTestRunner::registerTest | ( | const char * | name, |
| UnitTestFunc | func, | ||
| const char * | description = "", | ||
| const char * | category = "", | ||
| bool | inDefaultRun = true ) |
Register a test with the runner.
| name | Canonical test name (used by test=<name>); duplicates are ignored. |
| func | The test function. |
| description | One-line human description. |
| category | Grouping label shown in listings. |
| inDefaultRun | Include in the full-suite run (test=cmsdk). |
Definition at line 153 of file UnitTestFramework.cpp.
References cmlabs::UnitTestRecord::category, cmlabs::UnitTestRecord::description, cmlabs::UnitTestRecord::func, cmlabs::UnitTestRecord::inDefaultRun, and cmlabs::UnitTestRecord::name.
Referenced by cmlabs::Register_Base64_Tests(), cmlabs::Register_Bitmap_Tests(), cmlabs::Register_ComponentData_Tests(), cmlabs::Register_ComponentMemory_Tests(), cmlabs::Register_ControlMessage_Tests(), cmlabs::Register_DataMessage_Tests(), cmlabs::Register_Hash_Tests(), cmlabs::Register_HTML_Tests(), cmlabs::Register_MathClasses_Tests(), cmlabs::Register_MemoryManager_Tests(), cmlabs::Register_MemoryRequestServer_Tests(), cmlabs::Register_MessageIndex_Tests(), cmlabs::Register_MovingAverage_Tests(), cmlabs::Register_NetworkManager_Tests(), cmlabs::Register_NetworkProtocols_Tests(), cmlabs::Register_Observations_Tests(), cmlabs::Register_ProcessMemory_Tests(), cmlabs::Register_PsyTime_Tests(), cmlabs::Register_RequestClient_Tests(), cmlabs::Register_RequestGateway_Tests(), cmlabs::Register_RESTParser_Tests(), cmlabs::Register_Stats_Tests(), cmlabs::Register_Subscriptions_Tests(), cmlabs::Register_TemporalMemory_Tests(), cmlabs::Register_ThreadManager_Tests(), cmlabs::Register_Utils_Tests(), and cmlabs::Register_VantagePoints_Tests().
| bool cmlabs::UnitTestRunner::runAll | ( | ) |
Run every test marked inDefaultRun.
Definition at line 576 of file UnitTestFramework.cpp.
Referenced by cmlabs::RunCMSDKTests().
| bool cmlabs::UnitTestRunner::runOne | ( | const char * | name | ) |
Run a single named test in isolation.
Definition at line 594 of file UnitTestFramework.cpp.
References listTests(), cmlabs::UnitTestRecord::name, and stricmp.
Referenced by cmlabs::RunCMSDKTests().
| void cmlabs::UnitTestRunner::setCompareFile | ( | const char * | path | ) |
Set a previous perf JSON file to compare metrics against.
Definition at line 177 of file UnitTestFramework.cpp.
Referenced by cmlabs::RunCMSDKTests().
| void cmlabs::UnitTestRunner::setForkPerTest | ( | bool | v | ) |
Run each test in its own process (default: on where supported) so crashes/hangs are isolated.
Definition at line 181 of file UnitTestFramework.cpp.
Referenced by cmlabs::RunCMSDKTests().
| void cmlabs::UnitTestRunner::setOutputDir | ( | const char * | dir | ) |
Set the directory for the default (timestamped + latest) output files.
Definition at line 179 of file UnitTestFramework.cpp.
Referenced by cmlabs::RunCMSDKTests().
| void cmlabs::UnitTestRunner::setOutputFile | ( | const char * | path | ) |
Set an explicit perf JSON output path (overrides the timestamped default).
Definition at line 178 of file UnitTestFramework.cpp.
Referenced by cmlabs::RunCMSDKTests().
| void cmlabs::UnitTestRunner::setVerbose | ( | bool | v | ) |
Enable/disable verbose diagnostics (unittest::detail output).
Definition at line 176 of file UnitTestFramework.cpp.
Referenced by cmlabs::RunCMSDKTests().
| void cmlabs::UnitTestRunner::setWriteJSON | ( | bool | v | ) |
Enable/disable writing the perf JSON file at all.
Definition at line 180 of file UnitTestFramework.cpp.
| std::vector< std::string > cmlabs::UnitTestRunner::testNames | ( | ) | const |
Definition at line 190 of file UnitTestFramework.cpp.