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;
92 dm_token_t test_token = DM_NO_TOKEN;
103 if (Progname = strrchr(argv[0], '/')) {
110 while ((opt = getopt(argc, argv, "vn:s:")) != EOF) {
122 if (optind + 2 != argc) {
125 ls_path = argv[optind];
126 pathname = argv[optind+1];
128 if (dm_init_service(&name) == -1) {
129 fprintf(stderr, "Can't inititalize the DMAPI\n");
132 if (sid == DM_NO_SESSION)
133 find_test_session(&sid);
135 printf("Beginning EFAULT testing...\n");
137 /*----------------------------------*\
138 |* ## Traditional errno tests ## *|
139 \*----------------------------------*/
140 sprintf(test_file, "%s/DMAPI_EFAULT_test_file", pathname);
141 sprintf(command, "cp %s %s\n", ls_path, test_file);
144 if (dm_path_to_handle(test_file, &hanp, &hlen)) {
145 fprintf(stderr, "ERROR: can't get handle for %s; %s\n",
146 test_file, ERR_NAME);
151 /*---------------------------------------------------------
153 *---------------------------------------------------------
158 dm_extent_t *extentp;
161 ERRTEST(EFAULT, "get_allocinfo (bad offp)",
162 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
164 nelem, &extent, &nelem_ret))
165 ERRTEST(EFAULT, "get_allocinfo (bad extentp)",
166 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
167 &off, nelem, (dm_extent_t*)(-1000),
169 ERRTEST(EFAULT, "get_allocinfo (bad nelemp)",
170 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
171 &off, nelem, &extent,
175 /*------------------------------------------------------
176 * get_bulkattr: see test_fileattr.c
177 *------------------------------------------------------
179 *------------------------------------------------------
181 ERRTEST(EFAULT, "get_config",
182 dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
183 (dm_size_t*)(-1000)))
184 /*---------------------------------------------------------
186 *---------------------------------------------------------
191 dm_eventset_t *eventsetp;
192 eventsetp = (dm_eventset_t *)malloc(nelem*sizeof(dm_eventset_t));
193 if (eventsetp == NULL) {
194 printf("Couldn't malloc for config_events tests: %s\n", ERR_NAME);
197 ERRTEST(EFAULT, "get_config_events (bad eventsetp)",
198 dm_get_config_events(hanp, hlen, nelem,
199 (dm_eventset_t*)(-1000), nelemp))
200 ERRTEST(EFAULT, "get_config_events (bad nelemp)",
201 dm_get_config_events(hanp, hlen, nelem, eventsetp,
205 /*---------------------------------------------------------
206 * get_dirattrs: see test_fileattr.c
207 *---------------------------------------------------------
208 * get_fileattr: see test_fileattr.c
209 *---------------------------------------------------------
210 * get_region: see test_region.c
211 *---------------------------------------------------------
213 *---------------------------------------------------------
217 void *bufp = (void *)malloc(buflen*sizeof(dm_attrlist_t));
219 ERRTEST(EFAULT, "getall_dmattr (NULL handle)",
220 dm_getall_dmattr(sid, NULL, hlen, DM_NO_TOKEN,
221 buflen, bufp, rlenp))
222 ERRTEST(EFAULT, "getall_dmattr (incremented bufp)",
223 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
224 buflen, (void*)((char*)(bufp)+1), rlenp))
225 ERRTEST(EFAULT, "getall_dmattr (bad bufp)",
226 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
227 buflen, (void*)(-1000), rlenp))
228 ERRTEST(EFAULT, "getall_dmattr (bad rlenp)",
229 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
230 buflen, bufp, (size_t*)(-1000)))
232 /*---------------------------------------------------------
234 *---------------------------------------------------------
236 ERRTEST(ENOTSUP, "init_attrloc",
237 dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
238 (dm_attrloc_t*)(-1000)))
239 /*---------------------------------------------------------
240 * probe_hole: see test_hole.c
241 *---------------------------------------------------------
242 * remove_dmattr: see test_dmattr.c
243 *---------------------------------------------------------
244 * set_dmattr: see test_dmattr.c
245 *---------------------------------------------------------
246 * set_eventlist: see test_eventlist.c
247 *---------------------------------------------------------
248 * set_region: see test_region.c
249 *---------------------------------------------------------
253 sprintf(command, "rm %s\n", test_file);
256 printf("EFAULT testing complete.\n");