Sebastian Hahn
582f747049
Provide large enough buffer in test_util_sscanf()
...
This was causing crashes during unit test runs, as stack smashing
protections got triggered. Issue spotted by weasel
2012-03-27 15:16:22 +02:00
Nick Mathewson
c4bfc7ca0e
Disable some tor_sscanf tests that gcc says are illegal formats
2012-03-08 21:16:46 -05:00
Nick Mathewson
97b15e6fb0
Fix new strcmp_opt/len tests on OSs where strcmp() can return values >1 or <-1
2012-03-08 21:16:46 -05:00
Esteban Manchado Velázquez
998891e734
Add unit tests for path_is_relative
2012-03-08 21:16:46 -05:00
Esteban Manchado Velázquez
dbd170f752
Some more corner cases for tor_sscanf
2012-03-08 21:16:46 -05:00
Esteban Manchado Velázquez
8e88377905
expand_filename tests for trailing slash in $HOME
2012-03-08 21:16:46 -05:00
Esteban Manchado Velázquez
043e154cdd
Add some tests for expand_filename
2012-03-08 21:16:45 -05:00
Esteban Manchado Velázquez
6beec6a373
Add two small tests for tor_sscanf
2012-03-08 21:16:45 -05:00
Esteban Manchado Velázquez
fa4ca5ddc1
Add test for broken escapes in parse_config_...
2012-03-08 21:16:45 -05:00
Esteban Manchado Velázquez
8bb68011f0
Add some unit tests for parse_iso_time
2012-03-08 21:16:45 -05:00
Esteban Manchado Velázquez
c097401879
Add tests for string_is_C_identifier
2012-03-08 21:16:45 -05:00
Esteban Manchado Velázquez
1f6e3ec500
Improve coverage in string-related unit tests
2012-03-08 21:16:45 -05:00
Esteban Manchado Velázquez
03258529d8
Improve coverage in time-related unit tests
2012-03-08 21:16:45 -05:00
Esteban Manchado Velázquez
a3679d30c0
Remove unreliable assertion
...
* This assertion fails when executing the whole suite, but not when executing
this test by itself
* Ideally I'd prefer starting with a guaranteed empty directory, but it's not
very important in this case as non-existence of other paths is being checked
explicitly
2012-03-08 20:49:26 -05:00
Esteban Manchado Velázquez
8d62e42fd3
Add extra tests for wrap_string
2012-03-08 20:49:26 -05:00
Esteban Manchado Velázquez
9ae7d511f4
Add extra tests for get_parent_directory
2012-03-08 20:49:26 -05:00
Esteban Manchado Velázquez
fa1d6f812c
Tweak test case text so it's clearer
2012-03-08 20:49:26 -05:00
Esteban Manchado Velázquez
4beebea698
Improve eat_whitespace* unit tests
2012-03-08 20:49:25 -05:00
Esteban Manchado Velázquez
3e4a977781
Put expected first in n_bits_set_u8 unit tests
2012-03-08 20:49:25 -05:00
Esteban Manchado Velázquez
afb89b83f2
Improve tor_split_lines unit tests
...
* Add some more test cases
* Switch to test_assert et al
2012-03-08 20:49:25 -05:00
Esteban Manchado Velázquez
699af29bae
Use test_streq in join_win_cmdline unit tests
2012-03-08 20:49:25 -05:00
Esteban Manchado Velázquez
7b8a7556a8
Use test_eq et al in spawn_background unit tests
2012-03-08 20:49:25 -05:00
Esteban Manchado Velázquez
6b3854f8a3
Use test_streq in format_helper_exit_status tests
2012-03-08 20:49:25 -05:00
Esteban Manchado Velázquez
22a915bcd2
Improve get_parent_directory unit tests
...
* Add more test cases to the get_parent_directory tests
* Switch the parameter order so that the expected value is the first one
2012-03-08 20:49:25 -05:00
Esteban Manchado Velázquez
275b81ec5d
Improve listdir unit tests
2012-03-08 20:49:24 -05:00
Esteban Manchado Velázquez
667f30e465
Improve a bit asprintf unit tests
2012-03-08 20:49:24 -05:00
Esteban Manchado Velázquez
781c6676ca
Rewrite the find_str_at_start_of_line unit tests
2012-03-08 20:49:24 -05:00
Esteban Manchado Velázquez
667f5ea409
Improve/extend strtok_r unit tests
...
* Add several failing tests (embedded in an "#if 0" block) for behaviour that
doesn't match strtok_r
* Add another, passing, more interesting test
* Use test_eq_ptr(NULL, ...) instead of test_assert(NULL == ...)
2012-03-08 20:49:24 -05:00
Esteban Manchado Velázquez
ee317256bb
Improve tor_sscanf tests
...
* Add many new test cases, tweak/improve existing ones, reorganize them a bit
* Switch the parameters in all test_eq calls so the expected value is the first
* Change all the "r = tor_sscanf(...);\ntest_eq(1, r)" to the more compact
"test_eq(1, tor_sscanf(...))". It may be a tiny bit harder to find the
tor_sscanf calls (it's the long lines anyway), but it saves a lot of lines,
which should help readability.
2012-03-08 20:49:24 -05:00
Esteban Manchado Velázquez
4e44024ced
Improve test case for read_escaped_data unit test
2012-03-08 20:49:23 -05:00
Esteban Manchado Velázquez
3c5a3b33e8
Trivial readability changes in mmap unit tests
2012-03-08 20:49:23 -05:00
Esteban Manchado Velázquez
f90406cb01
Clean up and improve gzip unit tests
...
* Switch some test_eq parameters so the expected is always the first parameter
* Drop some manual checks of compressed format magic numbers (they're pointless
and they make the unit tests less readable and more fragile, considering
we're already indirectly checking those magic numbers via the
detect_compression_method function)
* Add a couple of extra assertions
2012-03-08 20:49:23 -05:00
Esteban Manchado Velázquez
f4242d2e4a
Add/improve the rest of the strmisc tests
2012-03-08 20:49:23 -05:00
Esteban Manchado Velázquez
14177f03a9
Improve tor_snprintf tests
2012-03-08 20:49:18 -05:00
Esteban Manchado Velázquez
314c851bc2
Add/improve tests for str{,case}cmp{start,end}
2012-03-08 20:49:18 -05:00
Esteban Manchado Velázquez
f11be57860
Add more/better tests in test_util_strmisc
2012-03-08 20:49:18 -05:00
Esteban Manchado Velázquez
73d9868232
Trivial cosmetic fix in test comments
2012-03-08 20:49:18 -05:00
Esteban Manchado Velázquez
ab39382cf8
Organize test_util_time in blocks
...
* Separate the tests for different functions with a comment
* Move some test init code further down, closer to where it was actually being
used
2012-03-08 20:49:18 -05:00
Esteban Manchado Velázquez
f81af6d791
Add test for comments in the config parser
2012-03-08 20:49:17 -05:00
Esteban Manchado Velázquez
f9ad35c361
Add test for broken hex parsing
...
* The test currently fails, but it's commented out (with an "#if 0")
* As a broken octal actually gives a parse error, it seems fair that this
fails, too
2012-03-08 20:49:17 -05:00
Esteban Manchado Velázquez
72d455b5eb
Improve config parser escaped content tests
2012-03-08 20:49:17 -05:00
Esteban Manchado Velázquez
4d9dda9bb9
Add tests for escaped content in config
2012-03-08 20:49:17 -05:00
Esteban Manchado Velázquez
57a4e07665
Add quoted content tests for the config parser
2012-03-08 20:49:16 -05:00
Patrick Mézard
857ae345c8
Fix off-by-one error in test_util_make_environment
2012-02-20 14:12:50 +01:00
Robert Ransom
773290c09a
Add unit tests for easily tested, non-trivial utility functions
2012-02-17 11:42:21 -05:00
Nick Mathewson
5cf9167f91
Use the standard _WIN32, not the Torism MS_WINDOWS or deprecated WIN32
...
This commit is completely mechanical; I used this perl script to make it:
#!/usr/bin/perl -w -i.bak -p
if (/^\s*\#/) {
s/MS_WINDOWS/_WIN32/g;
s/\bWIN32\b/_WIN32/g;
}
2012-01-31 15:48:47 -05:00
Nick Mathewson
26e789fbfd
Rename nonconformant identifiers.
...
Fixes bug 4893.
These changes are pure mechanical, and were generated with this
perl script:
/usr/bin/perl -w -i.bak -p
s/crypto_pk_env_t/crypto_pk_t/g;
s/crypto_dh_env_t/crypto_dh_t/g;
s/crypto_cipher_env_t/crypto_cipher_t/g;
s/crypto_digest_env_t/crypto_digest_t/g;
s/aes_free_cipher/aes_cipher_free/g;
s/crypto_free_cipher_env/crypto_cipher_free/g;
s/crypto_free_digest_env/crypto_digest_free/g;
s/crypto_free_pk_env/crypto_pk_free/g;
s/_crypto_dh_env_get_dh/_crypto_dh_get_dh/g;
s/_crypto_new_pk_env_rsa/_crypto_new_pk_from_rsa/g;
s/_crypto_pk_env_get_evp_pkey/_crypto_pk_get_evp_pkey/g;
s/_crypto_pk_env_get_rsa/_crypto_pk_get_rsa/g;
s/crypto_new_cipher_env/crypto_cipher_new/g;
s/crypto_new_digest_env/crypto_digest_new/g;
s/crypto_new_digest256_env/crypto_digest256_new/g;
s/crypto_new_pk_env/crypto_pk_new/g;
s/crypto_create_crypto_env/crypto_cipher_new/g;
s/connection_create_listener/connection_listener_new/g;
s/smartlist_create/smartlist_new/g;
s/transport_create/transport_new/g;
2012-01-18 15:53:30 -05:00
Nick Mathewson
f729e1e984
Merge branch 'feature3457-v4-nm-squashed'
...
Conflicts:
src/or/rendclient.c
2012-01-11 12:10:14 -05:00
Nick Mathewson
b5af456685
Use spaceless ISO8601 time format, not sec,usec.
2012-01-11 12:08:01 -05:00
Peter Palfrader
f6b19ac79c
test_util_spawn_background_ok: fix expectation
...
test_util_spawn_background_ok() hardcoded the expected value
for ENOENT to 2. This isn't portable as error numbers are
platform specific, and particularly the hurd has ENOENT at
0x40000002.
Construct expected string at runtime, using the correct value
for ENOENT (closes : #4733 ).
2011-12-17 12:21:51 -05:00
Nick Mathewson
d106caaadc
Add an initializer to appease older gcc
2011-11-30 18:08:07 -05:00
Nick Mathewson
e83862a0ff
Resolve a resource leak in test_util_split_lines
...
Fixes coverity CID # 488
2011-11-30 12:16:08 -05:00
Nick Mathewson
d6c18c5804
Make process_handle_t private and fix some unit tests
...
Let's *not* expose more cross-platform-compatibility structures, or
expect code to use them right.
Also, don't fclose() stdout_handle and stdin_handle until we do
tor_process_handle_destroy, or we risk a double-fclose.
2011-11-25 16:47:25 -05:00
Gisle Vanem
af12a7ac00
Fix test_util.c compilation on MSVC
...
"Those '{}' constructs are not well liked by MSVC (cl v.16.xx)."
Received on tor-dev; fixes bug on 0.2.3.3-alpha.
2011-11-11 23:49:53 -05:00
Anders Sundman
8d6ce1625f
Unit tests for eat_whitespace functions
2011-11-10 23:26:39 +01:00
Anders Sundman
c0efd461d3
Unit test for n_bits_set func
2011-11-10 23:26:39 +01:00
Anders Sundman
fa9aef6eec
Unit test for hex_str func
...
Note: Too long input is undefined by contract. That behaviour should not be asserted in test.
2011-11-10 23:26:29 +01:00
Nick Mathewson
ed39621a9d
Merge remote-tracking branch 'asn2/bug3656'
...
Conflicts:
src/common/util.c
src/common/util.h
src/or/config.h
src/or/main.c
src/test/test_util.c
2011-10-07 16:05:13 -04:00
Steven Murdoch
f5df96c94f
Handle test case where fgets() sees EOF on the last read
...
On some platforms, with non-blocking IO, on EOF you first
get EAGAIN, and then on the second read you get zero bytes
and EOF is set. However on others, the EOF flag is set as
soon as the last byte is read. This patch fixes the test
case in the latter scenario.
2011-09-01 18:17:54 +01:00
Steven Murdoch
cfa9ee5fe7
Fix double-closing a stdio stream
...
After a stream reached eof, we fclose it, but then
test_util_spawn_background_partial_read() reads from it again, which causes
an error and thus another fclose(). Some platforms are fine with this, others
(e.g. debian-sid-i386) trigger a double-free() error. The actual code used by
Tor (log_from_pipe() and tor_check_port_forwarding()) handle this case
correctly.
2011-09-01 14:15:54 +01:00
Nick Mathewson
6a3e4a89a2
Tweaks on last process-launch patches
2011-08-31 22:14:38 -04:00
Steven Murdoch
5b8a20ed44
Make a version of tor_read_all_handle() for non-Windows platforms
...
Mainly used for testing reading from subprocesses. To be more generic
we now pass in a pointer to a process_handle_t rather than a Windows-
specific HANDLE.
2011-09-01 01:43:44 +01:00
Steven Murdoch
76fde28475
Fix off-by-one error when allocating memory in test_util_split_lines()
...
Triggered "failed OVER picket-fence magic-number check (err 27)" when
memory debugging using dmalloc is enabled (at 'low' or higher).
2011-08-31 23:40:29 +01:00
Nick Mathewson
2778cdd671
Rename tor_join_cmdline to tor_join_win_cmdline; tweak doxygen
2011-08-30 16:00:08 -04:00
Steven Murdoch
da34360952
Factor out and re-write code for splitting lines from a handle
...
Now handles non-printable characters and will not output a spurious
new-line if given a partial line.
2011-08-30 14:55:51 +01:00
Steven Murdoch
bc97f41080
Refactor out command line formatting
...
Now correctly handles whitespace, quotes and backslashes. Passes all unit tests.
2011-08-29 14:37:38 +01:00
Steven Murdoch
f1ff65dfad
Replace two magic tristates with #define'd names
...
- process_handle_t.status
- return value of tor_get_exit_code()
2011-08-29 00:30:18 +01:00
Steven Murdoch
3f0a197aad
Make signature of tor_spawn_background more conventional
...
Conventionally in Tor, structs are returned as pointers, so change
tor_spawn_background() to return the process handle in a pointer rather
than as return value.
2011-08-28 23:35:02 +01:00
Steven Murdoch
1da5081ae0
Appease "make check-spaces"
2011-08-24 21:34:13 +01:00
Steven Murdoch
476807211c
We don't need to find our own path, just tell Windows to search
2011-08-24 20:50:58 +01:00
Steven Murdoch
6304e088d0
Find test-child.exe by looking in same directory as test.exe
2011-08-24 19:56:38 +01:00
Steven Murdoch
50504fc4cb
Fix test cases to handle MSYS style paths (/c/foo rather than c:/foo)
...
Also fix test case to expect 1 on successfully spawning a subprocess
2011-08-22 20:05:11 +01:00
Steven Murdoch
1ad986335a
Tidy up subprocess code
...
- Better error handling
- Write description of functions
- Don't assume non-negative process return values
2011-08-22 19:43:38 +01:00
Steven Murdoch
f46f6aabb4
Fix some compiler warnings
2011-08-22 18:13:58 +01:00
Steven Murdoch
7d015c886a
Complete logging of output from port forwarding helper
2011-08-18 18:41:23 +01:00
Steven Murdoch
5bf9890b3b
Test case for reading the partial output of a background process
2011-07-25 04:08:08 +01:00
Steven Murdoch
2d5059e08e
Use PeekNamedPipe to avoid blocking ReadFile when there is nothing to read
2011-07-22 21:12:00 +01:00
Steven Murdoch
55a1cb53d6
Add code to read all from a handle, but this block forever
...
See http://stackoverflow.com/questions/3722409/windows-child-process-with-redirected-input-and-output
for a potential solution
2011-07-22 15:57:56 +01:00
Steven Murdoch
fec902dd60
Add Windows version of tor_spawn_background and ancillary functions
2011-07-21 19:26:19 +01:00
Steven Murdoch
35c89be02b
Generalize process spawning so its test compiles (but fails) in Windows
...
- pid, stdout/stderr_pipe now encapsulated in process_handle
- read_all replaced by tor_read_all_from_process_stdin/stderr
- waitpid replaced by tor_get_exit_code
Untested on *nix
2011-07-21 16:34:48 +01:00
George Kadianakis
810a7a5fa0
Make some utility functions.
...
* Create a function that will get input from a stream, so that we can
communicate with the managed proxy.
* Hackish change to tor_spawn_background() so that we can specify an
environ for our spawn.
2011-07-13 18:59:52 +02:00
Nick Mathewson
b2e7c356db
Prefer tt_assert in unit tests, not tor_assert
2011-06-08 20:33:53 -04:00
Sebastian Hahn
3bf808c341
Fix a minor coverity-found bug in tests
2011-06-08 20:00:47 +02:00
Nick Mathewson
4ac8ff9c9f
Merge remote-tracking branch 'origin/maint-0.2.2'
2011-05-15 20:22:44 -04:00
Nick Mathewson
3b6cbf2534
Add a function to pull off the final component of a path
2011-05-15 20:20:29 -04:00
Nick Mathewson
aa8db013e4
Fixup whitespace issues from 3122 commit in 0.2.3
2011-05-15 20:13:12 -04:00
Nick Mathewson
9fba014e3f
Merge remote-tracking branch 'public/bug3122_memcmp_022' into bug3122_memcmp_023
...
Conflicts in various places, mainly node-related. Resolved them in
favor of HEAD, with copying of tor_mem* operations from bug3122_memcmp_022.
src/common/Makefile.am
src/or/circuitlist.c
src/or/connection_edge.c
src/or/directory.c
src/or/microdesc.c
src/or/networkstatus.c
src/or/router.c
src/or/routerlist.c
src/test/test_util.c
2011-05-11 16:39:45 -04:00
Nick Mathewson
9964c314c6
fwd-port test_util_di_ops into tinytest format
2011-05-11 16:25:51 -04:00
Nick Mathewson
d8cb4f9f0c
Use read_all() to read messages from spawn_background
...
Using read() is an invitation to get some of the data you want, not all.
Possible fix for bug 2462
2011-05-04 23:32:18 -04:00
Nick Mathewson
394a6bf4cd
Merge remote branch 'origin/maint-0.2.2'
2011-01-03 12:47:58 -05:00
Nick Mathewson
bb5f99d4df
Merge remote branch 'sebastian/bug2314' into maint-0.2.2
2011-01-03 12:47:14 -05:00
Nick Mathewson
8730884ebe
Merge remote branch 'origin/maint-0.2.2'
2011-01-03 11:53:28 -05:00
Nick Mathewson
30b3475e6d
Bump copyright statements to 2011 (0.2.2)
2011-01-03 11:52:09 -05:00
Sebastian Hahn
9ecf133686
Fix compile wanrings revealed by gcc 4.5 on mingw
2010-12-27 09:47:41 +01:00
Steven Murdoch
06eafb3fcc
Fix running unit tests from outside of the build directory (fixes bug #2051 )
...
Currently the unit tests test_util_spawn_background_* assume that they
are run from the Tor build directory. This is not the case when running
make distcheck, so the test will fail. This problem is fixed by autoconf
setting BUILDDIR to be the root of the Tor build directory, and this
preprocessor variable being used to specify the absolute path to
test-child. Also, in test-child, do not print out argv[0] because this will
no longer be predictable. Found by Sebastian Hahn.
2010-10-11 23:29:52 +01:00
Nick Mathewson
544a8afe5a
Merge remote branch 'sjmurdoch/bug1903'
2010-10-11 11:01:15 -04:00
Steven Murdoch
f7338d3baa
Skip running fgets_eagain test until we fix it
2010-10-11 15:56:14 +01:00
Nick Mathewson
8f76f31761
Make tor_sscanf handle %x
2010-10-11 10:50:47 -04:00
Steven Murdoch
8a12ce2cf9
Add a unit test for tor_spawn_background
...
- Test sucessfully starting a process
- Test failing to find the executable
2010-10-10 19:08:44 +01:00
Steven Murdoch
8ee559bd63
Add a unit test for fgets (currently fails)
...
- For a non-blocking pipe, check that on EAGAIN fgets returns NULL
rather than a partial line
2010-10-10 19:08:44 +01:00