1 /* Sanity check for the process and IPC primitives.
3 * Copyright (C) 2016 g10 code GmbH
5 * This file is part of GnuPG.
7 * GnuPG is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * GnuPG is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <https://www.gnu.org/licenses/>.
31 main (int argc, char **argv)
34 memset (buffer, 'A', sizeof buffer);
36 if (! setmode (stdin, O_BINARY))
38 if (! setmode (stdout, O_BINARY))
44 else if (strcmp (argv[1], "return0") == 0)
46 else if (strcmp (argv[1], "return1") == 0)
48 else if (strcmp (argv[1], "return77") == 0)
50 else if (strcmp (argv[1], "hello_stdout") == 0)
51 fprintf (stdout, "hello");
52 else if (strcmp (argv[1], "hello_stderr") == 0)
53 fprintf (stderr, "hello");
54 else if (strcmp (argv[1], "stdout4096") == 0)
55 fwrite (buffer, 1, sizeof buffer, stdout);
56 else if (strcmp (argv[1], "stdout8192") == 0)
58 fwrite (buffer, 1, sizeof buffer, stdout);
59 fwrite (buffer, 1, sizeof buffer, stdout);
61 else if (strcmp (argv[1], "cat") == 0)
62 while (! feof (stdin))
65 bytes_read = fread (buffer, 1, sizeof buffer, stdin);
66 fwrite (buffer, 1, bytes_read, stdout);
70 fprintf (stderr, "unknown command %s\n", argv[1]);