/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1999-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#include "sftest.h"
/* This test checks to see if sfread() will always fill the buffer
** from a piped-stream correctly even if the other end of the pipe
** is writing odd amounts of bytes.
*/
tmain()
{
int p[2];
int i, r, n;
if(pipe(p) < 0 )
terror("Making pipe for communication");
terror("Making read stream");
for(i = 0; i < sizeof(wbuf); ++i)
switch(fork())
{
case -1 :
terror("fork() failed");
case 0 :
terror("Write to pipe failed i=%d", i);
break;
default:
for(i = 0; i < ITER; ++i)
terror("Read from pipe failed i=%d", i);
for(n = 0; n < sizeof(wbuf); ++n)
if(s[n] != (n%10)+'0')
terror("Bad data i=%d n=%d", i, n);
}
break;
}
texit(0);
}