dpkg 1.21.11
Macros
Test suite support
Collaboration diagram for Test suite support:

Macros

#define test_bail(reason)
 
#define test_xstringify(str)    #str
 
#define test_stringify(str)    test_xstringify(str)
 
#define test_alloc(ptr)    test_alloc((ptr), "cannot allocate memory for " #ptr " in " __FILE__ ":" test_stringify(__LINE__))
 
#define test_try(jmp)
 
#define test_catch    else
 
#define test_finally    pop_error_context(ehflag_normaltidy);
 
#define test_get_srcdir()    test_get_envdir("srcdir")
 
#define test_get_builddir()    test_get_envdir("builddir")
 
#define test_plan(n)    printf("1..%d\n", n);
 
#define test_skip_all(reason)
 
#define test_skip(reason)    printf("ok %d # SKIP %s\n", test_id++, (reason))
 
#define test_skip_block(cond)
 
#define test_todo(a, reason, desc)
 
#define test_todo_block(reason)
 
#define test_case(a, fmt, ...)
 
#define test_pass(a)    test_case((a), "pass %s", #a)
 
#define test_fail(a)    test_case(!(a), "fail %s", #a)
 
#define test_str(a, op, b)    test_case(strcmp((a), (b)) op 0, "strcmp '%s' %s '%s'", a, #op, b)
 
#define test_mem(a, op, b, size)    test_case(memcmp((a), (b), (size)) op 0, "memcmp %p %s %p", a, #op, b)
 
#define test_warn(e)
 
#define test_error(e)
 

Detailed Description

Macro Definition Documentation

◆ test_alloc

#define test_alloc (   ptr)     test_alloc((ptr), "cannot allocate memory for " #ptr " in " __FILE__ ":" test_stringify(__LINE__))

◆ test_bail

#define test_bail (   reason)
Value:
do { \
printf("Bail out! %s\n", (reason)); \
exit(255); \
} while (0)

◆ test_case

#define test_case (   a,
  fmt,
  ... 
)
Value:
printf("%sok %d - " fmt "%s%s\n", \
test_skip_code || (a) ? "" : "not ", \
test_id++, __VA_ARGS__, \
test_skip_reason ? test_skip_prefix : "", \
test_skip_reason ? test_skip_reason : "")

◆ test_catch

#define test_catch    else

◆ test_error

#define test_error (   e)
Value:
do { \
test_pass((e).type == DPKG_MSG_ERROR); \
dpkg_error_destroy(&(e)); \
} while (0)
@ DPKG_MSG_ERROR
Definition: error.h:39

◆ test_fail

#define test_fail (   a)     test_case(!(a), "fail %s", #a)

◆ test_finally

#define test_finally    pop_error_context(ehflag_normaltidy);

◆ test_get_builddir

#define test_get_builddir ( )     test_get_envdir("builddir")

◆ test_get_srcdir

#define test_get_srcdir ( )     test_get_envdir("srcdir")

◆ test_mem

#define test_mem (   a,
  op,
  b,
  size 
)     test_case(memcmp((a), (b), (size)) op 0, "memcmp %p %s %p", a, #op, b)

◆ test_pass

#define test_pass (   a)     test_case((a), "pass %s", #a)

◆ test_plan

#define test_plan (   n)     printf("1..%d\n", n);

◆ test_skip

#define test_skip (   reason)     printf("ok %d # SKIP %s\n", test_id++, (reason))

◆ test_skip_all

#define test_skip_all (   reason)
Value:
do { \
printf("1..0 # SKIP %s\n", (reason)); \
exit(0); \
} while (0)

◆ test_skip_block

#define test_skip_block (   cond)
Value:
for (test_skip_prefix = " # SKIP ", \
test_skip_reason = cond ? #cond : DPKG_NULL, \
test_skip_code = 1; \
test_skip_prefix; \
test_skip_prefix = test_skip_reason = DPKG_NULL, \
test_skip_code = 0)
#define DPKG_NULL
A null pointer constant that works on C or C++.
Definition: macros.h:102

◆ test_str

#define test_str (   a,
  op,
 
)     test_case(strcmp((a), (b)) op 0, "strcmp '%s' %s '%s'", a, #op, b)

◆ test_stringify

#define test_stringify (   str)     test_xstringify(str)

◆ test_todo

#define test_todo (   a,
  reason,
  desc 
)
Value:
do { \
test_skip_prefix = " # TODO "; \
test_skip_reason = reason; \
test_case(a, "%s", desc); \
test_skip_prefix = test_skip_reason = DPKG_NULL; \
} while(0)

◆ test_todo_block

#define test_todo_block (   reason)
Value:
for (test_skip_prefix = " # TODO ", test_skip_reason = reason; \
test_skip_prefix; \
test_skip_prefix = test_skip_reason = DPKG_NULL)

◆ test_try

#define test_try (   jmp)
Value:
push_error_context_jump(&(jmp), DPKG_NULL, "test try"); \
if (!setjmp((jmp)))
void push_error_context_jump(jmp_buf *jumper, error_printer_func *printer, const void *printer_data)
Definition: ehandle.c:232

◆ test_warn

#define test_warn (   e)
Value:
do { \
test_pass((e).type == DPKG_MSG_WARN); \
dpkg_error_destroy(&(e)); \
} while (0)
@ DPKG_MSG_WARN
Definition: error.h:38

◆ test_xstringify

#define test_xstringify (   str)     #str