head 1.3; access; symbols SFIO_1999:1.1.1.3 SFIO_1998:1.1.1.2 SFIO_1997:1.1.1.1 ATT:1.1.1; locks; strict; comment @ * @; 1.3 date 99.09.11.13.20.43; author rse; state Exp; branches; next 1.2; 1.2 date 99.09.11.12.42.10; author rse; state Exp; branches; next 1.1; 1.1 date 96.12.13.21.12.11; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 96.12.13.21.12.11; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 98.05.29.16.25.48; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 99.06.04.18.51.16; author rse; state Exp; branches; next ; desc @@ 1.3 log @Merge in Sfio 1999 changes @ text @#include "sftest.h" /* Test for /dev/null and hole-preserving code */ int main() { Sfio_t* null; Sfio_t* f; char buf[256*1024], b[256*1024]; int k, n; if(!(null = sfopen(NIL(Sfio_t*),"/dev/null","w")) ) terror("Opening /dev/null"); sfsetbuf(null,NIL(char*),(size_t)SF_UNBOUND); if(!SFISNULL(null) ) terror("Not /dev/null?"); if(!(f = sfopen(NIL(Sfio_t*), Kpv[0], "w+")) ) terror("Creating %s", Kpv[0]); sfwrite(f,"1234",4); sfseek(f,(Sfoff_t)1,0); sfsync(f); sfsetfd(null,-1); sfsetfd(null,sffileno(f)); sfsync(null); sfseek(f,(Sfoff_t)0,0); if(sfread(f,buf,4) != 4 || strncmp(buf,"1234",4) != 0) terror("Bad data"); for(k = 0; k < sizeof(buf); ++k) buf[k] = 1; for(k = sizeof(buf)/4; k < sizeof(buf)/2; ++k) /* make a big hole */ buf[k] = 0; if(!(f = sfopen(f, Kpv[0], "w+")) ) terror("Creating %s", Kpv[0]); n = sizeof(buf)-127; if(sfwrite(f,buf,n) != n) terror("Writing large buffer"); sfseek(f,(Sfoff_t)0,0); if(sfread(f,b,n) != n) terror("Reading large buffer"); for(k = 0; k < n; ++k) if(b[k] != buf[k]) terror("Bad data"); rmkpv(); return 0; } @ 1.2 log @Incorporate stuff from RSE's Sfio98 variant @ text @d9 1 a9 1 char buf[1024*1024], b[1024*1024]; d20 2 a21 2 if(!(f = sfopen(NIL(Sfio_t*),"xxx","w+")) ) terror("Creating xxx"); d36 1 a36 1 for(k = 256*1024; k < 512*1024; ++k) /* make a big hole */ d39 2 a40 2 if(!(f = sfopen(f,"xxx","w+")) ) terror("Creating xxx2"); d51 1 a51 2 unlink("xxx"); @ 1.1 log @Initial revision @ text @d5 1 a5 1 main() d9 2 a10 1 char buf[16]; d33 19 @ 1.1.1.1 log @Import of Sfio1997 @ text @@ 1.1.1.2 log @Import of Sfio1998 @ text @d9 1 a9 2 char buf[1024*1024], b[1024*1024]; int k, n; a31 19 for(k = 0; k < sizeof(buf); ++k) buf[k] = 1; for(k = 256*1024; k < 512*1024; ++k) /* make a big hole */ buf[k] = 0; if(!(f = sfopen(f,"xxx","w+")) ) terror("Creating xxx2"); n = sizeof(buf)-127; if(sfwrite(f,buf,n) != n) terror("Writing large buffer"); sfseek(f,(Sfoff_t)0,0); if(sfread(f,b,n) != n) terror("Reading large buffer"); for(k = 0; k < n; ++k) if(b[k] != buf[k]) terror("Bad data"); unlink("xxx"); @ 1.1.1.3 log @Import of Sfio1999 @ text @d9 1 a9 1 char buf[256*1024], b[256*1024]; d20 2 a21 2 if(!(f = sfopen(NIL(Sfio_t*), Kpv[0], "w+")) ) terror("Creating %s", Kpv[0]); d36 1 a36 1 for(k = sizeof(buf)/4; k < sizeof(buf)/2; ++k) /* make a big hole */ d39 2 a40 2 if(!(f = sfopen(f, Kpv[0], "w+")) ) terror("Creating %s", Kpv[0]); d51 2 a52 1 rmkpv(); @