15 static void do_test(void)
23 char filename
[] = "pwrite_test_XXXXXXX";
28 if ((fd
= mkstemp(filename
)) < 0) e(1);
30 size
= 1 + rand() % 4096;
33 if((wbuf
= malloc(sizeof(char)*size
)) == NULL
) e(2);
35 for(i
= 0; i
< size
; i
++) {
36 wbuf
[i
] = 1 + rand()%127;
39 if ((nwritten
= pwrite(fd
, wbuf
, size
, off
)) < 0) e(3);
40 if ((rbuf
= malloc(sizeof(char)*nwritten
)) == NULL
) e(4);
41 if ((nread
= pread(fd
, rbuf
, nwritten
, off
)) < 0) e(5);
42 if (strncmp(rbuf
, wbuf
, nread
) != 0) e(6);
55 return(-1); /* Unreachable */