27 #ifndef Common_TestHarness_h
28 #define Common_TestHarness_h
40 #include <sys/types.h>
94 std::quick_exit(
m_error ? 1 : 0);
105 m_error = system(command.c_str());
108 std::cerr <<
"Command: "<< command <<
" exited with "<<
m_error
127 std::cerr <<
"Error, see '" <<
m_output_file <<
"'" << std::endl;
128 std::quick_exit(EXIT_FAILURE);
146 #endif // Common_TestHarness_h
void initialize(const String &name)
Public initialization function - creates a singleton instance of LogWriter.
~TestHarness()
Destructor; if the test was successful then the logfile is deleted.
void regenerate_golden_file(const char *golden_file)
Regenerates the golden file by renaming the output file to the golden file.
int validate(const char *golden_file)
Validates the log file against the golden file.
std::string String
A String is simply a typedef to std::string.
A simple test framework which sets up the logging subsystem, can compare its output against a golden ...
void display_error_and_exit()
Prints an error and exits with exit code 1.
void set_test_mode(int fd=-1)
The test mode disables line numbers and timestamps and can redirect the output to a separate file des...
char m_output_file[128]
The output filename; the application name concatenated with the pid.
TestHarness(const char *name)
Constructor; redirects the logging output to a file.
int get_log_file_descriptor()
Returns the file descriptor of the log file.
Logging routines and macros.
int m_error
The error from the golden file validation.
LogWriter * get()
Accessor for the LogWriter singleton instance.
int m_fd
The logfile file descriptor.
#define HT_ERRORF(msg,...)
void validate_and_exit(const char *golden_file)
Validates the log file output with the golden file, then exits.