etc/services - sync with NetBSD-8
[minix.git] / minix / tests / test73.c
blobdc4a3b28f06da4ffd50cb5fb5193992aa8bc9534
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.
5 */
7 #define _MINIX_SYSTEM 1
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>
27 #include "testvm.h"
29 int max_error = 0;
31 #include "common.h"
32 #include "testcache.h"
34 int
35 main(int argc, char *argv[])
37 char pipefn[30], cwd[400], cmdline[400];
38 int pipefd;
39 static struct info i;
40 ssize_t r;
41 int big = 0;
43 #define ITER 3
44 #define BLOCKS 200
46 start(73);
48 setuid(geteuid());
50 if(getuid() != 0) {
51 printf("Test 73 has to be run as root; test aborted\n");
52 exit(1);
55 unlink(pipefn);
57 /* 'big' as a substring indicates to testvm that it's ok to
58 * run a long test
60 if(getenv(BIGVARNAME)) big = 1;
62 if(big) strcpy(pipefn, "pipe_testvm_big");
63 else strcpy(pipefn, "pipe_testvm");
65 umask(0);
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",
71 _PATH_MINIX_SERVICE);
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);
88 e(12);
89 exit(1);
92 if(i.result != 0) { e(i.result); }
94 quit();
96 return 0;