1 /* Test 73 - VM secondary cache blackbox test. 2 * 3 * Blackbox test of the VM secondary cache in isolation, implemented 4 * in testvm.c, started as a service by this test program. 5 */ 6 7 #define _MINIX_SYSTEM 1 8 9 #include <minix/sysutil.h> 10 #include <minix/syslib.h> 11 #include <minix/vm.h> 12 #include <minix/bdev.h> 13 #include <minix/paths.h> 14 #include <sys/types.h> 15 #include <sys/mman.h> 16 #include <sys/ioc_memory.h> 17 #include <stdio.h> 18 #include <stdarg.h> 19 #include <assert.h> 20 #include <string.h> 21 #include <stdlib.h> 22 #include <unistd.h> 23 #include <fcntl.h> 24 #include <math.h> 25 #include <minix/libminixfs.h> 26 27 #include "testvm.h" 28 29 int max_error = 0; 30 31 #include "common.h" 32 #include "testcache.h" 33 34 int 35 main(int argc, char *argv[]) 36 { 37 char pipefn[30], cwd[400], cmdline[400]; 38 int pipefd; 39 static struct info i; 40 ssize_t r; 41 int big = 0; 42 43 #define ITER 3 44 #define BLOCKS 200 45 46 start(73); 47 48 unlink(pipefn); 49 50 /* 'big' as a substring indicates to testvm that it's ok to 51 * run a long test 52 */ 53 if(getenv(BIGVARNAME)) big = 1; 54 55 if(big) strcpy(pipefn, "pipe_testvm_big"); 56 else strcpy(pipefn, "pipe_testvm"); 57 58 umask(0); 59 if(mkfifo(pipefn, 0666) < 0) { e(1); exit(1); } 60 if(!getcwd(cwd, sizeof(cwd))) { e(2); exit(1); } 61 62 /* stop residual testvm service if any */ 63 snprintf(cmdline, sizeof(cmdline), "%s down testvm >/dev/null 2>&1", 64 _PATH_SERVICE); 65 if(system(cmdline) < 0) { e(9); exit(1); } 66 67 /* start the testvm service */ 68 snprintf(cmdline, sizeof(cmdline), 69 "%s up /%s/../testvm -script /etc/rs.single " 70 "-args /%s/%s -config %s/../testvm.conf", 71 _PATH_SERVICE, cwd, cwd, pipefn, cwd); 72 if(system(cmdline) < 0) { e(10); exit(1); } 73 74 /* don't hang forever if the open or read block */ 75 alarm(big ? 6000 : 600); 76 77 if((pipefd=open(pipefn, O_RDONLY)) < 0) { e(3); exit(1); } 78 79 if((r=read(pipefd, &i, sizeof(i))) != sizeof(i)) { 80 printf("read returned %d\n", r); 81 e(12); 82 exit(1); 83 } 84 85 if(i.result != 0) { e(i.result); } 86 87 quit(); 88 89 return 0; 90 } 91 92