RTS API Documentation  1.10.11
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
switch_fct.h File Reference
#include <switch_platform.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <float.h>
#include <math.h>
#include <ctype.h>
#include <unistd.h>
+ Include dependency graph for switch_fct.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _fct_timer_t
 
struct  _fct_nlist_t
 
struct  _fctchk_t
 
struct  _fct_test_t
 
struct  _fct_ts_t
 
struct  _fctcl_init_t
 
struct  _fctcl_t
 
struct  _fct_clp_t
 
struct  _fct_namespace_t
 
struct  _fctkern_t
 
struct  _fct_logger_types_t
 
struct  _fct_logger_evt_t
 
struct  _fct_logger_i_vtable_t
 
struct  _fct_logger_i
 
struct  _fct_minimal_logger_t
 
struct  _fct_standard_logger_t
 
struct  _fct_junit_logger_t
 

Macros

#define FCT_DEFAULT_LOGGER   "standard"
 
#define FCT_VERSION_MAJOR   1
 
#define FCT_VERSION_MINOR   6
 
#define FCT_VERSION_MICRO   1
 
#define _FCT_QUOTEME(x)   #x
 
#define FCT_QUOTEME(x)   _FCT_QUOTEME(x)
 
#define FCT_VERSION_STR
 
#define FCT_MAX_NAME   256
 
#define FCT_MAX_LOG_LINE   2048
 
#define nbool_t   int
 
#define FCT_TRUE   1
 
#define FCT_FALSE   0
 
#define FCTMIN(x, y)   ( x < y) ? (x) : (y)
 
#define FCT_ASSERT(expr)   switch_assert(expr)
 
#define FCT_EXTERN_C
 
#define fct_pass()
 
#define fct_unused(x)   (void)(x)
 
#define _fct_cmt(string)
 
#define FCT_PIPE_RESERVE_BYTES_DEFAULT   512
 
#define _fct_pipe   pipe
 
#define _fct_dup   dup
 
#define _fct_dup2   dup2
 
#define _fct_close   close
 
#define _fct_read   read
 
#define FCT_SWITCH_STDOUT_TO_BUFFER()   fct_switch_std_to_buffer(fct_stdout_pipe, stdout, STDOUT_FILENO, &fct_saved_stdout)
 
#define FCT_SWITCH_STDOUT_TO_STDOUT()   fct_switch_std_to_std(stdout, STDOUT_FILENO, fct_saved_stdout)
 
#define FCT_SWITCH_STDERR_TO_BUFFER()   fct_switch_std_to_buffer(fct_stderr_pipe, stderr, STDERR_FILENO, &fct_saved_stderr)
 
#define FCT_SWITCH_STDERR_TO_STDERR()   fct_switch_std_to_std(stderr, STDERR_FILENO, fct_saved_stderr)
 
#define FCT_DOTTED_MAX_LEN   256
 
#define FCT_LIST_GROWTH_FACTOR   2
 
#define FCT_LIST_DEFAULT_START_SZ   8
 
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
 
#define FCT_NLIST_FOREACH_END()   }}}
 
#define fct_nlist__init(_LIST_PTR_)   (fct_nlist__init2((_LIST_PTR_), FCT_LIST_DEFAULT_START_SZ))
 
#define fctchk__is_pass(_CHK_)   ((_CHK_)->is_pass)
 
#define fctchk__file(_CHK_)   ((_CHK_)->file)
 
#define fctchk__lineno(_CHK_)   ((_CHK_)->lineno)
 
#define fctchk__cndtn(_CHK_)   ((_CHK_)->cndtn)
 
#define fctchk__msg(_CHK_)   ((_CHK_)->msg)
 
#define fctchk__name(_CHK_)   ((_CHK_)->name)
 
#define fct_test__name(_TEST_)   ((_TEST_)->name)
 
#define fct_test__clear_failed(test)   fct_nlist__clear(test->failed_chks, (fct_nlist_on_del_t)fctchk__del);\
 
#define fct_ts__is_setup_mode(ts)   ((ts)->mode == ts_mode_setup)
 
#define fct_ts__is_teardown_mode(ts)   ((ts)->mode == ts_mode_teardown)
 
#define fct_ts__is_test_mode(ts)   ((ts)->mode == ts_mode_test)
 
#define fct_ts__is_ending_mode(ts)   ((ts)->mode == ts_mode_ending)
 
#define fct_ts__is_end(ts)   ((ts)->mode == ts_mode_end)
 
#define fct_ts__is_cnt_mode(ts)   ((ts)->mode == ts_mode_cnt)
 
#define fct_ts__is_abort_mode(ts)   ((ts)->mode == ts_mode_abort)
 
#define fct_ts__ending(ts)   ((ts)->mode = ts_mode_ending)
 
#define fct_ts__end(ts)   ((ts)->mode = ts_mode_end)
 
#define fct_ts__name(ts)   ((ts)->name)
 
#define FCTCL_INIT_NULL   {NULL, NULL, FCTCL_STORE_UNDEFINED, NULL}
 
#define FCTCL_TRUE_STR   "1"
 
#define fctcl_new()   ((fctcl_t*)calloc(1, sizeof(fctcl_t)))
 
#define fctcl__set_value(_CLO_, _VAL_)   (_CLO_)->value = fctstr_clone((_VAL_));
 
#define FCT_CLP_MAX_ERR_MSG_LEN   256
 
#define fct_clp__optval(_CLP_, _OPTION_)   fct_clp__optval2((_CLP_), (_OPTION_), NULL)
 
#define fct_clp__is_error(_CLP_)   ((_CLP_)->is_error)
 
#define fct_clp__get_error(_CLP_)   ((_CLP_)->error_msg);
 
#define fct_clp__num_clo(_CLP_)   (fct_nlist__size(&((_CLP_)->clo_list)))
 
#define fct_clp__param_cnt(_CLP_)   (fct_nlist__size(&((_CLP_)->param_list)))
 
#define fct_clp__param_at(_CLP_, _IDX_)   ((char const*)fct_nlist__at(&((_CLP_)->param_list), (_IDX_)))
 
#define fct_clp__is(_CLP_, _OPTION_)   (fct_clp__optval((_CLP_), (_OPTION_)) != NULL)
 
#define FCT_OPT_VERSION   "--version"
 
#define FCT_OPT_VERSION_SHORT   "-v"
 
#define FCT_OPT_HELP   "--help"
 
#define FCT_OPT_HELP_SHORT   "-h"
 
#define FCT_OPT_LOGGER   "--logger"
 
#define FCT_OPT_LOGGER_SHORT   "-l"
 
#define fctkern__filter_cnt(_NK_)   (fct_nlist__size(&((_NK_)->prefix_list)))
 
#define fctkern__cl_is_parsed(_NK_)   ((_NK_)->cl_is_parsed)
 
#define fctkern__tst_cnt_failed(nk)   (fctkern__tst_cnt(nk) - fctkern__tst_cnt_passed(nk))
 
#define fctkern__end(nk)   /* unused */
 
#define fctkern__log_start(_NK_)
 
#define fctkern__log_end(_NK_)
 
#define _fct_logger_head
 
#define fct_logger__on_fctx_start(LOGGER, KERN)
 
#define fct_logger__on_fctx_end(LOGGER, KERN)
 
#define FCT_STANDARD_LOGGER_MAX_LINE   68
 
#define FCT_REFERENCE_FUNCS()
 
#define FCT_INIT(_ARGC_, _ARGV_)
 
#define FCT_FINAL()
 
#define FCT_NUM_FAILED()   fctkern_ptr__->ns.num_total_failed \
 
#define FCT_EXPECTED_FAILURES(_NUM_FAILS_)   ((fctkern_ptr__->num_expected_failures = (_NUM_FAILS_)))
 
#define FCT_BGN_FN(_FNNAME_)
 
#define FCT_END_FN()   FCT_END()
 
#define FCT_BGN()   FCT_BGN_FN(main)
 
#define FCT_END_WARNINGFIX_BGN
 
#define FCT_END_WARNINGFIX_END
 
#define FCT_END()
 
#define fctlog_install(_CUST_LOGGER_LIST_)   fctkern_ptr__->lt_usr = (_CUST_LOGGER_LIST_)
 
#define fctcl_install(_CLO_INIT_)
 
#define fctcl_is(_OPT_STR_)   (fctkern__cl_is(fctkern_ptr__, (_OPT_STR_)))
 
#define fctcl_val(_OPT_STR_)   (fctcl_val2((_OPT_STR_), NULL))
 
#define fctcl_val2(_OPT_STR_, _DEF_STR_)   (fctkern__cl_val2(fctkern_ptr__, (_OPT_STR_), (_DEF_STR_)))
 
#define FCT_FIXTURE_SUITE_BGN(_NAME_)
 
#define FCT_FIXTURE_SUITE_END()
 
#define FCT_FIXTURE_SUITE_BGN_IF(_CONDITION_, _NAME_)
 
#define FCT_FIXTURE_SUITE_END_IF()
 
#define FCT_SETUP_BGN()   if ( fct_ts__is_setup_mode(fctkern_ptr__->ns.ts_curr) ) {
 
#define FCT_SETUP_END()   fct_ts__setup_end(fctkern_ptr__->ns.ts_curr); }
 
#define FCT_TEARDOWN_BGN()   if ( fct_ts__is_teardown_mode(fctkern_ptr__->ns.ts_curr) ) {\
 
#define FCT_TEARDOWN_END()
 
#define FCT_SUITE_BGN(Name)
 
#define FCT_SUITE_END()   } FCT_FIXTURE_SUITE_END()
 
#define FCT_SUITE_BGN_IF(_CONDITION_, _NAME_)
 
#define FCT_SUITE_END_IF()   } FCT_FIXTURE_SUITE_END_IF()
 
#define FCT_TEST_BGN_IF(_CONDITION_, _NAME_)
 
#define FCT_TEST_END_IF()
 
#define FCT_TEST_BGN(_NAME_)
 
#define FCT_TEST_END()
 
#define fct_xchk
 
#define fct_xchk2
 
#define fct_chk(_CNDTN_)   (fct_xchk((_CNDTN_) ? 1 : 0, #_CNDTN_))
 
#define _fct_req(_CNDTN_)   if ( !(fct_xchk((_CNDTN_) ? 1 : 0, #_CNDTN_)) ) { break; }
 
#define fct_req(_CNDTN_)
 
#define fct_chk_eq_dbl(V1, V2)
 
#define fct_chk_neq_dbl(V1, V2)
 
#define fct_chk_eq_str(V1, V2)
 
#define fct_chk_neq_str(V1, V2)
 
#define fct_chk_empty_str(V)
 
#define fct_chk_full_str(V)
 
#define fct_chk_eq_istr(V1, V2)
 
#define fct_chk_neq_istr(V1, V2)
 
#define fct_chk_endswith_str(STR, CHECK)
 
#define fct_chk_iendswith_str(STR, CHECK)
 
#define fct_chk_excl_str(STR, CHECK_EXCLUDE)
 
#define fct_chk_excl_istr(ISTR, ICHECK_EXCLUDE)
 
#define fct_chk_incl_str(STR, CHECK_INCLUDE)
 
#define fct_chk_incl_istr(ISTR, ICHECK_INCLUDE)
 
#define fct_chk_startswith_str(STR, CHECK)
 
#define fct_chk_startswith_istr(STR, CHECK)
 
#define fct_chk_eq_int(V1, V2)
 
#define fct_chk_neq_int(V1, V2)
 
#define fct_chk_ex(EXCEPTION, CODE)
 
#define _FCT_GUTCHK(_CNDTN_)
 
#define FCTMF_FIXTURE_SUITE_BGN(NAME)
 
#define FCTMF_FIXTURE_SUITE_END()
 
#define FCTMF_SUITE_BGN(NAME)
 
#define FCTMF_SUITE_END()
 
#define FCTMF_SUITE_DEF(NAME)
 
#define FCTMF_SUITE_CALL(NAME)
 
#define FCT_QTEST_BGN(NAME)
 
#define FCT_QTEST_END()
 
#define FCT_QTEST_BGN_IF(_CONDITION_, _NAME_)
 
#define FCT_QTEST_END_IF()
 

Typedefs

typedef struct _fct_logger_evt_t fct_logger_evt_t
 
typedef struct _fct_logger_i fct_logger_i
 
typedef struct _fct_logger_types_t fct_logger_types_t
 
typedef struct _fct_standard_logger_t fct_standard_logger_t
 
typedef struct _fct_junit_logger_t fct_junit_logger_t
 
typedef struct _fct_minimal_logger_t fct_minimal_logger_t
 
typedef struct _fctchk_t fctchk_t
 
typedef struct _fct_test_t fct_test_t
 
typedef struct _fct_ts_t fct_ts_t
 
typedef struct _fctkern_t fctkern_t
 
typedef struct _fct_timer_t fct_timer_t
 
typedef struct _fct_nlist_t fct_nlist_t
 
typedef void(* fct_nlist_on_del_t) (void *)
 
typedef struct _fctcl_init_t fctcl_init_t
 
typedef struct _fctcl_t fctcl_t
 
typedef struct _fct_clp_t fct_clp_t
 
typedef struct _fct_namespace_t fct_namespace_t
 
typedef fct_logger_i *(* fct_logger_new_fn) (void)
 
typedef struct _fct_logger_i_vtable_t fct_logger_i_vtable_t
 

Enumerations

enum  ts_mode {
  ts_mode_cnt, ts_mode_setup, ts_mode_teardown, ts_mode_test,
  ts_mode_ending, ts_mode_end, ts_mode_abort
}
 
enum  fct_test_status { fct_test_status_SUCCESS, fct_test_status_FAILURE }
 
enum  fctcl_store_t { FCTCL_STORE_UNDEFINED, FCTCL_STORE_TRUE, FCTCL_STORE_VALUE }
 
enum  FCT_TEST_END_FLAG { FCT_TEST_END_FLAG_Default = 0x0000, FCT_TEST_END_FLAG_ClearFail = 0x0001 }
 

Functions

static fct_logger_ifct_standard_logger_new (void)
 
static fct_logger_ifct_minimal_logger_new (void)
 
static fct_junit_logger_tfct_junit_logger_new (void)
 
static void fct_logger__del (fct_logger_i *logger)
 
static void fct_logger__on_chk (fct_logger_i *self, fctchk_t const *chk)
 
static void fct_logger__on_test_start (fct_logger_i *logger, fct_test_t const *test)
 
static void fct_logger__on_test_end (fct_logger_i *logger, fct_test_t *test)
 
static void fct_logger__on_test_suite_start (fct_logger_i *logger, fct_ts_t const *ts)
 
static void fct_logger__on_test_suite_end (fct_logger_i *logger, fct_ts_t const *ts)
 
static void fct_logger__on_test_suite_skip (fct_logger_i *logger, char const *condition, char const *name)
 
static void fct_logger__on_test_skip (fct_logger_i *logger, char const *condition, char const *name)
 
static void fct_logger__on_warn (fct_logger_i *logger, char const *warn)
 
static void fct_switch_std_to_buffer (int std_pipe[2], FILE *out, int fileno_, int *save_handle)
 
static void fct_switch_std_to_std (FILE *out, int fileno_, int save_handle)
 
static void fctstr_safe_cpy (char *dst, char const *src, size_t num)
 
static int fct_vsnprintf (char *buffer, size_t buffer_len, char const *format, va_list args)
 
static int fct_snprintf (char *buffer, size_t buffer_len, char const *format,...)
 
static char * fctstr_clone (char const *s)
 
static char * fctstr_clone_lower (char const *s)
 
static nbool_t fct_filter_pass (char const *prefix, char const *test_str)
 
static int fctstr_eq (char const *s1, char const *s2)
 
static int fctstr_ieq (char const *s1, char const *s2)
 
static int fctstr_incl (char const *str, char const *check_incl)
 
static int fctstr_iincl (char const *str, char const *check_incl)
 
static int fctstr_startswith (char const *str, char const *check)
 
static int fctstr_istartswith (char const *str, char const *check)
 
static int fctstr_endswith (char const *str, char const *check)
 
static int fctstr_iendswith (char const *str, char const *check)
 
static void fct_dotted_line_start (size_t maxwidth, char const *startwith)
 
static void fct_dotted_line_end (char const *endswith)
 
static void fct_timer__init (fct_timer_t *timer)
 
static void fct_timer__start (fct_timer_t *timer)
 
static void fct_timer__stop (fct_timer_t *timer)
 
static double fct_timer__duration (fct_timer_t const *timer)
 
static void fct_nlist__clear (fct_nlist_t *list, fct_nlist_on_del_t on_del)
 
static void fct_nlist__final (fct_nlist_t *list, fct_nlist_on_del_t on_del)
 
static int fct_nlist__init2 (fct_nlist_t *list, size_t start_sz)
 
static size_t fct_nlist__size (fct_nlist_t const *list)
 
static void * fct_nlist__at (fct_nlist_t const *list, size_t idx)
 
static void fct_nlist__append (fct_nlist_t *list, void *itm)
 
static fctchk_tfctchk_new (int is_pass, char const *cndtn, char const *name, char const *file, int lineno, char const *format, va_list args)
 
static void fctchk__del (fctchk_t *chk)
 
static void fct_test__del (fct_test_t *test)
 
static fct_test_tfct_test_new (char const *name)
 
static void fct_test__start_timer (fct_test_t *test)
 
static void fct_test__stop_timer (fct_test_t *test)
 
static double fct_test__duration (fct_test_t const *test)
 
static nbool_t fct_test__is_pass (fct_test_t const *test)
 
static void fct_test__add (fct_test_t *test, fctchk_t *chk)
 
static size_t fct_test__chk_cnt (fct_test_t const *test)
 
static void fct_ts__del (fct_ts_t *ts)
 
static fct_ts_tfct_ts_new (char const *name)
 
static nbool_t fct_ts__is_more_tests (fct_ts_t const *ts)
 
static void fct_ts__test_begin (fct_ts_t *ts)
 
static void fct_ts__add_test (fct_ts_t *ts, fct_test_t *test)
 
static void fct_ts__test_end (fct_ts_t *ts)
 
static void fct_ts__inc_total_test_num (fct_ts_t *ts)
 
static void fct_ts__setup_end (fct_ts_t *ts)
 
static fct_test_tfct_ts__make_abort_test (fct_ts_t *ts)
 
static void fct_ts__setup_abort (fct_ts_t *ts)
 
static void fct_ts__teardown_end (fct_ts_t *ts)
 
static void fct_ts__cnt_end (fct_ts_t *ts)
 
static nbool_t fct_ts__is_test_cnt (fct_ts_t const *ts, int test_num)
 
static size_t fct_ts__tst_cnt (fct_ts_t const *ts)
 
static size_t fct_ts__tst_cnt_passed (fct_ts_t const *ts)
 
static size_t fct_ts__chk_cnt (fct_ts_t const *ts)
 
static double fct_ts__duration (fct_ts_t const *ts)
 
static void fctcl__del (fctcl_t *clo)
 
static fctcl_tfctcl_new2 (fctcl_init_t const *clo_init)
 
static int fctcl__is_option (fctcl_t const *clo, char const *option)
 
static void fct_clp__final (fct_clp_t *clp)
 
static int fct_clp__add_options (fct_clp_t *clp, fctcl_init_t const *options)
 
static int fct_clp__init (fct_clp_t *clp, fctcl_init_t const *options)
 
static void fct_clp__parse (fct_clp_t *clp, int argc, char const *argv[])
 
static fctcl_t const * fct_clp__get_clo (fct_clp_t const *clp, char const *option)
 
static char const * fct_clp__optval2 (fct_clp_t *clp, char const *option, char const *default_val)
 
static int fct_clp__is_param (fct_clp_t *clp, char const *param)
 
static void fct_namespace_init (fct_namespace_t *ns)
 
static void fctkern__add_logger (fctkern_t *nk, fct_logger_i *logger_owns)
 
static void fctkern__write_help (fctkern_t *nk, FILE *out)
 
static void fctkern__add_prefix_filter (fctkern_t *nk, char const *prefix_filter)
 
static void fctkern__final (fctkern_t *nk)
 
static int fctkern__cl_is (fctkern_t *nk, char const *opt_str)
 
static char const * fctkern__cl_val2 (fctkern_t *nk, char const *opt_str, char const *def_str)
 
static fct_logger_ifckern_sel_log (fct_logger_types_t *search, char const *sel_logger)
 
static int fctkern__cl_parse_config_logger (fctkern_t *nk)
 
static int fctkern__cl_parse (fctkern_t *nk)
 
static int fctkern__init (fctkern_t *nk, int argc, const char *argv[])
 
static void fctkern__add_ts (fctkern_t *nk, fct_ts_t *ts)
 
static nbool_t fctkern__pass_filter (fctkern_t *nk, char const *test_name)
 
static size_t fctkern__tst_cnt (fctkern_t const *nk)
 
static size_t fctkern__tst_cnt_passed (fctkern_t const *nk)
 
static void fctkern__log_suite_start (fctkern_t *nk, fct_ts_t const *ts)
 
static void fctkern__log_suite_end (fctkern_t *nk, fct_ts_t const *ts)
 
static void fctkern__log_suite_skip (fctkern_t *nk, char const *condition, char const *name)
 
static void fctkern__log_test_skip (fctkern_t *nk, char const *condition, char const *name)
 
static void fctkern__log_chk (fctkern_t *nk, fctchk_t const *chk)
 
static void fctkern__log_warn (fctkern_t *nk, char const *warn)
 
static void fctkern__log_test_start (fctkern_t *nk, fct_test_t const *test)
 
static void fctkern__log_test_end (fctkern_t *nk, fct_test_t *test)
 
static void fct_logger__stub (fct_logger_i *l, fct_logger_evt_t const *e)
 
static void fct_logger__init (fct_logger_i *logger)
 
static void fct_logger_record_failure (fctchk_t const *chk, fct_nlist_t *fail_list)
 
static void fct_logger_print_failures (fct_nlist_t const *fail_list)
 
static void fct_minimal_logger__on_chk (fct_logger_i *self_, fct_logger_evt_t const *e)
 
static void fct_minimal_logger__on_fctx_end (fct_logger_i *self_, fct_logger_evt_t const *e)
 
static void fct_minimal_logger__on_delete (fct_logger_i *self_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_chk (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_test_skip (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_test_start (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_test_end (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_fctx_start (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_fctx_end (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_delete (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_standard_logger__on_warn (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_junit_logger__on_test_suite_start (fct_logger_i *l, fct_logger_evt_t const *e)
 
static void fct_junit_logger__on_test_suite_end (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_junit_logger__on_fct_start (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_junit_logger__on_fctx_end (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static void fct_junit_logger__on_delete (fct_logger_i *logger_, fct_logger_evt_t const *e)
 
static int _fct_xchk_fn_varg (char const *condition, int is_pass, char const *format, va_list args)
 
static int fct_xchk2_fn (const char *condition, int is_pass, char const *format,...)
 
static int fct_xchk_fn (int is_pass, char const *format,...)
 
static int _fct_chk_empty_str (char const *s)
 
static int _fct_chk_full_str (char const *s)
 

Variables

static int fct_stdout_pipe [2]
 
static int fct_stderr_pipe [2]
 
static int fct_saved_stdout
 
static int fct_saved_stderr
 
static fctcl_init_t FCT_CLP_OPTIONS []
 
static fct_logger_types_t FCT_LOGGER_TYPES []
 
static fct_logger_i_vtable_t fct_logger_default_vtable
 
static int fct_xchk_lineno =0
 
static char const * fct_xchk_file = NULL
 
static fct_test_tfct_xchk_test = NULL
 
static fctkern_tfct_xchk_kern =NULL
 

Macro Definition Documentation

◆ _fct_close

#define _fct_close   close

Definition at line 208 of file switch_fct.h.

Referenced by fct_switch_std_to_buffer().

◆ _fct_cmt

#define _fct_cmt (   string)

Definition at line 172 of file switch_fct.h.

◆ _fct_dup

#define _fct_dup   dup

Definition at line 206 of file switch_fct.h.

Referenced by fct_switch_std_to_buffer().

◆ _fct_dup2

#define _fct_dup2   dup2

Definition at line 207 of file switch_fct.h.

Referenced by fct_switch_std_to_buffer(), and fct_switch_std_to_std().

◆ _FCT_GUTCHK

#define _FCT_GUTCHK (   _CNDTN_)
Value:
if ( !(_CNDTN_) ) {\
fprintf(stderr, "gutchk fail: '" #_CNDTN_ "' was not true.\n");\
exit(1);\
}\
else {\
fprintf(stdout, "gutchk pass: '" #_CNDTN_ "'\n");\
}

Definition at line 3883 of file switch_fct.h.

◆ _fct_logger_head

#define _fct_logger_head
Value:
fct_logger_evt_t evt

Definition at line 2557 of file switch_fct.h.

◆ _fct_pipe

#define _fct_pipe   pipe

Definition at line 205 of file switch_fct.h.

Referenced by fct_switch_std_to_buffer().

◆ _FCT_QUOTEME

#define _FCT_QUOTEME (   x)    #x

Definition at line 66 of file switch_fct.h.

◆ _fct_read

#define _fct_read   read

Definition at line 209 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_end().

◆ _fct_req

#define _fct_req (   _CNDTN_)    if ( !(fct_xchk((_CNDTN_) ? 1 : 0, #_CNDTN_)) ) { break; }

Definition at line 3660 of file switch_fct.h.

◆ FCT_ASSERT

#define FCT_ASSERT (   expr)    switch_assert(expr)

◆ FCT_BGN

#define FCT_BGN ( )    FCT_BGN_FN(main)

Definition at line 3318 of file switch_fct.h.

◆ FCT_BGN_FN

#define FCT_BGN_FN (   _FNNAME_)
Value:
int _FNNAME_(int argc, char* argv[])\
{ \
FCT_INIT(argc, argv)

Definition at line 3308 of file switch_fct.h.

◆ fct_chk

#define fct_chk (   _CNDTN_)    (fct_xchk((_CNDTN_) ? 1 : 0, #_CNDTN_))

Definition at line 3658 of file switch_fct.h.

◆ fct_chk_empty_str

#define fct_chk_empty_str (   V)
Value:
"string not empty: '%s'",\
(V)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int _fct_chk_empty_str(char const *s)
Definition: switch_fct.h:3727

Definition at line 3746 of file switch_fct.h.

◆ fct_chk_endswith_str

#define fct_chk_endswith_str (   STR,
  CHECK 
)
Value:
fct_xchk(fctstr_endswith((STR),(CHECK)),\
"fct_chk_endswith_str: '%s' doesn't end with '%s'",\
(STR),\
(CHECK)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_endswith(char const *str, char const *check)
Definition: switch_fct.h:517

Definition at line 3775 of file switch_fct.h.

◆ fct_chk_eq_dbl

#define fct_chk_eq_dbl (   V1,
  V2 
)
Value:
((int)(fabs((V1)-(V2)) < DBL_EPSILON)),\
"chk_eq_dbl: %f != %f",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643

Definition at line 3690 of file switch_fct.h.

◆ fct_chk_eq_int

#define fct_chk_eq_int (   V1,
  V2 
)
Value:
((V1) == (V2)),\
"chq_eq_int: %d != %d",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643

Definition at line 3837 of file switch_fct.h.

◆ fct_chk_eq_istr

#define fct_chk_eq_istr (   V1,
  V2 
)
Value:
fct_xchk(fctstr_ieq((V1), (V2)),\
"chk_eq_str: '%s' != '%s'",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_ieq(char const *s1, char const *s2)
Definition: switch_fct.h:413

Definition at line 3759 of file switch_fct.h.

◆ fct_chk_eq_str

#define fct_chk_eq_str (   V1,
  V2 
)
Value:
fct_xchk(fctstr_eq((V1), (V2)),\
"chk_eq_str: '%s' != '%s'",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_eq(char const *s1, char const *s2)
Definition: switch_fct.h:389

Definition at line 3708 of file switch_fct.h.

◆ fct_chk_ex

#define fct_chk_ex (   EXCEPTION,
  CODE 
)
Value:
{ \
bool pass_chk_ex = false; \
try { \
CODE; \
pass_chk_ex = false; \
} catch ( EXCEPTION ) { \
pass_chk_ex = true; \
} catch ( ... ) { \
pass_chk_ex = false; \
} \
fct_xchk( \
pass_chk_ex, \
"%s exception not generated", \
#EXCEPTION \
); \
} \

Definition at line 3854 of file switch_fct.h.

◆ fct_chk_excl_istr

#define fct_chk_excl_istr (   ISTR,
  ICHECK_EXCLUDE 
)
Value:
fct_xchk(!fctstr_iincl((ISTR), (ICHECK_EXCLUDE)),\
"fct_chk_excl_istr (case insensitive): '%s' is "\
"included in'%s'",\
(ISTR),\
(ICHECK_EXCLUDE)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_iincl(char const *str, char const *check_incl)
Definition: switch_fct.h:464

Definition at line 3797 of file switch_fct.h.

◆ fct_chk_excl_str

#define fct_chk_excl_str (   STR,
  CHECK_EXCLUDE 
)
Value:
fct_xchk(!fctstr_incl((STR), (CHECK_EXCLUDE)),\
"fct_chk_excl_str: '%s' is included in '%s'",\
(STR),\
(CHECK_EXCLUDE)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_incl(char const *str, char const *check_incl)
Definition: switch_fct.h:441

Definition at line 3790 of file switch_fct.h.

◆ fct_chk_full_str

#define fct_chk_full_str (   V)
Value:
"string is full: '%s'",\
(V)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int _fct_chk_full_str(char const *s)
Definition: switch_fct.h:3736

Definition at line 3752 of file switch_fct.h.

◆ fct_chk_iendswith_str

#define fct_chk_iendswith_str (   STR,
  CHECK 
)
Value:
fct_xchk(fctstr_iendswith((STR), (CHECK)),\
"fch_chk_iendswith_str: '%s' doesn't end with '%s'.",\
(STR),\
(CHECK)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_iendswith(char const *str, char const *check)
Definition: switch_fct.h:549

Definition at line 3783 of file switch_fct.h.

◆ fct_chk_incl_istr

#define fct_chk_incl_istr (   ISTR,
  ICHECK_INCLUDE 
)
Value:
fct_xchk(fctstr_iincl((ISTR), (ICHECK_INCLUDE)),\
"fct_chk_incl_istr (case insensitive): '%s' does "\
"not include '%s'",\
(ISTR),\
(ICHECK_INCLUDE)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_iincl(char const *str, char const *check_incl)
Definition: switch_fct.h:464

Definition at line 3813 of file switch_fct.h.

◆ fct_chk_incl_str

#define fct_chk_incl_str (   STR,
  CHECK_INCLUDE 
)
Value:
fct_xchk(fctstr_incl((STR), (CHECK_INCLUDE)),\
"fct_chk_incl_str: '%s' does not include '%s'",\
(STR),\
(CHECK_INCLUDE)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_incl(char const *str, char const *check_incl)
Definition: switch_fct.h:441

Definition at line 3805 of file switch_fct.h.

◆ fct_chk_neq_dbl

#define fct_chk_neq_dbl (   V1,
  V2 
)
Value:
((int)(fabs((V1)-(V2)) >= DBL_EPSILON)),\
"chk_neq_dbl: %f == %f",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643

Definition at line 3699 of file switch_fct.h.

◆ fct_chk_neq_int

#define fct_chk_neq_int (   V1,
  V2 
)
Value:
((V1) != (V2)),\
"chq_neq_int: %d == %d",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643

Definition at line 3846 of file switch_fct.h.

◆ fct_chk_neq_istr

#define fct_chk_neq_istr (   V1,
  V2 
)
Value:
fct_xchk(!fctstr_ieq((V1), (V2)),\
"chk_neq_str: '%s' == '%s'",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_ieq(char const *s1, char const *s2)
Definition: switch_fct.h:413

Definition at line 3767 of file switch_fct.h.

◆ fct_chk_neq_str

#define fct_chk_neq_str (   V1,
  V2 
)
Value:
fct_xchk(!fctstr_eq((V1), (V2)),\
"chk_neq_str: '%s' == '%s'",\
(V1),\
(V2)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_eq(char const *s1, char const *s2)
Definition: switch_fct.h:389

Definition at line 3716 of file switch_fct.h.

◆ fct_chk_startswith_istr

#define fct_chk_startswith_istr (   STR,
  CHECK 
)
Value:
fct_xchk(fctstr_istartswith((STR), (CHECK)),\
"case insensitive check: '%s' does not start with '%s'",\
(STR),\
(CHECK)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_istartswith(char const *str, char const *check)
Definition: switch_fct.h:500

Definition at line 3830 of file switch_fct.h.

◆ fct_chk_startswith_str

#define fct_chk_startswith_str (   STR,
  CHECK 
)
Value:
fct_xchk(fctstr_startswith((STR), (CHECK)),\
"'%s' does not start with '%s'",\
(STR),\
(CHECK)\
)
#define fct_xchk
Definition: switch_fct.h:3643
static int fctstr_startswith(char const *str, char const *check)
Definition: switch_fct.h:481

Definition at line 3822 of file switch_fct.h.

◆ fct_clp__get_error

#define fct_clp__get_error (   _CLP_)    ((_CLP_)->error_msg);

Definition at line 1790 of file switch_fct.h.

Referenced by fctkern__cl_parse().

◆ fct_clp__is

#define fct_clp__is (   _CLP_,
  _OPTION_ 
)    (fct_clp__optval((_CLP_), (_OPTION_)) != NULL)

Definition at line 1806 of file switch_fct.h.

Referenced by fctkern__cl_is().

◆ fct_clp__is_error

#define fct_clp__is_error (   _CLP_)    ((_CLP_)->is_error)

Definition at line 1789 of file switch_fct.h.

Referenced by fctkern__cl_parse().

◆ fct_clp__num_clo

#define fct_clp__num_clo (   _CLP_)    (fct_nlist__size(&((_CLP_)->clo_list)))

Definition at line 1792 of file switch_fct.h.

◆ fct_clp__optval

#define fct_clp__optval (   _CLP_,
  _OPTION_ 
)    fct_clp__optval2((_CLP_), (_OPTION_), NULL)

Definition at line 1747 of file switch_fct.h.

◆ fct_clp__param_at

#define fct_clp__param_at (   _CLP_,
  _IDX_ 
)    ((char const*)fct_nlist__at(&((_CLP_)->param_list), (_IDX_)))

Definition at line 1800 of file switch_fct.h.

Referenced by fctkern__cl_parse().

◆ fct_clp__param_cnt

#define fct_clp__param_cnt (   _CLP_)    (fct_nlist__size(&((_CLP_)->param_list)))

Definition at line 1795 of file switch_fct.h.

Referenced by fctkern__cl_parse().

◆ FCT_CLP_MAX_ERR_MSG_LEN

#define FCT_CLP_MAX_ERR_MSG_LEN   256

Definition at line 1548 of file switch_fct.h.

Referenced by fct_clp__parse().

◆ FCT_DEFAULT_LOGGER

#define FCT_DEFAULT_LOGGER   "standard"

Definition at line 59 of file switch_fct.h.

Referenced by fctkern__cl_parse_config_logger(), and fctkern__write_help().

◆ FCT_DOTTED_MAX_LEN

#define FCT_DOTTED_MAX_LEN   256

Definition at line 586 of file switch_fct.h.

Referenced by fct_dotted_line_start().

◆ FCT_END

#define FCT_END ( )
Value:
{ \
return (int) FCT_NUM_FAILED();\
FCT_END_WARNINGFIX_END \
}\
}
#define FCT_NUM_FAILED()
Definition: switch_fct.h:3296
#define FCT_FINAL()
Definition: switch_fct.h:3280

Definition at line 3333 of file switch_fct.h.

◆ FCT_END_FN

#define FCT_END_FN ( )    FCT_END()

Definition at line 3313 of file switch_fct.h.

◆ FCT_END_WARNINGFIX_BGN

#define FCT_END_WARNINGFIX_BGN

Definition at line 3323 of file switch_fct.h.

◆ FCT_END_WARNINGFIX_END

#define FCT_END_WARNINGFIX_END

Definition at line 3324 of file switch_fct.h.

◆ FCT_EXPECTED_FAILURES

#define FCT_EXPECTED_FAILURES (   _NUM_FAILS_)    ((fctkern_ptr__->num_expected_failures = (_NUM_FAILS_)))

Definition at line 3304 of file switch_fct.h.

◆ FCT_EXTERN_C

#define FCT_EXTERN_C

Definition at line 96 of file switch_fct.h.

◆ FCT_FALSE

#define FCT_FALSE   0

Definition at line 87 of file switch_fct.h.

Referenced by fct_filter_pass(), fct_test_new(), and fctkern__pass_filter().

◆ FCT_FINAL

#define FCT_FINAL ( )
Value:
fctkern_ptr__->ns.num_total_failed = fctkern__tst_cnt_failed( \
(fctkern_ptr__) \
); \
fctkern__log_end(fctkern_ptr__); \
fctkern__end(fctkern_ptr__); \
fctkern__final(fctkern_ptr__); \
FCT_ASSERT( !((int)fctkern_ptr__->ns.num_total_failed < 0) \
&& "or we got truncated!"); \
if ( fctkern_ptr__->ns.num_total_failed == \
fctkern_ptr__->num_expected_failures) { \
fctkern_ptr__->ns.num_total_failed = 0; \
} \
#define fctkern__tst_cnt_failed(nk)
Definition: switch_fct.h:2310

Definition at line 3280 of file switch_fct.h.

◆ FCT_FIXTURE_SUITE_BGN

#define FCT_FIXTURE_SUITE_BGN (   _NAME_)

Definition at line 3379 of file switch_fct.h.

◆ FCT_FIXTURE_SUITE_BGN_IF

#define FCT_FIXTURE_SUITE_BGN_IF (   _CONDITION_,
  _NAME_ 
)
Value:
fctkern_ptr__->ns.ts_is_skip_suite = !(_CONDITION_);\
fctkern_ptr__->ns.ts_skip_cndtn = #_CONDITION_;\
if ( fctkern_ptr__->ns.ts_is_skip_suite ) {\
fctkern__log_suite_skip((fctkern_ptr__), #_CONDITION_, #_NAME_);\
}\
FCT_FIXTURE_SUITE_BGN(_NAME_);

Definition at line 3431 of file switch_fct.h.

◆ FCT_FIXTURE_SUITE_END

#define FCT_FIXTURE_SUITE_END ( )
Value:
if ( fct_ts__is_cnt_mode(fctkern_ptr__->ns.ts_curr) )\
{\
fct_ts__cnt_end(fctkern_ptr__->ns.ts_curr);\
}\
}\
fctkern__add_ts((fctkern_ptr__), fctkern_ptr__->ns.ts_curr);\
fctkern__log_suite_end((fctkern_ptr__), fctkern_ptr__->ns.ts_curr);\
fct_ts__end(fctkern_ptr__->ns.ts_curr);\
fctkern_ptr__->ns.ts_curr = NULL;\
}\
}
#define fct_ts__is_cnt_mode(ts)
Definition: switch_fct.h:1131

Definition at line 3418 of file switch_fct.h.

◆ FCT_FIXTURE_SUITE_END_IF

#define FCT_FIXTURE_SUITE_END_IF ( )
Value:
fctkern_ptr__->ns.ts_is_skip_suite =0;\
fctkern_ptr__->ns.ts_skip_cndtn =NULL;\
#define FCT_FIXTURE_SUITE_END()
Definition: switch_fct.h:3418

Definition at line 3439 of file switch_fct.h.

◆ FCT_INIT

#define FCT_INIT (   _ARGC_,
  _ARGV_ 
)
Value:
fctkern_t fctkern__; \
fctkern_t* fctkern_ptr__ = &fctkern__; \
FCT_REFERENCE_FUNCS(); \
if ( !fctkern__init(fctkern_ptr__, (_ARGC_), (const char **)(_ARGV_)) ) {\
(void)fprintf( \
stderr, "FATAL ERROR: Unable to initialize FCTX Kernel." \
); \
exit(EXIT_FAILURE); \
} \
static int fctkern__init(fctkern_t *nk, int argc, const char *argv[])
Definition: switch_fct.h:2202

Definition at line 3268 of file switch_fct.h.

◆ FCT_LIST_DEFAULT_START_SZ

#define FCT_LIST_DEFAULT_START_SZ   8

Definition at line 678 of file switch_fct.h.

◆ FCT_LIST_GROWTH_FACTOR

#define FCT_LIST_GROWTH_FACTOR   2

Definition at line 674 of file switch_fct.h.

Referenced by fct_nlist__append().

◆ fct_logger__on_fctx_end

#define fct_logger__on_fctx_end (   LOGGER,
  KERN 
)
Value:
(LOGGER)->evt.kern = (KERN);\
(LOGGER)->vtable.on_fctx_end((LOGGER), &((LOGGER)->evt));

Definition at line 2687 of file switch_fct.h.

◆ fct_logger__on_fctx_start

#define fct_logger__on_fctx_start (   LOGGER,
  KERN 
)
Value:
(LOGGER)->evt.kern = (KERN);\
(LOGGER)->vtable.on_fctx_start((LOGGER), &((LOGGER)->evt));

Definition at line 2681 of file switch_fct.h.

◆ FCT_MAX_LOG_LINE

#define FCT_MAX_LOG_LINE   2048

Definition at line 83 of file switch_fct.h.

Referenced by fct_ts__make_abort_test(), and fctchk_new().

◆ FCT_MAX_NAME

#define FCT_MAX_NAME   256

Definition at line 82 of file switch_fct.h.

Referenced by fct_test_new(), and fct_ts_new().

◆ fct_nlist__init

#define fct_nlist__init (   _LIST_PTR_)    (fct_nlist__init2((_LIST_PTR_), FCT_LIST_DEFAULT_START_SZ))

Definition at line 779 of file switch_fct.h.

Referenced by fct_clp__init(), fct_test_new(), fct_ts_new(), and fctkern__init().

◆ FCT_NLIST_FOREACH_BGN

#define FCT_NLIST_FOREACH_BGN (   Type,
  Var,
  List 
)
Value:
{\
if ( List != NULL ) {\
size_t item_i##Var;\
size_t num_items##Var = fct_nlist__size(List);\
for( item_i##Var =0; item_i##Var != num_items##Var; ++item_i##Var )\
{\
Type Var = (Type) fct_nlist__at((List), item_i##Var);
static size_t fct_nlist__size(fct_nlist_t const *list)
Definition: switch_fct.h:785
static void * fct_nlist__at(fct_nlist_t const *list, size_t idx)
Definition: switch_fct.h:794

Definition at line 690 of file switch_fct.h.

Referenced by fct_clp__get_clo(), fct_clp__is_param(), fct_clp__parse(), fct_junit_logger__on_test_suite_end(), fct_logger_print_failures(), fct_ts__chk_cnt(), fct_ts__duration(), fct_ts__tst_cnt_passed(), fctkern__log_chk(), fctkern__log_suite_end(), fctkern__log_suite_skip(), fctkern__log_suite_start(), fctkern__log_test_end(), fctkern__log_test_skip(), fctkern__log_test_start(), fctkern__log_warn(), fctkern__tst_cnt(), fctkern__tst_cnt_passed(), and fctkern__write_help().

◆ FCT_NLIST_FOREACH_END

#define FCT_NLIST_FOREACH_END ( )    }}}

◆ FCT_NUM_FAILED

#define FCT_NUM_FAILED ( )    fctkern_ptr__->ns.num_total_failed \

Definition at line 3296 of file switch_fct.h.

◆ FCT_OPT_HELP

#define FCT_OPT_HELP   "--help"

Definition at line 1899 of file switch_fct.h.

Referenced by fctkern__cl_parse().

◆ FCT_OPT_HELP_SHORT

#define FCT_OPT_HELP_SHORT   "-h"

Definition at line 1900 of file switch_fct.h.

◆ FCT_OPT_LOGGER

#define FCT_OPT_LOGGER   "--logger"

Definition at line 1901 of file switch_fct.h.

Referenced by fctkern__cl_parse_config_logger(), and fctkern__write_help().

◆ FCT_OPT_LOGGER_SHORT

#define FCT_OPT_LOGGER_SHORT   "-l"

Definition at line 1902 of file switch_fct.h.

◆ FCT_OPT_VERSION

#define FCT_OPT_VERSION   "--version"

Definition at line 1897 of file switch_fct.h.

Referenced by fctkern__cl_parse().

◆ FCT_OPT_VERSION_SHORT

#define FCT_OPT_VERSION_SHORT   "-v"

Definition at line 1898 of file switch_fct.h.

◆ fct_pass

#define fct_pass ( )

Definition at line 162 of file switch_fct.h.

◆ FCT_PIPE_RESERVE_BYTES_DEFAULT

#define FCT_PIPE_RESERVE_BYTES_DEFAULT   512

Definition at line 183 of file switch_fct.h.

◆ FCT_QTEST_BGN

#define FCT_QTEST_BGN (   NAME)
Value:
FCT_SUITE_BGN(NAME) {\
FCT_TEST_BGN(NAME) {\
#define FCT_SUITE_BGN(Name)
Definition: switch_fct.h:3460

Definition at line 3951 of file switch_fct.h.

◆ FCT_QTEST_BGN_IF

#define FCT_QTEST_BGN_IF (   _CONDITION_,
  _NAME_ 
)
Value:
FCT_SUITE_BGN(_NAME_) {\
FCT_TEST_BGN_IF(_CONDITION_, _NAME_) {\
#define FCT_SUITE_BGN(Name)
Definition: switch_fct.h:3460

Definition at line 3960 of file switch_fct.h.

◆ FCT_QTEST_END

#define FCT_QTEST_END ( )
Value:
#define FCT_TEST_END()
Definition: switch_fct.h:3537
#define FCT_SUITE_END()
Definition: switch_fct.h:3465

Definition at line 3955 of file switch_fct.h.

◆ FCT_QTEST_END_IF

#define FCT_QTEST_END_IF ( )
Value:
#define FCT_TEST_END_IF()
Definition: switch_fct.h:3486
#define FCT_SUITE_END()
Definition: switch_fct.h:3465

Definition at line 3964 of file switch_fct.h.

◆ FCT_QUOTEME

#define FCT_QUOTEME (   x)    _FCT_QUOTEME(x)

Definition at line 67 of file switch_fct.h.

◆ FCT_REFERENCE_FUNCS

#define FCT_REFERENCE_FUNCS ( )

Definition at line 3217 of file switch_fct.h.

◆ fct_req

#define fct_req (   _CNDTN_)
Value:
if ( fct_ts__is_test_mode(fctkern_ptr__->ns.ts_curr) ) { \
_fct_req((_CNDTN_)); \
} \
else if ( fct_ts__is_setup_mode(fctkern_ptr__->ns.ts_curr) \
|| fct_ts__is_teardown_mode(fctkern_ptr__->ns.ts_curr) ) { \
fctkern_ptr__->ns.curr_test = fct_ts__make_abort_test( \
fctkern_ptr__->ns.ts_curr \
); \
if ( !(fct_xchk((_CNDTN_) ? 1 : 0, #_CNDTN_)) ) { \
fct_ts__setup_abort(fctkern_ptr__->ns.ts_curr); \
fct_ts__add_test( \
fctkern_ptr__->ns.ts_curr, fctkern_ptr__->ns.curr_test \
); \
} else { \
fct_test__del(fctkern_ptr__->ns.curr_test); \
fctkern_ptr__->ns.curr_test = NULL; \
} \
} else { \
switch_assert("invalid condition for fct_req!"); \
_fct_req((_CNDTN_)); \
}
static fct_test_t * fct_ts__make_abort_test(fct_ts_t *ts)
Definition: switch_fct.h:1233
#define fct_xchk
Definition: switch_fct.h:3643
#define fct_ts__is_setup_mode(ts)
Definition: switch_fct.h:1126
#define fct_ts__is_test_mode(ts)
Definition: switch_fct.h:1128
#define fct_ts__is_teardown_mode(ts)
Definition: switch_fct.h:1127

Definition at line 3666 of file switch_fct.h.

◆ FCT_SETUP_BGN

#define FCT_SETUP_BGN ( )    if ( fct_ts__is_setup_mode(fctkern_ptr__->ns.ts_curr) ) {

Definition at line 3444 of file switch_fct.h.

◆ FCT_SETUP_END

#define FCT_SETUP_END ( )    fct_ts__setup_end(fctkern_ptr__->ns.ts_curr); }

Definition at line 3447 of file switch_fct.h.

◆ FCT_STANDARD_LOGGER_MAX_LINE

#define FCT_STANDARD_LOGGER_MAX_LINE   68

◆ FCT_SUITE_BGN

#define FCT_SUITE_BGN (   Name)
Value:
FCT_SETUP_BGN() {_fct_cmt("stubbed"); } FCT_SETUP_END()\
FCT_TEARDOWN_BGN() {_fct_cmt("stubbed");} FCT_TEARDOWN_END()\
#define FCT_FIXTURE_SUITE_BGN(_NAME_)
Definition: switch_fct.h:3379
#define _fct_cmt(string)
Definition: switch_fct.h:172
#define FCT_TEARDOWN_END()
Definition: switch_fct.h:3453
#define FCT_SETUP_END()
Definition: switch_fct.h:3447

Definition at line 3460 of file switch_fct.h.

◆ FCT_SUITE_BGN_IF

#define FCT_SUITE_BGN_IF (   _CONDITION_,
  _NAME_ 
)
Value:
FCT_FIXTURE_SUITE_BGN_IF(_CONDITION_, (_NAME_)) {\
FCT_SETUP_BGN() {_fct_cmt("stubbed"); } FCT_SETUP_END()\
FCT_TEARDOWN_BGN() {_fct_cmt("stubbed");} FCT_TEARDOWN_END()\
#define _fct_cmt(string)
Definition: switch_fct.h:172
#define FCT_TEARDOWN_END()
Definition: switch_fct.h:3453
#define FCT_FIXTURE_SUITE_BGN_IF(_CONDITION_, _NAME_)
Definition: switch_fct.h:3431
#define FCT_SETUP_END()
Definition: switch_fct.h:3447

Definition at line 3467 of file switch_fct.h.

◆ FCT_SUITE_END

#define FCT_SUITE_END ( )    } FCT_FIXTURE_SUITE_END()

Definition at line 3465 of file switch_fct.h.

◆ FCT_SUITE_END_IF

#define FCT_SUITE_END_IF ( )    } FCT_FIXTURE_SUITE_END_IF()

Definition at line 3472 of file switch_fct.h.

◆ FCT_SWITCH_STDERR_TO_BUFFER

#define FCT_SWITCH_STDERR_TO_BUFFER ( )    fct_switch_std_to_buffer(fct_stderr_pipe, stderr, STDERR_FILENO, &fct_saved_stderr)

Definition at line 241 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_start().

◆ FCT_SWITCH_STDERR_TO_STDERR

#define FCT_SWITCH_STDERR_TO_STDERR ( )    fct_switch_std_to_std(stderr, STDERR_FILENO, fct_saved_stderr)

Definition at line 243 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_end().

◆ FCT_SWITCH_STDOUT_TO_BUFFER

#define FCT_SWITCH_STDOUT_TO_BUFFER ( )    fct_switch_std_to_buffer(fct_stdout_pipe, stdout, STDOUT_FILENO, &fct_saved_stdout)

Definition at line 237 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_start().

◆ FCT_SWITCH_STDOUT_TO_STDOUT

#define FCT_SWITCH_STDOUT_TO_STDOUT ( )    fct_switch_std_to_std(stdout, STDOUT_FILENO, fct_saved_stdout)

Definition at line 239 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_end().

◆ FCT_TEARDOWN_BGN

#define FCT_TEARDOWN_BGN ( )    if ( fct_ts__is_teardown_mode(fctkern_ptr__->ns.ts_curr) ) {\

Definition at line 3450 of file switch_fct.h.

◆ FCT_TEARDOWN_END

#define FCT_TEARDOWN_END ( )
Value:
fct_ts__teardown_end(fctkern_ptr__->ns.ts_curr); \
continue; \
}
static void fct_ts__teardown_end(fct_ts_t *ts)
Definition: switch_fct.h:1252

Definition at line 3453 of file switch_fct.h.

◆ fct_test__clear_failed

#define fct_test__clear_failed (   test)    fct_nlist__clear(test->failed_chks, (fct_nlist_on_del_t)fctchk__del);\

Definition at line 946 of file switch_fct.h.

◆ fct_test__name

#define fct_test__name (   _TEST_)    ((_TEST_)->name)

◆ FCT_TEST_BGN

#define FCT_TEST_BGN (   _NAME_)

Definition at line 3499 of file switch_fct.h.

◆ FCT_TEST_BGN_IF

#define FCT_TEST_BGN_IF (   _CONDITION_,
  _NAME_ 
)
Value:
{ \
fctkern_ptr__->ns.test_is_skip = !(_CONDITION_);\
fctkern_ptr__->ns.test_skip_cndtn = #_CONDITION_;\
FCT_TEST_BGN(_NAME_) {\

Definition at line 3481 of file switch_fct.h.

◆ FCT_TEST_END

#define FCT_TEST_END ( )
Value:
break;\
}\
fct_test__stop_timer(fctkern_ptr__->ns.curr_test);\
}\
fct_ts__add_test(fctkern_ptr__->ns.ts_curr, fctkern_ptr__->ns.curr_test);\
fctkern__log_test_end(fctkern_ptr__, fctkern_ptr__->ns.curr_test);\
}\
fct_ts__test_end(fctkern_ptr__->ns.ts_curr);\
continue;\
}\
}\

Definition at line 3537 of file switch_fct.h.

◆ FCT_TEST_END_IF

#define FCT_TEST_END_IF ( )
Value:
fctkern_ptr__->ns.test_is_skip = 0;\
fctkern_ptr__->ns.test_skip_cndtn = NULL;\
}
#define FCT_TEST_END()
Definition: switch_fct.h:3537

Definition at line 3486 of file switch_fct.h.

◆ FCT_TRUE

#define FCT_TRUE   1

Definition at line 86 of file switch_fct.h.

Referenced by fct_filter_pass(), fct_test_new(), and fctkern__pass_filter().

◆ fct_ts__end

#define fct_ts__end (   ts)    ((ts)->mode = ts_mode_end)

Definition at line 1139 of file switch_fct.h.

◆ fct_ts__ending

#define fct_ts__ending (   ts)    ((ts)->mode = ts_mode_ending)

Definition at line 1136 of file switch_fct.h.

◆ fct_ts__is_abort_mode

#define fct_ts__is_abort_mode (   ts)    ((ts)->mode == ts_mode_abort)

Definition at line 1132 of file switch_fct.h.

◆ fct_ts__is_cnt_mode

#define fct_ts__is_cnt_mode (   ts)    ((ts)->mode == ts_mode_cnt)

Definition at line 1131 of file switch_fct.h.

Referenced by fct_ts__cnt_end(), and fct_ts__inc_total_test_num().

◆ fct_ts__is_end

#define fct_ts__is_end (   ts)    ((ts)->mode == ts_mode_end)

◆ fct_ts__is_ending_mode

#define fct_ts__is_ending_mode (   ts)    ((ts)->mode == ts_mode_ending)

Definition at line 1129 of file switch_fct.h.

◆ fct_ts__is_setup_mode

#define fct_ts__is_setup_mode (   ts)    ((ts)->mode == ts_mode_setup)

Definition at line 1126 of file switch_fct.h.

◆ fct_ts__is_teardown_mode

#define fct_ts__is_teardown_mode (   ts)    ((ts)->mode == ts_mode_teardown)

Definition at line 1127 of file switch_fct.h.

◆ fct_ts__is_test_mode

#define fct_ts__is_test_mode (   ts)    ((ts)->mode == ts_mode_test)

Definition at line 1128 of file switch_fct.h.

◆ fct_ts__name

#define fct_ts__name (   ts)    ((ts)->name)

Definition at line 1141 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_end(), and fct_ts__make_abort_test().

◆ fct_unused

#define fct_unused (   x)    (void)(x)

◆ FCT_VERSION_MAJOR

#define FCT_VERSION_MAJOR   1

Definition at line 62 of file switch_fct.h.

◆ FCT_VERSION_MICRO

#define FCT_VERSION_MICRO   1

Definition at line 64 of file switch_fct.h.

◆ FCT_VERSION_MINOR

#define FCT_VERSION_MINOR   6

Definition at line 63 of file switch_fct.h.

◆ FCT_VERSION_STR

#define FCT_VERSION_STR
Value:
FCT_QUOTEME(FCT_VERSION_MINOR) "."\
FCT_QUOTEME(FCT_VERSION_MICRO))
#define FCT_VERSION_MICRO
Definition: switch_fct.h:64
#define FCT_VERSION_MAJOR
Definition: switch_fct.h:62
#define FCT_QUOTEME(x)
Definition: switch_fct.h:67
#define FCT_VERSION_MINOR
Definition: switch_fct.h:63

Definition at line 69 of file switch_fct.h.

Referenced by fctkern__cl_parse().

◆ fct_xchk

#define fct_xchk
Value:
fct_xchk_kern = fctkern_ptr__,\
fct_xchk_test = fctkern_ptr__->ns.curr_test,\
fct_xchk_lineno =__LINE__,\
fct_xchk_file=__FILE__,\
fct_xchk_fn
static fctkern_t * fct_xchk_kern
Definition: switch_fct.h:3573
fct_test_t * curr_test
Definition: switch_fct.h:1829
fct_namespace_t ns
Definition: switch_fct.h:1862

Definition at line 3643 of file switch_fct.h.

◆ fct_xchk2

#define fct_xchk2
Value:
fct_xchk_kern = fctkern_ptr__,\
fct_xchk_test = fctkern_ptr__->ns.curr_test,\
fct_xchk_lineno =__LINE__,\
fct_xchk_file=__FILE__,\
fct_xchk2_fn
static fctkern_t * fct_xchk_kern
Definition: switch_fct.h:3573
fct_test_t * curr_test
Definition: switch_fct.h:1829
fct_namespace_t ns
Definition: switch_fct.h:1862

Definition at line 3649 of file switch_fct.h.

◆ fctchk__cndtn

#define fctchk__cndtn (   _CHK_)    ((_CHK_)->cndtn)

Definition at line 860 of file switch_fct.h.

◆ fctchk__file

#define fctchk__file (   _CHK_)    ((_CHK_)->file)

Definition at line 858 of file switch_fct.h.

Referenced by fct_logger_print_failures(), and fct_standard_logger__on_chk().

◆ fctchk__is_pass

#define fctchk__is_pass (   _CHK_)    ((_CHK_)->is_pass)

◆ fctchk__lineno

#define fctchk__lineno (   _CHK_)    ((_CHK_)->lineno)

Definition at line 859 of file switch_fct.h.

Referenced by fct_logger_print_failures(), and fct_standard_logger__on_chk().

◆ fctchk__msg

#define fctchk__msg (   _CHK_)    ((_CHK_)->msg)

Definition at line 861 of file switch_fct.h.

Referenced by fct_logger_print_failures(), and fct_standard_logger__on_chk().

◆ fctchk__name

#define fctchk__name (   _CHK_)    ((_CHK_)->name)

Definition at line 862 of file switch_fct.h.

Referenced by fct_logger_print_failures().

◆ fctcl__set_value

#define fctcl__set_value (   _CLO_,
  _VAL_ 
)    (_CLO_)->value = fctstr_clone((_VAL_));

Definition at line 1539 of file switch_fct.h.

Referenced by fct_clp__parse().

◆ FCTCL_INIT_NULL

#define FCTCL_INIT_NULL   {NULL, NULL, FCTCL_STORE_UNDEFINED, NULL}

Definition at line 1406 of file switch_fct.h.

◆ fctcl_install

#define fctcl_install (   _CLO_INIT_)
Value:
{\
fctkern_ptr__->cl_user_opts = (_CLO_INIT_);\
_fct_cmt("Delay parse in order to allow for user customization.");\
if ( !fctkern__cl_is_parsed((fctkern_ptr__)) ) {\
int status = fctkern__cl_parse((fctkern_ptr__));\
_fct_cmt("Need to parse command line before we start logger.");\
fctkern__log_start((fctkern_ptr__));\
switch( status ) {\
case -1:\
case 0:\
fctkern__final(fctkern_ptr__);\
exit( (status == 0) ? (EXIT_FAILURE) : (EXIT_SUCCESS) );\
break;\
default:\
fct_pass();\
}\
}\
}
#define fctkern__cl_is_parsed(_NK_)
Definition: switch_fct.h:2053
static int fctkern__cl_parse(fctkern_t *nk)
Definition: switch_fct.h:2135

Definition at line 3347 of file switch_fct.h.

◆ fctcl_is

#define fctcl_is (   _OPT_STR_)    (fctkern__cl_is(fctkern_ptr__, (_OPT_STR_)))

Definition at line 3368 of file switch_fct.h.

◆ fctcl_new

#define fctcl_new ( )    ((fctcl_t*)calloc(1, sizeof(fctcl_t)))

Definition at line 1443 of file switch_fct.h.

Referenced by fctcl_new2().

◆ FCTCL_TRUE_STR

#define FCTCL_TRUE_STR   "1"

Definition at line 1423 of file switch_fct.h.

Referenced by fct_clp__parse().

◆ fctcl_val

#define fctcl_val (   _OPT_STR_)    (fctcl_val2((_OPT_STR_), NULL))

Definition at line 3370 of file switch_fct.h.

◆ fctcl_val2

#define fctcl_val2 (   _OPT_STR_,
  _DEF_STR_ 
)    (fctkern__cl_val2(fctkern_ptr__, (_OPT_STR_), (_DEF_STR_)))

Definition at line 3372 of file switch_fct.h.

◆ fctkern__cl_is_parsed

#define fctkern__cl_is_parsed (   _NK_)    ((_NK_)->cl_is_parsed)

Definition at line 2053 of file switch_fct.h.

◆ fctkern__end

#define fctkern__end (   nk)    /* unused */

Definition at line 2333 of file switch_fct.h.

◆ fctkern__filter_cnt

#define fctkern__filter_cnt (   _NK_)    (fct_nlist__size(&((_NK_)->prefix_list)))

Definition at line 1959 of file switch_fct.h.

Referenced by fctkern__pass_filter().

◆ fctkern__log_end

#define fctkern__log_end (   _NK_)
Value:
{\
FCT_NLIST_FOREACH_BGN(fct_logger_i*, logger, &((_NK_)->logger_list))\
{\
fct_logger__on_fctx_end(logger, (_NK_));\
}\
FCT_NLIST_FOREACH_END();\
}

Definition at line 2454 of file switch_fct.h.

◆ fctkern__log_start

#define fctkern__log_start (   _NK_)
Value:
{\
FCT_NLIST_FOREACH_BGN(fct_logger_i*, logger, &((_NK_)->logger_list))\
{\
fct_logger__on_fctx_start(logger, (_NK_));\
}\
FCT_NLIST_FOREACH_END();\
}

Definition at line 2444 of file switch_fct.h.

◆ fctkern__tst_cnt_failed

#define fctkern__tst_cnt_failed (   nk)    (fctkern__tst_cnt(nk) - fctkern__tst_cnt_passed(nk))

Definition at line 2310 of file switch_fct.h.

◆ fctlog_install

#define fctlog_install (   _CUST_LOGGER_LIST_)    fctkern_ptr__->lt_usr = (_CUST_LOGGER_LIST_)

Definition at line 3342 of file switch_fct.h.

◆ FCTMF_FIXTURE_SUITE_BGN

#define FCTMF_FIXTURE_SUITE_BGN (   NAME)
Value:
void NAME (fctkern_t *fctkern_ptr__) {\
FCT_REFERENCE_FUNCS();\
FCT_FIXTURE_SUITE_BGN( NAME ) {

Definition at line 3912 of file switch_fct.h.

◆ FCTMF_FIXTURE_SUITE_END

#define FCTMF_FIXTURE_SUITE_END ( )
Value:
}
#define FCT_FIXTURE_SUITE_END()
Definition: switch_fct.h:3418

Definition at line 3917 of file switch_fct.h.

◆ FCTMF_SUITE_BGN

#define FCTMF_SUITE_BGN (   NAME)
Value:
void NAME (fctkern_t *fctkern_ptr__) {\
FCT_REFERENCE_FUNCS();\
FCT_SUITE_BGN( NAME ) {

Definition at line 3921 of file switch_fct.h.

◆ FCTMF_SUITE_CALL

#define FCTMF_SUITE_CALL (   NAME)
Value:
{\
void NAME (fctkern_t *);\
NAME (fctkern_ptr__);\
}

Definition at line 3935 of file switch_fct.h.

◆ FCTMF_SUITE_DEF

#define FCTMF_SUITE_DEF (   NAME)

Definition at line 3931 of file switch_fct.h.

◆ FCTMF_SUITE_END

#define FCTMF_SUITE_END ( )
Value:
}
#define FCT_SUITE_END()
Definition: switch_fct.h:3465

Definition at line 3925 of file switch_fct.h.

◆ FCTMIN

#define FCTMIN (   x,
 
)    ( x < y) ? (x) : (y)

Definition at line 89 of file switch_fct.h.

Referenced by fct_dotted_line_start().

◆ nbool_t

#define nbool_t   int

Typedef Documentation

◆ fct_clp_t

typedef struct _fct_clp_t fct_clp_t

◆ fct_junit_logger_t

Definition at line 106 of file switch_fct.h.

◆ fct_logger_evt_t

Definition at line 102 of file switch_fct.h.

◆ fct_logger_i

typedef struct _fct_logger_i fct_logger_i

Definition at line 103 of file switch_fct.h.

◆ fct_logger_i_vtable_t

◆ fct_logger_new_fn

typedef fct_logger_i*(* fct_logger_new_fn) (void)

Definition at line 1929 of file switch_fct.h.

◆ fct_logger_types_t

Definition at line 104 of file switch_fct.h.

◆ fct_minimal_logger_t

Definition at line 107 of file switch_fct.h.

◆ fct_namespace_t

◆ fct_nlist_on_del_t

typedef void(* fct_nlist_on_del_t) (void *)

Definition at line 716 of file switch_fct.h.

◆ fct_nlist_t

typedef struct _fct_nlist_t fct_nlist_t

Definition at line 704 of file switch_fct.h.

◆ fct_standard_logger_t

Definition at line 105 of file switch_fct.h.

◆ fct_test_t

typedef struct _fct_test_t fct_test_t

Definition at line 109 of file switch_fct.h.

◆ fct_timer_t

typedef struct _fct_timer_t fct_timer_t

Definition at line 624 of file switch_fct.h.

◆ fct_ts_t

typedef struct _fct_ts_t fct_ts_t

Definition at line 110 of file switch_fct.h.

◆ fctchk_t

typedef struct _fctchk_t fctchk_t

Definition at line 108 of file switch_fct.h.

◆ fctcl_init_t

typedef struct _fctcl_init_t fctcl_init_t

◆ fctcl_t

typedef struct _fctcl_t fctcl_t

◆ fctkern_t

typedef struct _fctkern_t fctkern_t

Definition at line 111 of file switch_fct.h.

Enumeration Type Documentation

◆ FCT_TEST_END_FLAG

Enumerator
FCT_TEST_END_FLAG_Default 
FCT_TEST_END_FLAG_ClearFail 

Definition at line 3474 of file switch_fct.h.

◆ fct_test_status

Enumerator
fct_test_status_SUCCESS 
fct_test_status_FAILURE 

Definition at line 1100 of file switch_fct.h.

◆ fctcl_store_t

Enumerator
FCTCL_STORE_UNDEFINED 
FCTCL_STORE_TRUE 
FCTCL_STORE_VALUE 

Definition at line 1383 of file switch_fct.h.

◆ ts_mode

enum ts_mode
Enumerator
ts_mode_cnt 
ts_mode_setup 
ts_mode_teardown 
ts_mode_test 
ts_mode_ending 
ts_mode_end 
ts_mode_abort 

Definition at line 1088 of file switch_fct.h.

1089 {
1090  ts_mode_cnt, /* To setup when done counting. */
1091  ts_mode_setup, /* To test when done setup. */
1092  ts_mode_teardown, /* To ending mode, when no more tests. */
1093  ts_mode_test, /* To tear down mode. */
1094  ts_mode_ending, /* To ... */
1095  ts_mode_end, /* .. The End. */
1096  ts_mode_abort /* Abort */
1097 };

Function Documentation

◆ _fct_chk_empty_str()

static int _fct_chk_empty_str ( char const *  s)
static

Definition at line 3727 of file switch_fct.h.

3728 {
3729  if ( s == NULL )
3730  {
3731  return 1;
3732  }
3733  return strlen(s) ==0;
3734 }

◆ _fct_chk_full_str()

static int _fct_chk_full_str ( char const *  s)
static

Definition at line 3736 of file switch_fct.h.

3737 {
3738  if ( s == NULL )
3739  {
3740  return 0;
3741  }
3742  return strlen(s) >0;
3743 }

◆ _fct_xchk_fn_varg()

static int _fct_xchk_fn_varg ( char const *  condition,
int  is_pass,
char const *  format,
va_list  args 
)
static

Definition at line 3577 of file switch_fct.h.

References fct_test__add(), fct_test__name, fct_xchk_file, fct_xchk_lineno, fctchk_new(), fctkern__log_chk(), and fctkern__log_warn().

Referenced by fct_xchk2_fn(), and fct_xchk_fn().

3583 {
3584  fctchk_t *chk =NULL;
3585  chk = fctchk_new(
3586 
3587  is_pass,
3588  condition,
3590  fct_xchk_file,
3592  format,
3593  args
3594  );
3595  if ( chk == NULL )
3596  {
3597  fctkern__log_warn(fct_xchk_kern, "out of memory (aborting test)");
3598  goto finally;
3599  }
3600 
3603 finally:
3604  fct_xchk_lineno =0;
3605  fct_xchk_file =NULL;
3606  fct_xchk_test =NULL;
3607  fct_xchk_kern =NULL;
3608  return is_pass;
3609 }
static fct_test_t * fct_xchk_test
Definition: switch_fct.h:3572
static void fct_test__add(fct_test_t *test, fctchk_t *chk)
Definition: switch_fct.h:1036
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
static int fct_xchk_lineno
Definition: switch_fct.h:3570
static fctkern_t * fct_xchk_kern
Definition: switch_fct.h:3573
static void fctkern__log_warn(fctkern_t *nk, char const *warn)
Definition: switch_fct.h:2405
static void fctkern__log_chk(fctkern_t *nk, fctchk_t const *chk)
Definition: switch_fct.h:2391
static fctchk_t * fctchk_new(int is_pass, char const *cndtn, char const *name, char const *file, int lineno, char const *format, va_list args)
Definition: switch_fct.h:865
#define fct_test__name(_TEST_)
Definition: switch_fct.h:943
static char const * fct_xchk_file
Definition: switch_fct.h:3571

◆ fckern_sel_log()

static fct_logger_i* fckern_sel_log ( fct_logger_types_t search,
char const *  sel_logger 
)
static

Definition at line 2084 of file switch_fct.h.

References FCT_ASSERT, fctstr_ieq(), _fct_logger_types_t::logger_new_fn, and _fct_logger_types_t::name.

Referenced by fctkern__cl_parse_config_logger().

2085 {
2086  fct_logger_types_t *iter;
2087  FCT_ASSERT(search != NULL);
2088  FCT_ASSERT(sel_logger != NULL);
2089  FCT_ASSERT(strlen(sel_logger) > 0);
2090  for ( iter = search; iter->name != NULL; ++iter)
2091  {
2092  if ( fctstr_ieq(iter->name, sel_logger) )
2093  {
2094  return iter->logger_new_fn();
2095  }
2096  }
2097  return NULL;
2098 }
fct_logger_new_fn logger_new_fn
Definition: switch_fct.h:1933
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static int fctstr_ieq(char const *s1, char const *s2)
Definition: switch_fct.h:413
char const * name
Definition: switch_fct.h:1932

◆ fct_clp__add_options()

static int fct_clp__add_options ( fct_clp_t clp,
fctcl_init_t const *  options 
)
static

Definition at line 1573 of file switch_fct.h.

References _fctcl_init_t::action, _fct_clp_t::clo_list, fct_nlist__append(), fctcl_new2(), and FCTCL_STORE_UNDEFINED.

Referenced by fct_clp__init(), and fctkern__cl_parse().

1574 {
1575  fctcl_init_t const *pclo =NULL;
1576  int ok;
1577  for ( pclo = options; pclo->action != FCTCL_STORE_UNDEFINED; ++pclo )
1578  {
1579  fctcl_t *cpy = fctcl_new2(pclo);
1580  if ( cpy == NULL )
1581  {
1582  ok = 0;
1583  goto finally;
1584  }
1585  fct_nlist__append(&(clp->clo_list), (void*)cpy);
1586  }
1587  ok =1;
1588 finally:
1589  return ok;
1590 }
fctcl_store_t action
Definition: switch_fct.h:1398
fct_nlist_t clo_list
Definition: switch_fct.h:1553
static fctcl_t * fctcl_new2(fctcl_init_t const *clo_init)
Definition: switch_fct.h:1462
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fct_clp__final()

static void fct_clp__final ( fct_clp_t clp)
static

Definition at line 1564 of file switch_fct.h.

References _fct_clp_t::clo_list, fct_nlist__final(), fctcl__del(), and _fct_clp_t::param_list.

Referenced by fct_clp__init(), and fctkern__final().

1565 {
1568 }
void(* fct_nlist_on_del_t)(void *)
Definition: switch_fct.h:716
static void fctcl__del(fctcl_t *clo)
Definition: switch_fct.h:1447
fct_nlist_t clo_list
Definition: switch_fct.h:1553
static void fct_nlist__final(fct_nlist_t *list, fct_nlist_on_del_t on_del)
Definition: switch_fct.h:741
fct_nlist_t param_list
Definition: switch_fct.h:1556

◆ fct_clp__get_clo()

static fctcl_t const* fct_clp__get_clo ( fct_clp_t const *  clp,
char const *  option 
)
static

Definition at line 1730 of file switch_fct.h.

References _fct_clp_t::clo_list, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and fctcl__is_option().

Referenced by fct_clp__optval2().

1731 {
1732  fctcl_t const *found =NULL;
1733 
1734  FCT_NLIST_FOREACH_BGN(fctcl_t const*, pclo, &(clp->clo_list))
1735  {
1736  if ( fctcl__is_option(pclo, option) )
1737  {
1738  found = pclo;
1739  break;
1740  }
1741  }
1743  return found;
1744 }
static int fctcl__is_option(fctcl_t const *clo, char const *option)
Definition: switch_fct.h:1523
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fct_clp__init()

static int fct_clp__init ( fct_clp_t clp,
fctcl_init_t const *  options 
)
static

Definition at line 1594 of file switch_fct.h.

References _fct_clp_t::clo_list, FCT_ASSERT, fct_clp__add_options(), fct_clp__final(), fct_nlist__init, and _fct_clp_t::param_list.

Referenced by fctkern__init().

1595 {
1596  int ok =0;
1597  FCT_ASSERT( clp != NULL );
1598  /* It is just much saner to manage a clone of the options. Then we know
1599  who is in charge of the memory. */
1600  ok = fct_nlist__init(&(clp->clo_list));
1601  if ( !ok )
1602  {
1603  goto finally;
1604  }
1605  if ( options != NULL )
1606  {
1607  ok = fct_clp__add_options(clp, options);
1608  if ( !ok )
1609  {
1610  goto finally;
1611  }
1612  }
1613  ok = fct_nlist__init(&(clp->param_list));
1614  if ( !ok )
1615  {
1616  goto finally;
1617  }
1618  ok =1;
1619 finally:
1620  if ( !ok )
1621  {
1622  fct_clp__final(clp);
1623  }
1624  return ok;
1625 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static void fct_clp__final(fct_clp_t *clp)
Definition: switch_fct.h:1564
fct_nlist_t clo_list
Definition: switch_fct.h:1553
fct_nlist_t param_list
Definition: switch_fct.h:1556
#define fct_nlist__init(_LIST_PTR_)
Definition: switch_fct.h:779
static int fct_clp__add_options(fct_clp_t *clp, fctcl_init_t const *options)
Definition: switch_fct.h:1573

◆ fct_clp__is_param()

static int fct_clp__is_param ( fct_clp_t clp,
char const *  param 
)
static

Definition at line 1771 of file switch_fct.h.

References FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fctstr_eq(), and _fct_clp_t::param_list.

1772 {
1773  if ( clp == NULL || param == NULL )
1774  {
1775  return 0;
1776  }
1777  FCT_NLIST_FOREACH_BGN(char *, aparam, &(clp->param_list))
1778  {
1779  if ( fctstr_eq(aparam, param) )
1780  {
1781  return 1;
1782  }
1783  }
1785  return 0;
1786 }
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
fct_nlist_t param_list
Definition: switch_fct.h:1556
static int fctstr_eq(char const *s1, char const *s2)
Definition: switch_fct.h:389
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fct_clp__optval2()

static char const* fct_clp__optval2 ( fct_clp_t clp,
char const *  option,
char const *  default_val 
)
static

Definition at line 1754 of file switch_fct.h.

References FCT_ASSERT, fct_clp__get_clo(), and _fctcl_t::value.

Referenced by fctkern__cl_val2().

1755 {
1756  fctcl_t const *clo =NULL;
1757  FCT_ASSERT( clp != NULL );
1758  FCT_ASSERT( option != NULL );
1759  clo = fct_clp__get_clo(clp, option);
1760  if ( clo == NULL || clo->value == NULL)
1761  {
1762  return default_val;
1763  }
1764  return clo->value;
1765 }
static fctcl_t const * fct_clp__get_clo(fct_clp_t const *clp, char const *option)
Definition: switch_fct.h:1730
char * value
Definition: switch_fct.h:1439
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_clp__parse()

static void fct_clp__parse ( fct_clp_t clp,
int  argc,
char const *  argv[] 
)
static

Definition at line 1631 of file switch_fct.h.

References _fct_clp_t::clo_list, _fct_clp_t::error_msg, FCT_ASSERT, FCT_CLP_MAX_ERR_MSG_LEN, fct_nlist__append(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fct_snprintf(), fctcl__is_option(), fctcl__set_value, FCTCL_STORE_TRUE, FCTCL_STORE_VALUE, FCTCL_TRUE_STR, fctstr_clone(), _fct_clp_t::is_error, is_option(), and _fct_clp_t::param_list.

Referenced by fctkern__cl_parse().

1632 {
1633  int argi =1;
1634  int is_option =0;
1635  char *arg =NULL;
1636  char *token =NULL;
1637  char *next_token =NULL;
1638 
1639  clp->error_msg[0] = '\0';
1640  clp->is_error =0;
1641 
1642  while ( argi < argc )
1643  {
1644  is_option =0;
1645  token =NULL;
1646  next_token = NULL;
1647  arg = fctstr_clone(argv[argi]);
1648 
1649 #if defined(_MSC_VER) && _MSC_VER > 1300
1650  token = strtok_s(arg, "=", &next_token);
1651 #else
1652  token = strtok(arg, "=");
1653  next_token = strtok(NULL, "=");
1654 #endif
1655 
1656  FCT_NLIST_FOREACH_BGN(fctcl_t*, pclo, &(clp->clo_list))
1657  {
1658  /* Need to reset for each search. strtok below is destructive. */
1659  if ( fctcl__is_option(pclo, token) )
1660  {
1661  is_option =1;
1662  if ( pclo->action == FCTCL_STORE_VALUE )
1663  {
1664  /* If this is --xxxx=value then the next strtok should succeed.
1665  Otherwise, we need to chew up the next argument. */
1666  if ( next_token != NULL && strlen(next_token) > 0 )
1667  {
1668  fctcl__set_value(pclo, next_token);
1669  }
1670  else
1671  {
1672  ++argi; /* Chew up the next value */
1673  if ( argi >= argc )
1674  {
1675  /* error */
1676  fct_snprintf(
1677  clp->error_msg,
1679  "missing argument for %s",
1680  token
1681  );
1682  clp->is_error =1;
1683  break;
1684  }
1685  fctcl__set_value(pclo, argv[argi]);
1686  }
1687  }
1688  else if (pclo->action == FCTCL_STORE_TRUE)
1689  {
1691  }
1692  else
1693  {
1694  FCT_ASSERT("undefined action requested");
1695  }
1696  break; /* No need to parse this argument further. */
1697  }
1698  }
1700  /* If we have an error, exit. */
1701  if ( clp->is_error )
1702  {
1703  break;
1704  }
1705  /* If we walked through all the options, and didn't find
1706  anything, then we must have a parameter. Forget the fact that
1707  an unknown option will be treated like a parameter... */
1708  if ( !is_option )
1709  {
1710  fct_nlist__append(&(clp->param_list), arg);
1711  arg =NULL; /* Owned by the nlist */
1712  }
1713  ++argi;
1714  if ( arg != NULL )
1715  {
1716  free(arg);
1717  arg =NULL;
1718  }
1719  }
1720 
1721  if (arg != NULL)
1722  {
1723  free(arg);
1724  arg = NULL;
1725  }
1726 }
static int fctcl__is_option(fctcl_t const *clo, char const *option)
Definition: switch_fct.h:1523
#define fctcl__set_value(_CLO_, _VAL_)
Definition: switch_fct.h:1539
static int fct_snprintf(char *buffer, size_t buffer_len, char const *format,...)
Definition: switch_fct.h:287
char error_msg[FCT_CLP_MAX_ERR_MSG_LEN]
Definition: switch_fct.h:1558
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static char * fctstr_clone(char const *s)
Definition: switch_fct.h:301
fct_nlist_t clo_list
Definition: switch_fct.h:1553
#define FCTCL_TRUE_STR
Definition: switch_fct.h:1423
static switch_bool_t is_option(const char *p)
Definition: switch.c:481
#define FCT_CLP_MAX_ERR_MSG_LEN
Definition: switch_fct.h:1548
fct_nlist_t param_list
Definition: switch_fct.h:1556
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fct_dotted_line_end()

static void fct_dotted_line_end ( char const *  endswith)
static

Definition at line 608 of file switch_fct.h.

Referenced by fct_standard_logger__on_test_end(), and fct_standard_logger__on_test_skip().

609 {
610  printf(" %s\n", endswith);
611 }

◆ fct_dotted_line_start()

static void fct_dotted_line_start ( size_t  maxwidth,
char const *  startwith 
)
static

Definition at line 588 of file switch_fct.h.

References FCT_DOTTED_MAX_LEN, FCTMIN, and memset().

Referenced by fct_standard_logger__on_test_skip(), and fct_standard_logger__on_test_start().

589 {
590  char line[FCT_DOTTED_MAX_LEN];
591  size_t len =0;
592  size_t line_len =0;
593 
594  memset(line, '.', sizeof(char)*maxwidth);
595  len = strlen(startwith);
596  line_len = FCTMIN(maxwidth-1, len);
597  memcpy(line, startwith, sizeof(char)*line_len);
598  if ( len < maxwidth-1)
599  {
600  line[len] = ' ';
601  }
602  line[maxwidth-1] = '\0';
603  fputs(line, stdout);
604 }
#define FCTMIN(x, y)
Definition: switch_fct.h:89
#define FCT_DOTTED_MAX_LEN
Definition: switch_fct.h:586
memset(buf, 0, buflen)

◆ fct_filter_pass()

static nbool_t fct_filter_pass ( char const *  prefix,
char const *  test_str 
)
static

Definition at line 341 of file switch_fct.h.

References FCT_ASSERT, FCT_FALSE, FCT_TRUE, and nbool_t.

Referenced by fctkern__pass_filter().

342 {
343  nbool_t is_match = FCT_FALSE;
344  char const *prefix_p;
345  char const *test_str_p;
346 
347  /* If you got nothing to test against, why test? */
348  FCT_ASSERT( test_str != NULL );
349 
350  /* When the prefix is NULL or blank, we always return FCT_TRUE. */
351  if ( prefix == NULL || prefix[0] == '\0' )
352  {
353  return FCT_TRUE;
354  }
355 
356  /* Iterate through both character arrays at the same time. We are
357  going to play a game and see if we can beat the house. */
358  for ( prefix_p = prefix, test_str_p = test_str;
359  *prefix_p != '\0' && *test_str_p != '\0';
360  ++prefix_p, ++test_str_p )
361  {
362  is_match = *prefix_p == *test_str_p;
363  if ( !is_match )
364  {
365  break; /* Quit the first time we don't match. */
366  }
367  }
368 
369  /* If the iterator for the test_str is pointing at the null char, and
370  the iterator for the prefix string is not, then the prefix string is
371  larger than the actual test string, and therefore we failed to pass the
372  filter. */
373  if ( *test_str_p == '\0' && *prefix_p != '\0' )
374  {
375  return FCT_FALSE;
376  }
377 
378  /* is_match will be set to the either FCT_TRUE if we kicked of the loop
379  early because our filter ran out of characters or FCT_FALSE if we
380  encountered a mismatch before our filter ran out of characters. */
381  return is_match;
382 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_TRUE
Definition: switch_fct.h:86
#define FCT_FALSE
Definition: switch_fct.h:87
#define nbool_t
Definition: switch_fct.h:85

◆ fct_junit_logger__on_delete()

static void fct_junit_logger__on_delete ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 3175 of file switch_fct.h.

References fct_unused.

Referenced by fct_junit_logger_new().

3179 {
3180  fct_junit_logger_t *logger = (fct_junit_logger_t*)logger_;
3181  fct_unused(e);
3182  free(logger);
3183  logger_ =NULL;
3184 }
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_junit_logger__on_fct_start()

static void fct_junit_logger__on_fct_start ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 3152 of file switch_fct.h.

References fct_unused.

Referenced by fct_junit_logger_new().

3156 {
3157  fct_unused(logger_);
3158  fct_unused(e);
3159  printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
3160  printf("<testsuites>\n");
3161 }
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_junit_logger__on_fctx_end()

static void fct_junit_logger__on_fctx_end ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 3164 of file switch_fct.h.

References fct_unused.

Referenced by fct_junit_logger_new().

3168 {
3169  fct_unused(logger_);
3170  fct_unused(e);
3171  printf("</testsuites>\n");
3172 }
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_junit_logger__on_test_suite_end()

static void fct_junit_logger__on_test_suite_end ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 3050 of file switch_fct.h.

References _fct_read, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fct_stderr_pipe, fct_stdout_pipe, FCT_SWITCH_STDERR_TO_STDERR, FCT_SWITCH_STDOUT_TO_STDOUT, fct_test__duration(), fct_test__is_pass(), fct_test__name, fct_ts__duration(), fct_ts__name, fct_ts__tst_cnt(), fct_ts__tst_cnt_passed(), fct_unused, nbool_t, _fct_ts_t::test_list, and _fct_logger_evt_t::ts.

Referenced by fct_junit_logger_new().

3054 {
3055  fct_ts_t const *ts = e->ts; /* Test Suite */
3056  nbool_t is_pass;
3057  double elasped_time = 0;
3058  char std_buffer[1024];
3059  int read_length;
3060  int first_out_line;
3061 
3062  fct_unused(logger_);
3063 
3064  elasped_time = fct_ts__duration(ts);
3065 
3068 
3069  /* opening testsuite tag */
3070  printf("\t<testsuite errors=\"%lu\" failures=\"0\" tests=\"%lu\" "
3071  "name=\"%s\" time=\"%.4f\">\n",
3072  (unsigned long) fct_ts__tst_cnt(ts)
3073  - fct_ts__tst_cnt_passed(ts),
3074  (unsigned long) fct_ts__tst_cnt(ts),
3075  fct_ts__name(ts),
3076  elasped_time);
3077 
3079  {
3080  is_pass = fct_test__is_pass(test);
3081 
3082  /* opening testcase tag */
3083  if (is_pass)
3084  {
3085  printf("\t\t<testcase name=\"%s\" time=\"%.3f\"",
3086  fct_test__name(test),
3087  fct_test__duration(test)
3088  );
3089  }
3090  else
3091  {
3092  printf("\t\t<testcase name=\"%s\" time=\"%.3f\">\n",
3093  fct_test__name(test),
3094  fct_test__duration(test)
3095  );
3096  }
3097 
3098  FCT_NLIST_FOREACH_BGN(fctchk_t*, chk, &(test->failed_chks))
3099  {
3100  /* error tag */
3101  printf("\t\t\t<error message=\"%s\" "
3102  "type=\"fctx\">", chk->msg);
3103  printf("file:%s, line:%d", chk->file, chk->lineno);
3104  printf("</error>\n");
3105  }
3107 
3108  /* closing testcase tag */
3109  if (is_pass)
3110  {
3111  printf(" />\n");
3112  }
3113  else
3114  {
3115  printf("\t\t</testcase>\n");
3116  }
3117  }
3119 
3120  /* print the std streams */
3121  first_out_line = 1;
3122  printf("\t\t<system-out>\n\t\t\t<![CDATA[");
3123  while ( (read_length = _fct_read(fct_stdout_pipe[0], std_buffer, 1024)) > 0)
3124  {
3125  if (first_out_line)
3126  {
3127  printf("\n");
3128  first_out_line = 0;
3129  }
3130  printf("%.*s", read_length, std_buffer);
3131  }
3132  printf("]]>\n\t\t</system-out>\n");
3133 
3134  first_out_line = 1;
3135  printf("\t\t<system-err>\n\t\t\t<![CDATA[");
3136  while ((read_length = _fct_read(fct_stderr_pipe[0], std_buffer, 1024)) > 0)
3137  {
3138  if (first_out_line)
3139  {
3140  printf("\n");
3141  first_out_line = 0;
3142  }
3143  printf("%.*s", read_length, std_buffer);
3144  }
3145  printf("]]>\n\t\t</system-err>\n");
3146 
3147  /* closing testsuite tag */
3148  printf("\t</testsuite>\n");
3149 }
#define FCT_SWITCH_STDOUT_TO_STDOUT()
Definition: switch_fct.h:239
#define _fct_read
Definition: switch_fct.h:209
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
#define FCT_SWITCH_STDERR_TO_STDERR()
Definition: switch_fct.h:243
static double fct_test__duration(fct_test_t const *test)
Definition: switch_fct.h:1020
static size_t fct_ts__tst_cnt(fct_ts_t const *ts)
Definition: switch_fct.h:1310
static int fct_stdout_pipe[2]
Definition: switch_fct.h:184
static nbool_t fct_test__is_pass(fct_test_t const *test)
Definition: switch_fct.h:1028
#define fct_ts__name(ts)
Definition: switch_fct.h:1141
static double fct_ts__duration(fct_ts_t const *ts)
Definition: switch_fct.h:1360
static size_t fct_ts__tst_cnt_passed(fct_ts_t const *ts)
Definition: switch_fct.h:1323
#define fct_unused(x)
Definition: switch_fct.h:164
static int fct_stderr_pipe[2]
Definition: switch_fct.h:185
fct_nlist_t test_list
Definition: switch_fct.h:1122
#define fct_test__name(_TEST_)
Definition: switch_fct.h:943
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690
#define nbool_t
Definition: switch_fct.h:85

◆ fct_junit_logger__on_test_suite_start()

static void fct_junit_logger__on_test_suite_start ( fct_logger_i l,
fct_logger_evt_t const *  e 
)
static

Definition at line 3037 of file switch_fct.h.

References FCT_SWITCH_STDERR_TO_BUFFER, FCT_SWITCH_STDOUT_TO_BUFFER, and fct_unused.

Referenced by fct_junit_logger_new().

3041 {
3042  fct_unused(l);
3043  fct_unused(e);
3046 }
#define fct_unused(x)
Definition: switch_fct.h:164
#define FCT_SWITCH_STDERR_TO_BUFFER()
Definition: switch_fct.h:241
#define FCT_SWITCH_STDOUT_TO_BUFFER()
Definition: switch_fct.h:237

◆ fct_junit_logger_new()

fct_junit_logger_t * fct_junit_logger_new ( void  )
static

Definition at line 3188 of file switch_fct.h.

References fct_junit_logger__on_delete(), fct_junit_logger__on_fct_start(), fct_junit_logger__on_fctx_end(), fct_junit_logger__on_test_suite_end(), fct_junit_logger__on_test_suite_start(), and fct_logger__init().

3189 {
3190  fct_junit_logger_t *logger =
3191  (fct_junit_logger_t *)calloc(1, sizeof(fct_junit_logger_t));
3192  if ( logger == NULL )
3193  {
3194  return NULL;
3195  }
3196  fct_logger__init((fct_logger_i*)logger);
3197  logger->vtable.on_test_suite_start = fct_junit_logger__on_test_suite_start;
3198  logger->vtable.on_test_suite_end = fct_junit_logger__on_test_suite_end;
3199  logger->vtable.on_fctx_start = fct_junit_logger__on_fct_start;
3200  logger->vtable.on_fctx_end = fct_junit_logger__on_fctx_end;
3201  logger->vtable.on_delete = fct_junit_logger__on_delete;
3202  return logger;
3203 }
static void fct_logger__init(fct_logger_i *logger)
Definition: switch_fct.h:2594
static void fct_junit_logger__on_test_suite_end(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:3050
static void fct_junit_logger__on_fct_start(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:3152
static void fct_junit_logger__on_delete(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:3175
static void fct_junit_logger__on_fctx_end(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:3164
static void fct_junit_logger__on_test_suite_start(fct_logger_i *l, fct_logger_evt_t const *e)
Definition: switch_fct.h:3037

◆ fct_logger__del()

static void fct_logger__del ( fct_logger_i logger)
static

Definition at line 2606 of file switch_fct.h.

Referenced by fctkern__final().

2607 {
2608  if ( logger )
2609  {
2610  logger->vtable.on_delete(logger, &(logger->evt));
2611  }
2612 }

◆ fct_logger__init()

static void fct_logger__init ( fct_logger_i logger)
static

Definition at line 2594 of file switch_fct.h.

References FCT_ASSERT, and memset().

Referenced by fct_junit_logger_new(), fct_minimal_logger_new(), and fct_standard_logger_new().

2595 {
2596  FCT_ASSERT( logger != NULL );
2597  memcpy(
2598  &(logger->vtable),
2600  sizeof(fct_logger_i_vtable_t)
2601  );
2602  memset(&(logger->evt),0, sizeof(fct_logger_evt_t));
2603 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static fct_logger_i_vtable_t fct_logger_default_vtable
Definition: switch_fct.h:2575
memset(buf, 0, buflen)

◆ fct_logger__on_chk()

static void fct_logger__on_chk ( fct_logger_i self,
fctchk_t const *  chk 
)
static

Definition at line 2674 of file switch_fct.h.

Referenced by fctkern__log_chk().

2675 {
2676  logger->evt.chk = chk;
2677  logger->vtable.on_chk(logger, &(logger->evt));
2678 }

◆ fct_logger__on_test_end()

static void fct_logger__on_test_end ( fct_logger_i logger,
fct_test_t test 
)
static

Definition at line 2624 of file switch_fct.h.

Referenced by fctkern__log_test_end().

2625 {
2626  logger->evt.test = test;
2627  logger->vtable.on_test_end(logger, &(logger->evt));
2628 }

◆ fct_logger__on_test_skip()

static void fct_logger__on_test_skip ( fct_logger_i logger,
char const *  condition,
char const *  name 
)
static

Definition at line 2661 of file switch_fct.h.

References name.

Referenced by fctkern__log_test_skip().

2666 {
2667  logger->evt.cndtn = condition;
2668  logger->evt.name = name;
2669  logger->vtable.on_test_skip(logger, &(logger->evt));
2670 }
const char *const name
Definition: switch_cJSON.h:250

◆ fct_logger__on_test_start()

static void fct_logger__on_test_start ( fct_logger_i logger,
fct_test_t const *  test 
)
static

Definition at line 2616 of file switch_fct.h.

Referenced by fctkern__log_test_start().

2617 {
2618  logger->evt.test = test;
2619  logger->vtable.on_test_start(logger, &(logger->evt));
2620 }

◆ fct_logger__on_test_suite_end()

static void fct_logger__on_test_suite_end ( fct_logger_i logger,
fct_ts_t const *  ts 
)
static

Definition at line 2640 of file switch_fct.h.

Referenced by fctkern__log_suite_end().

2641 {
2642  logger->evt.ts = ts;
2643  logger->vtable.on_test_suite_end(logger, &(logger->evt));
2644 }

◆ fct_logger__on_test_suite_skip()

static void fct_logger__on_test_suite_skip ( fct_logger_i logger,
char const *  condition,
char const *  name 
)
static

Definition at line 2648 of file switch_fct.h.

References name.

Referenced by fctkern__log_suite_skip().

2653 {
2654  logger->evt.cndtn = condition;
2655  logger->evt.name = name;
2656  logger->vtable.on_test_suite_skip(logger, &(logger->evt));
2657 }
const char *const name
Definition: switch_cJSON.h:250

◆ fct_logger__on_test_suite_start()

static void fct_logger__on_test_suite_start ( fct_logger_i logger,
fct_ts_t const *  ts 
)
static

Definition at line 2632 of file switch_fct.h.

Referenced by fctkern__log_suite_start().

2633 {
2634  logger->evt.ts = ts;
2635  logger->vtable.on_test_suite_start(logger, &(logger->evt));
2636 }

◆ fct_logger__on_warn()

static void fct_logger__on_warn ( fct_logger_i logger,
char const *  warn 
)
static

Definition at line 2693 of file switch_fct.h.

Referenced by fctkern__log_warn().

2694 {
2695  logger->evt.msg = msg;
2696  logger->vtable.on_warn(logger, &(logger->evt));
2697 }

◆ fct_logger__stub()

static void fct_logger__stub ( fct_logger_i l,
fct_logger_evt_t const *  e 
)
static

Definition at line 2568 of file switch_fct.h.

References fct_unused.

2569 {
2570  fct_unused(l);
2571  fct_unused(e);
2572 }
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_logger_print_failures()

static void fct_logger_print_failures ( fct_nlist_t const *  fail_list)
static

Definition at line 2715 of file switch_fct.h.

References FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fctchk__file, fctchk__lineno, fctchk__msg, and fctchk__name.

Referenced by fct_minimal_logger__on_fctx_end(), and fct_standard_logger__on_fctx_end().

2716 {
2717  const char *last_test = NULL;
2718  puts(
2719  "\n----------------------------------------------------------------------------\n"
2720  );
2721  puts("FAILED TESTS\n");
2722  FCT_NLIST_FOREACH_BGN(fctchk_t const *, chk, fail_list)
2723  {
2724  if (!last_test || strcmp(last_test, fctchk__name(chk))) {
2725  printf("\n%s\n", fctchk__name(chk));
2726  }
2727  last_test = fctchk__name(chk);
2728  printf(" %s(%d):\n %s\n",
2729  fctchk__file(chk),
2730  fctchk__lineno(chk),
2731  fctchk__msg(chk));
2732  }
2734 
2735  puts("\n");
2736 }
#define fctchk__name(_CHK_)
Definition: switch_fct.h:862
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
#define fctchk__msg(_CHK_)
Definition: switch_fct.h:861
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690
#define fctchk__file(_CHK_)
Definition: switch_fct.h:858
#define fctchk__lineno(_CHK_)
Definition: switch_fct.h:859

◆ fct_logger_record_failure()

static void fct_logger_record_failure ( fctchk_t const *  chk,
fct_nlist_t fail_list 
)
static

Definition at line 2704 of file switch_fct.h.

References FCT_ASSERT, and fct_nlist__append().

Referenced by fct_minimal_logger__on_chk(), and fct_standard_logger__on_chk().

2705 {
2706  fctchk_t *dup_chk = (fctchk_t *)malloc(sizeof(*dup_chk));
2707  FCT_ASSERT( dup_chk != NULL );
2708  memcpy(dup_chk, chk, sizeof(*dup_chk));
2709  fct_nlist__append(fail_list, (void *)dup_chk);
2710 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fct_minimal_logger__on_chk()

static void fct_minimal_logger__on_chk ( fct_logger_i self_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2764 of file switch_fct.h.

References _fct_logger_evt_t::chk, fct_logger_record_failure(), and fctchk__is_pass.

Referenced by fct_minimal_logger_new().

2768 {
2770  if ( fctchk__is_pass(e->chk) )
2771  {
2772  fputs(".", stdout);
2773  }
2774  else
2775  {
2776  fputs("x", stdout);
2777  fct_logger_record_failure(e->chk, &(self->failed_cndtns_list));
2778 
2779  }
2780 }
static void fct_logger_record_failure(fctchk_t const *chk, fct_nlist_t *fail_list)
Definition: switch_fct.h:2704
#define fctchk__is_pass(_CHK_)
Definition: switch_fct.h:857

◆ fct_minimal_logger__on_delete()

static void fct_minimal_logger__on_delete ( fct_logger_i self_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2798 of file switch_fct.h.

References fct_nlist__final(), fct_unused, and fctchk__del().

Referenced by fct_minimal_logger_new().

2802 {
2804  fct_unused(e);
2805  fct_nlist__final(&(self->failed_cndtns_list), (fct_nlist_on_del_t)fctchk__del);
2806  free(self);
2807 
2808 }
void(* fct_nlist_on_del_t)(void *)
Definition: switch_fct.h:716
static void fctchk__del(fctchk_t *chk)
Definition: switch_fct.h:910
static void fct_nlist__final(fct_nlist_t *list, fct_nlist_on_del_t on_del)
Definition: switch_fct.h:741
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_minimal_logger__on_fctx_end()

static void fct_minimal_logger__on_fctx_end ( fct_logger_i self_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2783 of file switch_fct.h.

References fct_logger_print_failures(), fct_nlist__size(), and fct_unused.

Referenced by fct_minimal_logger_new().

2787 {
2789  fct_unused(e);
2790  if ( fct_nlist__size(&(self->failed_cndtns_list)) >0 )
2791  {
2792  fct_logger_print_failures(&(self->failed_cndtns_list));
2793  }
2794 }
static size_t fct_nlist__size(fct_nlist_t const *list)
Definition: switch_fct.h:785
static void fct_logger_print_failures(fct_nlist_t const *fail_list)
Definition: switch_fct.h:2715
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_minimal_logger_new()

fct_logger_i * fct_minimal_logger_new ( void  )
static

Definition at line 2812 of file switch_fct.h.

References fct_logger__init(), fct_minimal_logger__on_chk(), fct_minimal_logger__on_delete(), fct_minimal_logger__on_fctx_end(), and fct_nlist__init2().

2813 {
2815  calloc(1,sizeof(fct_minimal_logger_t));
2816  if ( self == NULL )
2817  {
2818  return NULL;
2819  }
2821  self->vtable.on_chk = fct_minimal_logger__on_chk;
2822  self->vtable.on_fctx_end = fct_minimal_logger__on_fctx_end;
2823  self->vtable.on_delete = fct_minimal_logger__on_delete;
2824  fct_nlist__init2(&(self->failed_cndtns_list), 0);
2825  return (fct_logger_i*)self;
2826 }
static void fct_logger__init(fct_logger_i *logger)
Definition: switch_fct.h:2594
static void fct_minimal_logger__on_fctx_end(fct_logger_i *self_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2783
static void fct_minimal_logger__on_delete(fct_logger_i *self_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2798
static int fct_nlist__init2(fct_nlist_t *list, size_t start_sz)
Definition: switch_fct.h:751
static void fct_minimal_logger__on_chk(fct_logger_i *self_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2764

◆ fct_namespace_init()

static void fct_namespace_init ( fct_namespace_t ns)
static

Definition at line 1842 of file switch_fct.h.

References FCT_ASSERT, and memset().

Referenced by fctkern__init().

1843 {
1844  FCT_ASSERT( ns != NULL && "invalid argument!");
1845  memset(ns, 0, sizeof(fct_namespace_t));
1846 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
memset(buf, 0, buflen)

◆ fct_nlist__append()

static void fct_nlist__append ( fct_nlist_t list,
void *  itm 
)
static

Definition at line 803 of file switch_fct.h.

References _fct_nlist_t::avail_itm_num, FCT_ASSERT, FCT_LIST_GROWTH_FACTOR, _fct_nlist_t::itm_list, and _fct_nlist_t::used_itm_num.

Referenced by fct_clp__add_options(), fct_clp__parse(), fct_logger_record_failure(), fct_test__add(), fct_ts__add_test(), fctkern__add_logger(), fctkern__add_prefix_filter(), and fctkern__add_ts().

804 {
805  FCT_ASSERT( list != NULL );
806  /* If we ran out of room, then the last increment should be equal to the
807  available space, in this case we need to grow a little more. If this
808  list started as size 0, then we should encounter the same effect as
809  "running out of room." */
810  if ( list->used_itm_num == list->avail_itm_num )
811  {
812  /* Use multiple and add, since the avail_itm_num could be 0. */
814  FCT_LIST_GROWTH_FACTOR;
815  list->itm_list = (void**)realloc(
816  list->itm_list, sizeof(void*)*list->avail_itm_num
817  );
818  FCT_ASSERT( list->itm_list != NULL && "memory check");
819  }
820 
821  list->itm_list[list->used_itm_num] = itm;
822  ++(list->used_itm_num);
823 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
size_t used_itm_num
Definition: switch_fct.h:714
size_t avail_itm_num
Definition: switch_fct.h:711
#define FCT_LIST_GROWTH_FACTOR
Definition: switch_fct.h:674
void ** itm_list
Definition: switch_fct.h:708

◆ fct_nlist__at()

static void* fct_nlist__at ( fct_nlist_t const *  list,
size_t  idx 
)
static

Definition at line 794 of file switch_fct.h.

References FCT_ASSERT, and _fct_nlist_t::itm_list.

Referenced by fctkern__pass_filter().

795 {
796  FCT_ASSERT( list != NULL );
797  FCT_ASSERT( idx < list->used_itm_num );
798  return list->itm_list[idx];
799 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_nlist__clear()

static void fct_nlist__clear ( fct_nlist_t list,
fct_nlist_on_del_t  on_del 
)
static

Definition at line 723 of file switch_fct.h.

References FCT_ASSERT, _fct_nlist_t::itm_list, and _fct_nlist_t::used_itm_num.

Referenced by fct_nlist__final().

724 {
725  size_t itm_i__ =0;
726  FCT_ASSERT( list != NULL );
727  if ( on_del != NULL )
728  {
729  for ( itm_i__=0; itm_i__ != list->used_itm_num; ++itm_i__ )
730  {
731  on_del(list->itm_list[itm_i__]);
732  }
733  }
734  list->used_itm_num =0;
735 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
size_t used_itm_num
Definition: switch_fct.h:714
void ** itm_list
Definition: switch_fct.h:708

◆ fct_nlist__final()

static void fct_nlist__final ( fct_nlist_t list,
fct_nlist_on_del_t  on_del 
)
static

Definition at line 741 of file switch_fct.h.

References FCT_ASSERT, fct_nlist__clear(), and _fct_nlist_t::itm_list.

Referenced by fct_clp__final(), fct_minimal_logger__on_delete(), fct_standard_logger__on_delete(), fct_test__del(), fct_ts__del(), and fctkern__final().

742 {
743  FCT_ASSERT( list != NULL );
744  fct_nlist__clear(list, on_del);
745  free(list->itm_list);
746  list->itm_list = NULL;
747 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static void fct_nlist__clear(fct_nlist_t *list, fct_nlist_on_del_t on_del)
Definition: switch_fct.h:723
void ** itm_list
Definition: switch_fct.h:708

◆ fct_nlist__init2()

static int fct_nlist__init2 ( fct_nlist_t list,
size_t  start_sz 
)
static

Definition at line 751 of file switch_fct.h.

References _fct_nlist_t::avail_itm_num, FCT_ASSERT, _fct_nlist_t::itm_list, and _fct_nlist_t::used_itm_num.

Referenced by fct_minimal_logger_new(), fct_standard_logger_new(), fct_test_new(), and fctkern__init().

752 {
753  FCT_ASSERT( list != NULL );
754  if ( start_sz == 0 )
755  {
756  list->itm_list = NULL;
757  }
758  else
759  {
760  list->itm_list = (void**)malloc(sizeof(void*)*start_sz);
761  if ( list->itm_list == NULL )
762  {
763  list->used_itm_num = 0;
764  return 0;
765  }
766  }
767  /* If these are both 0, then they are equal and that means
768  that the first append operation will allocate memory. The beauty
769  here is that if the list remains empty, then we save a malloc.
770  Empty lists are relatively common in FCT (consider an error list). */
771  list->avail_itm_num = start_sz;
772  list->used_itm_num =0;
773  return 1;
774 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
size_t used_itm_num
Definition: switch_fct.h:714
size_t avail_itm_num
Definition: switch_fct.h:711
void ** itm_list
Definition: switch_fct.h:708

◆ fct_nlist__size()

static size_t fct_nlist__size ( fct_nlist_t const *  list)
static

Definition at line 785 of file switch_fct.h.

References FCT_ASSERT, and _fct_nlist_t::used_itm_num.

Referenced by fct_minimal_logger__on_fctx_end(), fct_standard_logger__on_fctx_end(), fct_test__chk_cnt(), fct_test__is_pass(), and fct_ts__tst_cnt().

786 {
787  FCT_ASSERT( list != NULL );
788  return list->used_itm_num;
789 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_snprintf()

static int fct_snprintf ( char *  buffer,
size_t  buffer_len,
char const *  format,
  ... 
)
static

Definition at line 287 of file switch_fct.h.

References count, and fct_vsnprintf().

Referenced by fct_clp__parse(), fct_standard_logger__on_test_skip(), and fct_ts__make_abort_test().

288 {
289  int count =0;
290  va_list args;
291  va_start(args, format);
292  count =fct_vsnprintf(buffer, buffer_len, format, args);
293  va_end(args);
294  return count;
295 }
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
char * buffer
Definition: switch_cJSON.h:153
int count
Definition: switch_cJSON.h:204
static int fct_vsnprintf(char *buffer, size_t buffer_len, char const *format, va_list args)
Definition: switch_fct.h:265

◆ fct_standard_logger__on_chk()

static void fct_standard_logger__on_chk ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2853 of file switch_fct.h.

References _fct_logger_evt_t::chk, _fct_standard_logger_t::failed_cndtns_list, fct_logger_record_failure(), fctchk__file, fctchk__is_pass, fctchk__lineno, and fctchk__msg.

Referenced by fct_standard_logger_new().

2857 {
2858  fct_standard_logger_t *logger = (fct_standard_logger_t*)logger_;
2859  /* Only record failures. */
2860  if ( !fctchk__is_pass(e->chk) )
2861  {
2862  printf("\nTEST FAIL: %s(%d): %s\n",
2863  fctchk__file(e->chk),
2864  fctchk__lineno(e->chk),
2865  fctchk__msg(e->chk));
2866  fct_logger_record_failure(e->chk, &(logger->failed_cndtns_list));
2867  }
2868 }
fct_nlist_t failed_cndtns_list
Definition: switch_fct.h:2843
static void fct_logger_record_failure(fctchk_t const *chk, fct_nlist_t *fail_list)
Definition: switch_fct.h:2704
#define fctchk__is_pass(_CHK_)
Definition: switch_fct.h:857
#define fctchk__msg(_CHK_)
Definition: switch_fct.h:861
#define fctchk__file(_CHK_)
Definition: switch_fct.h:858
#define fctchk__lineno(_CHK_)
Definition: switch_fct.h:859

◆ fct_standard_logger__on_delete()

static void fct_standard_logger__on_delete ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2973 of file switch_fct.h.

References _fct_standard_logger_t::failed_cndtns_list, fct_nlist__final(), fct_unused, and fctchk__del().

Referenced by fct_standard_logger_new().

2977 {
2978  fct_standard_logger_t *logger = (fct_standard_logger_t*)logger_;
2979  fct_unused(e);
2981  free(logger);
2982  logger_ =NULL;
2983 }
void(* fct_nlist_on_del_t)(void *)
Definition: switch_fct.h:716
static void fctchk__del(fctchk_t *chk)
Definition: switch_fct.h:910
fct_nlist_t failed_cndtns_list
Definition: switch_fct.h:2843
static void fct_nlist__final(fct_nlist_t *list, fct_nlist_on_del_t on_del)
Definition: switch_fct.h:741
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_standard_logger__on_fctx_end()

static void fct_standard_logger__on_fctx_end ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2929 of file switch_fct.h.

References _fct_standard_logger_t::failed_cndtns_list, fct_logger_print_failures(), fct_nlist__size(), fct_timer__duration(), fct_timer__stop(), fctkern__tst_cnt(), fctkern__tst_cnt_passed(), _fct_logger_evt_t::kern, nbool_t, and _fct_standard_logger_t::timer.

Referenced by fct_standard_logger_new().

2933 {
2934  fct_standard_logger_t *logger = (fct_standard_logger_t*)logger_;
2935  nbool_t is_success =1;
2936  double elasped_time =0;
2937  size_t num_tests =0;
2938  size_t num_passed =0;
2939 
2940  fct_timer__stop(&(logger->timer));
2941 
2942  is_success = fct_nlist__size(&(logger->failed_cndtns_list)) ==0;
2943 
2944  if ( !is_success )
2945  {
2947  }
2948  puts(
2949  "\n----------------------------------------------------------------------------\n"
2950  );
2951  num_tests = fctkern__tst_cnt(e->kern);
2952  num_passed = fctkern__tst_cnt_passed(e->kern);
2953  printf(
2954  "%s (%lu/%lu tests",
2955  (is_success) ? "PASSED" : "FAILED",
2956  (unsigned long) num_passed,
2957  (unsigned long) num_tests
2958  );
2959  elasped_time = fct_timer__duration(&(logger->timer));
2960  if ( elasped_time > 0.0000001 )
2961  {
2962  printf(" in %.6fs)\n", elasped_time);
2963  }
2964  else
2965  {
2966  /* Don't bother displaying the time to execute. */
2967  puts(")\n");
2968  }
2969 }
static void fct_timer__stop(fct_timer_t *timer)
Definition: switch_fct.h:650
static size_t fct_nlist__size(fct_nlist_t const *list)
Definition: switch_fct.h:785
fct_nlist_t failed_cndtns_list
Definition: switch_fct.h:2843
static double fct_timer__duration(fct_timer_t const *timer)
Definition: switch_fct.h:660
static void fct_logger_print_failures(fct_nlist_t const *fail_list)
Definition: switch_fct.h:2715
static size_t fctkern__tst_cnt_passed(fctkern_t const *nk)
Definition: switch_fct.h:2294
static size_t fctkern__tst_cnt(fctkern_t const *nk)
Definition: switch_fct.h:2279
#define nbool_t
Definition: switch_fct.h:85

◆ fct_standard_logger__on_fctx_start()

static void fct_standard_logger__on_fctx_start ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2917 of file switch_fct.h.

References fct_timer__start(), fct_unused, and _fct_standard_logger_t::timer.

Referenced by fct_standard_logger_new().

2921 {
2922  fct_standard_logger_t *logger = (fct_standard_logger_t*)logger_;
2923  fct_unused(e);
2924  fct_timer__start(&(logger->timer));
2925 }
static void fct_timer__start(fct_timer_t *timer)
Definition: switch_fct.h:642
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_standard_logger__on_test_end()

static void fct_standard_logger__on_test_end ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2904 of file switch_fct.h.

References fct_dotted_line_end(), fct_test__is_pass(), fct_unused, nbool_t, and _fct_logger_evt_t::test.

Referenced by fct_standard_logger_new().

2908 {
2909  nbool_t is_pass;
2910  fct_unused(logger_);
2911  is_pass = fct_test__is_pass(e->test);
2912  fct_dotted_line_end((is_pass) ? "PASS" : "FAIL ***" );
2913 }
static nbool_t fct_test__is_pass(fct_test_t const *test)
Definition: switch_fct.h:1028
#define fct_unused(x)
Definition: switch_fct.h:164
static void fct_dotted_line_end(char const *endswith)
Definition: switch_fct.h:608
#define nbool_t
Definition: switch_fct.h:85

◆ fct_standard_logger__on_test_skip()

static void fct_standard_logger__on_test_skip ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2872 of file switch_fct.h.

References _fct_logger_evt_t::cndtn, fct_dotted_line_end(), fct_dotted_line_start(), fct_snprintf(), FCT_STANDARD_LOGGER_MAX_LINE, fct_unused, name, and _fct_logger_evt_t::name.

Referenced by fct_standard_logger_new().

2876 {
2877  char const *condition = e->cndtn;
2878  char const *name = e->name;
2879  char msg[256] = {'\0'};
2880  fct_unused(logger_);
2881  fct_unused(condition);
2882  fct_snprintf(msg, sizeof(msg), "%s (%s)", name, condition);
2883  msg[sizeof(msg)-1] = '\0';
2885  fct_dotted_line_end("- SKIP -");
2886 }
static int fct_snprintf(char *buffer, size_t buffer_len, char const *format,...)
Definition: switch_fct.h:287
#define FCT_STANDARD_LOGGER_MAX_LINE
Definition: switch_fct.h:2847
#define fct_unused(x)
Definition: switch_fct.h:164
static void fct_dotted_line_end(char const *endswith)
Definition: switch_fct.h:608
static void fct_dotted_line_start(size_t maxwidth, char const *startwith)
Definition: switch_fct.h:588
const char *const name
Definition: switch_cJSON.h:250

◆ fct_standard_logger__on_test_start()

static void fct_standard_logger__on_test_start ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2890 of file switch_fct.h.

References fct_dotted_line_start(), FCT_STANDARD_LOGGER_MAX_LINE, fct_test__name, fct_unused, and _fct_logger_evt_t::test.

Referenced by fct_standard_logger_new().

2894 {
2895  fct_unused(logger_);
2898  fct_test__name(e->test)
2899  );
2900 }
#define FCT_STANDARD_LOGGER_MAX_LINE
Definition: switch_fct.h:2847
#define fct_unused(x)
Definition: switch_fct.h:164
#define fct_test__name(_TEST_)
Definition: switch_fct.h:943
static void fct_dotted_line_start(size_t maxwidth, char const *startwith)
Definition: switch_fct.h:588

◆ fct_standard_logger__on_warn()

static void fct_standard_logger__on_warn ( fct_logger_i logger_,
fct_logger_evt_t const *  e 
)
static

Definition at line 2987 of file switch_fct.h.

References fct_unused, and _fct_logger_evt_t::msg.

Referenced by fct_standard_logger_new().

2991 {
2992  fct_unused(logger_);
2993  (void)printf("WARNING: %s", e->msg);
2994 }
#define fct_unused(x)
Definition: switch_fct.h:164

◆ fct_standard_logger_new()

fct_logger_i * fct_standard_logger_new ( void  )
static

Definition at line 2998 of file switch_fct.h.

References fct_logger__init(), fct_nlist__init2(), fct_standard_logger__on_chk(), fct_standard_logger__on_delete(), fct_standard_logger__on_fctx_end(), fct_standard_logger__on_fctx_start(), fct_standard_logger__on_test_end(), fct_standard_logger__on_test_skip(), fct_standard_logger__on_test_start(), fct_standard_logger__on_warn(), and fct_timer__init().

2999 {
3000  fct_standard_logger_t *logger = (fct_standard_logger_t *)calloc(
3001  1, sizeof(fct_standard_logger_t)
3002  );
3003  if ( logger == NULL )
3004  {
3005  return NULL;
3006  }
3007  fct_logger__init((fct_logger_i*)logger);
3008  logger->vtable.on_chk = fct_standard_logger__on_chk;
3009  logger->vtable.on_test_start = fct_standard_logger__on_test_start;
3010  logger->vtable.on_test_end = fct_standard_logger__on_test_end;
3011  logger->vtable.on_fctx_start = fct_standard_logger__on_fctx_start;
3012  logger->vtable.on_fctx_end = fct_standard_logger__on_fctx_end;
3013  logger->vtable.on_delete = fct_standard_logger__on_delete;
3014  logger->vtable.on_warn = fct_standard_logger__on_warn;
3015  logger->vtable.on_test_skip = fct_standard_logger__on_test_skip;
3016  fct_nlist__init2(&(logger->failed_cndtns_list), 0);
3017  fct_timer__init(&(logger->timer));
3018  return (fct_logger_i*)logger;
3019 }
static void fct_standard_logger__on_warn(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2987
static void fct_logger__init(fct_logger_i *logger)
Definition: switch_fct.h:2594
fct_nlist_t failed_cndtns_list
Definition: switch_fct.h:2843
static void fct_standard_logger__on_fctx_start(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2917
static void fct_standard_logger__on_chk(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2853
static void fct_standard_logger__on_test_start(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2890
static int fct_nlist__init2(fct_nlist_t *list, size_t start_sz)
Definition: switch_fct.h:751
static void fct_standard_logger__on_test_end(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2904
static void fct_timer__init(fct_timer_t *timer)
Definition: switch_fct.h:634
static void fct_standard_logger__on_delete(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2973
static void fct_standard_logger__on_fctx_end(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2929
static void fct_standard_logger__on_test_skip(fct_logger_i *logger_, fct_logger_evt_t const *e)
Definition: switch_fct.h:2872

◆ fct_switch_std_to_buffer()

static void fct_switch_std_to_buffer ( int  std_pipe[2],
FILE *  out,
int  fileno_,
int *  save_handle 
)
static

Definition at line 216 of file switch_fct.h.

References _fct_close, _fct_dup, _fct_dup2, and _fct_pipe.

217 {
218  fflush(out);
219  *save_handle = _fct_dup(fileno_);
220  if ( _fct_pipe(std_pipe) != 0 )
221  {
222  exit(1);
223  }
224  _fct_dup2(std_pipe[1], fileno_);
225  _fct_close(std_pipe[1]);
226 }
#define _fct_dup
Definition: switch_fct.h:206
#define _fct_close
Definition: switch_fct.h:208
#define _fct_pipe
Definition: switch_fct.h:205
#define _fct_dup2
Definition: switch_fct.h:207

◆ fct_switch_std_to_std()

static void fct_switch_std_to_std ( FILE *  out,
int  fileno_,
int  save_handle 
)
static

Definition at line 230 of file switch_fct.h.

References _fct_dup2.

231 {
232  fflush(out);
233  _fct_dup2(save_handle, fileno_);
234 }
#define _fct_dup2
Definition: switch_fct.h:207

◆ fct_test__add()

static void fct_test__add ( fct_test_t test,
fctchk_t chk 
)
static

Definition at line 1036 of file switch_fct.h.

References _fct_test_t::failed_chks, FCT_ASSERT, fct_nlist__append(), fctchk__is_pass, and _fct_test_t::passed_chks.

Referenced by _fct_xchk_fn_varg().

1037 {
1038 
1039  FCT_ASSERT( test != NULL );
1040  FCT_ASSERT( chk != NULL );
1041 
1042  if ( fctchk__is_pass(chk) )
1043  {
1044  fct_nlist__append(&(test->passed_chks), (void*)chk);
1045  }
1046  else
1047  {
1048  fct_nlist__append(&(test->failed_chks), (void*)chk);
1049  }
1050 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t passed_chks
Definition: switch_fct.h:934
#define fctchk__is_pass(_CHK_)
Definition: switch_fct.h:857
fct_nlist_t failed_chks
Definition: switch_fct.h:933
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fct_test__chk_cnt()

static size_t fct_test__chk_cnt ( fct_test_t const *  test)
static

Definition at line 1054 of file switch_fct.h.

References _fct_test_t::failed_chks, FCT_ASSERT, fct_nlist__size(), and _fct_test_t::passed_chks.

Referenced by fct_ts__chk_cnt().

1055 {
1056  FCT_ASSERT( test != NULL );
1057  return fct_nlist__size(&(test->failed_chks)) \
1058  + fct_nlist__size(&(test->passed_chks));
1059 }
static size_t fct_nlist__size(fct_nlist_t const *list)
Definition: switch_fct.h:785
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_test__del()

static void fct_test__del ( fct_test_t test)
static

Definition at line 951 of file switch_fct.h.

References _fct_test_t::failed_chks, fct_nlist__final(), fctchk__del(), and _fct_test_t::passed_chks.

Referenced by fct_test_new(), and fct_ts__del().

952 {
953  if (test == NULL )
954  {
955  return;
956  }
959  free(test);
960 }
void(* fct_nlist_on_del_t)(void *)
Definition: switch_fct.h:716
static void fctchk__del(fctchk_t *chk)
Definition: switch_fct.h:910
static void fct_nlist__final(fct_nlist_t *list, fct_nlist_on_del_t on_del)
Definition: switch_fct.h:741
fct_nlist_t passed_chks
Definition: switch_fct.h:934
fct_nlist_t failed_chks
Definition: switch_fct.h:933

◆ fct_test__duration()

static double fct_test__duration ( fct_test_t const *  test)
static

Definition at line 1020 of file switch_fct.h.

References FCT_ASSERT, fct_timer__duration(), nbool_t, and _fct_test_t::timer.

Referenced by fct_junit_logger__on_test_suite_end(), and fct_ts__duration().

1021 {
1022  FCT_ASSERT( test != NULL );
1023  return fct_timer__duration(&(test->timer));
1024 }
static double fct_timer__duration(fct_timer_t const *timer)
Definition: switch_fct.h:660
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_test__is_pass()

static nbool_t fct_test__is_pass ( fct_test_t const *  test)
static

Definition at line 1028 of file switch_fct.h.

References _fct_test_t::failed_chks, FCT_ASSERT, and fct_nlist__size().

Referenced by fct_junit_logger__on_test_suite_end(), fct_standard_logger__on_test_end(), and fct_ts__tst_cnt_passed().

1029 {
1030  FCT_ASSERT( test != NULL );
1031  return fct_nlist__size(&(test->failed_chks)) == 0;
1032 }
static size_t fct_nlist__size(fct_nlist_t const *list)
Definition: switch_fct.h:785
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_test__start_timer()

static void fct_test__start_timer ( fct_test_t test)
static

Definition at line 1004 of file switch_fct.h.

References FCT_ASSERT, fct_timer__start(), and _fct_test_t::timer.

1005 {
1006  FCT_ASSERT( test != NULL );
1007  fct_timer__start(&(test->timer));
1008 }
fct_timer_t timer
Definition: switch_fct.h:937
static void fct_timer__start(fct_timer_t *timer)
Definition: switch_fct.h:642
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_test__stop_timer()

static void fct_test__stop_timer ( fct_test_t test)
static

Definition at line 1012 of file switch_fct.h.

References FCT_ASSERT, fct_timer__stop(), and _fct_test_t::timer.

1013 {
1014  FCT_ASSERT( test != NULL );
1015  fct_timer__stop(&(test->timer));
1016 }
fct_timer_t timer
Definition: switch_fct.h:937
static void fct_timer__stop(fct_timer_t *timer)
Definition: switch_fct.h:650
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_test_new()

static fct_test_t* fct_test_new ( char const *  name)
static

Definition at line 964 of file switch_fct.h.

References _fct_test_t::failed_chks, FCT_FALSE, FCT_MAX_NAME, fct_nlist__init, fct_nlist__init2(), fct_test__del(), fct_timer__init(), FCT_TRUE, fctstr_safe_cpy(), _fct_test_t::name, nbool_t, _fct_test_t::passed_chks, and _fct_test_t::timer.

Referenced by fct_ts__make_abort_test().

965 {
966  nbool_t ok =FCT_FALSE;
967  fct_test_t *test =NULL;
968 
969 #ifndef __clang_analyzer__
970  test = (fct_test_t*)malloc(sizeof(fct_test_t));
971 #else
972  test = NULL;
973 #endif
974  if ( test == NULL )
975  {
976  return NULL;
977  }
978 
980 
981  /* Failures are an exception, so lets not allocate up
982  the list until we need to. */
983  fct_nlist__init2(&(test->failed_chks), 0);
984  if (!fct_nlist__init(&(test->passed_chks)))
985  {
986  ok =FCT_FALSE;
987  goto finally;
988  }
989 
990  fct_timer__init(&(test->timer));
991 
992  ok =FCT_TRUE;
993 finally:
994  if ( !ok )
995  {
996  fct_test__del(test);
997  test =NULL;
998  }
999  return test;
1000 }
fct_timer_t timer
Definition: switch_fct.h:937
char name[FCT_MAX_NAME]
Definition: switch_fct.h:940
static void fct_test__del(fct_test_t *test)
Definition: switch_fct.h:951
static int fct_nlist__init2(fct_nlist_t *list, size_t start_sz)
Definition: switch_fct.h:751
#define FCT_MAX_NAME
Definition: switch_fct.h:82
#define fct_nlist__init(_LIST_PTR_)
Definition: switch_fct.h:779
static void fct_timer__init(fct_timer_t *timer)
Definition: switch_fct.h:634
fct_nlist_t passed_chks
Definition: switch_fct.h:934
#define FCT_TRUE
Definition: switch_fct.h:86
#define FCT_FALSE
Definition: switch_fct.h:87
const char *const name
Definition: switch_cJSON.h:250
fct_nlist_t failed_chks
Definition: switch_fct.h:933
static void fctstr_safe_cpy(char *dst, char const *src, size_t num)
Definition: switch_fct.h:250
#define nbool_t
Definition: switch_fct.h:85

◆ fct_timer__duration()

static double fct_timer__duration ( fct_timer_t const *  timer)
static

Definition at line 660 of file switch_fct.h.

References _fct_timer_t::duration, and FCT_ASSERT.

Referenced by fct_standard_logger__on_fctx_end(), and fct_test__duration().

661 {
662  FCT_ASSERT( timer != NULL );
663  return timer->duration;
664 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_timer__init()

static void fct_timer__init ( fct_timer_t timer)
static

Definition at line 634 of file switch_fct.h.

References FCT_ASSERT, and memset().

Referenced by fct_standard_logger_new(), and fct_test_new().

635 {
636  FCT_ASSERT(timer != NULL);
637  memset(timer, 0, sizeof(fct_timer_t));
638 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
memset(buf, 0, buflen)

◆ fct_timer__start()

static void fct_timer__start ( fct_timer_t timer)
static

Definition at line 642 of file switch_fct.h.

References FCT_ASSERT, and _fct_timer_t::start.

Referenced by fct_standard_logger__on_fctx_start(), and fct_test__start_timer().

643 {
644  FCT_ASSERT(timer != NULL);
645  timer->start = clock();
646 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
clock_t start
Definition: switch_fct.h:627

◆ fct_timer__stop()

static void fct_timer__stop ( fct_timer_t timer)
static

Definition at line 650 of file switch_fct.h.

References _fct_timer_t::duration, FCT_ASSERT, _fct_timer_t::start, and _fct_timer_t::stop.

Referenced by fct_standard_logger__on_fctx_end(), and fct_test__stop_timer().

651 {
652  FCT_ASSERT(timer != NULL);
653  timer->stop = clock();
654  timer->duration = (double) (timer->stop - timer->start) / CLOCKS_PER_SEC;
655 }
clock_t stop
Definition: switch_fct.h:628
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
double duration
Definition: switch_fct.h:629
clock_t start
Definition: switch_fct.h:627

◆ fct_ts__add_test()

static void fct_ts__add_test ( fct_ts_t ts,
fct_test_t test 
)
static

Definition at line 1191 of file switch_fct.h.

References FCT_ASSERT, fct_nlist__append(), fct_ts__is_end, and _fct_ts_t::test_list.

1192 {
1193  FCT_ASSERT( ts != NULL && "invalid arg");
1194  FCT_ASSERT( test != NULL && "invalid arg");
1195  FCT_ASSERT( !fct_ts__is_end(ts) );
1196  fct_nlist__append(&(ts->test_list), test);
1197 }
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t test_list
Definition: switch_fct.h:1122
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fct_ts__chk_cnt()

static size_t fct_ts__chk_cnt ( fct_ts_t const *  ts)
static

Definition at line 1344 of file switch_fct.h.

References FCT_ASSERT, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fct_test__chk_cnt(), and _fct_ts_t::test_list.

1345 {
1346  size_t tally =0;
1347 
1348  FCT_ASSERT( ts != NULL );
1349 
1350  FCT_NLIST_FOREACH_BGN(fct_test_t *, test, &(ts->test_list))
1351  {
1352  tally += fct_test__chk_cnt(test);
1353  }
1355  return tally;
1356 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690
static size_t fct_test__chk_cnt(fct_test_t const *test)
Definition: switch_fct.h:1054

◆ fct_ts__cnt_end()

static void fct_ts__cnt_end ( fct_ts_t ts)
static

Definition at line 1277 of file switch_fct.h.

References FCT_ASSERT, fct_ts__is_cnt_mode, fct_ts__is_end, _fct_ts_t::mode, nbool_t, _fct_ts_t::total_test_num, ts_mode_ending, and ts_mode_setup.

1278 {
1279  FCT_ASSERT( ts != NULL );
1281  FCT_ASSERT( !fct_ts__is_end(ts) );
1282  if (ts->total_test_num == 0 )
1283  {
1284  ts->mode = ts_mode_ending;
1285  }
1286  else
1287  {
1288  ts->mode = ts_mode_setup;
1289  }
1290 }
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
enum ts_mode mode
Definition: switch_fct.h:1116
int total_test_num
Definition: switch_fct.h:1112
#define fct_ts__is_cnt_mode(ts)
Definition: switch_fct.h:1131

◆ fct_ts__del()

static void fct_ts__del ( fct_ts_t ts)
static

Definition at line 1145 of file switch_fct.h.

References fct_nlist__final(), fct_test__del(), and _fct_ts_t::test_list.

Referenced by fctkern__final().

1146 {
1147  if ( ts == NULL )
1148  {
1149  return;
1150  }
1152  free(ts);
1153 }
void(* fct_nlist_on_del_t)(void *)
Definition: switch_fct.h:716
static void fct_test__del(fct_test_t *test)
Definition: switch_fct.h:951
static void fct_nlist__final(fct_nlist_t *list, fct_nlist_on_del_t on_del)
Definition: switch_fct.h:741
fct_nlist_t test_list
Definition: switch_fct.h:1122

◆ fct_ts__duration()

static double fct_ts__duration ( fct_ts_t const *  ts)
static

Definition at line 1360 of file switch_fct.h.

References FCT_ASSERT, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fct_test__duration(), and _fct_ts_t::test_list.

Referenced by fct_junit_logger__on_test_suite_end().

1361 {
1362  double tally =0.0;
1363  FCT_ASSERT( ts != NULL );
1364  FCT_NLIST_FOREACH_BGN(fct_test_t *, test, &(ts->test_list))
1365  {
1366  tally += fct_test__duration(test);
1367  }
1369  return tally;
1370 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static double fct_test__duration(fct_test_t const *test)
Definition: switch_fct.h:1020
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fct_ts__inc_total_test_num()

static void fct_ts__inc_total_test_num ( fct_ts_t ts)
static

Definition at line 1211 of file switch_fct.h.

References FCT_ASSERT, fct_ts__is_cnt_mode, fct_ts__is_end, and _fct_ts_t::total_test_num.

1212 {
1213  FCT_ASSERT( ts != NULL );
1215  FCT_ASSERT( !fct_ts__is_end(ts) );
1216  ++(ts->total_test_num);
1217 }
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
int total_test_num
Definition: switch_fct.h:1112
#define fct_ts__is_cnt_mode(ts)
Definition: switch_fct.h:1131

◆ fct_ts__is_more_tests()

static nbool_t fct_ts__is_more_tests ( fct_ts_t const *  ts)
static

Definition at line 1171 of file switch_fct.h.

References _fct_ts_t::curr_test_num, FCT_ASSERT, fct_ts__is_end, and _fct_ts_t::total_test_num.

Referenced by fct_ts__teardown_end().

1172 {
1173  FCT_ASSERT( ts != NULL );
1174  FCT_ASSERT( !fct_ts__is_end(ts) );
1175  return ts->curr_test_num < ts->total_test_num;
1176 }
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_ts__is_test_cnt()

static nbool_t fct_ts__is_test_cnt ( fct_ts_t const *  ts,
int  test_num 
)
static

Definition at line 1294 of file switch_fct.h.

References _fct_ts_t::curr_test_num, FCT_ASSERT, and fct_ts__is_end.

1295 {
1296  FCT_ASSERT( ts != NULL );
1297  FCT_ASSERT( 0 <= test_num );
1298  FCT_ASSERT( test_num < ts->total_test_num );
1299  FCT_ASSERT( !fct_ts__is_end(ts) );
1300 
1301  /* As we roll through the tests we increment the count. With this
1302  count we can decide if we need to execute a test or not. */
1303  return test_num == ts->curr_test_num;
1304 }
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_ts__make_abort_test()

static fct_test_t* fct_ts__make_abort_test ( fct_ts_t ts)
static

Definition at line 1233 of file switch_fct.h.

References FCT_MAX_LOG_LINE, fct_snprintf(), fct_test_new(), and fct_ts__name.

1234 {
1235  char setup_testname[FCT_MAX_LOG_LINE+1] = {'\0'};
1236  char const *suitename = fct_ts__name(ts);
1237  fct_snprintf(setup_testname, FCT_MAX_LOG_LINE, "setup_%s", suitename);
1238  return fct_test_new(setup_testname);
1239 }
static int fct_snprintf(char *buffer, size_t buffer_len, char const *format,...)
Definition: switch_fct.h:287
#define fct_ts__name(ts)
Definition: switch_fct.h:1141
#define FCT_MAX_LOG_LINE
Definition: switch_fct.h:83
static fct_test_t * fct_test_new(char const *name)
Definition: switch_fct.h:964

◆ fct_ts__setup_abort()

static void fct_ts__setup_abort ( fct_ts_t ts)
static

Definition at line 1243 of file switch_fct.h.

References FCT_ASSERT, _fct_ts_t::mode, and ts_mode_abort.

1244 {
1245  FCT_ASSERT( ts != NULL );
1246  ts->mode = ts_mode_abort;
1247 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
enum ts_mode mode
Definition: switch_fct.h:1116

◆ fct_ts__setup_end()

static void fct_ts__setup_end ( fct_ts_t ts)
static

Definition at line 1223 of file switch_fct.h.

References _fct_ts_t::mode, ts_mode_abort, and ts_mode_test.

1224 {
1225  if ( ts->mode != ts_mode_abort )
1226  {
1227  ts->mode = ts_mode_test;
1228  }
1229 }
enum ts_mode mode
Definition: switch_fct.h:1116

◆ fct_ts__teardown_end()

static void fct_ts__teardown_end ( fct_ts_t ts)
static

Definition at line 1252 of file switch_fct.h.

References fct_ts__is_more_tests(), _fct_ts_t::mode, ts_mode_abort, ts_mode_ending, and ts_mode_setup.

1253 {
1254  if ( ts->mode == ts_mode_abort )
1255  {
1256  return; /* Because we are aborting . */
1257  }
1258  /* We have to decide if we should keep on testing by moving into tear down
1259  mode or if we have reached the real end and should be moving into the
1260  ending mode. */
1261  if ( fct_ts__is_more_tests(ts) )
1262  {
1263  ts->mode = ts_mode_setup;
1264  }
1265  else
1266  {
1267  ts->mode = ts_mode_ending;
1268  }
1269 }
enum ts_mode mode
Definition: switch_fct.h:1116
static nbool_t fct_ts__is_more_tests(fct_ts_t const *ts)
Definition: switch_fct.h:1171

◆ fct_ts__test_begin()

static void fct_ts__test_begin ( fct_ts_t ts)
static

Definition at line 1181 of file switch_fct.h.

References _fct_ts_t::curr_test_num, FCT_ASSERT, and fct_ts__is_end.

1182 {
1183  FCT_ASSERT( !fct_ts__is_end(ts) );
1184  ++(ts->curr_test_num);
1185 }
int curr_test_num
Definition: switch_fct.h:1111
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_ts__test_end()

static void fct_ts__test_end ( fct_ts_t ts)
static

Definition at line 1201 of file switch_fct.h.

References FCT_ASSERT, _fct_ts_t::mode, and ts_mode_teardown.

1202 {
1203  FCT_ASSERT( ts != NULL );
1204  /* After a test has completed, move to teardown mode. */
1205  ts->mode = ts_mode_teardown;
1206 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
enum ts_mode mode
Definition: switch_fct.h:1116

◆ fct_ts__tst_cnt()

static size_t fct_ts__tst_cnt ( fct_ts_t const *  ts)
static

Definition at line 1310 of file switch_fct.h.

References FCT_ASSERT, fct_nlist__size(), fct_ts__is_end, and _fct_ts_t::test_list.

Referenced by fct_junit_logger__on_test_suite_end(), and fctkern__tst_cnt().

1311 {
1312  FCT_ASSERT( ts != NULL );
1313  FCT_ASSERT(
1314  fct_ts__is_end(ts)
1315  && "can't count number of tests executed until the test suite ends"
1316  );
1317  return fct_nlist__size(&(ts->test_list));
1318 }
static size_t fct_nlist__size(fct_nlist_t const *list)
Definition: switch_fct.h:785
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fct_ts__tst_cnt_passed()

static size_t fct_ts__tst_cnt_passed ( fct_ts_t const *  ts)
static

Definition at line 1323 of file switch_fct.h.

References FCT_ASSERT, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fct_test__is_pass(), fct_ts__is_end, and _fct_ts_t::test_list.

Referenced by fct_junit_logger__on_test_suite_end(), and fctkern__tst_cnt_passed().

1324 {
1325  size_t tally =0;
1326 
1327  FCT_ASSERT( ts != NULL );
1328  FCT_ASSERT( fct_ts__is_end(ts) );
1329 
1330  FCT_NLIST_FOREACH_BGN(fct_test_t*, test, &(ts->test_list))
1331  {
1332  if ( fct_test__is_pass(test) )
1333  {
1334  tally += 1;
1335  }
1336  }
1338  return tally;
1339 }
#define fct_ts__is_end(ts)
Definition: switch_fct.h:1130
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static nbool_t fct_test__is_pass(fct_test_t const *test)
Definition: switch_fct.h:1028
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fct_ts_new()

static fct_ts_t* fct_ts_new ( char const *  name)
static

Definition at line 1156 of file switch_fct.h.

References FCT_ASSERT, FCT_MAX_NAME, fct_nlist__init, fctstr_safe_cpy(), _fct_ts_t::mode, _fct_ts_t::name, nbool_t, _fct_ts_t::test_list, and ts_mode_cnt.

1157 {
1158  fct_ts_t *ts =NULL;
1159  ts = (fct_ts_t*)calloc(1, sizeof(fct_ts_t));
1160  FCT_ASSERT( ts != NULL );
1161 
1163  ts->mode = ts_mode_cnt;
1164  fct_nlist__init(&(ts->test_list));
1165  return ts;
1166 }
char name[FCT_MAX_NAME]
Definition: switch_fct.h:1119
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
enum ts_mode mode
Definition: switch_fct.h:1116
#define FCT_MAX_NAME
Definition: switch_fct.h:82
#define fct_nlist__init(_LIST_PTR_)
Definition: switch_fct.h:779
fct_nlist_t test_list
Definition: switch_fct.h:1122
const char *const name
Definition: switch_cJSON.h:250
static void fctstr_safe_cpy(char *dst, char const *src, size_t num)
Definition: switch_fct.h:250

◆ fct_vsnprintf()

static int fct_vsnprintf ( char *  buffer,
size_t  buffer_len,
char const *  format,
va_list  args 
)
static

Definition at line 265 of file switch_fct.h.

References count.

Referenced by fct_snprintf(), and fctchk_new().

269 {
270  int count =0;
271  /* Older Microsoft compilers where not ANSI compliant with this
272  function and you had to use _vsnprintf. I will assume that newer
273  Microsoft Compilers start implementing vsnprintf. */
274 #if defined(_MSC_VER) && (_MSC_VER < 1400)
275  count = _vsnprintf(buffer, buffer_len, format, args);
276 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
277  count = vsnprintf_s(buffer, buffer_len, _TRUNCATE, format, args);
278 #else
279  count = vsnprintf(buffer, buffer_len, format, args);
280 #endif
281  return count;
282 }
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
char * buffer
Definition: switch_cJSON.h:153
int count
Definition: switch_cJSON.h:204

◆ fct_xchk2_fn()

static int fct_xchk2_fn ( const char *  condition,
int  is_pass,
char const *  format,
  ... 
)
static

Definition at line 3613 of file switch_fct.h.

References _fct_xchk_fn_varg().

3614 {
3615  int r =0;
3616  va_list args;
3617  va_start(args, format);
3618  r = _fct_xchk_fn_varg(condition, is_pass, format, args);
3619  va_end(args);
3620  return r;
3621 }
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
static int _fct_xchk_fn_varg(char const *condition, int is_pass, char const *format, va_list args)
Definition: switch_fct.h:3577

◆ fct_xchk_fn()

static int fct_xchk_fn ( int  is_pass,
char const *  format,
  ... 
)
static

Definition at line 3625 of file switch_fct.h.

References _fct_xchk_fn_varg().

3626 {
3627  int r=0;
3628  va_list args;
3629  va_start(args, format);
3630  r = _fct_xchk_fn_varg("<none-from-xchk>", is_pass, format, args);
3631  va_end(args);
3632  return r;
3633 }
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
static int _fct_xchk_fn_varg(char const *condition, int is_pass, char const *format, va_list args)
Definition: switch_fct.h:3577

◆ fctchk__del()

static void fctchk__del ( fctchk_t chk)
static

Definition at line 910 of file switch_fct.h.

Referenced by fct_minimal_logger__on_delete(), fct_standard_logger__on_delete(), and fct_test__del().

911 {
912  if ( chk == NULL )
913  {
914  return;
915  }
916  free( chk );
917 }

◆ fctchk_new()

static fctchk_t* fctchk_new ( int  is_pass,
char const *  cndtn,
char const *  name,
char const *  file,
int  lineno,
char const *  format,
va_list  args 
)
static

Definition at line 865 of file switch_fct.h.

References _fctchk_t::cndtn, FCT_ASSERT, FCT_MAX_LOG_LINE, fct_vsnprintf(), fctstr_safe_cpy(), _fctchk_t::file, _fctchk_t::is_pass, _fctchk_t::lineno, _fctchk_t::msg, and _fctchk_t::name.

Referenced by _fct_xchk_fn_varg().

872 {
873  fctchk_t *chk = NULL;
874 
875  FCT_ASSERT( cndtn != NULL );
876  FCT_ASSERT( file != NULL );
877  FCT_ASSERT( lineno > 0 );
878 
879  chk = (fctchk_t*)calloc(1, sizeof(fctchk_t));
880  if ( chk == NULL )
881  {
882  return NULL;
883  }
884 
886  fctstr_safe_cpy(chk->cndtn, cndtn, FCT_MAX_LOG_LINE);
888  chk->lineno = lineno;
889 
890  chk->is_pass =is_pass;
891 
892  if ( format != NULL )
893  {
895  }
896  else
897  {
898  /* Default to make the condition be the message, if there was no format
899  specified. */
900  fctstr_safe_cpy(chk->msg, cndtn, FCT_MAX_LOG_LINE);
901  }
902 
903  return chk;
904 }
nbool_t is_pass
Definition: switch_fct.h:849
int lineno
Definition: switch_fct.h:847
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
char cndtn[FCT_MAX_LOG_LINE]
Definition: switch_fct.h:842
#define FCT_MAX_LOG_LINE
Definition: switch_fct.h:83
char file[FCT_MAX_LOG_LINE]
Definition: switch_fct.h:845
char msg[FCT_MAX_LOG_LINE]
Definition: switch_fct.h:854
char name[FCT_MAX_LOG_LINE]
Definition: switch_fct.h:839
const char *const name
Definition: switch_cJSON.h:250
static void fctstr_safe_cpy(char *dst, char const *src, size_t num)
Definition: switch_fct.h:250
static int fct_vsnprintf(char *buffer, size_t buffer_len, char const *format, va_list args)
Definition: switch_fct.h:265

◆ fctcl__del()

static void fctcl__del ( fctcl_t clo)
static

Definition at line 1447 of file switch_fct.h.

References _fctcl_t::help, _fctcl_t::long_opt, _fctcl_t::short_opt, and _fctcl_t::value.

Referenced by fct_clp__final(), and fctcl_new2().

1448 {
1449  if ( clo == NULL )
1450  {
1451  return;
1452  }
1453  free(clo->long_opt);
1454  free(clo->short_opt);
1455  free(clo->value);
1456  free(clo->help);
1457  free(clo);
1458 }
char * help
Definition: switch_fct.h:1436
char * value
Definition: switch_fct.h:1439
char * short_opt
Definition: switch_fct.h:1430
char * long_opt
Definition: switch_fct.h:1429

◆ fctcl__is_option()

static int fctcl__is_option ( fctcl_t const *  clo,
char const *  option 
)
static

Definition at line 1523 of file switch_fct.h.

References FCT_ASSERT, fctstr_eq(), _fctcl_t::long_opt, and _fctcl_t::short_opt.

Referenced by fct_clp__get_clo(), and fct_clp__parse().

1524 {
1525  FCT_ASSERT( clo != NULL );
1526  if ( option == NULL )
1527  {
1528  return 0;
1529  }
1530  return ((clo->long_opt != NULL
1531  && fctstr_eq(clo->long_opt, option))
1532  ||
1533  (clo->short_opt != NULL
1534  && fctstr_eq(clo->short_opt, option))
1535  );
1536 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static int fctstr_eq(char const *s1, char const *s2)
Definition: switch_fct.h:389

◆ fctcl_new2()

static fctcl_t* fctcl_new2 ( fctcl_init_t const *  clo_init)
static

Definition at line 1462 of file switch_fct.h.

References _fctcl_init_t::action, _fctcl_t::action, fctcl__del(), fctcl_new, fctstr_clone(), _fctcl_init_t::help, _fctcl_t::help, _fctcl_init_t::long_opt, _fctcl_t::long_opt, _fctcl_init_t::short_opt, and _fctcl_t::short_opt.

Referenced by fct_clp__add_options().

1463 {
1464  fctcl_t *clone = NULL;
1465  int ok =0;
1466  clone = fctcl_new();
1467  if ( clone == NULL )
1468  {
1469  return NULL;
1470  }
1471  clone->action = clo_init->action;
1472  if ( clo_init->help == NULL )
1473  {
1474  clone->help = NULL;
1475  }
1476  else
1477  {
1478  clone->help = fctstr_clone(clo_init->help);
1479  if ( clone->help == NULL )
1480  {
1481  ok =0;
1482  goto finally;
1483  }
1484  }
1485  if ( clo_init->long_opt == NULL )
1486  {
1487  clone->long_opt = NULL;
1488  }
1489  else
1490  {
1491  clone->long_opt = fctstr_clone(clo_init->long_opt);
1492  if ( clone->long_opt == NULL )
1493  {
1494  ok = 0;
1495  goto finally;
1496  }
1497  }
1498  if ( clo_init->short_opt == NULL )
1499  {
1500  clone->short_opt = NULL;
1501  }
1502  else
1503  {
1504  clone->short_opt = fctstr_clone(clo_init->short_opt);
1505  if ( clone->short_opt == NULL )
1506  {
1507  ok =0;
1508  goto finally;
1509  }
1510  }
1511  ok = 1;
1512 finally:
1513  if ( !ok )
1514  {
1515  fctcl__del(clone);
1516  clone = NULL;
1517  }
1518  return clone;
1519 }
char * help
Definition: switch_fct.h:1436
static void fctcl__del(fctcl_t *clo)
Definition: switch_fct.h:1447
static char * fctstr_clone(char const *s)
Definition: switch_fct.h:301
char * short_opt
Definition: switch_fct.h:1430
#define fctcl_new()
Definition: switch_fct.h:1443
char * long_opt
Definition: switch_fct.h:1429
fctcl_store_t action
Definition: switch_fct.h:1433

◆ fctkern__add_logger()

static void fctkern__add_logger ( fctkern_t nk,
fct_logger_i logger_owns 
)
static

Definition at line 1963 of file switch_fct.h.

References FCT_ASSERT, fct_nlist__append(), and _fctkern_t::logger_list.

Referenced by fctkern__cl_parse_config_logger().

1964 {
1965  FCT_ASSERT(nk != NULL && "invalid arg");
1966  FCT_ASSERT(logger_owns != NULL && "invalid arg");
1967  fct_nlist__append(&(nk->logger_list), logger_owns);
1968 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t logger_list
Definition: switch_fct.h:1877
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fctkern__add_prefix_filter()

static void fctkern__add_prefix_filter ( fctkern_t nk,
char const *  prefix_filter 
)
static

Definition at line 2020 of file switch_fct.h.

References FCT_ASSERT, fct_nlist__append(), fctstr_safe_cpy(), and _fctkern_t::prefix_list.

Referenced by fctkern__cl_parse().

2021 {
2022  char *filter =NULL;
2023  size_t filter_len =0;
2024  FCT_ASSERT( nk != NULL && "invalid arg" );
2025  FCT_ASSERT( prefix_filter != NULL && "invalid arg" );
2026  FCT_ASSERT( strlen(prefix_filter) > 0 && "invalid arg" );
2027  /* First we make a copy of the prefix, then we store it away
2028  in our little list. */
2029  filter_len = strlen(prefix_filter);
2030  filter = (char*)malloc(sizeof(char)*(filter_len+1));
2031  FCT_ASSERT( filter != NULL );
2032  fctstr_safe_cpy(filter, prefix_filter, filter_len+1);
2033  fct_nlist__append(&(nk->prefix_list), (void*)filter);
2034 }
fct_nlist_t prefix_list
Definition: switch_fct.h:1886
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static void fctstr_safe_cpy(char *dst, char const *src, size_t num)
Definition: switch_fct.h:250
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fctkern__add_ts()

static void fctkern__add_ts ( fctkern_t nk,
fct_ts_t ts 
)
static

Definition at line 2232 of file switch_fct.h.

References FCT_ASSERT, fct_nlist__append(), nbool_t, and _fctkern_t::ts_list.

2233 {
2234  FCT_ASSERT( nk != NULL );
2235  FCT_ASSERT( ts != NULL );
2236  fct_nlist__append(&(nk->ts_list), ts);
2237 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t ts_list
Definition: switch_fct.h:1890
static void fct_nlist__append(fct_nlist_t *list, void *itm)
Definition: switch_fct.h:803

◆ fctkern__cl_is()

static int fctkern__cl_is ( fctkern_t nk,
char const *  opt_str 
)
static

Definition at line 2057 of file switch_fct.h.

References _fctkern_t::cl_parser, FCT_ASSERT, and fct_clp__is.

Referenced by fctkern__cl_parse().

2058 {
2059  FCT_ASSERT( opt_str != NULL );
2060  return opt_str[0] != '\0'
2061  && fct_clp__is(&(nk->cl_parser), opt_str);
2062 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_clp_t cl_parser
Definition: switch_fct.h:1865
#define fct_clp__is(_CLP_, _OPTION_)
Definition: switch_fct.h:1806

◆ fctkern__cl_parse()

static int fctkern__cl_parse ( fctkern_t nk)
static

Definition at line 2135 of file switch_fct.h.

References _fctkern_t::cl_argc, _fctkern_t::cl_argv, _fctkern_t::cl_is_parsed, _fctkern_t::cl_parser, _fctkern_t::cl_user_opts, fct_clp__add_options(), fct_clp__get_error, fct_clp__is_error, fct_clp__param_at, fct_clp__param_cnt, fct_clp__parse(), FCT_OPT_HELP, FCT_OPT_VERSION, FCT_VERSION_STR, fctkern__add_prefix_filter(), fctkern__cl_is(), fctkern__cl_parse_config_logger(), and fctkern__write_help().

2136 {
2137  int status =0;
2138  size_t num_params =0;
2139  size_t param_i =0;
2140  if ( nk == NULL )
2141  {
2142  return 0;
2143  }
2144  if ( nk->cl_user_opts != NULL )
2145  {
2146  if ( !fct_clp__add_options(&(nk->cl_parser), nk->cl_user_opts) )
2147  {
2148  status =0;
2149  goto finally;
2150  }
2151  }
2152  /* You want to add the "house options" after the user defined ones. The
2153  options are stored as a list so it means that any option listed after
2154  the above ones won't get parsed. */
2156  {
2157  status =0;
2158  goto finally;
2159  }
2160  fct_clp__parse(&(nk->cl_parser), nk->cl_argc, nk->cl_argv);
2161  if ( fct_clp__is_error(&(nk->cl_parser)) )
2162  {
2163  char *err = fct_clp__get_error(&(nk->cl_parser));
2164  fprintf(stderr, "error: %s", err);
2165  status =0;
2166  goto finally;
2167  }
2168  num_params = fct_clp__param_cnt(&(nk->cl_parser));
2169  for ( param_i =0; param_i != num_params; ++param_i )
2170  {
2171  char const *param = fct_clp__param_at(&(nk->cl_parser), param_i);
2172  fctkern__add_prefix_filter(nk, param);
2173  }
2174  if ( fctkern__cl_is(nk, FCT_OPT_VERSION) )
2175  {
2176  (void)printf("Built using FCTX version %s.\n", FCT_VERSION_STR);
2177  status = -1;
2178  goto finally;
2179  }
2180  if ( fctkern__cl_is(nk, FCT_OPT_HELP) )
2181  {
2182  fctkern__write_help(nk, stdout);
2183  status = -1;
2184  goto finally;
2185  }
2187  {
2188  status = -1;
2189  goto finally;
2190  }
2191  status =1;
2192  nk->cl_is_parsed =1;
2193 finally:
2194  return status;
2195 }
fctcl_init_t const * cl_user_opts
Definition: switch_fct.h:1871
char const ** cl_argv
Definition: switch_fct.h:1869
#define FCT_OPT_HELP
Definition: switch_fct.h:1899
#define fct_clp__param_at(_CLP_, _IDX_)
Definition: switch_fct.h:1800
#define fct_clp__param_cnt(_CLP_)
Definition: switch_fct.h:1795
#define fct_clp__is_error(_CLP_)
Definition: switch_fct.h:1789
#define fct_clp__get_error(_CLP_)
Definition: switch_fct.h:1790
fct_clp_t cl_parser
Definition: switch_fct.h:1865
static int fctkern__cl_parse_config_logger(fctkern_t *nk)
Definition: switch_fct.h:2101
static void fctkern__write_help(fctkern_t *nk, FILE *out)
Definition: switch_fct.h:1972
static void fct_clp__parse(fct_clp_t *clp, int argc, char const *argv[])
Definition: switch_fct.h:1631
#define FCT_OPT_VERSION
Definition: switch_fct.h:1897
static int fctkern__cl_is(fctkern_t *nk, char const *opt_str)
Definition: switch_fct.h:2057
static int fct_clp__add_options(fct_clp_t *clp, fctcl_init_t const *options)
Definition: switch_fct.h:1573
int cl_is_parsed
Definition: switch_fct.h:1874
#define FCT_VERSION_STR
Definition: switch_fct.h:69
static void fctkern__add_prefix_filter(fctkern_t *nk, char const *prefix_filter)
Definition: switch_fct.h:2020
static fctcl_init_t FCT_CLP_OPTIONS[]
Definition: switch_fct.h:1903

◆ fctkern__cl_parse_config_logger()

static int fctkern__cl_parse_config_logger ( fctkern_t nk)
static

Definition at line 2101 of file switch_fct.h.

References fckern_sel_log(), FCT_ASSERT, FCT_DEFAULT_LOGGER, FCT_OPT_LOGGER, fctkern__add_logger(), fctkern__cl_val2(), _fctkern_t::lt_sys, and _fctkern_t::lt_usr.

Referenced by fctkern__cl_parse().

2102 {
2103  fct_logger_i *logger =NULL;
2104  char const *sel_logger =NULL;
2105  char const *def_logger =FCT_DEFAULT_LOGGER;
2106  sel_logger = fctkern__cl_val2(nk, FCT_OPT_LOGGER, def_logger);
2107  FCT_ASSERT(sel_logger != NULL && "should never be NULL");
2108  /* First search the user selected types, then search the
2109  built-in types. */
2110  if ( nk->lt_usr != NULL )
2111  {
2112  logger = fckern_sel_log(nk->lt_usr, sel_logger);
2113  }
2114  if ( nk->lt_sys != NULL && logger == NULL )
2115  {
2116  logger = fckern_sel_log(nk->lt_sys, sel_logger);
2117  }
2118  if ( logger == NULL )
2119  {
2120  /* No logger configured, you must have supplied an invalid selection. */
2121  fprintf(stderr, "error: unknown logger selected - '%s'", sel_logger);
2122  return 0;
2123  }
2124  fctkern__add_logger(nk, logger);
2125  logger = NULL; /* owned by nk. */
2126  return 1;
2127 }
#define FCT_OPT_LOGGER
Definition: switch_fct.h:1901
static void fctkern__add_logger(fctkern_t *nk, fct_logger_i *logger_owns)
Definition: switch_fct.h:1963
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_DEFAULT_LOGGER
Definition: switch_fct.h:59
fct_logger_types_t * lt_sys
Definition: switch_fct.h:1882
static fct_logger_i * fckern_sel_log(fct_logger_types_t *search, char const *sel_logger)
Definition: switch_fct.h:2084
fct_logger_types_t * lt_usr
Definition: switch_fct.h:1881
static char const * fctkern__cl_val2(fctkern_t *nk, char const *opt_str, char const *def_str)
Definition: switch_fct.h:2070

◆ fctkern__cl_val2()

static char const* fctkern__cl_val2 ( fctkern_t nk,
char const *  opt_str,
char const *  def_str 
)
static

Definition at line 2070 of file switch_fct.h.

References _fctkern_t::cl_parser, FCT_ASSERT, and fct_clp__optval2().

Referenced by fctkern__cl_parse_config_logger().

2071 {
2072  FCT_ASSERT( opt_str != NULL );
2073  if ( nk == NULL )
2074  {
2075  return NULL;
2076  }
2077  return fct_clp__optval2(&(nk->cl_parser), opt_str, def_str);
2078 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_clp_t cl_parser
Definition: switch_fct.h:1865
static char const * fct_clp__optval2(fct_clp_t *clp, char const *option, char const *default_val)
Definition: switch_fct.h:1754

◆ fctkern__final()

static void fctkern__final ( fctkern_t nk)
static

Definition at line 2039 of file switch_fct.h.

References _fctkern_t::cl_parser, fct_clp__final(), fct_logger__del(), fct_nlist__final(), fct_ts__del(), _fctkern_t::logger_list, _fctkern_t::prefix_list, and _fctkern_t::ts_list.

2040 {
2041  if ( nk == NULL )
2042  {
2043  return;
2044  }
2045  fct_clp__final(&(nk->cl_parser));
2047  /* The prefix list is a list of malloc'd strings. */
2050 }
static void fct_ts__del(fct_ts_t *ts)
Definition: switch_fct.h:1145
void(* fct_nlist_on_del_t)(void *)
Definition: switch_fct.h:716
fct_nlist_t prefix_list
Definition: switch_fct.h:1886
fct_nlist_t logger_list
Definition: switch_fct.h:1877
static void fct_clp__final(fct_clp_t *clp)
Definition: switch_fct.h:1564
static void fct_nlist__final(fct_nlist_t *list, fct_nlist_on_del_t on_del)
Definition: switch_fct.h:741
static void fct_logger__del(fct_logger_i *logger)
Definition: switch_fct.h:2606
fct_clp_t cl_parser
Definition: switch_fct.h:1865
fct_nlist_t ts_list
Definition: switch_fct.h:1890

◆ fctkern__init()

static int fctkern__init ( fctkern_t nk,
int  argc,
const char *  argv[] 
)
static

Definition at line 2202 of file switch_fct.h.

References _fctkern_t::cl_argc, _fctkern_t::cl_argv, _fctkern_t::cl_is_parsed, _fctkern_t::cl_parser, fct_clp__init(), FCT_LOGGER_TYPES, fct_namespace_init(), fct_nlist__init, fct_nlist__init2(), _fctkern_t::logger_list, _fctkern_t::lt_sys, _fctkern_t::lt_usr, memset(), _fctkern_t::ns, _fctkern_t::prefix_list, and _fctkern_t::ts_list.

2203 {
2204  int ok = 0;
2205  if ( argc == 0 && argv == NULL )
2206  {
2207  return 0;
2208  }
2209  memset(nk, 0, sizeof(fctkern_t));
2210  ok = fct_clp__init(&(nk->cl_parser), NULL);
2211  if (!ok) return ok;
2212  fct_nlist__init(&(nk->logger_list));
2213  nk->lt_usr = NULL; /* Supplied via 'install' mechanics. */
2214  nk->lt_sys = FCT_LOGGER_TYPES;
2215  fct_nlist__init2(&(nk->prefix_list), 0);
2216  fct_nlist__init2(&(nk->ts_list), 0);
2217  nk->cl_is_parsed =0;
2218  /* Save a copy of the arguments. We do a delay parse of the command
2219  line arguments in order to allow the client code to optionally configure
2220  the command line parser.*/
2221  nk->cl_argc = argc;
2222  nk->cl_argv = argv;
2223  fct_namespace_init(&(nk->ns));
2224  return 1;
2225 }
static int fct_clp__init(fct_clp_t *clp, fctcl_init_t const *options)
Definition: switch_fct.h:1594
fct_nlist_t prefix_list
Definition: switch_fct.h:1886
static void fct_namespace_init(fct_namespace_t *ns)
Definition: switch_fct.h:1842
char const ** cl_argv
Definition: switch_fct.h:1869
fct_nlist_t logger_list
Definition: switch_fct.h:1877
static int fct_nlist__init2(fct_nlist_t *list, size_t start_sz)
Definition: switch_fct.h:751
static fct_logger_types_t FCT_LOGGER_TYPES[]
Definition: switch_fct.h:1937
fct_namespace_t ns
Definition: switch_fct.h:1862
fct_clp_t cl_parser
Definition: switch_fct.h:1865
#define fct_nlist__init(_LIST_PTR_)
Definition: switch_fct.h:779
fct_nlist_t ts_list
Definition: switch_fct.h:1890
fct_logger_types_t * lt_sys
Definition: switch_fct.h:1882
int cl_is_parsed
Definition: switch_fct.h:1874
fct_logger_types_t * lt_usr
Definition: switch_fct.h:1881
memset(buf, 0, buflen)

◆ fctkern__log_chk()

static void fctkern__log_chk ( fctkern_t nk,
fctchk_t const *  chk 
)
static

Definition at line 2391 of file switch_fct.h.

References FCT_ASSERT, fct_logger__on_chk(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

Referenced by _fct_xchk_fn_varg().

2392 {
2393  FCT_ASSERT( nk != NULL );
2394  FCT_ASSERT( chk != NULL );
2396  {
2397  fct_logger__on_chk(logger, chk);
2398  }
2400 }
static void fct_logger__on_chk(fct_logger_i *self, fctchk_t const *chk)
Definition: switch_fct.h:2674
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__log_suite_end()

static void fctkern__log_suite_end ( fctkern_t nk,
fct_ts_t const *  ts 
)
static

Definition at line 2350 of file switch_fct.h.

References FCT_ASSERT, fct_logger__on_test_suite_end(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

2351 {
2352  FCT_ASSERT( nk != NULL );
2353  FCT_ASSERT( ts != NULL );
2355  {
2356  fct_logger__on_test_suite_end(logger, ts);
2357  }
2359 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static void fct_logger__on_test_suite_end(fct_logger_i *logger, fct_ts_t const *ts)
Definition: switch_fct.h:2640
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__log_suite_skip()

static void fctkern__log_suite_skip ( fctkern_t nk,
char const *  condition,
char const *  name 
)
static

Definition at line 2363 of file switch_fct.h.

References fct_logger__on_test_suite_skip(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

2364 {
2365  if ( nk == NULL )
2366  {
2367  return;
2368  }
2370  {
2371  fct_logger__on_test_suite_skip(logger, condition, name);
2372  }
2374 }
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static void fct_logger__on_test_suite_skip(fct_logger_i *logger, char const *condition, char const *name)
Definition: switch_fct.h:2648
const char *const name
Definition: switch_cJSON.h:250
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__log_suite_start()

static void fctkern__log_suite_start ( fctkern_t nk,
fct_ts_t const *  ts 
)
static

Definition at line 2337 of file switch_fct.h.

References FCT_ASSERT, fct_logger__on_test_suite_start(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

2338 {
2339  FCT_ASSERT( nk != NULL );
2340  FCT_ASSERT( ts != NULL );
2342  {
2343  fct_logger__on_test_suite_start(logger, ts);
2344  }
2346 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static void fct_logger__on_test_suite_start(fct_logger_i *logger, fct_ts_t const *ts)
Definition: switch_fct.h:2632
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__log_test_end()

static void fctkern__log_test_end ( fctkern_t nk,
fct_test_t test 
)
static

Definition at line 2432 of file switch_fct.h.

References FCT_ASSERT, fct_logger__on_test_end(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

2433 {
2434  FCT_ASSERT( nk != NULL );
2435  FCT_ASSERT( test != NULL );
2437  {
2438  fct_logger__on_test_end(logger, test);
2439  }
2441 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690
static void fct_logger__on_test_end(fct_logger_i *logger, fct_test_t *test)
Definition: switch_fct.h:2624

◆ fctkern__log_test_skip()

static void fctkern__log_test_skip ( fctkern_t nk,
char const *  condition,
char const *  name 
)
static

Definition at line 2378 of file switch_fct.h.

References fct_logger__on_test_skip(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

2379 {
2381  {
2382  fct_logger__on_test_skip(logger, condition, name);
2383  }
2385 }
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static void fct_logger__on_test_skip(fct_logger_i *logger, char const *condition, char const *name)
Definition: switch_fct.h:2661
const char *const name
Definition: switch_cJSON.h:250
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__log_test_start()

static void fctkern__log_test_start ( fctkern_t nk,
fct_test_t const *  test 
)
static

Definition at line 2419 of file switch_fct.h.

References FCT_ASSERT, fct_logger__on_test_start(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

2420 {
2421  FCT_ASSERT( nk != NULL );
2422  FCT_ASSERT( test != NULL );
2424  {
2425  fct_logger__on_test_start(logger, test);
2426  }
2428 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static void fct_logger__on_test_start(fct_logger_i *logger, fct_test_t const *test)
Definition: switch_fct.h:2616
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__log_warn()

static void fctkern__log_warn ( fctkern_t nk,
char const *  warn 
)
static

Definition at line 2405 of file switch_fct.h.

References FCT_ASSERT, fct_logger__on_warn(), FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, and _fctkern_t::logger_list.

Referenced by _fct_xchk_fn_varg().

2406 {
2407  FCT_ASSERT( nk != NULL );
2408  FCT_ASSERT( warn != NULL );
2410  {
2411  fct_logger__on_warn(logger, warn);
2412  }
2414 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
fct_nlist_t logger_list
Definition: switch_fct.h:1877
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static void fct_logger__on_warn(fct_logger_i *logger, char const *warn)
Definition: switch_fct.h:2693
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__pass_filter()

static nbool_t fctkern__pass_filter ( fctkern_t nk,
char const *  test_name 
)
static

Definition at line 2243 of file switch_fct.h.

References FCT_ASSERT, FCT_FALSE, fct_filter_pass(), fct_nlist__at(), FCT_TRUE, fctkern__filter_cnt, nbool_t, and _fctkern_t::prefix_list.

2244 {
2245  size_t prefix_i =0;
2246  size_t prefix_list_size =0;
2247  FCT_ASSERT( nk != NULL && "invalid arg");
2248  FCT_ASSERT( test_name != NULL );
2249  FCT_ASSERT( strlen(test_name) > 0 );
2250  prefix_list_size = fctkern__filter_cnt(nk);
2251  /* If there is no filter list, then we return FCT_TRUE always. */
2252  if ( prefix_list_size == 0 )
2253  {
2254  return FCT_TRUE;
2255  }
2256  /* Iterate through the prefix filter list, and see if we have
2257  anything that does not pass. All we require is ONE item that
2258  passes the test in order for us to succeed here. */
2259  for ( prefix_i = 0; prefix_i != prefix_list_size; ++prefix_i )
2260  {
2261  char const *prefix = (char const*)fct_nlist__at(
2262  &(nk->prefix_list), prefix_i
2263  );
2264  nbool_t pass = fct_filter_pass(prefix, test_name);
2265  if ( pass )
2266  {
2267  return FCT_TRUE;
2268  }
2269  }
2270  /* Otherwise, we never managed to find a prefix that satisfied the
2271  supplied test name. Therefore we have failed to pass to the filter
2272  list test. */
2273  return FCT_FALSE;
2274 }
fct_nlist_t prefix_list
Definition: switch_fct.h:1886
#define fctkern__filter_cnt(_NK_)
Definition: switch_fct.h:1959
static nbool_t fct_filter_pass(char const *prefix, char const *test_str)
Definition: switch_fct.h:341
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static void * fct_nlist__at(fct_nlist_t const *list, size_t idx)
Definition: switch_fct.h:794
#define FCT_TRUE
Definition: switch_fct.h:86
#define FCT_FALSE
Definition: switch_fct.h:87
#define nbool_t
Definition: switch_fct.h:85

◆ fctkern__tst_cnt()

static size_t fctkern__tst_cnt ( fctkern_t const *  nk)
static

Definition at line 2279 of file switch_fct.h.

References FCT_ASSERT, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fct_ts__tst_cnt(), and _fctkern_t::ts_list.

Referenced by fct_standard_logger__on_fctx_end().

2280 {
2281  size_t tally =0;
2282  FCT_ASSERT( nk != NULL );
2283  FCT_NLIST_FOREACH_BGN(fct_ts_t *, ts, &(nk->ts_list))
2284  {
2285  tally += fct_ts__tst_cnt(ts);
2286  }
2288  return tally;
2289 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static size_t fct_ts__tst_cnt(fct_ts_t const *ts)
Definition: switch_fct.h:1310
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__tst_cnt_passed()

static size_t fctkern__tst_cnt_passed ( fctkern_t const *  nk)
static

Definition at line 2294 of file switch_fct.h.

References FCT_ASSERT, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, fct_ts__tst_cnt_passed(), and _fctkern_t::ts_list.

Referenced by fct_standard_logger__on_fctx_end().

2295 {
2296  size_t tally =0;
2297  FCT_ASSERT( nk != NULL );
2298 
2299  FCT_NLIST_FOREACH_BGN(fct_ts_t*, ts, &(nk->ts_list))
2300  {
2301  tally += fct_ts__tst_cnt_passed(ts);
2302  }
2304 
2305  return tally;
2306 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
static size_t fct_ts__tst_cnt_passed(fct_ts_t const *ts)
Definition: switch_fct.h:1323
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690

◆ fctkern__write_help()

static void fctkern__write_help ( fctkern_t nk,
FILE *  out 
)
static

Definition at line 1972 of file switch_fct.h.

References _fctkern_t::cl_parser, _fct_clp_t::clo_list, _fct_logger_types_t::desc, FCT_DEFAULT_LOGGER, FCT_NLIST_FOREACH_BGN, FCT_NLIST_FOREACH_END, FCT_OPT_LOGGER, fctstr_ieq(), _fctkern_t::lt_sys, _fctkern_t::lt_usr, and _fct_logger_types_t::name.

Referenced by fctkern__cl_parse().

1973 {
1974  fct_clp_t *clp = &(nk->cl_parser);
1975  fprintf(out, "test.exe [options] prefix_filter ...\n\n");
1976  FCT_NLIST_FOREACH_BGN(fctcl_t*, clo, &(clp->clo_list))
1977  {
1978  if ( clo->short_opt != NULL )
1979  {
1980  fprintf(out, "%s, %s\n", clo->short_opt, clo->long_opt);
1981  }
1982  else
1983  {
1984  fprintf(out, "%s\n", clo->long_opt);
1985  }
1986  if ( !fctstr_ieq(clo->long_opt, FCT_OPT_LOGGER) )
1987  {
1988  /* For now lets not get to fancy with the text wrapping. */
1989  fprintf(out, " %s\n", clo->help);
1990  }
1991  else
1992  {
1993  fct_logger_types_t *types[2];
1994  int type_i;
1995  fct_logger_types_t *itr;
1996  types[0] = nk->lt_sys;
1997  types[1] = nk->lt_usr;
1998  fputs(" Sets the logger. The types of loggers currently "
1999  "available are,\n", out);
2000  for (type_i =0; type_i != 2; ++type_i )
2001  {
2002  for ( itr=types[type_i]; itr && itr->name != NULL; ++itr )
2003  {
2004  fprintf(out, " =%s : %s\n", itr->name, itr->desc);
2005  }
2006  }
2007  fprintf(out, " default is '%s'.\n", FCT_DEFAULT_LOGGER);
2008  }
2009  }
2011  fputs("\n", out);
2012 }
#define FCT_OPT_LOGGER
Definition: switch_fct.h:1901
#define FCT_NLIST_FOREACH_END()
Definition: switch_fct.h:699
fct_nlist_t clo_list
Definition: switch_fct.h:1553
fct_clp_t cl_parser
Definition: switch_fct.h:1865
static int fctstr_ieq(char const *s1, char const *s2)
Definition: switch_fct.h:413
char const * desc
Definition: switch_fct.h:1934
#define FCT_DEFAULT_LOGGER
Definition: switch_fct.h:59
fct_logger_types_t * lt_sys
Definition: switch_fct.h:1882
fct_logger_types_t * lt_usr
Definition: switch_fct.h:1881
#define FCT_NLIST_FOREACH_BGN(Type, Var, List)
Definition: switch_fct.h:690
char const * name
Definition: switch_fct.h:1932

◆ fctstr_clone()

static char* fctstr_clone ( char const *  s)
static

Definition at line 301 of file switch_fct.h.

References FCT_ASSERT, and fctstr_safe_cpy().

Referenced by fct_clp__parse(), and fctcl_new2().

302 {
303  char *k =NULL;
304  size_t klen =0;
305  FCT_ASSERT( s != NULL && "invalid arg");
306  klen = strlen(s)+1;
307  k = (char*)malloc(sizeof(char)*klen+1);
308  FCT_ASSERT( k != NULL );
309  fctstr_safe_cpy(k, s, klen);
310  return k;
311 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91
static void fctstr_safe_cpy(char *dst, char const *src, size_t num)
Definition: switch_fct.h:250

◆ fctstr_clone_lower()

static char* fctstr_clone_lower ( char const *  s)
static

Definition at line 316 of file switch_fct.h.

References FCT_ASSERT, and nbool_t.

Referenced by fctstr_iincl(), and fctstr_istartswith().

317 {
318  char *k =NULL;
319  size_t klen =0;
320  size_t i;
321  if ( s == NULL )
322  {
323  return NULL;
324  }
325  klen = strlen(s)+1;
326  k = (char*)malloc(sizeof(char)*klen+1);
327  FCT_ASSERT( k != NULL );
328  for ( i=0; i != klen; ++i )
329  {
330  k[i] = (char)tolower(s[i]);
331  }
332  return k;
333 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fctstr_endswith()

static int fctstr_endswith ( char const *  str,
char const *  check 
)
static

Definition at line 517 of file switch_fct.h.

518 {
519  size_t check_i;
520  size_t str_i;
521  if ( str == NULL && check == NULL )
522  {
523  return 1;
524  }
525  else if ( ((str == NULL) && (check != NULL))
526  || ((str != NULL) && (check == NULL)) )
527  {
528  return 0;
529  }
530  check_i = strlen(check);
531  str_i = strlen(str);
532  if ( str_i < check_i )
533  {
534  return 0; /* Can't do it string is too small. */
535  }
536  for ( ; check_i != 0; --check_i, --str_i)
537  {
538  if ( str[str_i] != check[check_i] )
539  {
540  return 0; /* Found a case where they are not equal. */
541  }
542  }
543  /* Exhausted check against string, can only be true. */
544  return 1;
545 }

◆ fctstr_eq()

static int fctstr_eq ( char const *  s1,
char const *  s2 
)
static

Definition at line 389 of file switch_fct.h.

Referenced by fct_clp__is_param(), and fctcl__is_option().

390 {
391  if ( s1 == s2 )
392  {
393  return 1;
394  }
395  if ( (s1 == NULL && s2 != NULL)
396  || (s1 != NULL && s2 == NULL) )
397  {
398  return 0;
399  }
400  while (*s1 == *s2)
401  {
402  if (*s1 == '\0')
403  return 1;
404  s1++;
405  s2++;
406  }
407  /* Difference detected! */
408  return 0;
409 }

◆ fctstr_iendswith()

static int fctstr_iendswith ( char const *  str,
char const *  check 
)
static

Definition at line 549 of file switch_fct.h.

550 {
551  size_t check_i;
552  size_t str_i;
553  if ( str == NULL && check == NULL )
554  {
555  return 1;
556  }
557  else if ( ((str == NULL) && (check != NULL))
558  || ((str != NULL) && (check == NULL)) )
559  {
560  return 0;
561  }
562  check_i = strlen(check);
563  str_i = strlen(str);
564  if ( str_i < check_i )
565  {
566  return 0; /* Can't do it string is too small. */
567  }
568  for ( ; check_i != 0; --check_i, --str_i)
569  {
570  if ( tolower(str[str_i]) != tolower(check[check_i]) )
571  {
572  return 0; /* Found a case where they are not equal. */
573  }
574  }
575  /* Exhausted check against string, can only be true. */
576  return 1;
577 }

◆ fctstr_ieq()

static int fctstr_ieq ( char const *  s1,
char const *  s2 
)
static

Definition at line 413 of file switch_fct.h.

Referenced by fckern_sel_log(), and fctkern__write_help().

414 {
415  if ( s1 == s2 )
416  {
417  return 1;
418  }
419  if ( (s1 == NULL && s2 != NULL)
420  || (s1 != NULL && s2 == NULL) )
421  {
422  return 0;
423  }
424  while (tolower(*s1) == tolower(*s2))
425  {
426  if (*s1 == '\0')
427  return 1;
428  s1++;
429  s2++;
430  }
431  /* Difference detected! */
432  return 0;
433 }

◆ fctstr_iincl()

static int fctstr_iincl ( char const *  str,
char const *  check_incl 
)
static

Definition at line 464 of file switch_fct.h.

References fctstr_clone_lower(), and fctstr_incl().

465 {
466  /* Going to do this with a memory allocation to save coding
467  time. In the future this can be rewritten. Both clone_lower
468  and _incl are NULL tolerant. */
469  char *lstr = fctstr_clone_lower(str);
470  char *lcheck_incl = fctstr_clone_lower(check_incl);
471  int found = fctstr_incl(lstr, lcheck_incl);
472  free(lstr);
473  free(lcheck_incl);
474  return found;
475 }
static char * fctstr_clone_lower(char const *s)
Definition: switch_fct.h:316
static int fctstr_incl(char const *str, char const *check_incl)
Definition: switch_fct.h:441

◆ fctstr_incl()

static int fctstr_incl ( char const *  str,
char const *  check_incl 
)
static

Definition at line 441 of file switch_fct.h.

Referenced by fctstr_iincl().

442 {
443  static char const *blank_s = "";
444  char const *found = NULL;
445  if ( str == NULL )
446  {
447  str = blank_s;
448  }
449  if ( check_incl == NULL )
450  {
451  check_incl = blank_s;
452  }
453  if ( str == check_incl )
454  {
455  return 1;
456  }
457  found = strstr(str, check_incl);
458  return found != NULL;
459 }

◆ fctstr_istartswith()

static int fctstr_istartswith ( char const *  str,
char const *  check 
)
static

Definition at line 500 of file switch_fct.h.

References fctstr_clone_lower(), and fctstr_startswith().

501 {
502  /* Taking the lazy approach for now. */
503  char *istr = fctstr_clone_lower(str);
504  char *icheck = fctstr_clone_lower(check);
505  /* TODO: check for memory. */
506  int startswith = fctstr_startswith(istr, icheck);
507  free(istr);
508  free(icheck);
509  return startswith;
510 }
static char * fctstr_clone_lower(char const *s)
Definition: switch_fct.h:316
static int fctstr_startswith(char const *str, char const *check)
Definition: switch_fct.h:481

◆ fctstr_safe_cpy()

static void fctstr_safe_cpy ( char *  dst,
char const *  src,
size_t  num 
)
static

Definition at line 250 of file switch_fct.h.

References FCT_ASSERT.

Referenced by fct_test_new(), fct_ts_new(), fctchk_new(), fctkern__add_prefix_filter(), and fctstr_clone().

251 {
252  FCT_ASSERT( dst != NULL );
253  FCT_ASSERT( src != NULL );
254  FCT_ASSERT( num > 0 );
255 #if defined(WIN32) && _MSC_VER >= 1400
256  strncpy_s(dst, num, src, _TRUNCATE);
257 #else
258  strncpy(dst, src, num - 1);
259 #endif
260  dst[num-1] = '\0';
261 }
#define FCT_ASSERT(expr)
Definition: switch_fct.h:91

◆ fctstr_startswith()

static int fctstr_startswith ( char const *  str,
char const *  check 
)
static

Definition at line 481 of file switch_fct.h.

Referenced by fctstr_istartswith().

482 {
483  char const *sp;
484  if ( str == NULL && check == NULL )
485  {
486  return 1;
487  }
488  else if ( ((str == NULL) && (check != NULL))
489  || ((str != NULL) && (check == NULL)) )
490  {
491  return 0;
492  }
493  sp = strstr(str, check);
494  return sp == str;
495 }

Variable Documentation

◆ FCT_CLP_OPTIONS

fctcl_init_t FCT_CLP_OPTIONS[]
static
Initial value:
=
{
{
"Displays the FCTX version number and exits."
},
{
"Shows this help."
},
{
NULL
},
}
#define FCT_OPT_LOGGER
Definition: switch_fct.h:1901
#define FCT_OPT_LOGGER_SHORT
Definition: switch_fct.h:1902
#define FCT_OPT_HELP
Definition: switch_fct.h:1899
#define FCT_OPT_HELP_SHORT
Definition: switch_fct.h:1900
#define FCTCL_INIT_NULL
Definition: switch_fct.h:1406
#define FCT_OPT_VERSION
Definition: switch_fct.h:1897
#define FCT_OPT_VERSION_SHORT
Definition: switch_fct.h:1898

Definition at line 1903 of file switch_fct.h.

◆ fct_logger_default_vtable

fct_logger_i_vtable_t fct_logger_default_vtable
static
Initial value:

Definition at line 2575 of file switch_fct.h.

◆ FCT_LOGGER_TYPES

fct_logger_types_t FCT_LOGGER_TYPES[]
static
Initial value:
=
{
{
"standard",
"the basic fctx logger"
},
{
"minimal",
"the least amount of logging information."
},
{
"junit",
"junit compatible xml"
},
{NULL, (fct_logger_new_fn)NULL, NULL}
}
static fct_junit_logger_t * fct_junit_logger_new(void)
Definition: switch_fct.h:3188
fct_logger_i *(* fct_logger_new_fn)(void)
Definition: switch_fct.h:1929
static fct_logger_i * fct_minimal_logger_new(void)
Definition: switch_fct.h:2812
static fct_logger_i * fct_standard_logger_new(void)
Definition: switch_fct.h:2998

Definition at line 1937 of file switch_fct.h.

Referenced by fctkern__init().

◆ fct_saved_stderr

int fct_saved_stderr
static

Definition at line 187 of file switch_fct.h.

◆ fct_saved_stdout

int fct_saved_stdout
static

Definition at line 186 of file switch_fct.h.

◆ fct_stderr_pipe

int fct_stderr_pipe[2]
static

Definition at line 185 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_end().

◆ fct_stdout_pipe

int fct_stdout_pipe[2]
static

Definition at line 184 of file switch_fct.h.

Referenced by fct_junit_logger__on_test_suite_end().

◆ fct_xchk_file

char const* fct_xchk_file = NULL
static

Definition at line 3571 of file switch_fct.h.

Referenced by _fct_xchk_fn_varg().

◆ fct_xchk_kern

fctkern_t* fct_xchk_kern =NULL
static

Definition at line 3573 of file switch_fct.h.

◆ fct_xchk_lineno

int fct_xchk_lineno =0
static

Definition at line 3570 of file switch_fct.h.

Referenced by _fct_xchk_fn_varg().

◆ fct_xchk_test

fct_test_t* fct_xchk_test = NULL
static

Definition at line 3572 of file switch_fct.h.