Commit Graph

195 Commits

Author SHA1 Message Date
Nick Mathewson
8527a29966 Add an "AccountingRule" feature to permit limiting bw usage by read+write
Patch from "chobe".  Closes ticket 961.
2014-09-29 09:05:11 -04:00
Nick Mathewson
ea72b4f60a clean up eol whitespace from coccinelle-generated patches 2014-09-16 09:40:38 -04:00
Nick Mathewson
a6627fdb80 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;

--------------------
2014-09-16 09:30:22 -04:00
Nick Mathewson
d684657548 Replace all uses of test_{str,}eq 2014-09-15 21:36:23 -04:00
Nick Mathewson
0243895792 Use coccinelle scripts to clean up our unit tests
This should get rid of most of the users of the old test_*
functions.  Some are in macros and will need manual cleanup, though.

This patch is for 13119, and was automatically generated with these
scripts.  The perl scripts are there because coccinelle hates
operators as macro arguments.

------------------------------

s/==,/_X_EQ_,/g;
s/!=,/_X_NE_,/g;
s/<,/_X_LT_,/g;
s/>,/_X_GT_,/g;
s/>=,/_X_GEQ_,/g;
s/<=,/_X_LEQ_,/g;

------------------------------
@@
expression a;
identifier func;
@@
 func (...) {
<...
-test_fail_msg
+TT_DIE
 (
+(
 a
+)
 )
 ...>
 }

@@
identifier func;
@@
 func (...) {
<...
-test_fail()
+TT_DIE(("Assertion failed."))
 ...>
 }

@@
expression a;
identifier func;
@@
 func (...) {
<...
-test_assert
+tt_assert
	(a)
 ...>
 }

@@
expression a, b;
identifier func;
@@
 func (...) {
<...
-test_eq
+tt_int_op
 (a,
+_X_EQ_,
  b)
 ...>
 }

@@
expression a, b;
identifier func;
@@
 func (...) {
<...
-test_neq
+tt_int_op
 (a,
+_X_NEQ_,
  b)
 ...>
 }

@@
expression a, b;
identifier func;
@@
 func (...) {
<...
-test_streq
+tt_str_op
 (a,
+_X_EQ_,
  b)
 ...>
 }

@@
expression a, b;
identifier func;
@@
 func (...) {
<...
-test_strneq
+tt_str_op
 (a,
+_X_NEQ_,
  b)
 ...>
 }

@@
expression a, b;
identifier func;
@@
 func (...) {
<...
-test_eq_ptr
+tt_ptr_op
 (a,
+_X_EQ_,
  b)
 ...>
 }

@@
expression a, b;
identifier func;
@@
 func() {
<...
-test_neq_ptr
+tt_ptr_op
 (a,
+_X_NEQ_,
  b)
 ...>
 }

@@
expression a, b, len;
identifier func;
@@
 func (...) {
<...
-test_memeq
+tt_mem_op
 (a,
+_X_EQ_,
  b, len)
 ...>
 }

@@
expression a, b, len;
identifier func;
@@
 func (...) {
<...
-test_memneq
+tt_mem_op
 (a,
+_X_NEQ_,
  b, len)
 ...>
 }

------------------------------
@@
char a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a == b
+a, _X_EQ_, b
 )
 ...>
}

@@
int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a == b
+a, _X_EQ_, b
 )
 ...>
}

@@
long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a == b
+a, _X_EQ_, b
 )
 ...>
}

@@
unsigned int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a == b
+a, _X_EQ_, b
 )
 ...>
}

@@
unsigned long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a == b
+a, _X_EQ_, b
 )
 ...>
}

@@
char a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a != b
+a, _X_NEQ_, b
 )
 ...>
}

@@
int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a != b
+a, _X_NEQ_, b
 )
 ...>
}

@@
long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a != b
+a, _X_NEQ_, b
 )
 ...>
}

@@
unsigned int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a != b
+a, _X_NEQ_, b
 )
 ...>
}

@@
unsigned long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a != b
+a, _X_NEQ_, b
 )
 ...>
}

@@
char a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a >= b
+a, _X_GEQ_, b
 )
 ...>
}

@@
int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a >= b
+a, _X_GEQ_, b
 )
 ...>
}

@@
long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a >= b
+a, _X_GEQ_, b
 )
 ...>
}

@@
unsigned int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a >= b
+a, _X_GEQ_, b
 )
 ...>
}

@@
unsigned long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a >= b
+a, _X_GEQ_, b
 )
 ...>
}

@@
char a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a <= b
+a, _X_LEQ_, b
 )
 ...>
}

@@
int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a <= b
+a, _X_LEQ_, b
 )
 ...>
}

@@
long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a <= b
+a, _X_LEQ_, b
 )
 ...>
}

@@
unsigned int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a <= b
+a, _X_LEQ_, b
 )
 ...>
}

@@
unsigned long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a <= b
+a, _X_LEQ_, b
 )
 ...>
}

@@
char a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a > b
+a, _X_GT_, b
 )
 ...>
}

@@
int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a > b
+a, _X_GT_, b
 )
 ...>
}

@@
long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a > b
+a, _X_GT_, b
 )
 ...>
}

@@
unsigned int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a > b
+a, _X_GT_, b
 )
 ...>
}

@@
unsigned long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a > b
+a, _X_GT_, b
 )
 ...>
}

@@
char a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a < b
+a, _X_LT_, b
 )
 ...>
}

@@
int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a < b
+a, _X_LT_, b
 )
 ...>
}

@@
long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_int_op
 (
-a < b
+a, _X_LT_, b
 )
 ...>
}

@@
unsigned int a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a < b
+a, _X_LT_, b
 )
 ...>
}

@@
unsigned long a, b;
identifier func;
@@
 func (...) {
<...
-tt_assert
+tt_uint_op
 (
-a < b
+a, _X_LT_, b
 )
 ...>
}

------------------------------

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;

s/test_mem_op\(/tt_mem_op\(/g;
2014-09-15 21:18:21 -04:00
dana koch
c887e20e6a Introduce full coverage tests for module routerset.c.
This is using the paradigm introduced for test_status.c.
2014-08-29 12:55:28 -04:00
Nick Mathewson
9f9b19ed7b Initialize crash handler in unit tests
This way, we don't get locking failures when we hit an assertion in
the unit tests.  Also, we might find out about unit test bugs from
folks who can't do gdb.
2014-08-27 20:03:00 -04:00
Nick Mathewson
9222707e5c Use the ARRAY_LENGTH macro more consistently. 2014-08-24 13:35:48 -04:00
Nick Mathewson
d8705ec720 Merge remote-tracking branch 'asn/bug12207_second_draft' 2014-07-16 15:33:00 +02:00
Nick Mathewson
3f683aadcd When making a tempdir for windows unit tests, avoid an extra backslash
The extra \ is harmless, but mildly unpleasant.

Fixes 12392; bugfix on 0.2.2.25-alpha where we started using
GetTempDir().  Based on a patch by Gisle Vanem.
2014-07-16 11:39:03 +02:00
George Kadianakis
a8fcdbf4a0 Add the entrynodes.c unit tests. 2014-06-24 14:22:52 -04:00
Nick Mathewson
1a73e17801 Merge remote-tracking branch 'andrea/bug11476' 2014-05-22 16:27:29 -04:00
Andrea Shepard
39d4e67be8 Add --disable-mempools configure option 2014-05-12 18:23:34 -07:00
Nick Mathewson
3fa296ce28 fix uninitialized memory reads from test_geoip_with_pt. Found with valgrind 2014-04-26 00:12:16 -04:00
Nick Mathewson
fa202c4127 Fix memory leak in test_geoip 2014-04-26 00:11:46 -04:00
Nick Mathewson
1cf02605d4 Fix memory leak in test_onion_queues 2014-04-26 00:11:17 -04:00
Nick Mathewson
c7951731ed Fix memory leaks in test_circuit_timeout
Found with valgrind.
2014-04-26 00:10:04 -04:00
dana koch
3ce3984772 Uplift status.c unit test coverage with new test cases and macros.
A new set of unit test cases are provided, as well as introducing
an alternative paradigm and macros to support it. Primarily, each test
case is given its own namespace, in order to isolate tests from each
other. We do this by in the usual fashion, by appending module and
submodule names to our symbols. New macros assist by reducing friction
for this and other tasks, like overriding a function in the global
namespace with one in the current namespace, or declaring integer
variables to assist tracking how many times a mock has been called.

A set of tests for a small-scale module has been included in this
commit, in order to highlight how the paradigm can be used. This
suite gives 100% coverage to status.c in test execution.
2014-04-15 15:00:34 -04:00
Nick Mathewson
b933fdcc11 Move existing policy tests from test.c to new test_policy.c 2014-04-08 14:14:12 -04:00
Nick Mathewson
d0af665758 Remove unused extern decl for a nonexistent test suite 2014-04-08 14:10:59 -04:00
Nick Mathewson
245f273aaf Merge branch 'bug7952_final'
Conflicts:
	src/test/include.am
	src/test/test.c
2014-04-08 13:55:02 -04:00
rl1987
51e13cd1ad Making entire exit policy available to Tor controller. 2014-04-08 13:50:02 -04:00
Nick Mathewson
da908a593f Unit tests for connection_edge_process_resolved_cell
Also rename a function to be more accurate (resolve->resolved)
2014-04-02 15:38:00 -04:00
Nick Mathewson
119896cd43 Fix some leaks/missed checks in the unit tests
Coverity spotted these.
2014-03-13 10:07:10 -04:00
Nick Mathewson
f0b2dc83b6 Merge remote-tracking branch 'arma/ticket5528'
Conflicts:
	src/or/router.c
	src/test/test_dir.c
2014-03-05 12:44:40 -05:00
Nick Mathewson
ab225aaf28 Merge branch 'bug10169_025_v2'
Conflicts:
	src/test/test.c
2014-03-04 11:03:30 -05:00
Nick Mathewson
886d4be149 Unit tests for test_routerkeys_write_fingerprint 2014-02-28 08:53:14 -05:00
Nick Mathewson
48877e24a8 Initial unit tests for OOM handling 2014-02-12 12:49:56 -05:00
Nick Mathewson
c3720c05fa Free leakable values in the unit tests.
Thanks, Coverity!  (CID 1171414, 1171415, 1171416)
2014-02-11 18:10:33 -05:00
Qingping Hou
39ff3b00cf add test for node_get_verbose_nickname_by_id 2014-02-06 16:13:55 -05:00
Qingping Hou
0fbe7f3188 remove node_describe_by_id() function
This function is not used anymore
2014-02-06 16:13:55 -05:00
Qingping Hou
ebd99314cf add test case for node_describe_by_id 2014-01-29 22:47:05 -05:00
Qingping Hou
0b0d4b4ebc add test case for hidden service async events 2014-01-29 22:43:11 -05:00
Nick Mathewson
ab0fdbb618 Add an --accel switch to run unit tests with crypto acceleration 2014-01-17 11:58:09 -05:00
Nick Mathewson
569dbcc615 Fix another unit test memory leak. CID1087949,CID1087950. 2013-11-22 12:27:41 -05:00
Nick Mathewson
fbc20294aa Merge branch 'backtrace_squashed'
Conflicts:
	src/common/sandbox.c
	src/common/sandbox.h
	src/common/util.c
	src/or/main.c
	src/test/include.am
	src/test/test.c
2013-11-18 11:00:16 -05:00
Nick Mathewson
0cf234317f Unit tests for new functions in log.c 2013-11-18 10:43:15 -05:00
Karsten Loesing
2e0fad542c Merge branch 'morestats4' into morestats5
Conflicts:
	doc/tor.1.txt
	src/or/config.c
	src/or/connection.h
	src/or/control.c
	src/or/control.h
	src/or/or.h
	src/or/relay.c
	src/or/relay.h
	src/test/test.c
2013-10-28 12:09:42 +01:00
Nick Mathewson
a0a855d586 Fix unit tests with --disable-curve25519 2013-09-08 17:14:07 -04:00
Roger Dingledine
6156887adf Merge branch 'maint-0.2.4'
Conflicts:
	src/test/test.c
2013-09-04 23:44:39 -04:00
Roger Dingledine
bb32bfa2f2 refactor and give it unit tests 2013-09-04 23:21:45 -04:00
Nick Mathewson
172a55d9d6 Fix a wide line in test_geoip_with_pt 2013-08-15 12:10:10 -04:00
Nick Mathewson
74262f1571 Merge branch 'bug5040_4773_rebase_3' 2013-08-15 12:04:56 -04:00
Nick Mathewson
c342ea9879 Unit tests for ext_or_id_map. 2013-08-15 12:03:36 -04:00
Nick Mathewson
7a12cbc03d Split out buffers and socks tests into separate modules.
No other changes were made here.  Keeping everything in
src/test/test.c was a legacy of back when we had all our unit tests in
one big file.

Doing this now because I'm adding an ext_or_command test.
2013-08-15 12:03:36 -04:00
George Kadianakis
6ad535e6dc If a single client connects with multiple transports, note all transports. 2013-08-15 12:03:34 -04:00
George Kadianakis
85c556a4c2 Trivially change unittests to make them more readable.
Pluggable transport names are now in alphabetical order like they
appear in the bridge-ip-transports string.
2013-08-15 12:03:34 -04:00
George Kadianakis
b2c7379aec Make check-spaces happy. 2013-08-15 12:03:34 -04:00
George Kadianakis
f8a9591d31 Fix some unittests that broke when we added bridge-ip-transports. 2013-08-15 12:03:33 -04:00
George Kadianakis
f4b36bee7e Add a unittest for the bridge-ip-transports extra-info line. 2013-08-15 12:03:33 -04:00