Commit Graph

991 Commits

Author SHA1 Message Date
Andrea Shepard
5d81fd25a0 Add unit test for ClientTransportPlugin/ServerTransportPlugin config line parsing 2014-07-25 21:42:12 -07:00
Nick Mathewson
e7e92fb2f9 Merge remote-tracking branch 'origin/maint-0.2.5' 2014-07-21 14:01:00 -04:00
Sathyanarayanan Gunasekaran
3af2a5d00e Fix warning on building with bufferevents
Fixes #11578
2014-07-21 13:58:14 -04:00
Nick Mathewson
7259e3f604 Move test_descriptors.txt to an include file
Making the text file work out-of-tree didn't work on windows.

Maybe we can get it working that way later.
2014-07-16 22:37:00 +02:00
Nick Mathewson
facecce176 Fix tests when building out-of-tree
(This was too hard. Silly autoconf.)
2014-07-16 21:07:22 +02:00
Nick Mathewson
5690284559 Fix wide lines, make entry_is_live() non-inline 2014-07-16 16:52:16 +02:00
Nick Mathewson
368ff2291b Merge remote-tracking branch 'asn/bug12202' 2014-07-16 16:49:07 +02:00
Nick Mathewson
d8705ec720 Merge remote-tracking branch 'asn/bug12207_second_draft' 2014-07-16 15:33:00 +02:00
Nick Mathewson
867f5e6a76 Add a tor_ftruncate to replace ftruncate.
(Windows doesn't have ftruncate, and some ftruncates do not move the
file pointer to the start of the file.)
2014-07-16 13:58:55 +02:00
Arlo Breault
15e170e01b Add an option to overwrite logs
* Issue #5583
2014-07-16 12:16:49 +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
cypherpunks
6150741791 Fixed fgets_eagain unit test.
On a non-blocking pipe fgets sets EAGAIN when it encounters partial lines. No
error is set on full lines or EOF. EOF is reached when the writing end of the
pipe is closed. Partial lines and full lines are both returned by fgets, EOF
results in NULL.

Mention of this behaviour can be found in #1903 and #2045.
2014-07-16 09:50:09 +02:00
George Kadianakis
b74442db94 Change interface of router_descriptor_is_too_old(). 2014-07-09 19:20:41 +03:00
George Kadianakis
8bbb217964 Change the interface of entry_is_live() to take a bitmap. 2014-06-25 15:44:36 -04:00
George Kadianakis
46d41e6e9b Basic entry_is_live() unittest. 2014-06-25 15:39:00 -04:00
George Kadianakis
a8fcdbf4a0 Add the entrynodes.c unit tests. 2014-06-24 14:22:52 -04:00
Nick Mathewson
58f4200789 Thread support is now required
Long ago we supported systems where there was no support for
threads, or where the threading library was broken. We shouldn't
have do that any more: on every OS that matters, threads exist, and
the OS supports running threads across multiple CPUs.

This resolves tickets 9495 and 12439.  It's a prerequisite to making
our workqueue code work better, since sensible workqueue
implementations don't split across multiple processes.
2014-06-20 10:20:10 -04:00
Nick Mathewson
5b4ee475aa Remove code for Windows CE support
As far as I know, nobody has used this in ages.  It would be a
pretty big surprise if it had worked.

Closes ticket 11446.
2014-06-20 09:49:36 -04:00
George Kadianakis
727ed5448a Add some test descriptors to src/test/. 2014-06-15 19:03:38 -07:00
Nick Mathewson
a7cafb1ea9 Merge branch 'bug8746_v2_squashed'
Conflicts:
	src/common/include.am
2014-06-14 11:46:38 -04:00
Nick Mathewson
a5c092b34b refactor win/nix handling for test_spawn_background*()
Instead of having a #if ... for every function, just define
TEST_CHILD to the right patch and EOL to the expected line terminator.
2014-06-14 11:40:28 -04:00
Nick Mathewson
e3833193af More unit tests for process spawning
Try killing a running process; try noticing that a process has
exited without checking its output; verify that waitpid_cb (when
present) is set to NULL when you would expect it to be.
2014-06-14 11:40:27 -04:00
Nick Mathewson
1a73e17801 Merge remote-tracking branch 'andrea/bug11476' 2014-05-22 16:27:29 -04:00
Yawning Angel
7a18ac7454 Fixed the test build with --enable-gcc-warnings 2014-05-21 08:14:38 +00:00
Yawning Angel
41d2b4d3af Allow ClientTransportPlugins to use proxies
This change allows using Socks4Proxy, Socks5Proxy and HTTPSProxy with
ClientTransportPlugins via the TOR_PT_PROXY extension to the
pluggable transport specification.

This fixes bug #8402.
2014-05-21 08:14:38 +00:00
Andrea Shepard
39d4e67be8 Add --disable-mempools configure option 2014-05-12 18:23:34 -07:00
Nick Mathewson
6267d4f97a fix whitespace 2014-05-11 23:40:48 -04:00
dana koch
d6e6c63baf Quench clang's complaints with -Wshorten-64-to-32 when time_t is not long.
On OpenBSD 5.4, time_t is a 32-bit integer. These instances contain
implicit treatment of long and time_t as comparable types, so explicitly
cast to time_t.
2014-05-11 23:36:00 -04:00
Nick Mathewson
de2010e9c2 One more 64->32 2014-05-08 14:10:30 -04:00
Nick Mathewson
28538069b2 Fix numerous 64->32 errors in the unit tests
Before the 11825 fix, these were all silently ignored.
2014-05-08 14:01:17 -04:00
Nick Mathewson
df68478938 Fix unearthed problems in unit tests 2014-05-08 13:16:08 -04:00
Nick Mathewson
5bb6172367 Fix numerous type errors in the unit tests
Remove tinytest casts that were suppressing them.

Fix for #11825.
2014-05-08 13:08:13 -04:00
Nick Mathewson
1f11be2170 Fix test_util_max_mem on 32-bit CPUs 2014-05-08 12:48:41 -04:00
Nick Mathewson
891d239e01 More unit tests for #11648-related stuff
These are actually tests for #311.  It appears to me that we didn't
fix #311 properly when we thought we did in 475eb5d6; instead, the
real fix was 05eff35ac6, a few minutes earlier.
2014-05-08 12:41:01 -04:00
Nick Mathewson
8a2e66b623 Fix test_pick_circid on 32-bit platforms 2014-05-07 03:27:49 -04:00
Nick Mathewson
499e77663e Basic tests for get_unique_circ_id_by_chan. 2014-05-07 02:57:50 -04:00
Nick Mathewson
e198faa633 Quick-and-dirty test for packed_cell_is_destroy 2014-05-07 02:05:35 -04:00
Nick Mathewson
ba5069b310 Remove a spurious variable. 2014-05-06 20:46:26 -04:00
Nick Mathewson
4a740451ac Merge remote-tracking branch 'public/bug11750' 2014-05-06 20:44:41 -04:00
Nick Mathewson
5cea500ce7 Merge branch 'bug11743_option_b' 2014-05-06 20:40:40 -04:00
Nick Mathewson
52416f8cfb Unit test for dirvote_create_microdescriptor 2014-05-06 20:36:19 -04:00
Nick Mathewson
ed0e2ecaa7 Unit test for write_to_buf_zlib 2014-05-06 19:29:56 -04:00
Nick Mathewson
e9c1c3ff7f Add a siphash benchmark. 2014-05-06 12:55:39 -04:00
Nick Mathewson
29b7397ebe Fix test_config_write_to_data_subdir
Bugfix on aa0eb2022342798fc78b2bde89d393f37c59fe78; bugfix not on any
released Tor.
2014-05-01 13:27:20 -04:00
Nick Mathewson
b51ce90777 Merge remote-tracking branch 'public/valgrind_tests' 2014-05-01 12:29:31 -04:00
Nick Mathewson
aa0eb20223 Fix leaks in tests related to setting options->DataDirectory
We pre-populate that value in main(), and we weren't freeing it
before overriding it.
2014-04-29 12:48:02 -04:00
Nick Mathewson
ee9ed9d817 Fix memory leaks in test_status.c 2014-04-29 12:48:02 -04:00
Nick Mathewson
212e982d9b Fix leaks in dir voting tests 2014-04-29 12:48:02 -04:00
Andrea Shepard
91ff10f6be Make --disable-buf-freelists build and pass unit tests 2014-04-29 02:18:34 -07:00
Nick Mathewson
f4be34f70d Make the python test scripts work on python3
The python scripts invoked by 'make check' didn't work on python3
before.  That was a problem on systems where 'python' is python3.

Fixes bug 11608; bugfix on 0.2.5.2-alpha.
2014-04-27 22:54:24 -04:00
Nick Mathewson
504e2000ed Fix leaks in test_oom.c 2014-04-26 12:17:10 -04:00
Nick Mathewson
97664cfd2a Fix leaks in test_dir_formats 2014-04-26 12:16:12 -04:00
Nick Mathewson
b60782b6d6 Fix numerous leaks in test_pt.c
I didn't find a managed_proxy_free() function any place; shouldn't
there be one?
2014-04-26 11:28:39 -04:00
Nick Mathewson
b11ab0d91d test_cntev_append_cell_stats now no longer leaks 2014-04-26 00:40:22 -04:00
Nick Mathewson
b4b07c17e3 Fix leaks in test_exit_policy_dump_to_string 2014-04-26 00:36:09 -04:00
Nick Mathewson
558becad8c Memory leaks in test_config_addressmap 2014-04-26 00:27:21 -04:00
Nick Mathewson
ffffd860c9 Fix a leak in test_buffer_allocation_tracking 2014-04-26 00:18:15 -04:00
Nick Mathewson
1117889f4a Fix memory leak in unittest helper function. 2014-04-26 00:13:49 -04:00
Nick Mathewson
9fbb5a44b8 Fix memory leak in test_util_asprintf 2014-04-26 00:13:27 -04:00
Nick Mathewson
dc0fcbd812 Fix memory leaks in test_cntev_append_cell_stats 2014-04-26 00:12:39 -04: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
Nick Mathewson
167536a112 fix memory leak in dump_exit_policy_to_string tests 2014-04-25 01:59:20 -04:00
Nick Mathewson
d3c05a79f0 Merge branch 'scanbuild_fixes' 2014-04-25 01:24:39 -04:00
Nick Mathewson
67aa3685e7 Merge branch 'bug11396_v2_squashed'
Conflicts:
	src/or/main.c
2014-04-24 10:31:38 -04:00
Nick Mathewson
aca05fc5c0 get_total_system_memory(): see how much RAM we have 2014-04-24 10:26:14 -04:00
Nick Mathewson
685d450ab3 scan-build: avoid undef behaior in tor_inet_pton
If we had an address of the form "1.2.3.4" and we tried to pass it to
tor_inet_pton with AF_INET6, it was possible for our 'eow' pointer to
briefly move backwards to the point before the start of the string,
before we moved it right back to the start of the string.  C doesn't
allow that, and though we haven't yet hit a compiler that decided to
nuke us in response, it's best to fix.

So, be more explicit about requiring there to be a : before any IPv4
address part of the IPv6 address.  We would have rejected addresses
without a : for not being IPv6 later on anyway.
2014-04-19 13:14:33 -04:00
Nick Mathewson
1800e79ca5 scan-build: Fix harmless sizeof(ptr) in test_oom.c
We meant to using random bytes to fill a buffer, up to 3000 at a
time. Instead we were taking them sizeof(void*) at a time.
2014-04-19 12:52:00 -04:00
Nick Mathewson
69ea4450ca scan-build: fix a crash-on-fail possibility in test_policy.c 2014-04-18 20:33:21 -04:00
Nick Mathewson
0175fcaf7c Fix uninitialized-ram free in unit tests
Fix on fb595922; bug not in any released Tor. Found with
--enable-expensive-hardening.
2014-04-17 01:03:10 -04:00
Nick Mathewson
1126ce1d86 Fix compiler warning on test_status.c 2014-04-15 15:19:41 -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
0820031419 Merge remote-tracking branch 'asn/bug11486' 2014-04-12 21:42:45 -04:00
George Kadianakis
1ec4d52e59 Add another unit test for parse_bridge_line(). 2014-04-11 21:06:53 +03:00
Nick Mathewson
2f73525883 Fix a dumb C bug in the unit tests for 9841
Fixes bug 11460; bug only affects unit tests and is not in any
released version of Tor.
2014-04-09 09:20:25 -04:00
Nick Mathewson
fa6b80d6e5 Merge remote-tracking branch 'public/bug10431' 2014-04-09 08:29:21 -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
fffc59b0e9 Merge remote-tracking branch 'public/bug9841_025' 2014-04-08 12:06:03 -04:00
Nick Mathewson
f0bce2dc35 Fix some harmless/untriggerable memory leaks found by coverity 2014-04-07 23:20:13 -04:00
Nick Mathewson
595303fd1e Merge remote-tracking branch 'public/bug10363_024_squashed' 2014-04-07 23:03:04 -04:00
Nick Mathewson
9dd115d6b5 Another 10363 instance: this one in tor_memmem fallback code 2014-04-07 22:56:42 -04:00
Nick Mathewson
2ff664ee20 Merge remote-tracking branch 'public/bug10801_024'
Conflicts:
	src/common/address.c
	src/or/config.c
2014-04-05 14:50:57 -04:00
Nick Mathewson
b3469e4207 Make tor_addr_port_parse handle portless IPv6 addresses correctly.
(Not a bugfix on any Tor release; before 10801_024, it didn't handle
portless addresses at all.)
2014-04-05 14:41:37 -04:00
Nick Mathewson
eefa3ebc78 Add a test for default/port conflicts in tor_addr_port_parse 2014-04-05 14:18:39 -04:00
Nick Mathewson
d22ce149c8 Test for circuit_set_rend_token(.,.,NULL) 2014-04-04 12:06:54 -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
4215c801ff Tests for resolved_cell_parse 2014-04-02 15:38:00 -04:00
Nick Mathewson
fc9e84062b Merge remote-tracking branch 'public/bug4645'
Conflicts:
	src/or/dirserv.c
2014-04-01 21:49:01 -04:00
Nick Mathewson
6bef082d0a Merge remote-tracking branch 'public/bug11232' 2014-04-01 09:39:48 -04:00
Nick Mathewson
8e94d5f22e Check return values for tor_munmap_file() in unit tests 2014-03-31 11:40:00 -04:00
Nick Mathewson
b0bbe6b2f1 Report only the first bootstrap failure from an orconn
Otherwise, when we report "identity mismatch", we then later report
DONE when the connection gets closed.

Fixes bug 10431; bugfix on 0.2.1.1-alpha.
2014-03-27 15:58:43 -04:00
Nick Mathewson
9c0a1adfa2 Don't do a DNS lookup on a bridge line address
Fixes bug 10801; bugfix on 07bf274d in 0.2.0.1-alpha.
2014-03-27 15:31:29 -04:00
Nick Mathewson
a83abcf5ee Fix unittest compilation with --disable-curve25519
This is a fix for 9700, which we already fixed in 0.2.5.x, but which
got left in 0.2.4.x.

This is a partial backport of a0a855d586
2014-03-20 13:53:32 -04:00
Nick Mathewson
98b1aad201 Fix a use-after-free in test_circuitlist.c
Found by clang-3.4 analyzers.
2014-03-18 09:47:13 -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
cce06b649e Merge remote-tracking branch 'asn/bug11069_take2' 2014-03-11 11:04:47 -04:00
George Kadianakis
1c475eb018 Throw control port warning if we failed to connect to all our bridges. 2014-03-10 22:52:07 +00:00
Nick Mathewson
1365ff5b9a Upgrade to the latest version of tinytest.
This brings us to tinytest commit 709a36ba63ff16d8.

The only big change tor-side is that we don't need our own test_mem_op
operation any longer.
2014-03-06 18:06:08 -05:00
Nick Mathewson
065097b81b tinytest tt_{mem,str}_op now handle NULLs better
Now a NULL argument to either makes it fail, not crash.

Fies bug 9004; bugfix on 0.2.2.4-alpha.
2014-03-06 12:12:13 -05:00
Nick Mathewson
663aba07e5 Fix whitespace errors, all of them mine. 2014-03-05 14:36:32 -05: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
d98f743b28 Fix compilation warnings in tor_addr_make_null patch
There was one "missing prototype" warning because the test function
wasn't static, and one "unused parameter" warning about the "data"
parameter.

Also, I added a couple of tests to make sure that the "make_null"
addresses really were the addresses we expected, by formatting them
as strings.
2014-03-03 10:05:02 -05:00
Kevin Murray
4deae59e1c add test for tor_addr_make_null
Signed-off-by: Kevin Murray <spam@kdmurray.id.au>
2014-03-03 09:58:01 -05:00
Nick Mathewson
886d4be149 Unit tests for test_routerkeys_write_fingerprint 2014-02-28 08:53:14 -05:00
Nick Mathewson
0be9e6099b Unit tests for pk fingerprint functions 2014-02-28 08:53:14 -05:00
dana koch
f49805b681 Restitute a successful stat call to this test case.
Since the first stat call is made for it to deliberately fail, and we
reference st.st_mode without st having valid data, st.st_mode can contain
garbage and cause chmod to fail with EINVAL. We rerun stat and ensure it
succeeded.

Also make use of tt_abort_perror, to properly convey failure reasons to
the user.
2014-02-17 22:55:40 +00:00
Nick Mathewson
e1deb01e5f mingw fix: Rename a variable in the unit tests
Apparently, MS C is #defining "IN" on us, so we can't name a
variable IN.  Delightful!
2014-02-16 12:51:35 -05:00
Nick Mathewson
35423d397f Merge branch 'bug4900_siphash_v2' 2014-02-15 15:59:10 -05:00
Nick Mathewson
1987894626 fix a whitespace snafu 2014-02-14 23:00:04 -05:00
Nick Mathewson
fb595922b1 Tests for rend_token maps
This gets coverage of everything except for the cases which should be
impossible.
2014-02-13 15:24:15 -05:00
Nick Mathewson
ecd16edafe Disallow "*/maskbits" as an address pattern.
Fixes bug 7484. We've had this bug back in a8eaa79e03 in
0.0.2pre14, when we first started allowing address masks.
2014-02-12 16:00:26 -05:00
Nick Mathewson
c8d41da52d More unit tests for OOM handling.
This gets us up to no interesting untested new or changed lines for
the 10169 code.
2014-02-12 12:50:16 -05:00
Nick Mathewson
48877e24a8 Initial unit tests for OOM handling 2014-02-12 12:49:56 -05:00
Nick Mathewson
52d222aafb Add tests for buffer time tracking. 2014-02-12 12:48:11 -05:00
Nick Mathewson
d379fc6e0f Several tests for buffer allocation 2014-02-12 12:48:00 -05:00
Nick Mathewson
f425cf8338 Start writing tests for 10169.
Now we cover more chunk allocation functions.
2014-02-12 12:47:49 -05:00
Nick Mathewson
c1e98c8afe Randomize the global siphash key at startup
This completes our conversion to using siphash for our hash functions.
2014-02-12 12:12:58 -05:00
Nick Mathewson
f51df9bb93 Tests for siphash, from reference implementation. 2014-02-12 10:58:03 -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
Nick Mathewson
a0577aacb4 Merge remote-tracking branch 'origin/maint-0.2.4' 2014-02-07 17:41:41 -05:00
Nick Mathewson
9bb34aa897 Survive fedora's openssl in our benchmarks
Apparently fedora currently has ECDH but not P224. This isn't a huge
deal, since we no longer use OpenSSL's P224 ever (see #9780 and
72c1e5acfe). But we shouldn't have segfaulting benchmarks really.

Fixes bug 10835; bugfix on 0.2.4.8-alpha.
2014-02-07 17:36:11 -05:00
Nick Mathewson
aa3c8c1397 Use the right functions; strncpy is usually not the answer 2014-02-07 12:25:49 -05:00
Qingping Hou
57da1a5057 add test case for node_get_verbose_nickname 2014-02-06 16:13:55 -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
bf66ff915a fix longname returned in HS_DESC control events
According to control spec, longname should not contain any spaces and is
consists only of identy_digest + nickname

added two functions:
* node_get_verbose_nickname_by_id()
* node_describe_longname_by_id()
2014-02-06 16:13:55 -05:00
Nick Mathewson
34740a17ea Rename sun to s_un in test_addr.c
Apparently the compiler on solaris 9 didn't like "sun" as an identifier.

Fix for bug 10565; bugfix on 0.2.5.1-alpha.
2014-02-06 12:36:33 -05:00
Nick Mathewson
4268cbf294 Distcheck repair: add new python testing code to "tarballs"
'make distcheck' now passes again.
2014-02-04 11:08:22 -05:00
Nick Mathewson
c61a472076 test_config.c: log which address should have failed 2014-02-03 16:21:32 -05:00
Nick Mathewson
24544a10c0 Clean up test_hs.c: warning fix; tor_free() usage.
My OSX laptop rightly gave a warning because of sticking strlen() into
an int, but once I took a closer look... it appears that the strlen()
was part of a needlessly verbose implementation for tor_strdup().

While I was there, I fixed the usage of tor_free() in test_hs.c: It
checks for NULL, and it zeros its argument.  So instead of
    if (foo) {
      tor_free(foo);
      foo = NULL;
    }
we should just say
    tor_free(foo);
2014-02-03 16:12:30 -05:00
rl1987
3a4b24c3ab Removing is_internal_IP() function. Resolves ticket 4645. 2014-02-03 14:20:17 -05:00
Karsten Loesing
00ec6e6af0 More fixes to rip out all of the v2 directory code.
(This was a squash commit, but I forgot to squash it. Sorry! --Nick)
2014-02-03 13:34:30 -05:00
Nick Mathewson
8db8fda43f check-spaces fixes for test_router.c 2014-02-03 13:00:15 -05:00
Nick Mathewson
fee7f25ff8 Merge remote-tracking branch 'houqp/hs_control' 2014-02-03 12:28:42 -05:00
Nick Mathewson
27d81c756b slownacl's pure-python curve25519 lets us test ntor everywhere.
Improvement on f308adf838, where we made the ntor
unit tests run everywhere... so long as a python curve25519 module
was installed.  Now the unit tests don't require that module.
2014-02-03 11:34:13 -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
3193cbe2ba Rip out all of the v2 directory code.
The remaining vestige is that we continue to publish the V2dir flag,
and that, for the controller, we continue to emit v2 directory
formats when requested.
2014-01-29 15:17:05 -05:00
Nick Mathewson
8a49fac9e0 Coverate in util.c: test that tor_parse_* rejects negative base. 2014-01-17 11:58:09 -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
adfcc1da4a Merge remote-tracking branch 'origin/maint-0.2.4'
Conflicts:
	src/or/microdesc.c

Conflict because one change was on line adjacent to line where
01206893 got fixed.
2013-12-17 13:18:00 -05:00
Nick Mathewson
3d5154550c Merge remote-tracking branch 'public/bug10409_023' into maint-0.2.4 2013-12-17 13:15:45 -05:00
Nick Mathewson
d8cfa2ef4e Avoid free()ing from an mmap on corrupted microdesc cache
The 'body' field of a microdesc_t holds a strdup()'d value if the
microdesc's saved_location field is SAVED_IN_JOURNAL or
SAVED_NOWHERE, and holds a pointer to the middle of an mmap if the
microdesc is SAVED_IN_CACHE.  But we weren't setting that field
until a while after we parsed the microdescriptor, which left an
interval where microdesc_free() would try to free() the middle of
the mmap().

This patch also includes a regression test.

This is a fix for #10409; bugfix on 0.2.2.6-alpha.
2013-12-16 13:06:00 -05:00
Nick Mathewson
a7410c9199 Add checks to prevent memcmp(.,.,negative) in tests (CID 1064417) 2013-11-22 12:33:25 -05:00
Nick Mathewson
569dbcc615 Fix another unit test memory leak. CID1087949,CID1087950. 2013-11-22 12:27:41 -05:00
Nick Mathewson
7c76fd5a82 Fix a bunch of coverity-spotted unit test resource leaks
CIDs: 1130994, 1130993, 1130992, 1130991
2013-11-22 12:21:14 -05:00
Nick Mathewson
6f7eb7a0a5 Remove needless fd var from test. CID 1130989. 2013-11-22 12:16:17 -05:00
Nick Mathewson
027f4c82eb Whitespace cleanup 2013-11-20 11:05:00 -05:00
Nick Mathewson
e7165659e0 Fix crypto/digests test 2013-11-18 13:33:29 -05:00
Nick Mathewson
a7c9d64fd6 Merge branch 'finish_prop157' 2013-11-18 13:27:06 -05:00
Nick Mathewson
4b9ec85e47 Fix whitespace 2013-11-18 11:13:40 -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
56e3f056e9 Tests for backtrace.c
These need to be a separate executable, since the point of backtrace.c
is that it can crash and write stuff.
2013-11-18 10:43:15 -05:00
Nick Mathewson
0cf234317f Unit tests for new functions in log.c 2013-11-18 10:43:15 -05:00
Nick Mathewson
f6e07c158f Make the dir-key-crosscert element required
In proposal 157, we added a cross-certification element for
directory authority certificates. We implemented it in
0.2.1.9-alpha.  All Tor directory authorities now generate it.
Here, as planned, make it required, so that we can finally close
proposal 157.

The biggest change in the code is in the unit test data, where some
old hardcoded certs that we made long ago have become no longer
valid and now need to be replaced.
2013-11-14 09:37:41 -05:00
Nick Mathewson
4aa9affec2 Fix test_cmdline_args to work with old openssl
If openssl was old, Tor would add a warning about its version in
between saying "no torrc found, using reasonable defaults" and
"configuration was valid".
2013-11-11 15:22:08 -05:00
Nick Mathewson
940d286a74 Documentation and tests for 10060 2013-11-07 14:42:58 -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
Karsten Loesing
e46de82c97 squash! Pass const uint64_t pointers, document array length.
Don't cast uint64_t * to const uint64_t * explicitly.  The cast is always
safe, so C does it for us.  Doing the cast explitictly can hide bugs if
the input is secretly the wrong type.

Suggested by Nick.
2013-10-28 10:48:18 +01:00
Nick Mathewson
338bcad9e4 Make test_cmdline_args.py work with older pythons
I was using the assertIn() function on unit tests, which Python 2.7
introduced.  But we'd like to be able to run our unit tests on Pythons
from older operating systems.
2013-10-21 14:35:01 -04:00
Nick Mathewson
d5f050111e Fix out-of-tree "make check-local" 2013-10-11 13:42:27 -04:00
Nick Mathewson
f308adf838 When possible, run the ntor python integration tests too 2013-10-11 13:21:42 -04:00
Nick Mathewson
187398318e When python is available, run the commandline unit tests from "make check" 2013-10-11 13:07:14 -04:00
Nick Mathewson
0546edde66 Merge branch 'bug1376' 2013-10-11 12:51:15 -04:00
Nick Mathewson
7ef9ecf6b3 Fix some whitespace; tighten the tests. 2013-10-11 12:51:07 -04:00
Nick Mathewson
3d817fa29c Merge remote-tracking branch 'origin/maint-0.2.4' 2013-10-10 11:18:17 -04:00
Nick Mathewson
7b1b8c3694 Merge remote-tracking branch 'origin/maint-0.2.3' into maint-0.2.4 2013-10-10 11:18:07 -04:00
Nick Mathewson
004a9c6dd1 Fix unit test for format_helper_exit_status
Fix format_helper_exit_status to allow full HEX_ERRNO_SIZE answers,
*and* increase the buffer length again.
2013-10-10 11:15:35 -04:00
Jim Pannacciulli
8bc5b9f3d0 test-network.sh: tools dir in PATH, parameterization 2013-09-29 14:19:00 -04:00
Nick Mathewson
31f6806aa7 Use tt_ptr_op, not test_eq, for pointer comparisons in tests
Makes mingw64 a bit happier.
2013-09-23 01:57:34 -04:00
Nick Mathewson
2f2fa7683d Fix benchmarks to run without crashing.
I broke this when I added separate test-mode support by having
the benchmarks get built with TEST_CFLAGS.
2013-09-18 21:43:38 -04:00
Nick Mathewson
e35c972851 Merge branch 'bug4647_squashed' 2013-09-13 12:36:55 -04:00
Nick Mathewson
bf5e1e19f7 Finish tests for command-line arguments 2013-09-13 12:36:40 -04:00
Nick Mathewson
675eb1fea7 Integration test for parsing arguments on the commandline
(incomplete)
2013-09-13 12:36:40 -04:00
Karsten Loesing
b43a37bc5b Pass const uint64_t pointers, document array length.
Suggested by nickm.
2013-09-12 10:51:55 +02:00
Karsten Loesing
d5f0d792dd Pass around const struct timeval * instead of struct timeval.
Suggested by nickm.
2013-09-12 10:10:38 +02: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
Kevin Butler
0f070e7858 Added test for new write_chunks_to_file behaviour in #1376. 2013-09-04 23:25:41 +01:00
Nick Mathewson
5c9008e0b0 Fix some "ISO C90 forbids mixed declarations and code" warnings 2013-09-03 13:39:31 -04:00
Nick Mathewson
3753488011 Fix warnings in test_config_fix_my_family 2013-09-03 13:35:44 -04:00
Nick Mathewson
eb5f22eff2 Merge remote-tracking branch 'Ryman/bug4341' 2013-09-03 13:16:22 -04:00
Nick Mathewson
270b4f030a Handle HTTP minor versions greater than 9
(In practice they don't exist, but so long as we're making changes for
standards compliance...)

Also add several more unit tests for good and bad URL types.
2013-09-03 11:38:15 -04:00
Kevin Butler
5327605caa Tougher validation for parsing urls from HTTP headers. Fixes #2767. 2013-09-03 01:14:43 +01:00
Kevin Butler
0513643317 MyFamily option will now fix fingerprints missing their leading instead of complaining. Should fix #4341. 2013-08-31 04:49:04 +01:00
Nick Mathewson
078d6bcda5 Basic unit test for EVENT_TRANSPORT_LAUNCHED 2013-08-25 11:29:03 -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
George Kadianakis
c5269a59b0 Test ExtORPort cookie initialization when file writing is broken. 2013-08-15 12:03:38 -04:00
George Kadianakis
94db455472 Test some fail conditions of ext_orport.c USERADDR/TRANSPORT parsing. 2013-08-15 12:03:38 -04:00
George Kadianakis
794447d03d Fix some #5040 bugs found by Nick's tests.
- Set conn->address when we receive a USERADDR command.
- Set conn->state to a sane value when we transition from Extended
  ORPort to ORPort.
2013-08-15 12:03:38 -04:00
George Kadianakis
33c3e60a37 Implement and use a generic auth. cookie initialization function.
Use the generic function for both the ControlPort cookie and the
ExtORPort cookie.

Also, place the global cookie variables in the heap so that we can
pass them around more easily as pointers.

Also also, fix the unit tests that broke by this change.

Conflicts:
	src/or/config.h
	src/or/ext_orport.c
2013-08-15 12:03:37 -04:00
Nick Mathewson
28bb673584 White-box tests for the succeeding case of ext_or_port handshake.
(Okay, white-box plus mocking enough other functions so they don't
crash.)
2013-08-15 12:03:37 -04:00
Nick Mathewson
636aeb1f24 Test for initializing ext_or_auth_cookie file 2013-08-15 12:03:37 -04:00
Nick Mathewson
4e868a9bc3 Unit test for the ext_orport safe_cookie handshake 2013-08-15 12:03:37 -04:00
Nick Mathewson
fd6749203e More unit tests for handle_client_auth_nonce
Incidentally, this business here where I make crypto_rand mockable:
this is exactly the kind of thing that would make me never want to
include test-support stuff in production builds.
2013-08-15 12:03:37 -04:00
Nick Mathewson
4526c3e0b6 Unit test for basic ext_or_cookie authentication backend 2013-08-15 12:03:37 -04:00
Nick Mathewson
03e3881043 Tests for connection_write_ext_or_command. 2013-08-15 12:03:36 -04:00
Nick Mathewson
c342ea9879 Unit tests for ext_or_id_map. 2013-08-15 12:03:36 -04:00
Nick Mathewson
7da59721a9 Unit tests for fetch_ext_or_cmd 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
George Kadianakis
0c4baa016f Also test that server transports get written to Tor's state. 2013-08-05 21:05:39 +03:00
George Kadianakis
00a7d1af9f test_pt_configure_proxy(): verify the internals of the managed proxy. 2013-08-05 21:05:35 +03:00
Arlo Breault
506a01bda8 Use size_t for length in replaycache_add_test_and_elapsed()
For consistency with the rest of buffer lengths in Tor.

See #8960
2013-08-04 09:29:22 -04:00
Nick Mathewson
9ac0a681ce Unit test for smartlist_ints_eq
(This was the only wholly untested function in containers.c)
2013-08-02 13:45:25 -04:00
Nick Mathewson
362f60e2d4 Try to make the win32 ersatz_socketpair pass. 2013-08-02 11:04:30 -04:00
Nick Mathewson
bcc39c4666 Unit test for tor_{ersatz_,}socketpair.
This catches tor_accept as well.
2013-08-02 10:36:36 -04:00
Nick Mathewson
b8d9c84037 Simple unit test for tor_open_socket_with_extensions 2013-08-02 10:05:17 -04:00
Nick Mathewson
904a58d10f Merge branch 'bug9288_rebased'
Conflicts:
	src/test/test_pt.c
2013-07-31 13:51:15 -04:00
Nick Mathewson
8a0eedbbb0 Fix mixed declaration/statement warning 2013-07-31 13:36:17 -04:00
Nick Mathewson
22a074caa7 Update pt/configure_proxy until it stops segfaulting 2013-07-31 13:34:16 -04:00
George Kadianakis
aaf79eb4d3 Write unit tests for configure_proxy(). 2013-07-31 13:34:16 -04:00
Nick Mathewson
5343ee1a06 Add a signal-safe decimal formatting function 2013-07-19 13:26:25 -04:00
Nick Mathewson
8f0755fa85 Whoops; check in test_circuitmux.c 2013-07-19 12:05:38 -04:00
Nick Mathewson
34ad7642c8 Regression test for destroy cell queue
This exercises the code that crashed and caused #9296.
2013-07-19 10:17:00 -04:00
George Kadianakis
0ec4e5a698 Add transport information to the GeoIP database. 2013-07-18 14:59:57 -04:00
Nick Mathewson
f45e1fbd5b Start of a unit test for options_validate.
I added this so I could write a unit test for ServerTransportOptions,
but it incidentally exercises the succeed-on-defaults case of
options_validate too.
2013-07-18 14:40:12 -04:00
Nick Mathewson
1e78100b25 Add a test for n_cells_in_circuit_queues 2013-07-18 11:23:45 -04:00
Nick Mathewson
ae64197195 Unit tests for cell queues.
This removes some INLINE markers from functions that probably didn't
need them.
2013-07-18 11:23:45 -04:00
Nick Mathewson
e6c0fb2b6d Fix a wide line in test_pt.c 2013-07-18 08:49:52 -04:00
Nick Mathewson
d7ccb6a3b1 Merge branch 'bug8978_rebase_2'
Conflicts:
	src/test/test_pt.c
2013-07-18 08:48:20 -04:00
Nick Mathewson
b551988ef4 Merge branch 'bug8929_rebase_2' 2013-07-18 08:45:13 -04:00
Nick Mathewson
8a01a7c35b Improve test coverage of 8929 code 2013-07-18 08:45:03 -04:00
Nick Mathewson
31871f7d77 Fix memory leaks in test_config_parse_transport_options_line 2013-07-18 08:45:03 -04:00
George Kadianakis
1a0cf08841 Rename tor_escape_str_for_socks_arg() to something more generic.
Since we are going to be using that function to also escape parameters
passed to transport proxies using environment variables.
2013-07-18 08:45:03 -04:00
George Kadianakis
ea72958f25 Pass characters to be escaped to tor_escape_str_for_socks_arg().
This is in preparation for using tor_escape_str_for_socks_arg() to
escape server-side pluggable transport parameters.
2013-07-18 08:45:02 -04:00
George Kadianakis
6cfc2b5d73 Write unit tests for the ServerTransportOptions parsing function. 2013-07-18 08:45:02 -04:00
Nick Mathewson
e02b6b99f2 Add a basic unit test for pt_get_extra_info_descriptor_string. 2013-07-18 08:43:53 -04:00
Nick Mathewson
dd18789a9c Add a unit test for smethod lines with arguments. 2013-07-18 08:43:52 -04:00
Nick Mathewson
4824f3ad93 Merge remote-tracking branch 'asn/bug9265' 2013-07-16 09:55:51 -04:00
Nick Mathewson
74356aaeec Remove an unused variable in test_replaycache_scrub 2013-07-16 09:53:44 -04:00
Andrea Shepard
459d827193 Add more replaycache.c unit tests, bringing coverage to 100% for that file 2013-07-16 06:02:22 -07:00
George Kadianakis
4ccd4b5c51 Test deeper in test_pt_parsing().
We used to test parse_{c,s}method_line() without actually testing that
the resulting transport_t was well formed.
2013-07-16 14:07:03 +03:00
Nick Mathewson
55f5caf096 Appease "make check-spaces" 2013-07-15 17:35:56 -04:00
Nick Mathewson
9fda7e8cd1 Lightly refactor and test format_hex_number_sigsafe
Better tests for upper bounds, and for failing cases.

Also, change the function's interface to take a buffer length rather
than a maximum length, and then NUL-terminate: functions that don't
NUL-terminate are trouble waiting to happen.
2013-07-15 12:52:29 -04:00
Nick Mathewson
18136afbbb HEX_ERRNO_SIZE is no longer the correct upper limit for format_hex_number_sigsafe 2013-07-15 12:40:07 -04:00
Nick Mathewson
22977b7c1d Expose format_hex_number_..., and rename it to ..._sigsafe().
There are some other places in the code that will want a signal-safe
way to format numbers, so it shouldn't be static to util.c.
2013-07-15 12:26:55 -04:00
Nick Mathewson
449b2b7c58 Don't build format_helper_exit_status on win32
The only thing that used format_helper_exit_status on win32 was the
unit tests. This caused an error when we tried to leave a static
format_helper_exit_status lying around in a production object file.

The easiest solution is to admit that this way of dealing with process
exit status is Unix-only.
2013-07-15 12:17:23 -04:00