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 #include <sys/types.h>
26 #include <lib/dmport.h>
28 #include <lib/errtest.h>
34 /*---------------------------------------------------------------------------
35 Automated search for EFAULT in the following DMAPI commands:
42 There are other EFAULT tests, in the programs that test individual
43 DMAPI functions. Those other tests are referenced in comments in this source.
46 test_efault [-s sid] [-v] ls_path pathname
50 is the session ID whose events you you are interested in.
52 is the path to a copy of ls, which will be copied as a test file.
54 is the filesystem to use for the test.
55 ----------------------------------------------------------------------------*/
68 "Usage: %s [-v] [-s sid] ls_path pathname\n",
75 main(int argc, char **argv) {
77 dm_sessid_t sid = DM_NO_SESSION;
87 Progname = strrchr(argv[0], '/');
95 while ((opt = getopt(argc, argv, "vn:s:")) != EOF) {
107 if (optind + 2 != argc) {
110 ls_path = argv[optind];
111 pathname = argv[optind+1];
113 if (dm_init_service(&name) == -1) {
114 fprintf(stderr, "Can't initialize the DMAPI\n");
117 if (sid == DM_NO_SESSION)
118 find_test_session(&sid);
120 printf("Beginning EFAULT testing...\n");
122 /*----------------------------------*\
123 |* ## Traditional errno tests ## *|
124 \*----------------------------------*/
125 sprintf(test_file, "%s/DMAPI_EFAULT_test_file", pathname);
126 sprintf(command, "cp %s %s\n", ls_path, test_file);
129 if (dm_path_to_handle(test_file, &hanp, &hlen)) {
130 fprintf(stderr, "ERROR: can't get handle for %s; %s\n",
131 test_file, ERR_NAME);
136 /*---------------------------------------------------------
138 *---------------------------------------------------------
145 ERRTEST(EFAULT, "get_allocinfo (bad offp)",
146 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
148 nelem, &extent, &nelem_ret))
149 ERRTEST(EFAULT, "get_allocinfo (bad extentp)",
150 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
151 &off, nelem, (dm_extent_t*)(-1000),
153 ERRTEST(EFAULT, "get_allocinfo (bad nelemp)",
154 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
155 &off, nelem, &extent,
159 /*------------------------------------------------------
160 * get_bulkattr: see test_fileattr.c
161 *------------------------------------------------------
163 *------------------------------------------------------
165 ERRTEST(EFAULT, "get_config",
166 dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
167 (dm_size_t*)(-1000)))
168 /*---------------------------------------------------------
170 *---------------------------------------------------------
174 u_int *nelemp = NULL;
175 dm_eventset_t *eventsetp;
176 eventsetp = (dm_eventset_t *)malloc(nelem*sizeof(dm_eventset_t));
177 if (eventsetp == NULL) {
178 printf("Couldn't malloc for config_events tests: %s\n", ERR_NAME);
181 ERRTEST(EFAULT, "get_config_events (bad eventsetp)",
182 dm_get_config_events(hanp, hlen, nelem,
183 (dm_eventset_t*)(-1000), nelemp))
184 ERRTEST(EFAULT, "get_config_events (bad nelemp)",
185 dm_get_config_events(hanp, hlen, nelem, eventsetp,
189 /*---------------------------------------------------------
190 * get_dirattrs: see test_fileattr.c
191 *---------------------------------------------------------
192 * get_fileattr: see test_fileattr.c
193 *---------------------------------------------------------
194 * get_region: see test_region.c
195 *---------------------------------------------------------
197 *---------------------------------------------------------
201 void *bufp = (void *)malloc(buflen*sizeof(dm_attrlist_t));
202 size_t *rlenp = NULL;
203 ERRTEST(EFAULT, "getall_dmattr (NULL handle)",
204 dm_getall_dmattr(sid, NULL, hlen, DM_NO_TOKEN,
205 buflen, bufp, rlenp))
206 ERRTEST(EFAULT, "getall_dmattr (incremented bufp)",
207 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
208 buflen, (void*)((char*)(bufp)+1), rlenp))
209 ERRTEST(EFAULT, "getall_dmattr (bad bufp)",
210 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
211 buflen, (void*)(-1000), rlenp))
212 ERRTEST(EFAULT, "getall_dmattr (bad rlenp)",
213 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
214 buflen, bufp, (size_t*)(-1000)))
216 /*---------------------------------------------------------
218 *---------------------------------------------------------
220 ERRTEST(ENOTSUP, "init_attrloc",
221 dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
222 (dm_attrloc_t*)(-1000)))
223 /*---------------------------------------------------------
224 * probe_hole: see test_hole.c
225 *---------------------------------------------------------
226 * remove_dmattr: see test_dmattr.c
227 *---------------------------------------------------------
228 * set_dmattr: see test_dmattr.c
229 *---------------------------------------------------------
230 * set_eventlist: see test_eventlist.c
231 *---------------------------------------------------------
232 * set_region: see test_region.c
233 *---------------------------------------------------------
237 sprintf(command, "rm %s\n", test_file);
240 printf("EFAULT testing complete.\n");