debuggers.hg

view tools/libaio/harness/cases/10.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 /* 10.t - uses testdir.enospc/rwfile
2 - Check results on out-of-space and out-of-quota. (10.t)
3 - write that fills filesystem but does not go over should succeed
4 - write that fills filesystem and goes over should be partial
5 - write to full filesystem should return -ENOSPC
6 - read beyond end of file after ENOSPC should return 0
7 */
8 #include "aio_setup.h"
10 #include <sys/time.h>
11 #include <sys/resource.h>
12 #include <unistd.h>
14 int test_main(void)
15 {
16 /* Note: changing either of these requires updating the ext2-enospc.img
17 * filesystem image. Also, if SIZE is less than PAGE_SIZE, problems
18 * crop up due to ext2's preallocation.
19 */
20 #define LIMIT 65536
21 #define SIZE 65536
22 char *buf;
23 int rwfd;
24 int status = 0, res;
26 rwfd = open("testdir.enospc/rwfile", O_RDWR|O_CREAT|O_TRUNC, 0600);
27 assert(rwfd != -1);
28 res = ftruncate(rwfd, 0); assert(res == 0);
29 buf = malloc(SIZE); assert(buf != NULL);
30 memset(buf, 0, SIZE);
33 status |= attempt_rw(rwfd, buf, SIZE, LIMIT-SIZE, WRITE, SIZE);
34 status |= attempt_rw(rwfd, buf, SIZE, LIMIT-SIZE, READ, SIZE);
36 status |= attempt_rw(rwfd, buf, SIZE, LIMIT, WRITE, -ENOSPC);
37 status |= attempt_rw(rwfd, buf, SIZE, LIMIT, READ, 0);
39 res = ftruncate(rwfd, 0); assert(res == 0);
41 status |= attempt_rw(rwfd, buf, SIZE, 1+LIMIT-SIZE, WRITE, SIZE-1);
42 status |= attempt_rw(rwfd, buf, SIZE, 1+LIMIT-SIZE, READ, SIZE-1);
43 status |= attempt_rw(rwfd, buf, SIZE, LIMIT, READ, 0);
45 status |= attempt_rw(rwfd, buf, SIZE, LIMIT, WRITE, -ENOSPC);
46 status |= attempt_rw(rwfd, buf, SIZE, LIMIT, READ, 0);
47 status |= attempt_rw(rwfd, buf, 0, LIMIT, WRITE, 0);
49 res = close(rwfd); assert(res == 0);
50 res = unlink("testdir.enospc/rwfile"); assert(res == 0);
51 return status;
52 }