phys addr arg of 0 must be possible for pt_writemap too (instead of meaning
[minix.git] / test / test13.c
blob081775b829af194449bd1ae499c0887c5b3130bf
1 /* test 13 */
3 /* File: pipes.c - created by Marty Leisner */
4 /* Leisner.Henr 1-Dec-87 8:55:04 */
6 /* Copyright (C) 1987 by Martin Leisner. All rights reserved. */
7 /* Used by permission. */
9 #include <sys/types.h>
10 #include <sys/wait.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <stdio.h>
15 #define BLOCK_SIZE 1000
16 #define NUM_BLOCKS 1000
18 int errct = 0;
19 char buffer[BLOCK_SIZE];
21 _PROTOTYPE(int main, (void));
22 _PROTOTYPE(void quit, (void));
24 int main()
26 int stat_loc, pipefd[2];
27 register int i;
28 pipe(pipefd);
30 printf("Test 13 ");
31 fflush(stdout); /* have to flush for child's benefit */
33 system("rm -rf DIR_13; mkdir DIR_13");
34 chdir("DIR_13");
36 pipe(pipefd);
38 switch (fork()) {
39 case 0:
40 /* Child code */
41 for (i = 0; i < NUM_BLOCKS; i++)
42 if (read(pipefd[0], buffer, BLOCK_SIZE) != BLOCK_SIZE) break;
43 exit(0);
45 case -1:
46 perror("fork broke");
47 exit(1);
49 default:
50 /* Parent code */
51 for (i = 0; i < NUM_BLOCKS; i++) write(pipefd[1], buffer, BLOCK_SIZE);
52 wait(&stat_loc);
53 break;
55 quit();
56 return(-1); /* impossible */
59 void quit()
62 chdir("..");
63 system("rm -rf DIR*");
65 if (errct == 0) {
66 printf("ok\n");
67 exit(0);
68 } else {
69 printf("%d errors\n", errct);
70 exit(1);