0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
Hypertable::TestHarness Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

Hypertable::TestHarness::TestHarness ( const char *  name)
inline

Constructor; redirects the logging output to a file.

Parameters
nameThe application name; used in the logger's output and as part of the log filename

Definition at line 61 of file TestHarness.h.

Hypertable::TestHarness::~TestHarness ( )
inline

Destructor; if the test was successful then the logfile is deleted.

Definition at line 78 of file TestHarness.h.

Member Function Documentation

void Hypertable::TestHarness::display_error_and_exit ( )
inline

Prints an error and exits with exit code 1.

Definition at line 125 of file TestHarness.h.

int Hypertable::TestHarness::get_log_file_descriptor ( )
inline

Returns the file descriptor of the log file.

Definition at line 84 of file TestHarness.h.

void Hypertable::TestHarness::regenerate_golden_file ( const char *  golden_file)
inline

Regenerates the golden file by renaming the output file to the golden file.

Parameters
golden_fileFilename of the golden file

Definition at line 119 of file TestHarness.h.

int Hypertable::TestHarness::validate ( const char *  golden_file)
inline

Validates the log file against the golden file.

Returns 0 on success, else for failure. Uses diff to do the comparison.

Parameters
golden_fileFilename of the golden file

Definition at line 102 of file TestHarness.h.

void Hypertable::TestHarness::validate_and_exit ( const char *  golden_file)
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.

Parameters
golden_fileFilename of the golden file

Definition at line 92 of file TestHarness.h.

Member Data Documentation

int Hypertable::TestHarness::m_error
private

The error from the golden file validation.

Definition at line 139 of file TestHarness.h.

int Hypertable::TestHarness::m_fd
private

The logfile file descriptor.

Definition at line 136 of file TestHarness.h.

char Hypertable::TestHarness::m_output_file[128]
private

The output filename; the application name concatenated with the pid.

Definition at line 133 of file TestHarness.h.


The documentation for this class was generated from the following file: