source: trunk/minix/test/t11a.c@ 21

Last change on this file since 21 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.3 KB
RevLine 
[9]1/* t11a */
2
3#include <sys/types.h>
4#include <errno.h>
5#include <fcntl.h>
6#include <stdlib.h>
7#include <unistd.h>
8#include <stdio.h>
9
10#define MAX_ERROR 4
11
12int errct, subtest=1;
13
14_PROTOTYPE(int main, (int argc, char *argv [], char *envp []));
15_PROTOTYPE(int diff, (char *s1, char *s2));
16_PROTOTYPE(void e, (int n));
17
18int main(argc, argv, envp)
19int argc;
20char *argv[], *envp[];
21{
22/* See if arguments passed ok. */
23
24 char aa[4];
25
26 if (diff(argv[0], "t11a")) e(21);
27 if (diff(argv[1], "arg0")) e(22);
28 if (diff(argv[2], "arg1")) e(23);
29 if (diff(argv[3], "arg2")) e(24);
30 if (diff(envp[0], "spring")) e(25);
31 if (diff(envp[1], "summer")) e(26);
32 if (argc != 4) e(27);
33
34 /* Now see if the files are ok. */
35 if (read(3, aa, 4) != 2) e(28);
36 if (aa[0] != 7 || aa[1] != 9) e(29);
37
38 if (getuid() == 10) e(30);
39 if (geteuid() != 10) e(31);
40 if (getgid() == 20) e(32);
41 if (getegid() != 20) e(33);
42
43 if (open("t1", 0) < 0) e(34);
44 if (open("t2", 0) < 0) e(35);
45 exit(100);
46}
47
48int diff(s1, s2)
49char *s1, *s2;
50{
51 while (1) {
52 if (*s1 == 0 && *s2 == 0) return(0);
53 if (*s1 != *s2) return (1);
54 s1++;
55 s2++;
56 }
57}
58
59void e(n)
60int n;
61{
62 printf("Subtest %d, error %d errno=%d ", subtest, n, errno);
63 perror("");
64 if (errct++ > MAX_ERROR) {
65 printf("Too many errors; test aborted\n");
66 chdir("..");
67 system("rm -rf DIR*");
68 exit(1);
69 }
70}
Note: See TracBrowser for help on using the repository browser.