2 * Copyright (c) 2000 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 #include <sys/types.h>
40 #include <lib/dmport.h>
42 #include <lib/errtest.h>
48 /*---------------------------------------------------------------------------
49 Automated search for EFAULT in the following DMAPI commands:
56 There are other EFAULT tests, in the programs that test individual
57 DMAPI functions. Those other tests are referenced in comments in this source.
60 test_efault [-s sid] [-v] ls_path pathname
64 is the session ID whose events you you are interested in.
66 is the path to a copy of ls, which will be copied as a test file.
68 is the filesystem to use for the test.
69 ----------------------------------------------------------------------------*/
82 "Usage: %s [-v] [-s sid] ls_path pathname\n",
89 main(int argc, char **argv) {
91 dm_sessid_t sid = DM_NO_SESSION;
101 if (Progname = strrchr(argv[0], '/')) {
108 while ((opt = getopt(argc, argv, "vn:s:")) != EOF) {
120 if (optind + 2 != argc) {
123 ls_path = argv[optind];
124 pathname = argv[optind+1];
126 if (dm_init_service(&name) == -1) {
127 fprintf(stderr, "Can't inititalize the DMAPI\n");
130 if (sid == DM_NO_SESSION)
131 find_test_session(&sid);
133 printf("Beginning EFAULT testing...\n");
135 /*----------------------------------*\
136 |* ## Traditional errno tests ## *|
137 \*----------------------------------*/
138 sprintf(test_file, "%s/DMAPI_EFAULT_test_file", pathname);
139 sprintf(command, "cp %s %s\n", ls_path, test_file);
142 if (dm_path_to_handle(test_file, &hanp, &hlen)) {
143 fprintf(stderr, "ERROR: can't get handle for %s; %s\n",
144 test_file, ERR_NAME);
149 /*---------------------------------------------------------
151 *---------------------------------------------------------
158 ERRTEST(EFAULT, "get_allocinfo (bad offp)",
159 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
161 nelem, &extent, &nelem_ret))
162 ERRTEST(EFAULT, "get_allocinfo (bad extentp)",
163 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
164 &off, nelem, (dm_extent_t*)(-1000),
166 ERRTEST(EFAULT, "get_allocinfo (bad nelemp)",
167 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
168 &off, nelem, &extent,
172 /*------------------------------------------------------
173 * get_bulkattr: see test_fileattr.c
174 *------------------------------------------------------
176 *------------------------------------------------------
178 ERRTEST(EFAULT, "get_config",
179 dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
180 (dm_size_t*)(-1000)))
181 /*---------------------------------------------------------
183 *---------------------------------------------------------
188 dm_eventset_t *eventsetp;
189 eventsetp = (dm_eventset_t *)malloc(nelem*sizeof(dm_eventset_t));
190 if (eventsetp == NULL) {
191 printf("Couldn't malloc for config_events tests: %s\n", ERR_NAME);
194 ERRTEST(EFAULT, "get_config_events (bad eventsetp)",
195 dm_get_config_events(hanp, hlen, nelem,
196 (dm_eventset_t*)(-1000), nelemp))
197 ERRTEST(EFAULT, "get_config_events (bad nelemp)",
198 dm_get_config_events(hanp, hlen, nelem, eventsetp,
202 /*---------------------------------------------------------
203 * get_dirattrs: see test_fileattr.c
204 *---------------------------------------------------------
205 * get_fileattr: see test_fileattr.c
206 *---------------------------------------------------------
207 * get_region: see test_region.c
208 *---------------------------------------------------------
210 *---------------------------------------------------------
214 void *bufp = (void *)malloc(buflen*sizeof(dm_attrlist_t));
216 ERRTEST(EFAULT, "getall_dmattr (NULL handle)",
217 dm_getall_dmattr(sid, NULL, hlen, DM_NO_TOKEN,
218 buflen, bufp, rlenp))
219 ERRTEST(EFAULT, "getall_dmattr (incremented bufp)",
220 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
221 buflen, (void*)((char*)(bufp)+1), rlenp))
222 ERRTEST(EFAULT, "getall_dmattr (bad bufp)",
223 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
224 buflen, (void*)(-1000), rlenp))
225 ERRTEST(EFAULT, "getall_dmattr (bad rlenp)",
226 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
227 buflen, bufp, (size_t*)(-1000)))
229 /*---------------------------------------------------------
231 *---------------------------------------------------------
233 ERRTEST(ENOTSUP, "init_attrloc",
234 dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
235 (dm_attrloc_t*)(-1000)))
236 /*---------------------------------------------------------
237 * probe_hole: see test_hole.c
238 *---------------------------------------------------------
239 * remove_dmattr: see test_dmattr.c
240 *---------------------------------------------------------
241 * set_dmattr: see test_dmattr.c
242 *---------------------------------------------------------
243 * set_eventlist: see test_eventlist.c
244 *---------------------------------------------------------
245 * set_region: see test_region.c
246 *---------------------------------------------------------
250 sprintf(command, "rm %s\n", test_file);
253 printf("EFAULT testing complete.\n");