diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-16 09:30:22 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-16 09:30:22 -0400 |
commit | a6627fdb80935d68b8e7f1c4e098f8ce54894842 (patch) | |
tree | 0fd6bff96ab59e4fbed48e54dd27d77eb82d8c28 /src/test/test_addr.c | |
parent | c72a94ea1c51b53aa174f82da11cdbc8a99b3c40 (diff) | |
download | tor-a6627fdb80935d68b8e7f1c4e098f8ce54894842.tar.gz tor-a6627fdb80935d68b8e7f1c4e098f8ce54894842.zip |
Remove the legacy_test_helper and legacy_setup wrappers
These wrappers went into place when the default type for our unit
test functions changed from "void fn(void)" to "void fn(void *arg)".
To generate this patch, I did the same hokey-pokey as before with
replacing all operators used as macro arguments, then I ran a
coccinelle script, then I ran perl script to fix up everything that
used legacy_test_helper, then I manually removed the
legacy_test_helper functions, then I ran a final perl script to put
the operators back how they were.
==============================
#!/usr/bin/perl -w -i -p
s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;
--------------------
@@
identifier func =~ "test_.*$";
statement S, S2;
@@
static void func (
-void
+void *arg
)
{
... when != S2
+(void) arg;
S
...
}
--------------------
#!/usr/bin/perl -w -i -p
s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
--------------------
#!/usr/bin/perl -w -i -p
s/_X_NEQ_/!=/g;
s/_X_NE_/!=/g;
s/_X_EQ_/==/g;
s/_X_GT_/>/g;
s/_X_LT_/</g;
s/_X_GEQ_/>=/g;
s/_X_LEQ_/<=/g;
--------------------
Diffstat (limited to 'src/test/test_addr.c')
-rw-r--r-- | src/test/test_addr.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/test/test_addr.c b/src/test/test_addr.c index d319440ef6..28860f6a49 100644 --- a/src/test/test_addr.c +++ b/src/test/test_addr.c @@ -10,13 +10,14 @@ #include "addressmap.h" static void -test_addr_basic(void) +test_addr_basic(void *arg) { uint32_t u32; uint16_t u16; char *cp; /* Test addr_port_lookup */ + (void)arg; cp = NULL; u32 = 3; u16 = 3; tt_assert(!addr_port_lookup(LOG_WARN, "1.2.3.4", &cp, &u32, &u16)); tt_str_op(cp,==, "1.2.3.4"); @@ -179,7 +180,7 @@ test_addr_basic(void) /** Run unit tests for IPv6 encoding/decoding/manipulation functions. */ static void -test_addr_ip6_helpers(void) +test_addr_ip6_helpers(void *arg) { char buf[TOR_ADDR_BUF_LEN], bug[TOR_ADDR_BUF_LEN]; char rbuf[REVERSE_LOOKUP_NAME_BUF_LEN]; @@ -194,6 +195,7 @@ test_addr_ip6_helpers(void) struct sockaddr_in6 *sin6; /* Test tor_inet_ntop and tor_inet_pton: IPv6 */ + (void)arg; { const char *ip = "2001::1234"; const char *ip_ffff = "::ffff:192.168.1.2"; @@ -736,7 +738,7 @@ test_addr_ip6_helpers(void) /** Test tor_addr_port_parse(). */ static void -test_addr_parse(void) +test_addr_parse(void *arg) { int r; tor_addr_t addr; @@ -744,6 +746,7 @@ test_addr_parse(void) uint16_t port = 0; /* Correct call. */ + (void)arg; r= tor_addr_port_parse(LOG_DEBUG, "192.0.2.1:1234", &addr, &port, -1); @@ -1047,7 +1050,7 @@ test_addr_make_null(void *data) } #define ADDR_LEGACY(name) \ - { #name, legacy_test_helper, 0, &legacy_setup, test_addr_ ## name } + { #name, test_addr_ ## name , 0, NULL, NULL } struct testcase_t addr_tests[] = { ADDR_LEGACY(basic), |