CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
UnitTestFramework.cpp File Reference

Implementation of the CMSDK unit test harness (UnitTestRunner and the unittest:: reporting API). More...

#include "UnitTestFramework.h"
#include "PsyTime.h"
#include "jsmn.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/wait.h>
#include <signal.h>
#include <execinfo.h>
#include <fcntl.h>
Include dependency graph for UnitTestFramework.cpp:

Go to the source code of this file.

Namespaces

namespace  cmlabs
namespace  cmlabs::unittest
 API used by the body of a unit test.

Macros

#define ISATTY(fd)
#define FILENO(f)
#define UT_HAVE_FORK   1
#define UT_TEST_TIMEOUT_US   (30ULL * 1000000ULL)
#define UT_NAME_WIDTH   28
#define UT_INDENT   " "
#define UT_METRIC_WIDTH   26

Functions

static void cmlabs::ut_clearSegmentsIn (const char *dir, const char *prefix)
static void cmlabs::ClearStaleTestSegments ()
static void cmlabs::ut_timeoutTraceHandler (int)
static void cmlabs::ut_installTimeoutTraceHandler (const std::string &tracePath)
static std::string cmlabs::ut_readProgressNote (const std::string &path)
static void cmlabs::ut_printTraceFile (const std::string &path)
static std::string cmlabs::ut_escape_field (const std::string &s)
static void cmlabs::ut_writeChildResult (const std::string &path, const UnitTestRecord *rec)
static void cmlabs::ut_readChildResult (const std::string &path, UnitTestRecord *rec)
static std::string cmlabs::jsonEscape (const std::string &s)
static std::string cmlabs::unittest::ut_vformat (const char *fmt, va_list args)
void cmlabs::unittest::progress (int percent, const char *action)
 Report progress with a short description of the current action.
void cmlabs::unittest::progressf (int percent, const char *fmt,...)
 printf-style variant of progress().
void cmlabs::unittest::metric (const char *name, double value, const char *unit="", bool higherIsBetter=true)
 Record a performance metric.
void cmlabs::unittest::detail (const char *fmt,...)
 Verbose-only indented diagnostic line (shown only when verbose=1).
void cmlabs::unittest::fail (const char *fmt,...)
 Set an explanatory reason shown on the FAIL line.
bool cmlabs::unittest::verbose ()

Variables

static int cmlabs::ut_traceFd = -1

Detailed Description

Implementation of the CMSDK unit test harness (UnitTestRunner and the unittest:: reporting API).

See UnitTestFramework.h for the design overview: registration, per-test process forking, progress rendering, perf JSON output and compare-mode deltas.

Definition in file UnitTestFramework.cpp.

Macro Definition Documentation

◆ FILENO

#define FILENO ( f)
Value:
fileno(f)

Definition at line 31 of file UnitTestFramework.cpp.

◆ ISATTY

#define ISATTY ( fd)
Value:
isatty(fd)

Definition at line 30 of file UnitTestFramework.cpp.

◆ UT_HAVE_FORK

#define UT_HAVE_FORK   1

Definition at line 32 of file UnitTestFramework.cpp.

◆ UT_INDENT

#define UT_INDENT   " "

◆ UT_METRIC_WIDTH

#define UT_METRIC_WIDTH   26

Definition at line 133 of file UnitTestFramework.cpp.

◆ UT_NAME_WIDTH

#define UT_NAME_WIDTH   28

Definition at line 131 of file UnitTestFramework.cpp.

Referenced by cmlabs::UnitTestRunner::hookProgress().

◆ UT_TEST_TIMEOUT_US

#define UT_TEST_TIMEOUT_US   (30ULL * 1000000ULL)

Definition at line 38 of file UnitTestFramework.cpp.