retire nonsymbolic rootdev, dev2name
[minix.git] / test / test1.c
blob6160b676fb153436a7f2d115bbdb4b89a2c9ab1c
1 /* test 1 */
3 #include <sys/types.h>
4 #include <sys/wait.h>
5 #include <errno.h>
6 #include <signal.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include <stdio.h>
11 #define SIGNUM 10
12 #define MAX_ERROR 4
13 #define ITERATIONS 10
15 volatile int glov, gct;
16 int errct;
17 int subtest;
18 #include "common.c"
20 int main(int argc, char *argv []);
21 void test1a(void);
22 void parent(void);
23 void child(int i);
24 void test1b(void);
25 void parent1(int childpid);
26 void func(int s);
27 void child1(void);
29 int main(argc, argv)
30 int argc;
31 char *argv[];
33 int i, m = 0xFFFF;
35 start(1);
37 if (argc == 2) m = atoi(argv[1]);
39 for (i = 0; i < ITERATIONS; i++) {
40 if (m & 00001) test1a();
41 if (m & 00002) test1b();
44 quit();
45 return(-1); /* impossible */
48 void test1a()
50 int i, n, pid;
52 subtest = 1;
53 n = 4;
54 for (i = 0; i < n; i++) {
55 if ((pid = fork())) {
56 if (pid < 0) {
57 printf("\nTest 1 fork failed\n");
58 exit(1);
60 parent();
61 } else
62 child(i);
66 void parent()
69 int n;
71 n = getpid();
72 wait(&n);
75 void child(i)
76 int i;
78 int n;
80 n = getpid();
81 exit(100+i);
84 void test1b()
86 int i, k;
88 subtest = 2;
89 for (i = 0; i < 4; i++) {
90 glov = 0;
91 signal(SIGNUM, func);
92 if ((k = fork())) {
93 if (k < 0) {
94 printf("Test 1 fork failed\n");
95 exit(1);
97 parent1(k);
98 } else
99 child1();
103 void parent1(childpid)
104 int childpid;
107 int n;
109 for (n = 0; n < 5000; n++);
110 while (kill(childpid, SIGNUM) < 0) /* null statement */
112 wait(&n);
115 void func(s)
116 int s; /* for ANSI */
118 glov++;
119 gct++;
122 void child1()
124 while (glov == 0);
125 exit(gct);