mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Synchronize with upstream tinytest again: remove _identifiers
This commit is contained in:
parent
3b47a11654
commit
9efee31fae
@ -1,4 +1,5 @@
|
|||||||
o Minor bugfixes:
|
o Minor bugfixes:
|
||||||
- Update to the latest version of the tinytest unit testing framework.
|
- Update to the latest version of the tinytest unit testing framework.
|
||||||
This includes a couple of bugfixes that can be relevant for running
|
This includes a couple of bugfixes that can be relevant for running
|
||||||
forked unit tests on Windows.
|
forked unit tests on Windows, and a removal of all reserved
|
||||||
|
identifiers.
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
#define test_mem_op(expr1, op, expr2, len) \
|
#define test_mem_op(expr1, op, expr2, len) \
|
||||||
tt_assert_test_fmt_type(expr1,expr2,#expr1" "#op" "#expr2, \
|
tt_assert_test_fmt_type(expr1,expr2,#expr1" "#op" "#expr2, \
|
||||||
const char *, \
|
const char *, \
|
||||||
(memcmp(_val1, _val2, len) op 0), \
|
(memcmp(val1_, val2_, len) op 0), \
|
||||||
char *, "%s", \
|
char *, "%s", \
|
||||||
{ size_t printlen = (len)*2+1; \
|
{ size_t printlen = (len)*2+1; \
|
||||||
_print = tor_malloc(printlen); \
|
print_ = tor_malloc(printlen); \
|
||||||
base16_encode(_print, printlen, _value, \
|
base16_encode(print_, printlen, value_, \
|
||||||
(len)); }, \
|
(len)); }, \
|
||||||
{ tor_free(_print); }, \
|
{ tor_free(print_); }, \
|
||||||
TT_EXIT_TEST_FUNCTION \
|
TT_EXIT_TEST_FUNCTION \
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -73,17 +73,17 @@ test_addr_basic(void)
|
|||||||
#define _test_op_ip6(a,op,b,e1,e2) \
|
#define _test_op_ip6(a,op,b,e1,e2) \
|
||||||
STMT_BEGIN \
|
STMT_BEGIN \
|
||||||
tt_assert_test_fmt_type(a,b,e1" "#op" "e2,struct in6_addr*, \
|
tt_assert_test_fmt_type(a,b,e1" "#op" "e2,struct in6_addr*, \
|
||||||
(memcmp(_val1->s6_addr, _val2->s6_addr, 16) op 0), \
|
(memcmp(val1_->s6_addr, val2_->s6_addr, 16) op 0), \
|
||||||
char *, "%s", \
|
char *, "%s", \
|
||||||
{ int i; char *cp; \
|
{ int i; char *cp; \
|
||||||
cp = _print = tor_malloc(64); \
|
cp = print_ = tor_malloc(64); \
|
||||||
for (i=0;i<16;++i) { \
|
for (i=0;i<16;++i) { \
|
||||||
tor_snprintf(cp, 3,"%02x", (unsigned)_value->s6_addr[i]);\
|
tor_snprintf(cp, 3,"%02x", (unsigned)value_->s6_addr[i]);\
|
||||||
cp += 2; \
|
cp += 2; \
|
||||||
if (i != 15) *cp++ = ':'; \
|
if (i != 15) *cp++ = ':'; \
|
||||||
} \
|
} \
|
||||||
}, \
|
}, \
|
||||||
{ tor_free(_print); }, \
|
{ tor_free(print_); }, \
|
||||||
TT_EXIT_TEST_FUNCTION \
|
TT_EXIT_TEST_FUNCTION \
|
||||||
); \
|
); \
|
||||||
STMT_END
|
STMT_END
|
||||||
|
@ -305,7 +305,7 @@ test_dir_versions(void)
|
|||||||
|
|
||||||
#define tt_versionstatus_op(vs1, op, vs2) \
|
#define tt_versionstatus_op(vs1, op, vs2) \
|
||||||
tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \
|
tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \
|
||||||
(_val1 op _val2),"%d",TT_EXIT_TEST_FUNCTION)
|
(val1_ op val2_),"%d",TT_EXIT_TEST_FUNCTION)
|
||||||
#define test_v_i_o(val, ver, lst) \
|
#define test_v_i_o(val, ver, lst) \
|
||||||
tt_versionstatus_op(val, ==, tor_version_is_obsolete(ver, lst))
|
tt_versionstatus_op(val, ==, tor_version_is_obsolete(ver, lst))
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ static void usage(struct testgroup_t *groups, int list_groups)
|
|||||||
__attribute__((noreturn));
|
__attribute__((noreturn));
|
||||||
|
|
||||||
static enum outcome
|
static enum outcome
|
||||||
_testcase_run_bare(const struct testcase_t *testcase)
|
testcase_run_bare_(const struct testcase_t *testcase)
|
||||||
{
|
{
|
||||||
void *env = NULL;
|
void *env = NULL;
|
||||||
int outcome;
|
int outcome;
|
||||||
@ -100,7 +100,7 @@ _testcase_run_bare(const struct testcase_t *testcase)
|
|||||||
#define MAGIC_EXITCODE 42
|
#define MAGIC_EXITCODE 42
|
||||||
|
|
||||||
static enum outcome
|
static enum outcome
|
||||||
_testcase_run_forked(const struct testgroup_t *group,
|
testcase_run_forked_(const struct testgroup_t *group,
|
||||||
const struct testcase_t *testcase)
|
const struct testcase_t *testcase)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -119,7 +119,7 @@ _testcase_run_forked(const struct testgroup_t *group,
|
|||||||
DWORD exitcode;
|
DWORD exitcode;
|
||||||
|
|
||||||
if (!in_tinytest_main) {
|
if (!in_tinytest_main) {
|
||||||
printf("\nERROR. On Windows, _testcase_run_forked must be"
|
printf("\nERROR. On Windows, testcase_run_forked_ must be"
|
||||||
" called from within tinytest_main.\n");
|
" called from within tinytest_main.\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ _testcase_run_forked(const struct testgroup_t *group,
|
|||||||
int test_r, write_r;
|
int test_r, write_r;
|
||||||
char b[1];
|
char b[1];
|
||||||
close(outcome_pipe[0]);
|
close(outcome_pipe[0]);
|
||||||
test_r = _testcase_run_bare(testcase);
|
test_r = testcase_run_bare_(testcase);
|
||||||
assert(0<=(int)test_r && (int)test_r<=2);
|
assert(0<=(int)test_r && (int)test_r<=2);
|
||||||
b[0] = "NYS"[test_r];
|
b[0] = "NYS"[test_r];
|
||||||
write_r = (int)write(outcome_pipe[1], b, 1);
|
write_r = (int)write(outcome_pipe[1], b, 1);
|
||||||
@ -219,9 +219,9 @@ testcase_run_one(const struct testgroup_t *group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((testcase->flags & TT_FORK) && !(opt_forked||opt_nofork)) {
|
if ((testcase->flags & TT_FORK) && !(opt_forked||opt_nofork)) {
|
||||||
outcome = _testcase_run_forked(group, testcase);
|
outcome = testcase_run_forked_(group, testcase);
|
||||||
} else {
|
} else {
|
||||||
outcome = _testcase_run_bare(testcase);
|
outcome = testcase_run_bare_(testcase);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outcome == OK) {
|
if (outcome == OK) {
|
||||||
@ -247,7 +247,7 @@ testcase_run_one(const struct testgroup_t *group,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_tinytest_set_flag(struct testgroup_t *groups, const char *arg, unsigned long flag)
|
tinytest_set_flag_(struct testgroup_t *groups, const char *arg, unsigned long flag)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
size_t length = LONGEST_TEST_NAME;
|
size_t length = LONGEST_TEST_NAME;
|
||||||
@ -279,7 +279,7 @@ usage(struct testgroup_t *groups, int list_groups)
|
|||||||
puts(" Use --list-tests for a list of tests.");
|
puts(" Use --list-tests for a list of tests.");
|
||||||
if (list_groups) {
|
if (list_groups) {
|
||||||
puts("Known tests are:");
|
puts("Known tests are:");
|
||||||
_tinytest_set_flag(groups, "..", 0);
|
tinytest_set_flag_(groups, "..", 0);
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -322,28 +322,28 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const char *test = v[i];
|
const char *test = v[i];
|
||||||
int flag = _TT_ENABLED;
|
int flag = TT_ENABLED_;
|
||||||
if (test[0] == ':') {
|
if (test[0] == ':') {
|
||||||
++test;
|
++test;
|
||||||
flag = TT_SKIP;
|
flag = TT_SKIP;
|
||||||
} else {
|
} else {
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
if (!_tinytest_set_flag(groups, test, flag)) {
|
if (!tinytest_set_flag_(groups, test, flag)) {
|
||||||
printf("No such test as %s!\n", v[i]);
|
printf("No such test as %s!\n", v[i]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!n)
|
if (!n)
|
||||||
_tinytest_set_flag(groups, "..", _TT_ENABLED);
|
tinytest_set_flag_(groups, "..", TT_ENABLED_);
|
||||||
|
|
||||||
setvbuf(stdout, NULL, _IONBF, 0);
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
|
||||||
++in_tinytest_main;
|
++in_tinytest_main;
|
||||||
for (i=0; groups[i].prefix; ++i)
|
for (i=0; groups[i].prefix; ++i)
|
||||||
for (j=0; groups[i].cases[j].name; ++j)
|
for (j=0; groups[i].cases[j].name; ++j)
|
||||||
if (groups[i].cases[j].flags & _TT_ENABLED)
|
if (groups[i].cases[j].flags & TT_ENABLED_)
|
||||||
testcase_run_one(&groups[i],
|
testcase_run_one(&groups[i],
|
||||||
&groups[i].cases[j]);
|
&groups[i].cases[j]);
|
||||||
|
|
||||||
@ -362,13 +362,13 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_tinytest_get_verbosity(void)
|
tinytest_get_verbosity_(void)
|
||||||
{
|
{
|
||||||
return opt_verbosity;
|
return opt_verbosity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_tinytest_set_test_failed(void)
|
tinytest_set_test_failed_(void)
|
||||||
{
|
{
|
||||||
if (opt_verbosity <= 0 && cur_test_name) {
|
if (opt_verbosity <= 0 && cur_test_name) {
|
||||||
if (opt_verbosity==0) puts("");
|
if (opt_verbosity==0) puts("");
|
||||||
@ -379,7 +379,7 @@ _tinytest_set_test_failed(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_tinytest_set_test_skipped(void)
|
tinytest_set_test_skipped_(void)
|
||||||
{
|
{
|
||||||
if (cur_test_outcome==OK)
|
if (cur_test_outcome==OK)
|
||||||
cur_test_outcome = SKIP;
|
cur_test_outcome = SKIP;
|
||||||
|
@ -23,15 +23,15 @@
|
|||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TINYTEST_H
|
#ifndef TINYTEST_H_INCLUDED_
|
||||||
#define _TINYTEST_H
|
#define TINYTEST_H_INCLUDED_
|
||||||
|
|
||||||
/** Flag for a test that needs to run in a subprocess. */
|
/** Flag for a test that needs to run in a subprocess. */
|
||||||
#define TT_FORK (1<<0)
|
#define TT_FORK (1<<0)
|
||||||
/** Runtime flag for a test we've decided to skip. */
|
/** Runtime flag for a test we've decided to skip. */
|
||||||
#define TT_SKIP (1<<1)
|
#define TT_SKIP (1<<1)
|
||||||
/** Internal runtime flag for a test we've decided to run. */
|
/** Internal runtime flag for a test we've decided to run. */
|
||||||
#define _TT_ENABLED (1<<2)
|
#define TT_ENABLED_ (1<<2)
|
||||||
/** If you add your own flags, make them start at this point. */
|
/** If you add your own flags, make them start at this point. */
|
||||||
#define TT_FIRST_USER_FLAG (1<<3)
|
#define TT_FIRST_USER_FLAG (1<<3)
|
||||||
|
|
||||||
@ -65,18 +65,18 @@ struct testgroup_t {
|
|||||||
#define END_OF_GROUPS { NULL, NULL}
|
#define END_OF_GROUPS { NULL, NULL}
|
||||||
|
|
||||||
/** Implementation: called from a test to indicate failure, before logging. */
|
/** Implementation: called from a test to indicate failure, before logging. */
|
||||||
void _tinytest_set_test_failed(void);
|
void tinytest_set_test_failed_(void);
|
||||||
/** Implementation: called from a test to indicate that we're skipping. */
|
/** Implementation: called from a test to indicate that we're skipping. */
|
||||||
void _tinytest_set_test_skipped(void);
|
void tinytest_set_test_skipped_(void);
|
||||||
/** Implementation: return 0 for quiet, 1 for normal, 2 for loud. */
|
/** Implementation: return 0 for quiet, 1 for normal, 2 for loud. */
|
||||||
int _tinytest_get_verbosity(void);
|
int tinytest_get_verbosity_(void);
|
||||||
/** Implementation: Set a flag on tests matching a name; returns number
|
/** Implementation: Set a flag on tests matching a name; returns number
|
||||||
* of tests that matched. */
|
* of tests that matched. */
|
||||||
int _tinytest_set_flag(struct testgroup_t *, const char *, unsigned long);
|
int tinytest_set_flag_(struct testgroup_t *, const char *, unsigned long);
|
||||||
|
|
||||||
/** Set all tests in 'groups' matching the name 'named' to be skipped. */
|
/** Set all tests in 'groups' matching the name 'named' to be skipped. */
|
||||||
#define tinytest_skip(groups, named) \
|
#define tinytest_skip(groups, named) \
|
||||||
_tinytest_set_flag(groups, named, TT_SKIP)
|
tinytest_set_flag_(groups, named, TT_SKIP)
|
||||||
|
|
||||||
/** Run a single testcase in a single group. */
|
/** Run a single testcase in a single group. */
|
||||||
int testcase_run_one(const struct testgroup_t *,const struct testcase_t *);
|
int testcase_run_one(const struct testgroup_t *,const struct testcase_t *);
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TINYTEST_MACROS_H
|
#ifndef TINYTEST_MACROS_H_INCLUDED_
|
||||||
#define _TINYTEST_MACROS_H
|
#define TINYTEST_MACROS_H_INCLUDED_
|
||||||
|
|
||||||
/* Helpers for defining statement-like macros */
|
/* Helpers for defining statement-like macros */
|
||||||
#define TT_STMT_BEGIN do {
|
#define TT_STMT_BEGIN do {
|
||||||
@ -51,30 +51,30 @@
|
|||||||
/* Announce a non-failure if we're verbose. */
|
/* Announce a non-failure if we're verbose. */
|
||||||
#define TT_BLATHER(args) \
|
#define TT_BLATHER(args) \
|
||||||
TT_STMT_BEGIN \
|
TT_STMT_BEGIN \
|
||||||
if (_tinytest_get_verbosity()>1) TT_DECLARE(" OK", args); \
|
if (tinytest_get_verbosity_()>1) TT_DECLARE(" OK", args); \
|
||||||
TT_STMT_END
|
TT_STMT_END
|
||||||
|
|
||||||
#define TT_DIE(args) \
|
#define TT_DIE(args) \
|
||||||
TT_STMT_BEGIN \
|
TT_STMT_BEGIN \
|
||||||
_tinytest_set_test_failed(); \
|
tinytest_set_test_failed_(); \
|
||||||
TT_GRIPE(args); \
|
TT_GRIPE(args); \
|
||||||
TT_EXIT_TEST_FUNCTION; \
|
TT_EXIT_TEST_FUNCTION; \
|
||||||
TT_STMT_END
|
TT_STMT_END
|
||||||
|
|
||||||
#define TT_FAIL(args) \
|
#define TT_FAIL(args) \
|
||||||
TT_STMT_BEGIN \
|
TT_STMT_BEGIN \
|
||||||
_tinytest_set_test_failed(); \
|
tinytest_set_test_failed_(); \
|
||||||
TT_GRIPE(args); \
|
TT_GRIPE(args); \
|
||||||
TT_STMT_END
|
TT_STMT_END
|
||||||
|
|
||||||
/* Fail and abort the current test for the reason in msg */
|
/* Fail and abort the current test for the reason in msg */
|
||||||
#define tt_abort_printf(msg) TT_DIE(msg)
|
#define tt_abortprint_f(msg) TT_DIE(msg)
|
||||||
#define tt_abort_perror(op) TT_DIE(("%s: %s [%d]",(op),strerror(errno), errno))
|
#define tt_abort_perror(op) TT_DIE(("%s: %s [%d]",(op),strerror(errno), errno))
|
||||||
#define tt_abort_msg(msg) TT_DIE(("%s", msg))
|
#define tt_abort_msg(msg) TT_DIE(("%s", msg))
|
||||||
#define tt_abort() TT_DIE(("%s", "(Failed.)"))
|
#define tt_abort() TT_DIE(("%s", "(Failed.)"))
|
||||||
|
|
||||||
/* Fail but do not abort the current test for the reason in msg. */
|
/* Fail but do not abort the current test for the reason in msg. */
|
||||||
#define tt_fail_printf(msg) TT_FAIL(msg)
|
#define tt_failprint_f(msg) TT_FAIL(msg)
|
||||||
#define tt_fail_perror(op) TT_FAIL(("%s: %s [%d]",(op),strerror(errno), errno))
|
#define tt_fail_perror(op) TT_FAIL(("%s: %s [%d]",(op),strerror(errno), errno))
|
||||||
#define tt_fail_msg(msg) TT_FAIL(("%s", msg))
|
#define tt_fail_msg(msg) TT_FAIL(("%s", msg))
|
||||||
#define tt_fail() TT_FAIL(("%s", "(Failed.)"))
|
#define tt_fail() TT_FAIL(("%s", "(Failed.)"))
|
||||||
@ -86,10 +86,10 @@
|
|||||||
TT_EXIT_TEST_FUNCTION; \
|
TT_EXIT_TEST_FUNCTION; \
|
||||||
TT_STMT_END
|
TT_STMT_END
|
||||||
|
|
||||||
#define _tt_want(b, msg, fail) \
|
#define tt_want_(b, msg, fail) \
|
||||||
TT_STMT_BEGIN \
|
TT_STMT_BEGIN \
|
||||||
if (!(b)) { \
|
if (!(b)) { \
|
||||||
_tinytest_set_test_failed(); \
|
tinytest_set_test_failed_(); \
|
||||||
TT_GRIPE(("%s",msg)); \
|
TT_GRIPE(("%s",msg)); \
|
||||||
fail; \
|
fail; \
|
||||||
} else { \
|
} else { \
|
||||||
@ -99,11 +99,11 @@
|
|||||||
|
|
||||||
/* Assert b, but do not stop the test if b fails. Log msg on failure. */
|
/* Assert b, but do not stop the test if b fails. Log msg on failure. */
|
||||||
#define tt_want_msg(b, msg) \
|
#define tt_want_msg(b, msg) \
|
||||||
_tt_want(b, msg, );
|
tt_want_(b, msg, );
|
||||||
|
|
||||||
/* Assert b and stop the test if b fails. Log msg on failure. */
|
/* Assert b and stop the test if b fails. Log msg on failure. */
|
||||||
#define tt_assert_msg(b, msg) \
|
#define tt_assert_msg(b, msg) \
|
||||||
_tt_want(b, msg, TT_EXIT_TEST_FUNCTION);
|
tt_want_(b, msg, TT_EXIT_TEST_FUNCTION);
|
||||||
|
|
||||||
/* Assert b, but do not stop the test if b fails. */
|
/* Assert b, but do not stop the test if b fails. */
|
||||||
#define tt_want(b) tt_want_msg( (b), "want("#b")")
|
#define tt_want(b) tt_want_msg( (b), "want("#b")")
|
||||||
@ -113,28 +113,28 @@
|
|||||||
#define tt_assert_test_fmt_type(a,b,str_test,type,test,printf_type,printf_fmt, \
|
#define tt_assert_test_fmt_type(a,b,str_test,type,test,printf_type,printf_fmt, \
|
||||||
setup_block,cleanup_block,die_on_fail) \
|
setup_block,cleanup_block,die_on_fail) \
|
||||||
TT_STMT_BEGIN \
|
TT_STMT_BEGIN \
|
||||||
type _val1 = (type)(a); \
|
type val1_ = (type)(a); \
|
||||||
type _val2 = (type)(b); \
|
type val2_ = (type)(b); \
|
||||||
int _tt_status = (test); \
|
int tt_status_ = (test); \
|
||||||
if (!_tt_status || _tinytest_get_verbosity()>1) { \
|
if (!tt_status_ || tinytest_get_verbosity_()>1) { \
|
||||||
printf_type _print; \
|
printf_type print_; \
|
||||||
printf_type _print1; \
|
printf_type print1_; \
|
||||||
printf_type _print2; \
|
printf_type print2_; \
|
||||||
type _value = _val1; \
|
type value_ = val1_; \
|
||||||
setup_block; \
|
setup_block; \
|
||||||
_print1 = _print; \
|
print1_ = print_; \
|
||||||
_value = _val2; \
|
value_ = val2_; \
|
||||||
setup_block; \
|
setup_block; \
|
||||||
_print2 = _print; \
|
print2_ = print_; \
|
||||||
TT_DECLARE(_tt_status?" OK":"FAIL", \
|
TT_DECLARE(tt_status_?" OK":"FAIL", \
|
||||||
("assert(%s): "printf_fmt" vs "printf_fmt, \
|
("assert(%s): "printf_fmt" vs "printf_fmt, \
|
||||||
str_test, _print1, _print2)); \
|
str_test, print1_, print2_)); \
|
||||||
_print = _print1; \
|
print_ = print1_; \
|
||||||
cleanup_block; \
|
cleanup_block; \
|
||||||
_print = _print2; \
|
print_ = print2_; \
|
||||||
cleanup_block; \
|
cleanup_block; \
|
||||||
if (!_tt_status) { \
|
if (!tt_status_) { \
|
||||||
_tinytest_set_test_failed(); \
|
tinytest_set_test_failed_(); \
|
||||||
die_on_fail ; \
|
die_on_fail ; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -142,43 +142,43 @@
|
|||||||
|
|
||||||
#define tt_assert_test_type(a,b,str_test,type,test,fmt,die_on_fail) \
|
#define tt_assert_test_type(a,b,str_test,type,test,fmt,die_on_fail) \
|
||||||
tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \
|
tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \
|
||||||
{_print=_value;},{},die_on_fail)
|
{print_=value_;},{},die_on_fail)
|
||||||
|
|
||||||
/* Helper: assert that a op b, when cast to type. Format the values with
|
/* Helper: assert that a op b, when cast to type. Format the values with
|
||||||
* printf format fmt on failure. */
|
* printf format fmt on failure. */
|
||||||
#define tt_assert_op_type(a,op,b,type,fmt) \
|
#define tt_assert_op_type(a,op,b,type,fmt) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,type,(_val1 op _val2),fmt, \
|
tt_assert_test_type(a,b,#a" "#op" "#b,type,(val1_ op val2_),fmt, \
|
||||||
TT_EXIT_TEST_FUNCTION)
|
TT_EXIT_TEST_FUNCTION)
|
||||||
|
|
||||||
#define tt_int_op(a,op,b) \
|
#define tt_int_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,long,(_val1 op _val2), \
|
tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_), \
|
||||||
"%ld",TT_EXIT_TEST_FUNCTION)
|
"%ld",TT_EXIT_TEST_FUNCTION)
|
||||||
|
|
||||||
#define tt_uint_op(a,op,b) \
|
#define tt_uint_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \
|
tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \
|
||||||
(_val1 op _val2),"%lu",TT_EXIT_TEST_FUNCTION)
|
(val1_ op val2_),"%lu",TT_EXIT_TEST_FUNCTION)
|
||||||
|
|
||||||
#define tt_ptr_op(a,op,b) \
|
#define tt_ptr_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
|
tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
|
||||||
(_val1 op _val2),"%p",TT_EXIT_TEST_FUNCTION)
|
(val1_ op val2_),"%p",TT_EXIT_TEST_FUNCTION)
|
||||||
|
|
||||||
#define tt_str_op(a,op,b) \
|
#define tt_str_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
|
tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
|
||||||
(strcmp(_val1,_val2) op 0),"<%s>",TT_EXIT_TEST_FUNCTION)
|
(strcmp(val1_,val2_) op 0),"<%s>",TT_EXIT_TEST_FUNCTION)
|
||||||
|
|
||||||
#define tt_want_int_op(a,op,b) \
|
#define tt_want_int_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,long,(_val1 op _val2),"%ld",(void)0)
|
tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_),"%ld",(void)0)
|
||||||
|
|
||||||
#define tt_want_uint_op(a,op,b) \
|
#define tt_want_uint_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \
|
tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \
|
||||||
(_val1 op _val2),"%lu",(void)0)
|
(val1_ op val2_),"%lu",(void)0)
|
||||||
|
|
||||||
#define tt_want_ptr_op(a,op,b) \
|
#define tt_want_ptr_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
|
tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
|
||||||
(_val1 op _val2),"%p",(void)0)
|
(val1_ op val2_),"%p",(void)0)
|
||||||
|
|
||||||
#define tt_want_str_op(a,op,b) \
|
#define tt_want_str_op(a,op,b) \
|
||||||
tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
|
tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
|
||||||
(strcmp(_val1,_val2) op 0),"<%s>",(void)0)
|
(strcmp(val1_,val2_) op 0),"<%s>",(void)0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user