/***********************************************************************
* *
* 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"
static int Bufcount = 0;
#if __STD_C
#else
Sfio_t* f;
size_t n;
#endif
{
Bufcount += 1;
}
tmain()
{
int n, i;
s = "123456789\n";
n = strlen(s);
terror("Opening file to write");
for(i = 0; i < 1000; ++i)
if(sfwrite(f,s,n) != n)
terror("Writing data");
terror("Opening file to read");
terror("Bad seek to 128");
terror("Bad seek(0,1) to 128");
terror("Bad file length");
if(sftell(f) != (i*n))
terror("sftell");
for(; i > 0; --i)
terror("sfgetr");
terror("Expect=%s",s);
}
terror("Open to write");
for(n = sizeof(zero)-1; n >= 0; --n)
zero[n] = 0;
terror("Writing data");
terror("seeking1");
terror("seeking2");
terror("Open to write2");
for(n = 0; n < sizeof(buf); n++)
buf[n] = n;
for(n = 0; n < 256; n++)
terror("Writing data 2");
terror("Open to read2");
terror("Get first 2 bytes");
terror("Seeking ");
for(n = 0; n < 128; ++n)
terror("Reading data");
terror("Open to read3");
terror("sfread failed");
terror("sftell failed");
terror("sfseek failed");
terror("sfnew failed");
terror("sfread failed2");
if(sftell(f) != 10)
terror("sftell failed2");
terror("sfseek failed on sf");
terror("sfseek public failed");
/* test to see if the buffering algorithm does the right thing */
terror("Opening test file to write");
for(i = 0; i < 8192; ++i)
terror("writing test data");
terror("Opening test file to read");
for(i = 0; i < 8192; ++i)
terror("Reading data");
if(strcmp(s,"123456789") != 0)
terror("Bad data");
}
if(Bufcount != 10)
terror("Bad buffer filling count");
sfclose(f);
/* test buffer alignment for read streams - from a Daytona case */
terror("Opening to write");
for(i = 0; i < 500; ++i)
terror("writing test data");
sfclose(f);
terror("Opening to read");
terror("Bad seek");
terror("Bad sfreserve");
terror("Bad file position");
terror("Bad seek");
terror("Bad sfreserve");
terror("Bad reserved data");
texit(0);
}