1 /* Test 73 - VM secondary cache blackbox test.
3 * Blackbox test of the VM secondary cache in isolation, implemented
4 * in testvm.c, started as a service by this test program.
7 #define _MINIX_SYSTEM 1
9 #include <minix/sysutil.h>
10 #include <minix/syslib.h>
12 #include <minix/bdev.h>
13 #include <minix/paths.h>
14 #include <sys/types.h>
16 #include <sys/ioc_memory.h>
25 #include <minix/libminixfs.h>
32 #include "testcache.h"
35 main(int argc
, char *argv
[])
37 char pipefn
[30], cwd
[400], cmdline
[400];
51 printf("Test 73 has to be run as root; test aborted\n");
57 /* 'big' as a substring indicates to testvm that it's ok to
60 if(getenv(BIGVARNAME
)) big
= 1;
62 if(big
) strcpy(pipefn
, "pipe_testvm_big");
63 else strcpy(pipefn
, "pipe_testvm");
66 if(mkfifo(pipefn
, 0666) < 0) { e(1); exit(1); }
67 if(!getcwd(cwd
, sizeof(cwd
))) { e(2); exit(1); }
69 /* stop residual testvm service if any */
70 snprintf(cmdline
, sizeof(cmdline
), "%s down testvm >/dev/null 2>&1",
72 if(system(cmdline
) < 0) { e(9); exit(1); }
74 /* start the testvm service */
75 snprintf(cmdline
, sizeof(cmdline
),
76 "%s up /%s/../testvm -script /etc/rs.single "
77 "-args /%s/%s -config %s/../testvm.conf",
78 _PATH_MINIX_SERVICE
, cwd
, cwd
, pipefn
, cwd
);
79 if(system(cmdline
) < 0) { e(10); exit(1); }
81 /* don't hang forever if the open or read block */
82 alarm(big
? 6000 : 600);
84 if((pipefd
=open(pipefn
, O_RDONLY
)) < 0) { e(3); exit(1); }
86 if((r
=read(pipefd
, &i
, sizeof(i
))) != sizeof(i
)) {
87 printf("read returned %d\n", r
);
92 if(i
.result
!= 0) { e(i
.result
); }