2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #ifndef __ERRTEST_SEEN
33 #define __ERRTEST_SEEN
42 void* handle_clone(void* src_hanp, u_int hlen );
148 ((errno<NUM_ERRS)?(errno_names[errno]):("an unknown errno"))
150 #define ERRTEST(EXPECTED, NAME, FUNCTION) \
151 if ((FUNCTION) < 0) { \
152 if (errno == (EXPECTED)) { \
154 fprintf(stdout,"\treport on test for " #EXPECTED \
155 " in %s: test successful\n", (NAME)); \
158 fprintf(stdout, "\tERROR testing for " #EXPECTED \
159 " in %s: found %s.\n", (NAME), ERR_NAME); \
163 fprintf(stdout, "\tERROR testing for " #EXPECTED \
164 " in %s: no error was produced!\n", (NAME)); \
168 #define EXCLTEST(NAME, HANP, HLEN, TOKEN, FUNCTION) \
169 if (dm_create_userevent(sid, 10, "DMAPI" NAME, &(TOKEN))) { \
171 "\tERROR: can't create token (%s); skipping EACCES test\n", \
175 ERRTEST(EACCES, "no-right " NAME, (FUNCTION)) \
177 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_SHARED)) \
178 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to SHARED. %s\n", \
180 else ERRTEST(EACCES, "SHARED " NAME, (FUNCTION)) \
182 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_EXCL)) \
183 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL: %s\n", \
185 else if ((FUNCTION) < 0) \
186 fprintf(stdout, "\t"NAME" ERROR: token with DM_RIGHT_EXCL was " \
187 "denied access: %s\n", ERR_NAME); \
189 fprintf(stdout, "\treport on test for success in EXCL "NAME": " \
190 "test successful.\n"); \
192 if (dm_respond_event(sid, (TOKEN), DM_RESP_CONTINUE, 0, 0, 0)) \
193 fprintf(stdout, "\tERROR in responding to token: %s\n", ERR_NAME); \
198 #define SHAREDTEST(NAME, HANP, HLEN, TOKEN, FUNCTION) \
199 if (dm_create_userevent(sid, 10, "DMAPI" NAME, &(TOKEN))) { \
201 "\tCannot create_userevent (%s); skipping EACCES test\n", \
205 ERRTEST(EACCES, "no-right " NAME, (FUNCTION)) \
207 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), \
208 0, DM_RIGHT_SHARED)) \
209 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL. %s\n", \
211 else if ((FUNCTION) < 0) \
212 fprintf(stdout, "\t" NAME" ERROR: token with DM_RIGHT_SHARED " \
213 "was denied access. %s\n", ERR_NAME); \
215 fprintf(stdout, "\treport on test for success in SHARED "NAME": " \
216 "test successful.\n"); \
218 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_EXCL)) \
219 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL. %s\n", \
221 else if ((FUNCTION) < 0) \
222 fprintf(stdout, "\t" NAME" ERROR: token with DM_RIGHT_EXCL was " \
223 "denied access. %s\n", ERR_NAME); \
225 fprintf(stdout, "\treport on test for success in EXCL "NAME": " \
226 "test successful.\n"); \
228 if (dm_respond_event(sid, (TOKEN), DM_RESP_CONTINUE, 0, 0, 0)) \
229 fprintf(stderr, "\tERROR in responding to token: %s\n", ERR_NAME); \
235 handle_clone(void* src_hanp, u_int hlen )
239 if ((dest_hanp = malloc(hlen)) == NULL) return(NULL);
240 bcopy(src_hanp, dest_hanp, hlen);