0.2.6.5-rc will come out today, because why not.
[tor.git] / src / test / test-child.c
blob2ce01ea9bb0f107d8de38cdd8bd1569bcb526498
1 /* Copyright (c) 2011-2015, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #include <stdio.h>
5 #include "orconfig.h"
6 #ifdef _WIN32
7 #define WINDOWS_LEAN_AND_MEAN
8 #include <windows.h>
9 #else
10 #include <unistd.h>
11 #endif
12 #include <string.h>
14 #ifdef _WIN32
15 #define SLEEP(sec) Sleep((sec)*1000)
16 #else
17 #define SLEEP(sec) sleep(sec)
18 #endif
20 /** Trivial test program which prints out its command line arguments so we can
21 * check if tor_spawn_background() works */
22 int
23 main(int argc, char **argv)
25 int i;
26 int delay = 1;
27 int fast = 0;
29 if (argc > 1) {
30 if (!strcmp(argv[1], "--hang")) {
31 delay = 60;
32 } else if (!strcmp(argv[1], "--fast")) {
33 fast = 1;
34 delay = 0;
38 fprintf(stdout, "OUT\n");
39 fprintf(stderr, "ERR\n");
40 for (i = 1; i < argc; i++)
41 fprintf(stdout, "%s\n", argv[i]);
42 if (!fast)
43 fprintf(stdout, "SLEEPING\n");
44 /* We need to flush stdout so that test_util_spawn_background_partial_read()
45 succeed. Otherwise ReadFile() will get the entire output in one */
46 // XXX: Can we make stdio flush on newline?
47 fflush(stdout);
48 if (!fast)
49 SLEEP(1);
50 fprintf(stdout, "DONE\n");
51 fflush(stdout);
52 if (fast)
53 return 0;
55 while (--delay) {
56 SLEEP(1);
59 return 0;