debuggers.hg

view tools/libaio/harness/cases/11.t @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 /* 11.t - uses testdir/rwfile
2 - repeated read / write of same page (to check accounting) (11.t)
3 */
4 #include "aio_setup.h"
6 #include <sys/time.h>
7 #include <sys/resource.h>
8 #include <unistd.h>
10 int test_main(void)
11 {
12 #define COUNT 1000000
13 #define SIZE 256
14 char *buf;
15 int rwfd;
16 int status = 0;
17 int i;
19 rwfd = open("testdir/rwfile", O_RDWR|O_CREAT|O_TRUNC, 0600);
20 assert(rwfd != -1);
21 buf = malloc(SIZE); assert(buf != NULL);
22 memset(buf, 0, SIZE);
24 for (i=0; i<COUNT; i++) {
25 status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE_SILENT, SIZE);
26 if (status)
27 break;
28 }
29 printf("completed %d out of %d writes\n", i, COUNT);
30 for (i=0; i<COUNT; i++) {
31 status |= attempt_rw(rwfd, buf, SIZE, 0, READ_SILENT, SIZE);
32 if (status)
33 break;
34 }
35 printf("completed %d out of %d reads\n", i, COUNT);
37 return status;
38 }