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 if (Progname = strrchr(argv[0], '/')) {
94 while ((opt = getopt(argc, argv, "vn:s:")) != EOF) {
106 if (optind + 2 != argc) {
109 ls_path = argv[optind];
110 pathname = argv[optind+1];
112 if (dm_init_service(&name) == -1) {
113 fprintf(stderr, "Can't initialize the DMAPI\n");
116 if (sid == DM_NO_SESSION)
117 find_test_session(&sid);
119 printf("Beginning EFAULT testing...\n");
121 /*----------------------------------*\
122 |* ## Traditional errno tests ## *|
123 \*----------------------------------*/
124 sprintf(test_file, "%s/DMAPI_EFAULT_test_file", pathname);
125 sprintf(command, "cp %s %s\n", ls_path, test_file);
128 if (dm_path_to_handle(test_file, &hanp, &hlen)) {
129 fprintf(stderr, "ERROR: can't get handle for %s; %s\n",
130 test_file, ERR_NAME);
135 /*---------------------------------------------------------
137 *---------------------------------------------------------
144 ERRTEST(EFAULT, "get_allocinfo (bad offp)",
145 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
147 nelem, &extent, &nelem_ret))
148 ERRTEST(EFAULT, "get_allocinfo (bad extentp)",
149 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
150 &off, nelem, (dm_extent_t*)(-1000),
152 ERRTEST(EFAULT, "get_allocinfo (bad nelemp)",
153 dm_get_allocinfo(sid, hanp, hlen, DM_NO_TOKEN,
154 &off, nelem, &extent,
158 /*------------------------------------------------------
159 * get_bulkattr: see test_fileattr.c
160 *------------------------------------------------------
162 *------------------------------------------------------
164 ERRTEST(EFAULT, "get_config",
165 dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
166 (dm_size_t*)(-1000)))
167 /*---------------------------------------------------------
169 *---------------------------------------------------------
174 dm_eventset_t *eventsetp;
175 eventsetp = (dm_eventset_t *)malloc(nelem*sizeof(dm_eventset_t));
176 if (eventsetp == NULL) {
177 printf("Couldn't malloc for config_events tests: %s\n", ERR_NAME);
180 ERRTEST(EFAULT, "get_config_events (bad eventsetp)",
181 dm_get_config_events(hanp, hlen, nelem,
182 (dm_eventset_t*)(-1000), nelemp))
183 ERRTEST(EFAULT, "get_config_events (bad nelemp)",
184 dm_get_config_events(hanp, hlen, nelem, eventsetp,
188 /*---------------------------------------------------------
189 * get_dirattrs: see test_fileattr.c
190 *---------------------------------------------------------
191 * get_fileattr: see test_fileattr.c
192 *---------------------------------------------------------
193 * get_region: see test_region.c
194 *---------------------------------------------------------
196 *---------------------------------------------------------
200 void *bufp = (void *)malloc(buflen*sizeof(dm_attrlist_t));
202 ERRTEST(EFAULT, "getall_dmattr (NULL handle)",
203 dm_getall_dmattr(sid, NULL, hlen, DM_NO_TOKEN,
204 buflen, bufp, rlenp))
205 ERRTEST(EFAULT, "getall_dmattr (incremented bufp)",
206 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
207 buflen, (void*)((char*)(bufp)+1), rlenp))
208 ERRTEST(EFAULT, "getall_dmattr (bad bufp)",
209 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
210 buflen, (void*)(-1000), rlenp))
211 ERRTEST(EFAULT, "getall_dmattr (bad rlenp)",
212 dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
213 buflen, bufp, (size_t*)(-1000)))
215 /*---------------------------------------------------------
217 *---------------------------------------------------------
219 ERRTEST(ENOTSUP, "init_attrloc",
220 dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
221 (dm_attrloc_t*)(-1000)))
222 /*---------------------------------------------------------
223 * probe_hole: see test_hole.c
224 *---------------------------------------------------------
225 * remove_dmattr: see test_dmattr.c
226 *---------------------------------------------------------
227 * set_dmattr: see test_dmattr.c
228 *---------------------------------------------------------
229 * set_eventlist: see test_eventlist.c
230 *---------------------------------------------------------
231 * set_region: see test_region.c
232 *---------------------------------------------------------
236 sprintf(command, "rm %s\n", test_file);
239 printf("EFAULT testing complete.\n");