1 /* $Id: select.c,v 1.7 1994/06/24 10:06:45 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
35 char name1[] = "/usr/tmp/f1XXXXXX";
36 char name2[] = "/usr/tmp/f2XXXXXX";
37 char name3[] = "/usr/tmp/f3XXXXXX";
48 main(argc,argv) char **argv; {
52 prog = *argv++; --argc;
56 for (p = sigs; *p; p++)
57 if (signal(*p, stop) == SIG_IGN)
59 while (argc > 0 && argv[0][0] == '-') {
64 case '0': case '1': case '2': case '3': case '4':
65 case '5': case '6': case '7': case '8': case '9':
66 high = atoi(&argv[0][1]);
75 if (argc > 0 && argv[0][0] >= '0' && argv[0][0] <= '9') {
78 low = low*10 + *s++ - '0';
79 while (*s >= '0' && *s <= '9');
82 else if (*s++ == '-') {
87 fatal("bad range %s", argv[0]);
93 if (argc == 1 && freopen(argv[0], "r", stdin) == NULL)
94 fatal("cannot open %s", argv[0]);
95 if ((file1 = fopen(name1, "w")) == NULL)
96 fatal("cannot create %s", name1);
97 if ((file2 = fopen(name2, "w")) == NULL)
98 fatal("cannot create %s", name2);
99 if ((file3 = fopen(name3, "w")) == NULL)
100 fatal("cannot create %s", name3);
115 if (sscanf(line, "TEST %d", &i) != 1)
116 fatal("bad test identification(%s)", line);
117 if (i < low || i > high) {
123 fprintf(file2, "; %s\n", line);
126 fprintf(file1, ".%s\n", s);
127 fprintf(file1, " con \"tst%s\"\n", s);
128 fprintf(file2, " fil .%s\n", s);
136 if (sscanf(line, "MAIN%d", &i) != 1 || i%4 != 0)
143 if (strcmp(line, "PROC") != 0)
149 sscanf(line, "HOL%d", &i) != 1 ||
156 if (strcmp(line, "OK") != 0)
158 fprintf(f, " lin %d\n nop\n", oknum++);
161 if (f != file3 || strcmp(line, "ERRLAB") != 0)
163 fprintf(f, "1\n lin 1\n nop\n loc 1\n loc 1\n mon\n");
169 fatal("bad line (%s)", line);
176 printf("#define WS EM_WSIZE\n");
177 printf("#define PS EM_PSIZE\n");
178 printf("#include \"test.h\"\n");
179 printf(" mes 2,WS,PS\n");
181 printf(" mes 4,300\n");
183 printf(" hol %d,0,0\n", nhol);
185 printf(" exp $_m_a_i_n\n");
186 printf(" pro $_m_a_i_n,%d\n", nlocals);
187 printf(" loc 123\n");
188 printf(" loc -98\n");
190 printf(" loc -98\n");
192 printf(" loc 123\n");
208 if (freopen(s, "r", stdin) == NULL)
209 fatal("cannot reopen %s", s);
217 if (fgets(line, LINSIZ, stdin) == NULL)
220 if (line[len-1] != '\n')
221 fatal("line too long(%s)", line);
226 putline(f) FILE *f; {
227 fprintf(f, "%s\n", line);
230 fatal(s, a1, a2, a3, a4) char *s; {
231 fprintf(stderr, "%s: ", prog);
232 fprintf(stderr, s, a1, a2, a3, a4);
233 fprintf(stderr, " (fatal)\n");
239 fprintf(stderr, "usage: %s -f [[low]-[high]] [testcollection]\n", prog);
249 register char *s = buf;
251 *s++ = (i % 1000) / 100 + '0';
252 *s++ = (i % 100) / 10 + '0';
253 *s++ = (i % 10) + '0';