2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef __ERRTEST_SEEN
19 #define __ERRTEST_SEEN
28 void* handle_clone(void* src_hanp, u_int hlen );
134 ((errno<NUM_ERRS)?(errno_names[errno]):("an unknown errno"))
136 #define ERRTEST(EXPECTED, NAME, FUNCTION) \
137 if ((FUNCTION) < 0) { \
138 if (errno == (EXPECTED)) { \
140 fprintf(stdout,"\treport on test for " #EXPECTED \
141 " in %s: test successful\n", (NAME)); \
144 fprintf(stdout, "\tERROR testing for " #EXPECTED \
145 " in %s: found %s.\n", (NAME), ERR_NAME); \
149 fprintf(stdout, "\tERROR testing for " #EXPECTED \
150 " in %s: no error was produced!\n", (NAME)); \
154 #define EXCLTEST(NAME, HANP, HLEN, TOKEN, FUNCTION) \
155 if (dm_create_userevent(sid, 10, "DMAPI" NAME, &(TOKEN))) { \
157 "\tERROR: can't create token (%s); skipping EACCES test\n", \
161 ERRTEST(EACCES, "no-right " NAME, (FUNCTION)) \
163 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_SHARED)) \
164 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to SHARED. %s\n", \
166 else ERRTEST(EACCES, "SHARED " NAME, (FUNCTION)) \
168 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_EXCL)) \
169 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL: %s\n", \
171 else if ((FUNCTION) < 0) \
172 fprintf(stdout, "\t"NAME" ERROR: token with DM_RIGHT_EXCL was " \
173 "denied access: %s\n", ERR_NAME); \
175 fprintf(stdout, "\treport on test for success in EXCL "NAME": " \
176 "test successful.\n"); \
178 if (dm_respond_event(sid, (TOKEN), DM_RESP_CONTINUE, 0, 0, 0)) \
179 fprintf(stdout, "\tERROR in responding to token: %s\n", ERR_NAME); \
184 #define SHAREDTEST(NAME, HANP, HLEN, TOKEN, FUNCTION) \
185 if (dm_create_userevent(sid, 10, "DMAPI" NAME, &(TOKEN))) { \
187 "\tCannot create_userevent (%s); skipping EACCES test\n", \
191 ERRTEST(EACCES, "no-right " NAME, (FUNCTION)) \
193 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), \
194 0, DM_RIGHT_SHARED)) \
195 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL. %s\n", \
197 else if ((FUNCTION) < 0) \
198 fprintf(stdout, "\t" NAME" ERROR: token with DM_RIGHT_SHARED " \
199 "was denied access. %s\n", ERR_NAME); \
201 fprintf(stdout, "\treport on test for success in SHARED "NAME": " \
202 "test successful.\n"); \
204 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_EXCL)) \
205 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL. %s\n", \
207 else if ((FUNCTION) < 0) \
208 fprintf(stdout, "\t" NAME" ERROR: token with DM_RIGHT_EXCL was " \
209 "denied access. %s\n", ERR_NAME); \
211 fprintf(stdout, "\treport on test for success in EXCL "NAME": " \
212 "test successful.\n"); \
214 if (dm_respond_event(sid, (TOKEN), DM_RESP_CONTINUE, 0, 0, 0)) \
215 fprintf(stderr, "\tERROR in responding to token: %s\n", ERR_NAME); \
221 handle_clone(void* src_hanp, u_int hlen )
225 if ((dest_hanp = malloc(hlen)) == NULL) return(NULL);
226 bcopy(src_hanp, dest_hanp, hlen);