Commit Graph

94 Commits

Author SHA1 Message Date
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
Steven Murdoch
5a77c64834 Fix issues in nickm's review of format_helper_exit_status for bug #1903
- Responsibility of clearing hex_errno is no longer with caller
- More conservative bounds checking
- Length requirement of hex_errno documented
- Output format documented
2010-10-04 14:31:27 +01:00
Steven Murdoch
a6dc00fa75 Start tor-fw-helper in the background, and log whatever it outputs 2010-09-30 11:40:37 -04:00
Nick Mathewson
e385961542 Merge remote branch 'public/bug1954' into maint-0.2.2 2010-09-27 15:39:40 -04:00
Sebastian Hahn
1d29ad891e Add new torrc line continuation unit tests
We want to make sure that we don't break old torrc files that might have
used something like this made-up example:

    ContactInfo UberUser <uber@user.com> # /// Fake email! \\\
    Log info file /home/nick.mathewson/projects/tor-info.log

And we also want to support the following style of writing your torrc:

    ExcludeNodes \
    # Node1337 is run by the Bavarian Illuminati
      Node1337, \
    # The operator of Node99 looked at me funny
      Node99

The code already handles both cases, but the unit test should help prove
it.
2010-09-23 22:46:13 +02:00
Nick Mathewson
418e6caeeb New function to load windows system libraries
This function uses GetSystemDirectory() to make sure we load the version
of the library from c:\windows\system32 (or local equivalent) rather than
whatever version lives in the cwd.
2010-09-21 14:39:23 -04:00
Sebastian Hahn
a05ef55b66 Allow comments for multi-line torrc options 2010-09-11 01:41:23 +02:00
Nick Mathewson
07049b3d25 Support mutli-line torrc options via the usual backslash syntax 2010-09-10 09:19:10 -04:00
Nick Mathewson
34551cda6f Add unit test for tor_listdir. 2010-08-20 13:24:54 -04:00
Sebastian Hahn
0bfa34e1f6 Create control.h 2010-07-27 07:58:15 +02:00
Sebastian Hahn
c4f8f1316e Create config.h 2010-07-27 07:58:14 +02:00
Nick Mathewson
7221d15acc Merge commit 'origin/maint-0.2.1'
Conflicts:
	src/or/test.c
2010-04-12 18:22:06 -04:00
Nick Mathewson
927425150b Merge branch 'asprintf' 2010-04-02 12:30:46 -04:00
Nick Mathewson
da220157a9 Update copyright dates for files not in maint-0.2.1 2010-02-27 17:19:00 -05:00
Nick Mathewson
6fa8dacb97 Add a tor_asprintf() function, and use it in a couple of places.
asprintf() is a GNU extension that some BSDs have picked up: it does a printf
into a newly allocated chunk of RAM.

Our tor_asprintf() differs from standard asprintf() in that:
  - Like our other malloc functions, it asserts on OOM.
  - It works on windows.
  - It always sets its return-field.
2010-02-25 16:09:10 -05:00
Nick Mathewson
df3812ede1 Rearrange _thread_test_func to please Coverity Scan
I believe  that since  we were allocating  *cp while holding  a mutex,
coverity deduced that  *cp must be protected by  that mutex, and later
flipped out  when we didn't  use it  that way. If  this is so,  we can
solve our problems by moving the *cp = tor_strdup(buf) part outside of
the mutex-protected code.
2010-01-25 14:12:37 -05:00
Karsten Loesing
f80672d747 Remove duplicate words and a duplicate newline. 2009-12-18 12:55:05 +01:00
Nick Mathewson
235f1e1a96 Refactor out the 'find string at start of any line' logic.
We do this in too many places throughout the code; it's time to start
clamping down.

Also, refactor Karsten's patch to use strchr-then-strndup, rather than
malloc-then-strlcpy-then-strchr-then-clear.
2009-12-17 18:29:37 -05:00
Nick Mathewson
134ac8059b Fix the very noisy unit test memory leak of CID 420-421.
On any failing case in test_util_config_line, we would leak a couple
of strings.
2009-10-26 22:40:41 -04:00
Nick Mathewson
fa693118b1 Split directory tests into their own module.
(Also, clean up some whitespace.)
2009-09-23 00:24:43 -04:00
Nick Mathewson
050545405a Split test_util() into smaller functions. 2009-09-23 00:24:43 -04:00
Nick Mathewson
d9d0813809 Split general util and address tests into their own files. 2009-09-23 00:24:43 -04:00