1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 * This test runs in conjunction with the pipeping test.
11 * The pipeping test creates two pipes and redirects the
12 * stdin and stdout of this test to the pipes. Then the
13 * pipeping test writes "ping" to this test and this test
14 * writes "pong" back. Note that this test does not depend
15 * on NSPR at all. To run this pair of tests, just invoke
18 * Tested areas: process creation, pipes, file descriptor
19 * inheritance, standard I/O redirection.
26 #define NUM_ITERATIONS 10
28 int main(int argc
, char **argv
)
34 for (idx
= 0; idx
< NUM_ITERATIONS
; idx
++) {
35 memset(buf
, 0, sizeof(buf
));
36 nBytes
= fread(buf
, 1, 5, stdin
);
37 fprintf(stderr
, "pong process: received \"%s\"\n", buf
);
39 fprintf(stderr
, "pong process: expected 5 bytes but got %d bytes\n",
43 if (strcmp(buf
, "ping") != 0) {
44 fprintf(stderr
, "pong process: expected \"ping\" but got \"%s\"\n",
50 fprintf(stderr
, "pong process: sending \"%s\"\n", buf
);
51 nBytes
= fwrite(buf
, 1, 5, stdout
);
53 fprintf(stderr
, "pong process: fwrite failed\n");