2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
13 int filedes
[2] = { 0, 0 };
14 int dupfiledes
[2] = { 0, 0 };
19 char destination
[BUFLEN
];
24 for(i
= 0; i
< BUFLEN
; i
++)
25 source
[i
] = str
[i
% strlen(str
)];
27 TEST((pipe(filedes
) == 0));
28 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
29 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
30 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
32 for(i
= 0; i
< BUFLEN
; i
++)
33 source
[i
] = str2
[i
% strlen(str2
)];
35 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
36 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
37 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
39 for(i
= 0; i
< 10000; i
++)
43 TESTFALSE((write(filedes
[1], &src
, 1) == 1));
44 TESTFALSE((read(filedes
[0], &dst
, 1) == 1));
45 TESTFALSE((src
== dst
));
47 printf("10000 read-writes passed, line %d.\n", __LINE__
);
49 dupfiledes
[0] = dup(filedes
[0]);
50 TEST((dupfiledes
[0] != -1));
52 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
53 TEST((read(dupfiledes
[0], destination
, BUFLEN
) == BUFLEN
));
54 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
56 for(i
= 0; i
< 10000; i
++)
60 TESTFALSE((write(filedes
[1], &src
, 1) == 1));
61 TESTFALSE((read(dupfiledes
[0], &dst
, 1) == 1));
62 TESTFALSE((src
== dst
));
64 printf("10000 read-writes passed, line %d.\n", __LINE__
);
66 dupfiledes
[1] = dup(filedes
[1]);
67 TEST((dupfiledes
[1] != -1));
69 TEST((write(dupfiledes
[1], source
, BUFLEN
) == BUFLEN
));
70 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
71 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
73 for(i
= 0; i
< 10000; i
++)
77 TESTFALSE((write(dupfiledes
[1], &src
, 1) == 1));
78 TESTFALSE((read(filedes
[0], &dst
, 1) == 1));
79 TESTFALSE((src
== dst
));
81 printf("10000 read-writes passed, line %d.\n", __LINE__
);
83 TEST((write(dupfiledes
[1], source
, BUFLEN
) == BUFLEN
));
84 TEST((read(dupfiledes
[0], destination
, BUFLEN
) == BUFLEN
));
85 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
87 for(i
= 0; i
< 10000; i
++)
91 TESTFALSE((write(dupfiledes
[1], &src
, 1) == 1));
92 TESTFALSE((read(dupfiledes
[0], &dst
, 1) == 1));
93 TESTFALSE((src
== dst
));
95 printf("10000 read-writes passed, line %d.\n", __LINE__
);
97 TEST((close(dupfiledes
[0]) != -1));
99 TEST((close(dupfiledes
[1]) != -1));
102 TEST((write(filedes
[1], source
, BUFLEN
) == BUFLEN
));
103 TEST((read(filedes
[0], destination
, BUFLEN
) == BUFLEN
));
104 TEST((memcmp(source
, destination
, BUFLEN
) == 0));
106 for(i
= 0; i
< 10000; i
++)
110 TESTFALSE((write(filedes
[1], &src
, 1) == 1));
111 TESTFALSE((read(filedes
[0], &dst
, 1) == 1));
112 TESTFALSE((src
== dst
));
114 printf("10000 read-writes passed, line %d.\n", __LINE__
);
127 close(dupfiledes
[0]);
129 close(dupfiledes
[1]);