1 /* Test 71 - full hierachy storage test.
2 *
3 * Black box test of storage: test consistent file contents
4 * under various working sets and access patterns.
5 *
6 * Using varying working set sizes, exercise various cache
7 * layers separately.
8 *
9 * There is a 'smoke test' mode, suitable for running interactively,
10 * and a 'regression test' (big) mode, meant for batch invocation only
11 * as it takes very long.
12 */
13
14 #include <sys/types.h>
15 #include <sys/ioc_memory.h>
16 #include <stdio.h>
17 #include <assert.h>
18 #include <string.h>
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <fcntl.h>
22
23 #include "common.h"
24 #include "testcache.h"
25
26 int
dowriteblock(int b,int blocksize,u32_t seed,char * data)27 dowriteblock(int b, int blocksize, u32_t seed, char *data)
28 {
29 u64_t offset;
30 int fd;
31
32 get_fd_offset(b, blocksize, &offset, &fd);
33
34 if(pwrite(fd, data, blocksize, offset) < blocksize) {
35 perror("pwrite");
36 return -1;
37 }
38
39 return blocksize;
40 }
41
42 int
readblock(int b,int blocksize,u32_t seed,char * data)43 readblock(int b, int blocksize, u32_t seed, char *data)
44 {
45 u64_t offset;
46 int fd;
47
48 get_fd_offset(b, blocksize, &offset, &fd);
49
50 if(pread(fd, data, blocksize, offset) < blocksize) {
51 perror("pread");
52 return -1;
53 }
54
55 return blocksize;
56 }
57
testend(void)58 void testend(void) { }
59
60 int
main(int argc,char * argv[])61 main(int argc, char *argv[])
62 {
63 int iter = 2;
64
65 start(71);
66
67 cachequiet(!bigflag);
68 if(bigflag) iter = 3;
69
70 makefiles(MAXFILES);
71
72 /* Try various combinations working set sizes
73 * and block sizes in order to specifically
74 * target the primary cache, then primary+secondary
75 * cache, then primary+secondary cache+secondary
76 * cache eviction.
77 */
78
79 if(dotest(PAGE_SIZE, 100, iter)) e(5);
80 if(dotest(PAGE_SIZE*2, 100, iter)) e(2);
81 if(dotest(PAGE_SIZE*3, 100, iter)) e(3);
82 if(dotest(PAGE_SIZE, 20000, iter)) e(5);
83
84 if(bigflag) {
85 u32_t totalmem, freemem, cachedmem;
86 if(dotest(PAGE_SIZE, 150000, iter)) e(5);
87 getmem(&totalmem, &freemem, &cachedmem);
88 if(dotest(PAGE_SIZE, totalmem*1.5, iter)) e(6);
89 }
90
91 quit();
92
93 return 0;
94 }
95
96