CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
UnitTest_CMSDK.cpp
Go to the documentation of this file.
1
6#include "UnitTest_CMSDK.h"
7#include "UnitTestFramework.h"
8#include "ProcessMemory.h" // for PerfTest_CMSDK back-compat entry
9
10namespace cmlabs {
11
12// ----------------------------------------------------------------------------
13// Per-object registration functions. Each is defined in its own object's .cpp
14// (where that object's header is cleanly included), and forward-declared here.
15// This avoids cross-header conflicts and keeps each test self-contained.
16// ----------------------------------------------------------------------------
25
31// NOTE: ComponentData, ControlMessage and MemoryQueues are NOT part of the CMSDK
32// build (absent from the Makefile CPPFILES and unreferenced by any compiled
33// code). Their unit tests exist in-source but are not registered here. Add the
34// files to CPPFILES (resolving their header conflicts) to enable them.
35
41
50
51// ----------------------------------------------------------------------------
52// Central registration of every CMSDK unit test. Called once before running.
53// ----------------------------------------------------------------------------
54static bool g_registered = false;
55
57 if (g_registered) return;
58 g_registered = true;
59
60 // core / util
69
70 // memory
75 // Registered but excluded from the default run (see note in the Register
76 // function): MemoryRequestServer::init() fails on this platform. Available
77 // to run by name (test=memoryrequestserver) for debugging.
79
80 // network / protocol
86
87 // util / math / data
96}
97
98// ----------------------------------------------------------------------------
99// Entry points
100// ----------------------------------------------------------------------------
101bool RunCMSDKTests(const char* name, const char* compareFile, const char* outFile,
102 const char* outDir, bool verbose, bool listOnly, bool forkPerTest) {
105 r.setVerbose(verbose);
106 r.setForkPerTest(forkPerTest);
107 if (compareFile) r.setCompareFile(compareFile);
108 if (outFile) r.setOutputFile(outFile);
109 if (outDir) r.setOutputDir(outDir);
110
111 if (listOnly) { r.listTests(); return true; }
112
113 if (name && *name && stricmp(name, "cmsdk") != 0 &&
114 stricmp(name, "sdk") != 0 && stricmp(name, "all") != 0)
115 return r.runOne(name);
116
117 return r.runAll();
118}
119
120bool IsCMSDKTest(const char* name) {
122 return UnitTestRunner::instance().hasTest(name);
123}
124
125// Back-compatible entry (test=sdk). Runs all registered tests.
127 return RunCMSDKTests(NULL, NULL, NULL, NULL, false, false, true);
128}
129
132}
133
134} // namespace cmlabs
Shared-memory process ("space") table plus per-process message queues.
Top-level entry points for running the CMSDK unit test suite.
Small, dependency-free unit test harness used by all CMSDK object tests.
#define stricmp
Definition Utils.h:132
static bool PerfTest()
Queue throughput benchmark.
The test runner (process-wide singleton).
void setForkPerTest(bool v)
Run each test in its own process (default: on where supported) so crashes/hangs are isolated.
void listTests() const
Print the registered tests (name, category, description) to stdout.
void setOutputFile(const char *path)
Set an explicit perf JSON output path (overrides the timestamped default).
bool hasTest(const char *name) const
static UnitTestRunner & instance()
Access the singleton (created on first use).
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.
bool runAll()
Run every test marked inDefaultRun.
bool runOne(const char *name)
Run a single named test in isolation.
void setOutputDir(const char *dir)
Set the directory for the default (timestamped + latest) output files.
void Register_MemoryRequestServer_Tests()
bool RunCMSDKTests(const char *name, const char *compareFile, const char *outFile, const char *outDir, bool verbose, bool listOnly, bool forkPerTest=true)
Full configurable entry used by the Psyclone test= dispatch.
bool PerfTest_CMSDK()
Back-compatible entry: run the performance-oriented tests (legacy alias).
bool IsCMSDKTest(const char *name)
void Register_Base64_Tests()
Definition Base64.cpp:266
void Register_HTML_Tests()
Definition HTML.cpp:495
void Register_MemoryManager_Tests()
void Register_XMLParser_Tests()
void Register_PsyTime_Tests()
Definition PsyTime.cpp:818
bool UnitTest_CMSDK()
Back-compatible entry: run the full suite with default settings.
void Register_VantagePoints_Tests()
void Register_Bitmap_Tests()
Definition Bitmap.cpp:4704
static bool g_registered
void Register_Stats_Tests()
Definition Stats.cpp:169
void Register_TemporalMemory_Tests()
void Register_DataMessage_Tests()
void Register_ComponentMemory_Tests()
void Register_Hash_Tests()
Definition HashTest.cpp:190
void Register_MathClasses_Tests()
void Register_RESTParser_Tests()
Definition RESTAPI.cpp:1579
void Register_NetworkProtocols_Tests()
void Register_MessageIndex_Tests()
void Register_RequestGateway_Tests()
void Register_Utils_Tests()
Definition Utils.cpp:8106
void RegisterAllCMSDKTests()
Register every CMSDK unit test with the framework (idempotent).
void Register_RequestClient_Tests()
void Register_NetworkManager_Tests()
void Register_Observations_Tests()
Register the Observations tests with the unit test framework.
void Register_MovingAverage_Tests()
void Register_ProcessMemory_Tests()
void Register_ThreadManager_Tests()
void Register_Subscriptions_Tests()