A simple test framework which sets up the logging subsystem, can compare its output against a golden file or regenerate the golden file. More...
#include <TestHarness.h>
Public Member Functions | |
TestHarness (const char *name) | |
Constructor; redirects the logging output to a file. More... | |
~TestHarness () | |
Destructor; if the test was successful then the logfile is deleted. More... | |
int | get_log_file_descriptor () |
Returns the file descriptor of the log file. More... | |
void | validate_and_exit (const char *golden_file) |
Validates the log file output with the golden file, then exits. More... | |
int | validate (const char *golden_file) |
Validates the log file against the golden file. More... | |
void | regenerate_golden_file (const char *golden_file) |
Regenerates the golden file by renaming the output file to the golden file. More... | |
void | display_error_and_exit () |
Prints an error and exits with exit code 1. More... | |
Private Attributes | |
char | m_output_file [128] |
The output filename; the application name concatenated with the pid. More... | |
int | m_fd |
The logfile file descriptor. More... | |
int | m_error |
The error from the golden file validation. More... | |
A simple test framework which sets up the logging subsystem, can compare its output against a golden file or regenerate the golden file.
Definition at line 54 of file TestHarness.h.
|
inline |
Constructor; redirects the logging output to a file.
name | The application name; used in the logger's output and as part of the log filename |
Definition at line 61 of file TestHarness.h.
|
inline |
Destructor; if the test was successful then the logfile is deleted.
Definition at line 78 of file TestHarness.h.
|
inline |
Prints an error and exits with exit code 1.
Definition at line 125 of file TestHarness.h.
|
inline |
Returns the file descriptor of the log file.
Definition at line 84 of file TestHarness.h.
|
inline |
Regenerates the golden file by renaming the output file to the golden file.
golden_file | Filename of the golden file |
Definition at line 119 of file TestHarness.h.
|
inline |
Validates the log file against the golden file.
Returns 0 on success, else for failure. Uses diff
to do the comparison.
golden_file | Filename of the golden file |
Definition at line 102 of file TestHarness.h.
|
inline |
Validates the log file output with the golden file, then exits.
The exit code depends on the golden file comparison - 0 on success, else for error.
golden_file | Filename of the golden file |
Definition at line 92 of file TestHarness.h.
|
private |
The error from the golden file validation.
Definition at line 139 of file TestHarness.h.
|
private |
The logfile file descriptor.
Definition at line 136 of file TestHarness.h.
|
private |
The output filename; the application name concatenated with the pid.
Definition at line 133 of file TestHarness.h.