ARB
Classes | Macros | Enumerations | Functions | Variables
UnitTester.cxx File Reference
#include "UnitTester.hxx"
#include <cstdarg>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cerrno>
#include <climits>
#include <sys/time.h>
#include <sys/stat.h>
#include <arb_simple_assert.h>
#include <arb_backtrace.h>
#include <arb_pathlen.h>
#include <arb_sleep.h>
#include <test_unit.h>
#include <ut_valgrinded.h>
#include <valgrind.h>
#include <SuppressOutput.h>
#include <SigHandler.h>
#include <setjmp.h>
#include <unistd.h>
#include <string>
#include <signal.h>
#include <mod_rlimit.h>
#include "../SOURCE_TOOLS/arb_main.h"
Include dependency graph for UnitTester.cxx:

Go to the source code of this file.

Classes

struct  Globals
 
class  Flag
 
class  SimpleTester
 

Macros

#define ut_assert(cond)   arb_assert(cond)
 
#define TRACE_PREFIX   "UnitTester: "
 
#define SECOND   1000000
 

Enumerations

enum  TrapCode { TRAP_UNEXPECTED = 668, TRAP_SEGV, TRAP_INT, TRAP_TERM }
 

Functions

 __ATTR__FORMAT (1) static void trace(const char *format
 
 fflush (stdout)
 
 fflush (stderr)
 
 fputs (TRACE_PREFIX, stderr)
 
 va_start (parg, format)
 
 vfprintf (stderr, format, parg)
 
 va_end (parg)
 
 fputc ('\n', stderr)
 
static __ATTR__NORETURN void UNITTEST_sigsegv_handler (int sig)
 
static void terminate_called ()
 
static UnitTestResult execute_guarded_ClientCode (UnitTest_function fun, long *duration_usec)
 
bool kill_verbose (pid_t pid, int sig, const char *signame)
 
Flag getLocalFlag (const char *flagname)
 
static bool flag_callback (arb_test::FlagAction action, const char *name)
 
bool been_inside_environment ()
 
bool did_valgrinded_syscall ()
 
void reset_test_local_flags ()
 
void sleepms (long ms)
 
UnitTestResult execute_guarded (UnitTest_function fun, long *duration_usec, long max_allowed_duration_ms, bool detect_environment_calls)
 
const charas_text (size_t z)
 
const charas_text (double d)
 
void appendValue (string &report, const char *tag, const char *value)
 
void appendValue (string &report, const char *tag, size_t value)
 
void appendValue (string &report, const char *tag, double value)
 
static const chargenerateReport (const char *libname, size_t tests, size_t skipped, size_t passed, double duration_ms, size_t warnings)
 

Variables

static Globals GLOBAL
 
static const charreadable_result []
 
static jmp_buf UNITTEST_return_after_segv
 
static bool terminate_was_called = false
 
static char text_buffer [100]
 
const size_t Mb = 1024*1024
 
const size_t Gb = 1024*Mb
 

Macro Definition Documentation

#define ut_assert (   cond)    arb_assert(cond)
#define TRACE_PREFIX   "UnitTester: "

Definition at line 106 of file UnitTester.cxx.

#define SECOND   1000000

Definition at line 216 of file UnitTester.cxx.

Referenced by execute_guarded_ClientCode().

Enumeration Type Documentation

enum TrapCode
Enumerator
TRAP_UNEXPECTED 
TRAP_SEGV 
TRAP_INT 
TRAP_TERM 

Definition at line 157 of file UnitTester.cxx.

Function Documentation

__ATTR__FORMAT ( ) const
fflush ( stdout  )
fflush ( stderr  )
fputs ( TRACE_PREFIX  ,
stderr   
)

Referenced by aed_start_naligning(), aisc_add_destroy_callback(), aisc_server_errorf(), alloc_failure_panic(), ARB_main(), arb_socket_write(), ARB_textfiles_have_difflines(), ask_for_conversion_params(), ScrollSynchronizer::auto_update(), AW_add_inotification(), BackTraceInfo::BackTraceInfo(), NamedCommand::check_result(), XML_Text::close(), XML_Comment::close(), ED4_remap::compile(), AP_tree::compute_tree(), LineReader::copyTo(), AW_root::define_remote_command(), die(), PART::distanceTo(), BackTraceInfo::dump(), PT_statistic::dump(), ModRLimit::dump_error(), dump_token_recursive(), dumpError(), emit(), enter_stage_1_build_tree(), error_with_usage(), errorf(), execute_guarded_ClientCode(), export_nds_cb(), export_species_using_form(), export_structure_to_file(), export_tree_label(), export_tree_node_print(), LineQueue::flush(), flush_taxonomy_if_new_group_cb(), GB_internal_error(), gb_parse_ascii_rek(), gb_write_bin(), gbcms_talking_obsolete(), GBK_terminate(), GBK_test_address(), group_awar_changed_cb(), ins_ntree(), insert_ntree(), InsertDatainGDE(), Interpreter::launch(), LOG_STATUS(), main(), merge_startup_abort_cb(), NTREE_move_tree_info(), perform_query_cb(), InputFileError::print(), arb_test::print(), DiffLines::print_from(), arb_test::print_hex(), arb_test::print_pair(), arb_test::StaticCode::print_readable_string(), GBL_IMPL::print_trace(), Package::print_xsubs(), PT_dump_POS_TREE(), PT_start_design(), rebuild_rule_from_awars_cb(), run_command(), FileContent::save(), StorableSelectionList::save(), AWT_configuration::Save(), DI_MATRIX::save(), save_messagebox_content_to(), FieldTransfer::RuleSet::saveTo(), ED4_window::scrollbars_and_scrolledRect_inSync(), selectedSpeciesChanged_cb(), server_main_loop(), BasicStatus::set_gauge(), show_command_line_usage(), CLI::show_help(), show_help(), show_usage(), splitRNS(), SPOOLER::spool(), start_pt_server(), timed_inotifications_check_cb(), TREE_write_Newick(), UNITTEST_sigsegv_handler(), ScrollSynchronizer::update_explicit(), ScrollSynchronizer::update_implicit(), usage(), Usage(), warn_and_dump_counter_or_calling_progress(), AW_window::wm_activate(), FilteredExport::write_fasta(), SpecSetRegistry::write_node_information(), writeDefaultMaskfile(), and WriteNA_Flat().

va_start ( parg  ,
format   
)
vfprintf ( stderr  ,
format  ,
parg   
)
va_end ( parg  )
fputc ( '\n'  ,
stderr   
)
static __ATTR__NORETURN void UNITTEST_sigsegv_handler ( int  sig)
static
static void terminate_called ( )
static

Definition at line 218 of file UnitTester.cxx.

References terminate_was_called.

Referenced by execute_guarded_ClientCode().

static UnitTestResult execute_guarded_ClientCode ( UnitTest_function  fun,
long duration_usec 
)
static
bool kill_verbose ( pid_t  pid,
int  sig,
const char signame 
)
inline

Definition at line 290 of file UnitTester.cxx.

References fflush(), and result.

Flag getLocalFlag ( const char flagname)
inline
static bool flag_callback ( arb_test::FlagAction  action,
const char name 
)
static

Definition at line 326 of file UnitTester.cxx.

References getLocalFlag(), Flag::is_up(), Flag::raise(), and result.

Referenced by UnitTester::UnitTester().

bool been_inside_environment ( )
inline

Definition at line 344 of file UnitTester.cxx.

References ANY_SETUP, getLocalFlag(), and Flag::is_up().

bool did_valgrinded_syscall ( )
inline

Definition at line 347 of file UnitTester.cxx.

References seen_valgrinded_call().

void reset_test_local_flags ( )
inline

Definition at line 350 of file UnitTester.cxx.

References ANY_SETUP, getLocalFlag(), and Flag::lower_if_up().

void sleepms ( long  ms)

Definition at line 354 of file UnitTester.cxx.

References ARB_sleep(), MS, and SEC.

Referenced by Mutex::Mutex(), and FunInfo::switch_to().

UnitTestResult execute_guarded ( UnitTest_function  fun,
long duration_usec,
long  max_allowed_duration_ms,
bool  detect_environment_calls 
)
const char* as_text ( size_t  z)
inline

Definition at line 598 of file UnitTester.cxx.

References text_buffer.

Referenced by appendValue().

const char* as_text ( double  d)
inline

Definition at line 599 of file UnitTester.cxx.

References text_buffer.

void appendValue ( string report,
const char tag,
const char value 
)
inline

Definition at line 601 of file UnitTester.cxx.

Referenced by appendValue(), and generateReport().

void appendValue ( string report,
const char tag,
size_t  value 
)
inline

Definition at line 603 of file UnitTester.cxx.

References appendValue(), and as_text().

void appendValue ( string report,
const char tag,
double  value 
)
inline

Definition at line 604 of file UnitTester.cxx.

References appendValue(), and as_text().

static const char* generateReport ( const char libname,
size_t  tests,
size_t  skipped,
size_t  passed,
double  duration_ms,
size_t  warnings 
)
static

Definition at line 606 of file UnitTester.cxx.

References appendValue().

Referenced by UnitTester::UnitTester().

Variable Documentation

Globals GLOBAL
static

Definition at line 102 of file UnitTester.cxx.

const char* readable_result[]
static
Initial value:
= {
"OK" ,
"TRAPPED" ,
"VIOLATED" ,
"INTERRUPTED" ,
"THREW" ,
"INVALID" ,
"{unknown}" ,
}

Definition at line 141 of file UnitTester.cxx.

jmp_buf UNITTEST_return_after_segv
static

Definition at line 154 of file UnitTester.cxx.

Referenced by execute_guarded_ClientCode(), and UNITTEST_sigsegv_handler().

bool terminate_was_called = false
static

Definition at line 155 of file UnitTester.cxx.

Referenced by terminate_called(), and UNITTEST_sigsegv_handler().

char text_buffer[100]
static

Definition at line 596 of file UnitTester.cxx.

Referenced by as_text().

const size_t Mb = 1024*1024

Definition at line 629 of file UnitTester.cxx.

const size_t Gb = 1024*Mb

Definition at line 630 of file UnitTester.cxx.