1 /* Copyright (c) 2011-2020, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
7 #define WINDOWS_LEAN_AND_MEAN
11 #endif /* defined(_WIN32) */
16 #define SLEEP(sec) Sleep((sec)*1000)
18 #define SLEEP(sec) sleep(sec)
21 /* Trivial test program to test process_t. */
23 main(int argc
, char **argv
)
25 /* Does our process get the right arguments? */
26 for (int i
= 0; i
< argc
; ++i
) {
27 fprintf(stdout
, "argv[%d] = '%s'\n", i
, argv
[i
]);
31 /* Make sure our process got our environment variable. */
32 fprintf(stdout
, "Environment variable TOR_TEST_ENV = '%s'\n",
33 getenv("TOR_TEST_ENV"));
36 /* Test line handling on stdout and stderr. */
37 fprintf(stdout
, "Output on stdout\nThis is a new line\n");
40 fprintf(stderr
, "Output on stderr\nThis is a new line\n");
43 fprintf(stdout
, "Partial line on stdout ...");
46 fprintf(stderr
, "Partial line on stderr ...");
51 fprintf(stdout
, "end of partial line on stdout\n");
53 fprintf(stderr
, "end of partial line on stderr\n");
56 /* Echo input from stdin. */
61 while (fgets(buffer
, sizeof(buffer
), stdin
)) {
62 /* Strip the newline. */
63 size_t size
= strlen(buffer
);
65 if (size
>= 1 && buffer
[size
- 1] == '\n') {
66 buffer
[size
- 1] = '\0';
70 if (size
>= 1 && buffer
[size
- 1] == '\r') {
71 buffer
[size
- 1] = '\0';
75 fprintf(stdout
, "Read line from stdin: '%s'\n", buffer
);
82 fprintf(stdout
, "We are done for here, thank you!\n");