1 /* Test of large files */
4 #include "ucw/fastbuf.h"
24 b = bopen("/big/robert/large-file", O_CREAT | O_TRUNC | O_RDWR, 1<<20);
26 die("Cannot create large-file");
28 log(L_DEBUG, "Writing %d blocks of size %d", COUNT, BLOCK);
29 for (i=0; i<COUNT; i++)
31 memset(block, i & 0xff, BLOCK);
32 bwrite(b, block, BLOCK);
40 b = bopen("/big/robert/large-file", O_RDWR, 1<<20);
42 die("Cannot create large-file");
44 log(L_DEBUG, "Checking the file contents in %d tests", TESTS);
45 for (i=0; i<TESTS; i++)
47 uns idx = random()%COUNT;
48 sh_off_t ofs = idx*BLOCK;
49 bseek(b, ofs, SEEK_SET);
50 bread(b, block, BLOCK);
51 if (block[17] != (idx & 0xff))
52 die("Invalid block %d in test %d: %x != %x", idx, i, block[17], idx & 0xff);