aboutsummaryrefslogtreecommitdiff
path: root/src/test/test-child.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-06-14 11:46:38 -0400
committerNick Mathewson <nickm@torproject.org>2014-06-14 11:46:38 -0400
commita7cafb1ea9307864c94ad3e019af93d09d48350e (patch)
tree1c6cc26fb0a93f46d839b3cb46855c93aca135f4 /src/test/test-child.c
parenta58d94fb7c6c304ecba930eaa7ebbade1d0686ab (diff)
parente07d328457b26babe89abdcc1d5a550ee8273462 (diff)
downloadtor-a7cafb1ea9307864c94ad3e019af93d09d48350e.tar
tor-a7cafb1ea9307864c94ad3e019af93d09d48350e.tar.gz
Merge branch 'bug8746_v2_squashed'
Conflicts: src/common/include.am
Diffstat (limited to 'src/test/test-child.c')
-rw-r--r--src/test/test-child.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/test/test-child.c b/src/test/test-child.c
index ef10fbb92..756782e70 100644
--- a/src/test/test-child.c
+++ b/src/test/test-child.c
@@ -9,6 +9,13 @@
#else
#include <unistd.h>
#endif
+#include <string.h>
+
+#ifdef _WIN32
+#define SLEEP(sec) Sleep((sec)*1000)
+#else
+#define SLEEP(sec) sleep(sec)
+#endif
/** Trivial test program which prints out its command line arguments so we can
* check if tor_spawn_background() works */
@@ -16,27 +23,38 @@ int
main(int argc, char **argv)
{
int i;
+ int delay = 1;
+ int fast = 0;
+
+ if (argc > 1) {
+ if (!strcmp(argv[1], "--hang")) {
+ delay = 60;
+ } else if (!strcmp(argv[1], "--fast")) {
+ fast = 1;
+ delay = 0;
+ }
+ }
fprintf(stdout, "OUT\n");
fprintf(stderr, "ERR\n");
for (i = 1; i < argc; i++)
fprintf(stdout, "%s\n", argv[i]);
- fprintf(stdout, "SLEEPING\n");
+ if (!fast)
+ fprintf(stdout, "SLEEPING\n");
/* We need to flush stdout so that test_util_spawn_background_partial_read()
succeed. Otherwise ReadFile() will get the entire output in one */
// XXX: Can we make stdio flush on newline?
fflush(stdout);
-#ifdef _WIN32
- Sleep(1000);
-#else
- sleep(1);
-#endif
+ if (!fast)
+ SLEEP(1);
fprintf(stdout, "DONE\n");
-#ifdef _WIN32
- Sleep(1000);
-#else
- sleep(1);
-#endif
+ fflush(stdout);
+ if (fast)
+ return 0;
+
+ while (--delay) {
+ SLEEP(1);
+ }
return 0;
}