Commit 8a12ce2c authored by Steven Murdoch's avatar Steven Murdoch
Browse files

Add a unit test for tor_spawn_background

- Test sucessfully starting a process
- Test failing to find the executable
parent 68e576e9
Loading
Loading
Loading
Loading
+1 −0
Changes for .gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@
/src/test/Makefile
/src/test/Makefile.in
/src/test/test
/src/test/test-child


# /src/tools/
+1 −1
Changes for src/common/util.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -2973,7 +2973,7 @@ format_helper_exit_status(unsigned char child_state, int saved_errno,
 * -1.  Some parts of this code are based on the POSIX subprocess module from
 * Python.
 */
static int
int
tor_spawn_background(const char *const filename, int *stdout_read,
                     int *stderr_read, const char **argv)
{
+2 −0
Changes for src/common/util.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -350,6 +350,8 @@ HANDLE load_windows_system_library(const TCHAR *library_name);

#ifdef UTIL_PRIVATE
/* Prototypes for private functions only used by util.c (and unit tests) */
int tor_spawn_background(const char *const filename, int *stdout_read,
                         int *stderr_read, const char **argv);
void format_helper_exit_status(unsigned char child_state,
                               int saved_errno, char *hex_errno);

+1 −1
Changes for src/test/Makefile.am: 1 added line, 1 removed line.
Original line number Diff line number Diff line
TESTS = test

noinst_PROGRAMS = test
noinst_PROGRAMS = test test-child

AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \
        -DLOCALSTATEDIR="\"$(localstatedir)\"" \

src/test/test-child.c

0 → 100644
+18 −0
Changes for src/test/test-child.c: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
#include <stdio.h>

/** Trivial test program which prints out its command line arguments so we can
 * check if tor_spawn_background() works */
int
main(int argc, char **argv)
{
  int i;

  fprintf(stdout, "OUT\n");
  fprintf(stderr, "ERR\n");
  for (i = 0; i < argc; i++)
    fprintf(stdout, "%s\n", argv[i]);
  fprintf(stdout, "DONE\n");

  return 0;
}
Loading