1 /* test 3 - library routines rather than system calls */
4 #include <sys/utsname.h>
19 char el_weirdo
[] = "\n\t\\\e@@!!##\e\e\n\n";
23 int main(int argc
, char *argv
[]);
36 if (argc
== 2) m
= atoi(argv
[1]);
38 for (i
= 0; i
< ITERATIONS
; i
++) {
39 if (m
& 0001) test3a();
40 if (m
& 0004) test3c();
41 if (m
& 0010) test3d();
42 if (m
& 0020) test3e();
45 return(-1); /* impossible */
51 /* Signal set manipulation. */
56 errno
= -1000; /* None of these calls set errno. */
57 if (sigemptyset(&s
) != 0) e(1);
58 if (sigemptyset(&s1
) != 0) e(2);
59 if (sigaddset(&s
, SIGABRT
) != 0) e(3);
60 if (sigaddset(&s
, SIGALRM
) != 0) e(4);
61 if (sigaddset(&s
, SIGFPE
) != 0) e(5);
62 if (sigaddset(&s
, SIGHUP
) != 0) e(6);
63 if (sigaddset(&s
, SIGILL
) != 0) e(7);
64 if (sigaddset(&s
, SIGINT
) != 0) e(8);
65 if (sigaddset(&s
, SIGKILL
) != 0) e(9);
66 if (sigaddset(&s
, SIGPIPE
) != 0) e(10);
67 if (sigaddset(&s
, SIGQUIT
) != 0) e(11);
68 if (sigaddset(&s
, SIGSEGV
) != 0) e(12);
69 if (sigaddset(&s
, SIGTERM
) != 0) e(13);
70 if (sigaddset(&s
, SIGUSR1
) != 0) e(14);
71 if (sigaddset(&s
, SIGUSR2
) != 0) e(15);
73 if (sigismember(&s
, SIGABRT
) != 1) e(16);
74 if (sigismember(&s
, SIGALRM
) != 1) e(17);
75 if (sigismember(&s
, SIGFPE
) != 1) e(18);
76 if (sigismember(&s
, SIGHUP
) != 1) e(19);
77 if (sigismember(&s
, SIGILL
) != 1) e(20);
78 if (sigismember(&s
, SIGINT
) != 1) e(21);
79 if (sigismember(&s
, SIGKILL
) != 1) e(22);
80 if (sigismember(&s
, SIGPIPE
) != 1) e(23);
81 if (sigismember(&s
, SIGQUIT
) != 1) e(24);
82 if (sigismember(&s
, SIGSEGV
) != 1) e(25);
83 if (sigismember(&s
, SIGTERM
) != 1) e(26);
84 if (sigismember(&s
, SIGUSR1
) != 1) e(27);
85 if (sigismember(&s
, SIGUSR2
) != 1) e(28);
87 if (sigdelset(&s
, SIGABRT
) != 0) e(29);
88 if (sigdelset(&s
, SIGALRM
) != 0) e(30);
89 if (sigdelset(&s
, SIGFPE
) != 0) e(31);
90 if (sigdelset(&s
, SIGHUP
) != 0) e(32);
91 if (sigdelset(&s
, SIGILL
) != 0) e(33);
92 if (sigdelset(&s
, SIGINT
) != 0) e(34);
93 if (sigdelset(&s
, SIGKILL
) != 0) e(35);
94 if (sigdelset(&s
, SIGPIPE
) != 0) e(36);
95 if (sigdelset(&s
, SIGQUIT
) != 0) e(37);
96 if (sigdelset(&s
, SIGSEGV
) != 0) e(38);
97 if (sigdelset(&s
, SIGTERM
) != 0) e(39);
98 if (sigdelset(&s
, SIGUSR1
) != 0) e(40);
99 if (sigdelset(&s
, SIGUSR2
) != 0) e(41);
103 if (sigaddset(&s
, SIGILL
) != 0) e(43);
106 if (sigfillset(&s
) != 0) e(45);
107 if (sigismember(&s
, SIGABRT
) != 1) e(46);
108 if (sigismember(&s
, SIGALRM
) != 1) e(47);
109 if (sigismember(&s
, SIGFPE
) != 1) e(48);
110 if (sigismember(&s
, SIGHUP
) != 1) e(49);
111 if (sigismember(&s
, SIGILL
) != 1) e(50);
112 if (sigismember(&s
, SIGINT
) != 1) e(51);
113 if (sigismember(&s
, SIGKILL
) != 1) e(52);
114 if (sigismember(&s
, SIGPIPE
) != 1) e(53);
115 if (sigismember(&s
, SIGQUIT
) != 1) e(54);
116 if (sigismember(&s
, SIGSEGV
) != 1) e(55);
117 if (sigismember(&s
, SIGTERM
) != 1) e(56);
118 if (sigismember(&s
, SIGUSR1
) != 1) e(57);
119 if (sigismember(&s
, SIGUSR2
) != 1) e(58);
121 /* Test error returns. */
122 if (sigaddset(&s
, -1) != -1) e(59);
123 if (sigaddset(&s
, -1) != -1) e(60);
124 if (sigismember(&s
, -1) != -1) e(61);
125 if (sigaddset(&s
, 10000) != -1) e(62);
126 if (sigaddset(&s
, 10000) != -1) e(63);
127 if (sigismember(&s
, 10000) != -1) e(64);
133 /* Test getenv. Asume HOME, PATH, and LOGNAME exist (not strictly required).*/
138 errno
= -3000; /* None of these calls set errno. */
139 if ( (p
= getenv("HOME")) == NULL
) { fprintf(stderr
, "Please have $HOME set properly.\n"); e(1); }
140 if (*p
!= '/') { fprintf(stderr
, "Please have $HOME point to an abolute path.\n"); e(2); } /* path must be absolute */
141 if ( (p
= getenv("PATH")) == NULL
) { fprintf(stderr
, "Please have $PATH set properly.\n"); e(3); }
142 if ( (p
= getenv("LOGNAME")) == NULL
) { fprintf(stderr
, "Please have $LOGNAME set properly.\n"); e(5); }
143 strcpy(name
, p
); /* save it, since getlogin might wipe it out */
145 if (strcmp(p
, name
) != 0) { fprintf(stderr
, "Please have $LOGNAME set to your real username. (su - instead of su?)\n"); e(6); }
147 /* The following test could fail in a legal POSIX system. However, if it
148 * does, you deserve it to fail.
150 if (getenv(el_weirdo
) != NULL
) e(7);
155 /* Test ctermid, ttyname, and isatty. */
158 char *p
, name
[L_ctermid
];
161 errno
= -4000; /* None of these calls set errno. */
163 /* Test ctermid first. */
164 if ( (p
= ctermid(name
)) == NULL
) e(1);
165 if (strcmp(p
, name
) != 0) e(2);
166 if (strncmp(p
, "/dev/tty", 8) != 0) e(3); /* MINIX convention */
168 if ( (p
= ttyname(0)) == NULL
) e(4);
169 if (strncmp(p
, "/dev/tty", 8) != 0 && strcmp(p
, "/dev/console") != 0) e(5);
170 if ( (p
= ttyname(3)) != NULL
) e(6);
171 if (ttyname(5000) != NULL
) e(7);
172 if ( (fd
= creat("T3a", 0777)) < 0) e(8);
173 if (ttyname(fd
) != NULL
) e(9);
175 if (isatty(0) != 1) e(10);
176 if (isatty(3) != 0) e(11);
177 if (isatty(fd
) != 0) e(12);
178 if (close(fd
) != 0) e(13);
179 if (ttyname(fd
) != NULL
) e(14);
184 /* Test ctermid, ttyname, and isatty. */
187 errno
= -5000; /* None of these calls set errno. */
189 if (sysconf(_SC_ARG_MAX
) < _POSIX_ARG_MAX
) e(1);
190 if (sysconf(_SC_CHILD_MAX
) < _POSIX_CHILD_MAX
) e(2);
191 if (sysconf(_SC_NGROUPS_MAX
) < 0) e(3);
192 if (sysconf(_SC_OPEN_MAX
) < _POSIX_OPEN_MAX
) e(4);
194 /* The rest are MINIX specific */
195 if (sysconf(_SC_JOB_CONTROL
) >= 0) e(5); /* no job control! */