mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-01 08:03:31 +01:00
Upgrade to the latest version of tinytest
This commit is contained in:
parent
b2e7c356db
commit
676608f9a6
@ -45,7 +45,8 @@
|
||||
_print = tor_malloc(printlen); \
|
||||
base16_encode(_print, printlen, _value, \
|
||||
(len)); }, \
|
||||
{ tor_free(_print); } \
|
||||
{ tor_free(_print); }, \
|
||||
TT_EXIT_TEST_FUNCTION \
|
||||
);
|
||||
|
||||
#define test_memeq(expr1, expr2, len) test_mem_op((expr1), ==, (expr2), len)
|
||||
|
@ -74,7 +74,9 @@ test_addr_basic(void)
|
||||
cp += 2; \
|
||||
if (i != 15) *cp++ = ':'; \
|
||||
} \
|
||||
}, { tor_free(_print); } \
|
||||
}, \
|
||||
{ tor_free(_print); }, \
|
||||
TT_EXIT_TEST_FUNCTION \
|
||||
); \
|
||||
STMT_END
|
||||
|
||||
|
@ -298,7 +298,7 @@ test_dir_versions(void)
|
||||
|
||||
#define tt_versionstatus_op(vs1, op, vs2) \
|
||||
tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \
|
||||
(_val1 op _val2),"%d")
|
||||
(_val1 op _val2),"%d",TT_EXIT_TEST_FUNCTION)
|
||||
#define test_v_i_o(val, ver, lst) \
|
||||
tt_versionstatus_op(val, ==, tor_version_is_obsolete(ver, lst))
|
||||
|
||||
|
@ -28,7 +28,11 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef TINYTEST_LOCAL
|
||||
#include "tinytest_local.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
@ -40,9 +44,6 @@
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifdef TINYTEST_LOCAL
|
||||
#include "tinytest_local.h"
|
||||
#endif
|
||||
#include "tinytest.h"
|
||||
#include "tinytest_macros.h"
|
||||
|
||||
@ -64,7 +65,7 @@ const char *cur_test_prefix = NULL; /**< prefix of the current test group */
|
||||
/** Name of the current test, if we haven't logged is yet. Used for --quiet */
|
||||
const char *cur_test_name = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/** Pointer to argv[0] for win32. */
|
||||
static const char *commandname = NULL;
|
||||
#endif
|
||||
@ -103,7 +104,7 @@ static enum outcome
|
||||
_testcase_run_forked(const struct testgroup_t *group,
|
||||
const struct testcase_t *testcase)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
/* Fork? On Win32? How primitive! We'll do what the smart kids do:
|
||||
we'll invoke our own exe (whose name we recall from the command
|
||||
line) with a command line that tells it to run just the test we
|
||||
@ -174,6 +175,7 @@ _testcase_run_forked(const struct testgroup_t *group,
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
return FAIL; /* unreachable */
|
||||
} else {
|
||||
/* parent */
|
||||
int status, r;
|
||||
@ -239,6 +241,7 @@ testcase_run_one(const struct testgroup_t *group,
|
||||
|
||||
if (opt_forked) {
|
||||
exit(outcome==OK ? 0 : (outcome==SKIP?MAGIC_EXITCODE : 1));
|
||||
return 1; /* unreachable */
|
||||
} else {
|
||||
return (int)outcome;
|
||||
}
|
||||
@ -287,7 +290,7 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
|
||||
{
|
||||
int i, j, n=0;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
commandname = v[0];
|
||||
#endif
|
||||
for (i=1; i<c; ++i) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* tinytest_demo.c -- Copyright 2009 Nick Mathewson
|
||||
/* tinytest_demo.c -- Copyright 2009-2010 Nick Mathewson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -90,10 +90,10 @@
|
||||
TT_STMT_BEGIN \
|
||||
if (!(b)) { \
|
||||
_tinytest_set_test_failed(); \
|
||||
TT_GRIPE((msg)); \
|
||||
TT_GRIPE(("%s",msg)); \
|
||||
fail; \
|
||||
} else { \
|
||||
TT_BLATHER((msg)); \
|
||||
TT_BLATHER(("%s",msg)); \
|
||||
} \
|
||||
TT_STMT_END
|
||||
|
||||
@ -111,7 +111,7 @@
|
||||
#define tt_assert(b) tt_assert_msg((b), "assert("#b")")
|
||||
|
||||
#define tt_assert_test_fmt_type(a,b,str_test,type,test,printf_type,printf_fmt, \
|
||||
setup_block,cleanup_block) \
|
||||
setup_block,cleanup_block,die_on_fail) \
|
||||
TT_STMT_BEGIN \
|
||||
type _val1 = (type)(a); \
|
||||
type _val2 = (type)(b); \
|
||||
@ -135,33 +135,50 @@
|
||||
cleanup_block; \
|
||||
if (!_tt_status) { \
|
||||
_tinytest_set_test_failed(); \
|
||||
TT_EXIT_TEST_FUNCTION; \
|
||||
die_on_fail ; \
|
||||
} \
|
||||
} \
|
||||
TT_STMT_END
|
||||
|
||||
#define tt_assert_test_type(a,b,str_test,type,test,fmt) \
|
||||
#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, \
|
||||
{_print=_value;},{})
|
||||
{_print=_value;},{},die_on_fail)
|
||||
|
||||
/* Helper: assert that a op b, when cast to type. Format the values with
|
||||
* printf format fmt on failure. */
|
||||
#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)
|
||||
|
||||
#define tt_int_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,long,(_val1 op _val2),"%ld")
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,long,(_val1 op _val2), \
|
||||
"%ld",TT_EXIT_TEST_FUNCTION)
|
||||
|
||||
#define tt_uint_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \
|
||||
(_val1 op _val2),"%lu")
|
||||
(_val1 op _val2),"%lu",TT_EXIT_TEST_FUNCTION)
|
||||
|
||||
#define tt_ptr_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
|
||||
(_val1 op _val2),"%p")
|
||||
(_val1 op _val2),"%p",TT_EXIT_TEST_FUNCTION)
|
||||
|
||||
#define tt_str_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
|
||||
(strcmp(_val1,_val2) op 0),"<%s>")
|
||||
(strcmp(_val1,_val2) op 0),"<%s>",TT_EXIT_TEST_FUNCTION)
|
||||
|
||||
#define tt_want_int_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,long,(_val1 op _val2),"%ld",(void)0)
|
||||
|
||||
#define tt_want_uint_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,unsigned long, \
|
||||
(_val1 op _val2),"%lu",(void)0)
|
||||
|
||||
#define tt_want_ptr_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
|
||||
(_val1 op _val2),"%p",(void)0)
|
||||
|
||||
#define tt_want_str_op(a,op,b) \
|
||||
tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
|
||||
(strcmp(_val1,_val2) op 0),"<%s>",(void)0)
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user