source: trunk/packages/xen-3.1/xen-3.1/tools/libaio/harness/cases/6.t @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 1.0 KB
Line 
1/* 6.t
2- huge reads (pinned pages) (6.t)
3- huge writes (6.t)
4*/
5#include "aio_setup.h"
6#include <sys/mman.h>
7
8long getmemsize(void)
9{
10        FILE *f = fopen("/proc/meminfo", "r");
11        long size;
12        int gotit = 0;
13        char str[256];
14
15        assert(f != NULL);
16        while (NULL != fgets(str, 255, f)) {
17                str[255] = 0;
18                if (0 == memcmp(str, "MemTotal:", 9)) {
19                        if (1 == sscanf(str + 9, "%ld", &size)) {
20                                gotit = 1;
21                                break;
22                        }
23                }
24        }
25        fclose(f);
26
27        assert(gotit != 0);
28        return size;
29}
30
31int test_main(void)
32{
33        char *buf;
34        int rwfd;
35        int status = 0, res;
36        long size;
37
38        size = getmemsize();
39        printf("size = %ld\n", size);
40        assert(size >= (16 * 1024));
41        if (size > (768 * 1024))
42                size = 768 * 1024;
43        size *= 1024;
44
45        rwfd = open("testdir/rwfile", O_RDWR);          assert(rwfd != -1);
46        res = ftruncate(rwfd, 0);                       assert(res == 0);
47        buf = malloc(size);                             assert(buf != NULL);
48
49        //memset(buf, 0, size);
50        status |= attempt_rw(rwfd, buf, size,  0, WRITE, size);
51        status |= attempt_rw(rwfd, buf, size,  0,  READ, size);
52
53        //res = ftruncate(rwfd, 0);                     assert(res == 0);
54
55        return status;
56}
57
Note: See TracBrowser for help on using the repository browser.