64-bit VFS_LSEEK_OFF
[minix3.git] / test / test6.c
blob2976d48970c274b56dcc6c5877ea42dff1edc033
1 /* test 6 */
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <limits.h>
8 #include <signal.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <stdio.h>
13 int max_error = 3;
14 #include "common.h"
17 int subtest = 1;
18 int zilch[5000];
21 int main(int argc, char *argv []);
22 void test6a(void);
23 void test6b(void);
25 int main(argc, argv)
26 int argc;
27 char *argv[];
29 int i, m = 0xFFFF;
31 if (argc == 2) m = atoi(argv[1]);
33 start(6);
35 for (i = 0; i < 70; i++) {
36 if (m & 00001) test6a();
37 if (m & 00002) test6b();
40 quit();
41 return(-1); /* impossible */
44 void test6a()
46 /* Test sbrk() and brk(). */
48 char *addr, *addr2, *addr3;
49 int i, del, click, click2;
51 subtest = 1;
52 addr = sbrk(0);
53 addr = sbrk(0); /* force break to a click boundary */
54 for (i = 0; i < 10; i++) sbrk(7 * i);
55 for (i = 0; i < 10; i++) sbrk(-7 * i);
56 if (sbrk(0) != addr) e(1);
57 sbrk(30);
58 if (brk(addr) != 0) e(2);
59 if (sbrk(0) != addr) e(3);
61 del = 0;
62 do {
63 del++;
64 brk(addr + del);
65 addr2 = sbrk(0);
66 } while (addr2 == addr);
67 click = addr2 - addr;
68 sbrk(-1);
69 if (sbrk(0) != addr) e(4);
70 brk(addr);
71 if (sbrk(0) != addr) e(5);
73 del = 0;
74 do {
75 del++;
76 brk(addr - del);
77 addr3 = sbrk(0);
78 } while (addr3 == addr);
79 click2 = addr - addr3;
80 sbrk(1);
81 if (sbrk(0) != addr) e(6);
82 brk(addr);
83 if (sbrk(0) != addr) e(8);
84 if (click != click2) e(9);
86 brk(addr + 2 * click);
87 if (sbrk(0) != addr + 2 * click) e(10);
88 sbrk(3 * click);
89 if (sbrk(0) != addr + 5 * click) e(11);
90 sbrk(-5 * click);
91 if (sbrk(0) != addr) e(12);
94 void test6b()
96 int i, err;
98 subtest = 2;
99 signal(SIGQUIT, SIG_IGN);
100 err = 0;
101 for (i = 0; i < 5000; i++)
102 if (zilch[i] != 0) err++;
103 if (err > 0) e(1);
104 kill(getpid(), SIGQUIT);