David Goulet
e129393e40
test: Add missing socket errno in test_util.c
...
According to 21116, it seems to be needed for Wheezy Raspbian build. Also,
manpage of socket(2) does confirm that this errno value should be catched as
well in case of no support from the OS of IPv4 or/and IPv6.
Fixes #21116
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-02-08 09:00:48 -05:00
Hans Jerry Illikainen
a23fd15786
Fix unreachable heap corruption in base64_decode()
...
Give size_mul_check() external linkage and use it in base64_decode() to
avoid a potential integer wrap.
Closes #19222
2016-12-23 09:47:09 -05:00
Nick Mathewson
2cee38f76a
Merge branch 'prop271_030_v1_squashed'
2016-12-16 11:20:59 -05:00
Nick Mathewson
b0a842913a
Merge branch 'maint-0.2.9'
2016-12-07 11:09:27 -05:00
Nick Mathewson
fce425e3ff
Increase tolerances in util/monotonic_time tests
...
This is an attempt to fix #19974 .
2016-12-07 11:08:54 -05:00
Nick Mathewson
539eba0a4b
Teach parse_iso_time about the spaceless variant.
...
(We previously added support for generating the spaceless
2016-11-14T19:58:12 variant, but not for actually parsing it.)
2016-11-30 14:42:52 -05:00
overcaffeinated
c613446ca2
Refactor tests for tor_htonll and tor_ntohll
...
Following kind feedback from dgoulet: add tests for min (0) and
max (UINT64_MAX) values. Rename expected results to something more
sensible than 'n'.
2016-11-03 20:52:11 +00:00
overcaffeinated
c4603233db
Add unit test for tor_htonll and tor_ntohll
...
Add tests for tor_htonll and tor_ntohll - fixes bug 19563.
2016-11-03 19:37:59 +00:00
Nick Mathewson
55c468c521
Whitespace cleaning
2016-10-14 10:40:31 -04:00
Nick Mathewson
9615ad338f
Make the FreeBSD ersatz_socketpair test even more skippable.
...
(This is safe, since only windows actually -uses- erstaz_socketpair.)
2016-10-14 09:14:07 -04:00
Nick Mathewson
07f2e5748e
ersatz socketpair tests: work around freebsd jails.
2016-10-13 09:47:28 -04:00
paolo.ingls@gmail.com
ab78a4df93
torrc parsing b0rks on carriage-return
...
(Specifically, carriage return after a quoted value in a config
line. Fixes bug 19167; bugfix on 0.2.0.16-alpha when we introduced
support for quoted values. Unit tests, changes file, and this
parenthetical by nickm.)
2016-10-11 09:25:22 -04:00
Nick Mathewson
0baa276ea9
Coverity warning fix: let coverity tell we're closing sockets
...
Our use of the (mockable) tor_close_socket() in the util/socket_..
tests confused coverity, which could no longer tell that we were
actually closing the sockets.
2016-09-22 09:24:56 -04:00
Nick Mathewson
d5d29cd5a2
Whoops. Cant call sockaddr_in a "sin", since sin() is a thing.
2016-09-11 17:59:25 -04:00
Nick Mathewson
ccea2a5aa9
Fix gmtime unit test on openbsd
...
openbsd helpfully handles gmtime() of INT64_MIN. Good job!
Our tests didn't handle that so well.
2016-09-11 17:43:20 -04:00
Nick Mathewson
c6e70dacb8
Try to make our ersatz-socketpair test work better on FreeBSD jails
2016-09-11 17:28:29 -04:00
Nick Mathewson
a671a1c9d6
Tweak tor_gmtime_r test.
...
On openbsd64, I'm seeing a warning that the log isn't saying what
I'd expect, but I'm not seeing what the answer actually _is_ here.
2016-09-11 17:13:51 -04:00
Nick Mathewson
63e34e9e49
Reinstate a couple of teardown_capture_of_logs that I missed
...
Patch from rubiate. See #19999
2016-09-08 19:49:21 -04:00
Nick Mathewson
deb294ff53
Simplify log_test_helpers interface
...
Previously, you needed to store the previous log severity in a local
variable, and it wasn't clear if you were allowed to call these
functions more than once.
2016-09-08 15:03:11 -04:00
Nick Mathewson
f9cb9d8990
more consistent use of expect_log_msg_containing
2016-09-08 11:16:09 -04:00
Nick Mathewson
a49fee1c29
Capture and enforce bug warnings in util/time test
2016-09-07 12:15:46 -04:00
Nick Mathewson
3823d0aa7d
Capture and detect the BUG() warnings in test_util_parse_integer.
2016-09-06 21:01:52 -04:00
Nick Mathewson
2a4a815f58
Fix a unit test bug for passing arguments to tor_parse_ulong.
...
We wanted to make sure -50 was a bad input, but instead we were
passing a 'min' that was greater than 'max'.
2016-09-06 20:29:55 -04:00
Nick Mathewson
7ba47ca1fd
Split tor_parse_{some_int} testing into separate fn. Code movement only.
2016-09-06 20:25:54 -04:00
Andrea Shepard
341a159ab4
Appease make check-spaces
2016-09-05 17:47:39 +00:00
Nick Mathewson
cfc62e2374
Initialize monotonic timer code before using it in the tests
2016-08-31 14:34:49 -04:00
Nick Mathewson
d4f05dcd0e
Detect and suppress bug message from zlib compression bomb test
2016-08-31 14:30:34 -04:00
Nick Mathewson
d5614b2102
Use setup_full_capture_of_logs() where appropriate.
2016-08-31 12:53:18 -04:00
Nick Mathewson
9fe6fea1cc
Fix a huge pile of -Wshadow warnings.
...
These appeared on some of the Jenkins platforms. Apparently some
GCCs care when you shadow globals, and some don't.
2016-07-28 10:22:10 -04:00
Nick Mathewson
a8676b1ede
Merge branch 'bug18902_squashed'
2016-07-28 06:59:03 -04:00
Nick Mathewson
4757303873
Fix all -Wshadow warnings on Linux
...
This is a partial fix for 18902.
2016-07-28 06:58:44 -04:00
Nick Mathewson
09c25697d7
Add a function to simplify a fraction.
...
Apparently remembering euclid's algorithm does pay off sooner or later.
2016-07-26 11:23:34 -04:00
Nick Mathewson
90ca446048
Remove windows debugging prints: it was an integer overflow hitting ftrapv
2016-07-26 11:07:53 -04:00
Nick Mathewson
e77c23e455
Redux: Temporarily add windows verbosity to track down jenkins failures
2016-07-26 09:24:53 -04:00
Nick Mathewson
abcb8ce25d
Unit tests for monotonic time
2016-07-19 11:40:47 +02:00
Nick Mathewson
08cc0ef832
Capture the LOG_ERR messages in our tests that had logged errors.
...
(It's confusing for the test to write an expected error to stdout,
and then tell the user "OK".)
2016-07-06 13:01:08 -04:00
teor (Tim Wilson-Brown)
69535f1284
Add tv_udiff and tv_mdiff unit tests with negative values
2016-06-30 09:29:18 +10:00
teor (Tim Wilson-Brown)
d36a0c4d22
Add more unit tests for tv_udiff and tv_mdiff
2016-06-29 17:23:42 +10:00
Nick Mathewson
603cb712ef
Small coverage improvements on compat.c
2016-06-20 11:03:13 -04:00
U+039b
58e6a6aaeb
Fix #19063 : Add check in utility macro
2016-06-19 12:34:49 -04:00
Nick Mathewson
81cfd5c9a1
Merge branch 'zlib_coverage_squashed'
2016-06-19 12:20:38 -04:00
Nick Mathewson
d937b86699
Unindent block
2016-06-19 12:20:24 -04:00
Nick Mathewson
808015316a
Remove support for zlib <= 1.1
...
zlib 1.2 came out in 2003; earlier versions should be dead by now.
Our workaround code was only preventing us from using the gzip
encoding (if we decide to do so), and having some dead code linger
around in torgzip.c
2016-06-19 12:20:24 -04:00
Nick Mathewson
a418904962
Coverage on parse_config_line_from_str_verbose.
2016-06-16 15:52:19 -04:00
Nick Mathewson
c9ea9de806
Remove parse_config_line_from_str alias
...
All of our code just uses parse_config_line_from_str_verbose.
2016-06-16 15:40:56 -04:00
Nick Mathewson
128ab31c64
Mark code unreachable in unescape_string()
...
Also, add tests for it in case someday it does become reachable.
2016-06-16 15:36:08 -04:00
Nick Mathewson
dd73787190
On Windows, tv_sec is long, not time_t.
...
I'm not angry, Windows: just very disappointed.
2016-06-16 13:57:16 -04:00
Nick Mathewson
6ceb37971e
Try to fix memarea test on 32-bit systems
2016-06-16 11:59:51 -04:00
Nick Mathewson
79370914d1
tests for size_mul_check__()
...
it's important, and we should make sure we got it right.
2016-06-16 10:43:01 -04:00
Nick Mathewson
41cb26c169
Correct the rounding behavior on tv_mdiff.
...
Fix for bug 19428.
2016-06-16 10:16:04 -04:00
Nick Mathewson
f05a213fe1
Improve coverage on tv_udiff, and tv_mdiff.
...
I found some bugs in tv_mdiff; separate commit for that
2016-06-16 10:07:44 -04:00
Nick Mathewson
6dc2b605b8
Improve coverage on esc_for_log, esc_for_log_len
2016-06-16 09:58:53 -04:00
Nick Mathewson
f986e26850
Reach 100% line coverage on memarea.c
2016-06-16 09:37:44 -04:00
Nick Mathewson
d6b2af7a3a
Merge branch 'bug19180_easy_squashed'
2016-06-11 10:15:40 -04:00
Nick Mathewson
c3adbf755b
Resolve some warnings from OSX clang.
2016-06-11 10:11:53 -04:00
Nick Mathewson
493499a339
Add -Wfloat-conversion for GCC >= 4.9
...
This caught quite a few minor issues in our unit tests and elsewhere
in our code.
2016-06-11 10:11:52 -04:00
Nick Mathewson
f016213f7f
Unit tests for our zlib code to test and reject compression bombs.
2016-06-08 18:08:30 -04:00
Nick Mathewson
b458a81cc5
Merge branch 'maint-0.2.8'
2016-06-02 10:13:35 -04:00
Nick Mathewson
a32ca313c4
Merge branch 'maint-0.2.7' into maint-0.2.8
2016-06-02 10:12:56 -04:00
Nick Mathewson
5854b19816
Use tor_sscanf, not sscanf, in test_util.c.
...
Fixes the 0.2.7 case of bug #19213 , which prevented mingw64 from
working.
2016-06-02 10:11:29 -04:00
Nick Mathewson
f2205071f0
Remove round_int64_to_next_multiple_of: It is now unused.
2016-05-19 21:21:24 -04:00
Nick Mathewson
a7207329a8
Run tor_sscanf test in subprocess, in hopes of coaxing more info from jenkins
2016-05-12 13:37:05 -04:00
Nick Mathewson
d7a0382ba3
Don't call the system toupper or tolower.
...
Yes, we could cast to unsigned char first, but it's probably safest
to just use our own (in test_util), or remove bad-idea features that
we don't use (in readpassphrase.c).
Fixes 18728.
2016-04-05 23:22:28 -04:00
Nick Mathewson
32e8886314
One more test that didnt pass on windows. See #18665 .
2016-03-28 08:57:29 -04:00
Nick Mathewson
c0568a89d9
Whitespace fixes
2016-03-26 09:54:31 -04:00
Nick Mathewson
24c0c5ef19
Disable failing broken time format case for windows.
2016-03-25 22:00:20 -04:00
Nick Mathewson
4f86d75a4b
try to fix a test failure for sizeof(time_t)==4.
2016-03-24 12:26:46 -04:00
Nick Mathewson
6256c61d95
Merge branch 'timegm_overflow_squashed'
2016-03-24 10:18:00 -04:00
teor (Tim Wilson-Brown)
19fb86a2dc
Add a missing UL on a long in a unit test
2016-03-24 10:17:48 -04:00
teor (Tim Wilson-Brown)
b99bd3e7ff
Add unit tests with dates from 2035 to 2039
...
Platforms with 32-bit time_t sometimes give different results.
They don't always indicate failure on overflow, #18480 should
fix these.
2016-03-24 10:17:48 -04:00
Nick Mathewson
57699de005
Update the copyright year.
2016-02-27 18:48:19 +01:00
Nick Mathewson
1318c1611f
Another clang+_FORTIFY_SOURCE issue
...
There was a parenthesis issue in test_util that clang found
confusing. This part was only in master.
Closes issue 14821.
2016-02-23 14:06:45 -05:00
Nick Mathewson
16840e52e5
Make the touch_file unit test work around FS/system time sync issues
...
Sometimes you can call time() and then touch a file, and have the
second come out a little before the first. See #18025 for way more
information than you necessarily wanted.
2016-01-11 10:03:00 -05:00
Nick Mathewson
62bc4a199a
Fix #18012 harder.
2016-01-07 09:58:48 -08:00
Nick Mathewson
b5ce332958
Try to fix windows test build ( #18012 )
2016-01-07 09:25:44 -08:00
Nick Mathewson
7660471054
Unit tests for getpw* functions
2016-01-03 09:00:30 -08:00
Nick Mathewson
c941240f32
clean up the "skip this util test on windows" logic.
2016-01-03 08:47:14 -08:00
Nick Mathewson
8aa9ee73da
Add a test for touch_file
2016-01-03 08:37:14 -08:00
Nick Mathewson
35bfd782ea
Merge remote-tracking branch 'teor/bug17632-no-ipv4-no-localhost-squashed'
2015-11-19 11:19:31 -05:00
teor (Tim Wilson-Brown)
f19d6b81c8
Fixup #17638 : ignore EINVAL from FreeBSD jails without ::1
...
In my testing, an IPv6-only FreeBSD jail without ::1 returned EINVAL
from tor_ersatz_socketpair. Let's not fail the unit test because of
this - it would only ever use tor_socketpair() anyway.
2015-11-19 19:20:01 +11:00
teor (Tim Wilson-Brown)
53ec840bdf
Make tor_ersatz_socketpair work on IPv6-only systems
...
(But it won't work on some systems without IPv4/IPv6 localhost
(some BSD jails) by design, to avoid creating sockets on routable
IP addresses. However, those systems likely have the AF_UNIX socketpair,
which tor prefers.)
Fixes bug #17638 ; bugfix on a very early tor version,
earlier than 22dba27d8d
(23 Nov 2004) / svn:r2943.
Patch by "teor".
2015-11-19 19:08:22 +11:00
teor (Tim Wilson-Brown)
71fd66c866
Fix unit tests on systems without IPv4 or localhost addresses
...
Make unit tests pass on IPv6-only systems, and systems without
localhost addresses (like some FreeBSD jails).
Fixes:
* get_if_addrs_ifaddrs: systems without localhost
* get_if_addrs_ioctl: only works on IPv4 systems
* socket: check IPv4 and IPv6, skip on EPROTONOSUPPORT
* socketpair_ersatz: uses IPv4, skip on EPROTONOSUPPORT
Fixes bug #17632 ; bugfix on unit tests in 0.2.7.3-rc.
c464a36772
was a partial fix for this issue in #17255 ;
it was released in unit tests in 0.2.7.4-rc.
Patch by "teor".
2015-11-19 00:41:06 +11:00
teor (Tim Wilson-Brown)
a1ce111d32
Really Really Fixup 86eba14ac5
: Windows support, error return values
2015-11-19 00:13:58 +11:00
teor (Tim Wilson-Brown)
eed86892dd
Really Fixup 86eba14ac5
: error return values are negative
2015-11-18 23:54:26 +11:00
teor (Tim Wilson-Brown)
3351f69c75
Fixup 86eba14ac5
: add errno.h for EPROTONOSUPPORT
2015-11-18 23:47:12 +11:00
teor (Tim Wilson-Brown)
86eba14ac5
Fix unit tests on systems without IPv4 or localhost addresses
...
Make unit tests pass on IPv6-only systems, and systems without
localhost addresses (like some FreeBSD jails).
Fixes:
* get_if_addrs_ifaddrs: systems without localhost
* get_if_addrs_ioctl: only works on IPv4 systems
* socket: check IPv4 and IPv6, skip on EPROTONOSUPPORT
* socketpair_ersatz: uses IPv4, skip on EPROTONOSUPPORT
Fixes bug #17632 ; bugfix on unit tests in 0.2.7.3-rc.
c464a36772
was a partial fix for this issue in #17255 ;
it was released in unit tests in 0.2.7.4-rc.
Patch by "teor".
2015-11-18 23:25:21 +11:00
Nick Mathewson
d20a3d07e3
Merge branch 'karsten_bug13192_026_03_teor'
2015-11-12 11:40:58 -05:00
Nick Mathewson
1f7ba115a4
Rename cast_double_to_int64 to clamp_double_to_int64
2015-11-12 11:33:48 -05:00
Nick Mathewson
0694263b75
Make round_to_next_multiple_of always round upwards.
...
Yes, even if it has to return a non-multiple. This prevents us from
ever having a bug where we try to use it for allocation, and under-allocate.
2015-11-12 11:32:14 -05:00
Sebastian Hahn
5cf24ff3af
Fix a bunch of check-spaces complaints
2015-08-21 10:36:53 -04:00
Nick Mathewson
7f9a33a800
Bring the dimap tests up to 100%
2015-08-17 12:52:01 -04:00
Nick Mathewson
3fdc07df5b
Fix a 32-bit compilation warning
2015-08-11 09:07:27 -04:00
Nick Mathewson
50049df0d4
Add a compat function to check how much disk space is free.
...
Closes ticket 16734.
2015-08-05 14:01:49 -04:00
Yawning Angel
da6aa7bfa5
Allow a single trailing .
when validating FQDNs from SOCKS.
...
URI syntax (and DNS syntax) allows for a single trailing `.` to
explicitly distinguish between a relative and absolute
(fully-qualified) domain name. While this is redundant in that RFC 1928
DOMAINNAME addresses are *always* fully-qualified, certain clients
blindly pass the trailing `.` along in the request.
Fixes bug 16674; bugfix on 0.2.6.2-alpha.
2015-07-27 12:58:40 +00:00
Yawning Angel
3f336966a2
Work around nytimes.com's broken hostnames in our SOCKS checks.
...
RFC 952 is approximately 30 years old, and people are failing to comply,
by serving A records with '_' as part of the hostname. Since relaxing
the check is a QOL improvement for our userbase, relax the check to
allow such abominations as destinations, especially since there are
likely to be other similarly misconfigured domains out there.
2015-06-24 13:52:29 +00:00
teor
e0477de0e2
Remove undefined directive-in-macro in test_util_writepid
...
clang 3.7 complains that using a preprocessor directive inside
a macro invocation in test_util_writepid in test_util.c is undefined.
Fix on 79e85313aa
on 0.2.7.1-alpha.
2015-06-03 04:19:05 +10:00
Nick Mathewson
e086db7952
Merge branch 'writing_tests'
2015-05-07 15:29:56 -04:00
Nick Mathewson
79e85313aa
Write the outlines of a WritingTests.txt document
...
Also, add some sample tests to be examples.
2015-05-07 15:29:16 -04:00
teor
75fc4d5511
Remove test for strclear as it no longer exists in the codebase
2015-05-06 18:27:26 +10:00
teor
e60c612447
Use standard float.h header and resolve undefined left shift behaviour
2015-05-06 18:09:10 +10:00