8 int filedes
[2] = { 0, 0 };
9 int dupfiledes
[2] = { 0, 0 };
14 char destination
[BUFLEN
];
19 for(i
= 0; i
< BUFLEN
; i
++)
20 source
[i
] = str
[i
% strlen(str
)];
22 TEST((pipe(filedes
) == 0));
23 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
24 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
25 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
27 for(i
= 0; i
< BUFLEN
; i
++)
28 source
[i
] = str2
[i
% strlen(str2
)];
30 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
31 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
32 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
34 for(i
= 0; i
< 10000; i
++)
38 TEST((write(filedes
[1], &src
, 1) == 1));
39 TEST((read(filedes
[0], &dst
, 1) == 1));
43 dupfiledes
[0] = dup(filedes
[0]);
44 TEST((dupfiledes
[0] != -1));
46 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
47 TEST((read(dupfiledes
[0], destination
, BUFLEN
) == BUFLEN
));
48 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
50 for(i
= 0; i
< 10000; i
++)
54 TEST((write(filedes
[1], &src
, 1) == 1));
55 TEST((read(dupfiledes
[0], &dst
, 1) == 1));
59 dupfiledes
[1] = dup(filedes
[1]);
60 TEST((dupfiledes
[1] != -1));
62 TEST((write(dupfiledes
[1], source
, BUFLEN
) == BUFLEN
));
63 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
64 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
66 for(i
= 0; i
< 10000; i
++)
70 TEST((write(dupfiledes
[1], &src
, 1) == 1));
71 TEST((read(filedes
[0], &dst
, 1) == 1));
75 TEST((write(dupfiledes
[1], source
, BUFLEN
) == BUFLEN
));
76 TEST((read(dupfiledes
[0], destination
, BUFLEN
) == BUFLEN
));
77 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
79 for(i
= 0; i
< 10000; i
++)
83 TEST((write(dupfiledes
[1], &src
, 1) == 1));
84 TEST((read(dupfiledes
[0], &dst
, 1) == 1));
88 TEST((close(dupfiledes
[0]) != -1));
90 TEST((close(dupfiledes
[1]) != -1));
93 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
94 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
95 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
97 for(i
= 0; i
< 10000; i
++)
101 TEST((write(filedes
[1], &src
, 1) == 1));
102 TEST((read(filedes
[0], &dst
, 1) == 1));
117 close(dupfiledes
[0]);
119 close(dupfiledes
[1]);