CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
CMSDKTest.cpp
Go to the documentation of this file.
1
5// Replicoder.cpp : Defines the entry point for the console application.
6//
7
8#include "CMSDKTest.h"
9#include <string.h>
10#ifndef WIN32
11#include <signal.h>
12#endif
13
14using namespace cmlabs;
15
16void printUsage(const char* progname) {
17 printf("Usage: %s [test=<name>|list] [verbose] [out=<dir>]\n", progname);
18 printf(" test=<name> run a single registered test by name (e.g. test=processmemory_fuzz)\n");
19 printf(" test=cmsdk run the whole default suite (also the no-arg default)\n");
20 printf(" list list all registered tests and exit\n");
21 printf(" verbose enable per-test diagnostics\n\n");
22}
23
24int main(int argc, char* argv[]) {
25#ifndef WIN32
26 // A peer closing a socket mid-write must fail the write with EPIPE, not kill the
27 // process. Without this the SSL tests (network_https / _sslverify / _sslhostca)
28 // die on signal 13 during TLS teardown and the suite never prints its summary -
29 // exit=141, zero FAIL lines, silently truncated log. The Psyclone executable has
30 // always ignored SIGPIPE (Psyclone/src/Psyclone.cpp), which is why the very same
31 // tests pass under `Psyclone test=all` and only ever failed here.
32 signal(SIGPIPE, SIG_IGN);
33#endif
34 const char* name = NULL;
35 const char* outDir = NULL;
36 bool verbose = false;
37 bool listOnly = false;
38
39 for (int i = 1; i < argc; i++) {
40 const char* a = argv[i];
41 if (strncmp(a, "test=", 5) == 0) name = a + 5;
42 else if (strncmp(a, "out=", 4) == 0) outDir = a + 4;
43 else if (stricmp(a, "verbose") == 0) verbose = true;
44 else if (stricmp(a, "list") == 0) listOnly = true;
45 else if (stricmp(a, "help") == 0 || stricmp(a, "-h") == 0 ||
46 stricmp(a, "--help") == 0) { printUsage(argv[0]); return 0; }
47 }
48
49 // Single named tests must NOT fork-per-test (fork isolates registration state and
50 // swallows the child result for on-demand/off-default tests); the whole-suite run keeps
51 // its historical fork-per-test isolation.
52 bool forkPerTest = (name == NULL);
53 bool ok = RunCMSDKTests(name, NULL, NULL, outDir, verbose, listOnly, forkPerTest);
54 return ok ? 0 : 1;
55}
56
int main(int argc, char *argv[])
Definition CMSDKTest.cpp:24
void printUsage(const char *progname)
Definition CMSDKTest.cpp:16
Convenience umbrella header for the standalone CMSDKTest console program (see src/CMSDKTest....
#define stricmp
Definition Utils.h:132
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.