[tor-commits] [tor/master] Fix numerous type errors in the unit tests
nickm at torproject.org
nickm at torproject.org
Thu May 8 17:08:41 UTC 2014
commit 5bb617236704be189e68c713d95dac002912a219
Author: Nick Mathewson <nickm at torproject.org>
Date: Thu May 8 13:08:13 2014 -0400
Fix numerous type errors in the unit tests
Remove tinytest casts that were suppressing them.
Fix for #11825.
---
src/ext/tinytest_macros.h | 10 +++++-----
src/test/test_buffers.c | 2 +-
src/test/test_circuitlist.c | 2 +-
src/test/test_extorport.c | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/ext/tinytest_macros.h b/src/ext/tinytest_macros.h
index db2dfcb..c3728d1 100644
--- a/src/ext/tinytest_macros.h
+++ b/src/ext/tinytest_macros.h
@@ -113,8 +113,8 @@
#define tt_assert_test_fmt_type(a,b,str_test,type,test,printf_type,printf_fmt, \
setup_block,cleanup_block,die_on_fail) \
TT_STMT_BEGIN \
- type val1_ = (type)(a); \
- type val2_ = (type)(b); \
+ type val1_ = (a); \
+ type val2_ = (b); \
int tt_status_ = (test); \
if (!tt_status_ || tinytest_get_verbosity_()>1) { \
printf_type print_; \
@@ -163,7 +163,7 @@
(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*, \
+ tt_assert_test_type(a,b,#a" "#op" "#b,const void*, \
(val1_ op val2_),"%p",TT_EXIT_TEST_FUNCTION)
#define tt_str_op(a,op,b) \
@@ -173,7 +173,7 @@
#define tt_mem_op(expr1, op, expr2, len) \
tt_assert_test_fmt_type(expr1,expr2,#expr1" "#op" "#expr2, \
- const char *, \
+ const void *, \
(val1_ && val2_ && memcmp(val1_, val2_, len) op 0), \
char *, "%s", \
{ print_ = tinytest_format_hex_(value_, (len)); }, \
@@ -189,7 +189,7 @@
(val1_ op val2_),"%lu",(void)0)
#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,const void*, \
(val1_ op val2_),"%p",(void)0)
#define tt_want_str_op(a,op,b) \
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index cb78a4b..78b3aea 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -222,7 +222,7 @@ test_buffer_pullup(void *arg)
buf_pullup(buf, 16, 1);
buf_get_first_chunk_data(buf, &cp, &sz);
tt_ptr_op(cp, ==, NULL);
- tt_ptr_op(sz, ==, 0);
+ tt_uint_op(sz, ==, 0);
/* Let's make sure nothing got allocated */
tt_int_op(buf_get_total_allocation(), ==, 0);
diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c
index 7b7d415..b19edd1 100644
--- a/src/test/test_circuitlist.c
+++ b/src/test/test_circuitlist.c
@@ -53,7 +53,7 @@ circuitmux_detach_mock(circuitmux_t *cmux, circuit_t *circ)
tt_int_op(cam.ncalls, ==, 1); \
tt_ptr_op(cam.cmux, ==, (mux_)); \
tt_ptr_op(cam.circ, ==, (circ_)); \
- tt_ptr_op(cam.dir, ==, (dir_)); \
+ tt_int_op(cam.dir, ==, (dir_)); \
memset(&cam, 0, sizeof(cam)); \
} while (0)
diff --git a/src/test/test_extorport.c b/src/test/test_extorport.c
index d47792f..64ed24e 100644
--- a/src/test/test_extorport.c
+++ b/src/test/test_extorport.c
@@ -338,7 +338,7 @@ test_ext_or_cookie_auth_testvec(void *arg)
handle_client_auth_nonce(client_nonce, 32, &client_hash, &reply,
&reply_len));
tt_ptr_op(reply, !=, NULL );
- tt_ptr_op(reply_len, ==, 64);
+ tt_uint_op(reply_len, ==, 64);
test_memeq(reply+32, "te road There is always another ", 32);
/* HMACSHA256("Gliding wrapt in a brown mantle,"
* "ExtORPort authentication server-to-client hash"
More information about the tor-commits
mailing list