/***********************************************************************
* *
* 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 tests to see if SF_SYNC is raised at the right time */
static int Count = 0;
#if __STD_C
#else
Sfio_t* f;
int type;
#endif
{
Count += 1;
return 0;
}
/* this tests to see if data is written correctly */
typedef struct _mydisc_s
{
int sync;
} Mydisc_t;
#if __STD_C
#else
Sfio_t* f;
int type;
#endif
{
return 0;
}
#if __STD_C
#else
Sfio_t* f;
size_t n;
#endif
{
size_t i;
char* s = (char*)buf;
i = n;
else /* only write entire lines */
{ for(i = n; i > 0; --i)
if(s[i-1] == '\n')
break;
if(i <= 0)
return 0;
}
}
tmain()
{
int n, dupf2;
/* redirect stdout to a pipe */
terror("Creating pipe1");
/* redirect stdin to a pipe with some input */
close(0);
terror("Creating a pipe2");
terror("Writing to pipe");
terror("Line mode on unexpectedly");
terror("Premature eof");
terror("Weird error1");
terror("Should be eof");
terror("Weird error2");
terror("Purging stdout");
terror("Opening file to write");
terror("Opening file to read");
if(Count != 1)
terror("No sfsync call?");
Count = 0;
terror("Did not get all data n=%d", n);
if(Count != 0)
terror("Should not have seen SF_SYNC yet");
if(Count != 1)
terror("Should have seen SF_SYNC");
if(Count != 2)
if(Count != 3)
sfsync(0);
/* test to see if data is written correctly */
terror("Creating temp file");
for(n = 0; n < 10; ++n)
terror("Bad sfwrite call");
terror("Bad sfwrite call 2");
if(sfsync(f) != 0)
terror("Bad sfsync call");
terror("Bad sfseek call");
for(n = 0; n < 10; ++n)
terror("Bad sfgetr call");
if(strcmp(s, "0123456789") != 0)
terror("Bad read data");
}
texit(0);
}