2015-01-02 20:27:39 +01:00
|
|
|
/* Copyright (c) 2011-2015, The Tor Project, Inc. */
|
2012-06-05 02:58:17 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
2010-10-10 19:12:23 +02:00
|
|
|
#include <stdio.h>
|
2011-07-22 16:57:56 +02:00
|
|
|
#include "orconfig.h"
|
2012-01-31 16:59:42 +01:00
|
|
|
#ifdef _WIN32
|
2011-07-22 16:57:56 +02:00
|
|
|
#define WINDOWS_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2014-04-30 18:50:00 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define SLEEP(sec) Sleep((sec)*1000)
|
|
|
|
#else
|
|
|
|
#define SLEEP(sec) sleep(sec)
|
|
|
|
#endif
|
2010-10-10 19:12:23 +02:00
|
|
|
|
|
|
|
/** 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;
|
2014-04-30 18:50:00 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2010-10-10 19:12:23 +02:00
|
|
|
|
|
|
|
fprintf(stdout, "OUT\n");
|
|
|
|
fprintf(stderr, "ERR\n");
|
2010-10-12 00:22:52 +02:00
|
|
|
for (i = 1; i < argc; i++)
|
2010-10-10 19:12:23 +02:00
|
|
|
fprintf(stdout, "%s\n", argv[i]);
|
2014-04-30 18:50:00 +02:00
|
|
|
if (!fast)
|
|
|
|
fprintf(stdout, "SLEEPING\n");
|
2011-07-25 00:31:59 +02:00
|
|
|
/* 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);
|
2014-04-30 18:50:00 +02:00
|
|
|
if (!fast)
|
|
|
|
SLEEP(1);
|
2010-10-10 19:12:23 +02:00
|
|
|
fprintf(stdout, "DONE\n");
|
2014-04-30 18:50:00 +02:00
|
|
|
fflush(stdout);
|
|
|
|
if (fast)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (--delay) {
|
|
|
|
SLEEP(1);
|
|
|
|
}
|
2010-10-10 19:12:23 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|