blob: 7b4123fe87a941f7f37a6fbdeb4e258de0fc054a [file] [log] [blame]
vapierd13d74b2006-02-11 07:24:00 +00001/*
2 * Copyright (c) International Business Machines Corp., 2004
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
Wanlong Gao4548c6c2012-10-19 18:03:36 +080016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
vapierd13d74b2006-02-11 07:24:00 +000017 */
18
19/*
20 * TEST CASE : disp.c
21 *
22 * VARIATIONS : 155
23 *
24 * API'S TESTED : dm_get_config_events
25 * dm_set_disp
26 * dm_getall_disp
27 * dm_set_eventlist
28 * dm_get_eventlist
29 */
30#include <string.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <errno.h>
34#include <pthread.h>
35#include <unistd.h>
36#include <sys/stat.h>
37#include <sys/mount.h>
38#include <fcntl.h>
39#include "dm_test.h"
40
41#define TMP_FILELEN 1000
42
43pthread_t tid;
44dm_sessid_t sid;
45char dmMsgBuf[4096];
46char command[4096];
47char *mountPt;
48char *deviceNm;
49char DummyFile[FILENAME_MAX];
50char DummyFile2[FILENAME_MAX];
51char DummySubdir[FILENAME_MAX];
52
53void *Thread(void *);
54
55int main(int argc, char **argv)
56{
57
58 char *szFuncName;
59 char *varstr;
Wanlong Gao354ebb42012-12-07 10:10:04 +080060 int i;
61 int rc;
vapierd13d74b2006-02-11 07:24:00 +000062 char *szSessionInfo = "dm_test session info";
63 dm_eventset_t events, maxEvents, minEvents;
64 void *fshanp;
65 size_t fshlen;
66 int varNum;
67
68 DMOPT_PARSE(argc, argv);
69 DMLOG_START();
70
71 DMEV_ZERO(events);
72 DMEV_SET(DM_EVENT_MOUNT, events);
subrata_modakbdbaec52009-02-26 12:14:51 +000073
vapierd13d74b2006-02-11 07:24:00 +000074 /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
75 if ((rc = dm_init_service(&varstr)) != 0) {
Wanlong Gao354ebb42012-12-07 10:10:04 +080076 DMLOG_PRINT(DMLVL_ERR,
77 "dm_init_service failed! (rc = %d, errno = %d)\n",
78 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +000079 DM_EXIT();
Wanlong Gao354ebb42012-12-07 10:10:04 +080080 } else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
81 == -1) {
82 DMLOG_PRINT(DMLVL_ERR,
83 "dm_create_session failed! (rc = %d, errno = %d)\n",
84 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +000085 DM_EXIT();
Wanlong Gao354ebb42012-12-07 10:10:04 +080086 } else
87 if ((rc =
88 dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN,
89 &events, DM_EVENT_MAX)) == -1) {
90 DMLOG_PRINT(DMLVL_ERR,
91 "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
92 errno);
vapierd13d74b2006-02-11 07:24:00 +000093 dm_destroy_session(sid);
94 DM_EXIT();
95 } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
Wanlong Gao354ebb42012-12-07 10:10:04 +080096 DMLOG_PRINT(DMLVL_ERR,
97 "pthread_create failed! (rc = %d, errno = %d)\n",
98 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +000099 dm_destroy_session(sid);
100 DM_EXIT();
101 } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800102 DMLOG_PRINT(DMLVL_ERR,
103 "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc,
104 errno);
vapierd13d74b2006-02-11 07:24:00 +0000105 dm_destroy_session(sid);
106 DM_EXIT();
107 } else {
108 int fd;
109
110 sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
111 sprintf(DummyFile2, "%s/%s", mountPt, DUMMY_FILE2);
112 sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
113
114 remove(DummyFile);
115 remove(DummyFile2);
116 rmdir(DummySubdir);
117
118 EVENT_DELIVERY_DELAY;
subrata_modake753fd72008-07-11 10:56:34 +0000119 fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
vapierd13d74b2006-02-11 07:24:00 +0000120 if (fd != -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800121 for (i = 0; i < TMP_FILELEN / DUMMY_STRLEN; i++) {
122 if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
123 DUMMY_STRLEN) {
vapierd13d74b2006-02-11 07:24:00 +0000124 rc = -1;
125 break;
Garrett Cooper2c282152010-12-16 00:55:50 -0800126 }
vapierd13d74b2006-02-11 07:24:00 +0000127 }
128 } else {
129 rc = -1;
130 }
131 if (rc != -1) {
132 rc = fsync(fd);
133 }
134 if (rc != -1) {
135 rc = close(fd);
136 }
137 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800138 DMLOG_PRINT(DMLVL_ERR,
139 "creating dummy file failed! (rc = %d, errno = %d)\n",
140 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +0000141 dm_destroy_session(sid);
142 DM_EXIT();
143 }
Garrett Cooper2c282152010-12-16 00:55:50 -0800144
subrata_modake753fd72008-07-11 10:56:34 +0000145 rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
vapierd13d74b2006-02-11 07:24:00 +0000146 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800147 DMLOG_PRINT(DMLVL_ERR,
148 "creating dummy dir failed! (rc = %d, errno = %d)\n",
149 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +0000150 dm_destroy_session(sid);
151 DM_EXIT();
152 }
Garrett Cooper2c282152010-12-16 00:55:50 -0800153
vapierd13d74b2006-02-11 07:24:00 +0000154 DMEV_ZERO(maxEvents);
155 DMEV_SET(DM_EVENT_PREUNMOUNT, maxEvents);
156 DMEV_SET(DM_EVENT_UNMOUNT, maxEvents);
157 DMEV_SET(DM_EVENT_CREATE, maxEvents);
158 DMEV_SET(DM_EVENT_CLOSE, maxEvents);
159 DMEV_SET(DM_EVENT_POSTCREATE, maxEvents);
160 DMEV_SET(DM_EVENT_REMOVE, maxEvents);
161 DMEV_SET(DM_EVENT_POSTREMOVE, maxEvents);
162 DMEV_SET(DM_EVENT_RENAME, maxEvents);
163 DMEV_SET(DM_EVENT_POSTRENAME, maxEvents);
164 DMEV_SET(DM_EVENT_LINK, maxEvents);
165 DMEV_SET(DM_EVENT_POSTLINK, maxEvents);
166 DMEV_SET(DM_EVENT_SYMLINK, maxEvents);
167 DMEV_SET(DM_EVENT_POSTSYMLINK, maxEvents);
168 DMEV_SET(DM_EVENT_ATTRIBUTE, maxEvents);
169 DMEV_SET(DM_EVENT_DESTROY, maxEvents);
170 DMEV_SET(DM_EVENT_NOSPACE, maxEvents);
subrata_modakbdbaec52009-02-26 12:14:51 +0000171
vapierd13d74b2006-02-11 07:24:00 +0000172 DMEV_ZERO(minEvents);
173 DMEV_SET(DM_EVENT_PREUNMOUNT, minEvents);
174 DMEV_SET(DM_EVENT_UNMOUNT, minEvents);
175 }
176
Wanlong Gao354ebb42012-12-07 10:10:04 +0800177 DMLOG_PRINT(DMLVL_DEBUG,
178 "Starting DMAPI disposition/eventlist tests\n");
subrata_modakbdbaec52009-02-26 12:14:51 +0000179
vapierd13d74b2006-02-11 07:24:00 +0000180 szFuncName = "dm_get_config_events";
181
182 /*
183 * TEST : dm_get_config_events - invalid hanp
184 * EXPECTED: rc = -1, errno = EFAULT
185 */
186 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 1)) {
187 void *hanp;
188 size_t hlen;
189 dm_eventset_t eventset;
190 u_int nelem;
191
192 /* Variation set up */
193 rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
194 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800195 DMLOG_PRINT(DMLVL_DEBUG,
196 "Unable to set up variation! (errno = %d)\n",
197 errno);
vapierd13d74b2006-02-11 07:24:00 +0000198 DMVAR_SKIP();
199 } else {
200 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800201 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
202 szFuncName);
203 rc = dm_get_config_events((void *)INVALID_ADDR, hlen,
204 DM_EVENT_MAX, &eventset,
205 &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +0000206 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +0000207
208 /* Variation clean up */
209 dm_handle_free(hanp, hlen);
210 }
211 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000212
vapierd13d74b2006-02-11 07:24:00 +0000213 /*
214 * TEST : dm_get_config_events - invalid hlen
215 * EXPECTED: rc = -1, errno = EBADF
216 */
217 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 2)) {
218 void *hanp;
219 size_t hlen;
220 dm_eventset_t eventset;
221 u_int nelem;
222
223 /* Variation set up */
224 rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
225 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800226 DMLOG_PRINT(DMLVL_DEBUG,
227 "Unable to set up variation! (errno = %d)\n",
228 errno);
vapierd13d74b2006-02-11 07:24:00 +0000229 DMVAR_SKIP();
230 } else {
231 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800232 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
233 szFuncName);
234 rc = dm_get_config_events(hanp, INVALID_ADDR,
235 DM_EVENT_MAX, &eventset,
236 &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +0000237 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
vapierd13d74b2006-02-11 07:24:00 +0000238
239 /* Variation clean up */
240 dm_handle_free(hanp, hlen);
241 }
242 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000243
vapierd13d74b2006-02-11 07:24:00 +0000244 /*
245 * TEST : dm_get_config_events - invalid nelem
246 * EXPECTED: rc = -1, errno = E2BIG
247 *
248 * This variation uncovered XFS BUG #18 (nelem not updated)
249 */
250 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 3)) {
251 void *hanp;
252 size_t hlen;
253 dm_eventset_t eventset;
254 u_int nelem;
255
256 /* Variation set up */
257 rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
258 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800259 DMLOG_PRINT(DMLVL_DEBUG,
260 "Unable to set up variation! (errno = %d)\n",
261 errno);
vapierd13d74b2006-02-11 07:24:00 +0000262 DMVAR_SKIP();
263 } else {
264 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800265 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelem)\n",
266 szFuncName);
267 rc = dm_get_config_events(hanp, hlen, 0, &eventset,
268 &nelem);
vapierd13d74b2006-02-11 07:24:00 +0000269 if (rc == -1) {
270 if (errno == E2BIG) {
271 if (nelem == DM_EVENT_MAX) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800272 DMLOG_PRINT(DMLVL_DEBUG,
273 "%s passed with expected rc = %d and expected errno = %d (nelem = %d)\n",
274 szFuncName, rc,
275 errno, nelem);
vapierd13d74b2006-02-11 07:24:00 +0000276 DMVAR_PASS();
277 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800278 DMLOG_PRINT(DMLVL_ERR,
279 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
280 szFuncName, rc,
281 nelem,
282 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +0000283 DMVAR_FAIL();
284 }
285 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800286 DMLOG_PRINT(DMLVL_ERR,
287 "%s failed with expected rc = %d but unexpected errno = %d\n",
288 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +0000289 DMVAR_FAIL();
290 }
291 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800292 DMLOG_PRINT(DMLVL_ERR,
293 "%s failed with unexpected rc = %d\n",
294 szFuncName, rc);
vapierd13d74b2006-02-11 07:24:00 +0000295 DMVAR_FAIL();
296 }
297
298 /* Variation clean up */
299 dm_handle_free(hanp, hlen);
300 }
301 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000302
vapierd13d74b2006-02-11 07:24:00 +0000303 /*
304 * TEST : dm_get_config_events - invalid eventsetp
305 * EXPECTED: rc = -1, errno = EFAULT
306 */
307 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 4)) {
308 void *hanp;
309 size_t hlen;
310 u_int nelem;
311
312 /* Variation set up */
313 rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
314 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800315 DMLOG_PRINT(DMLVL_DEBUG,
316 "Unable to set up variation! (errno = %d)\n",
317 errno);
vapierd13d74b2006-02-11 07:24:00 +0000318 DMVAR_SKIP();
319 } else {
320 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800321 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
322 szFuncName);
323 rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
324 (dm_eventset_t *)
325 INVALID_ADDR, &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +0000326 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +0000327
328 /* Variation clean up */
329 dm_handle_free(hanp, hlen);
330 }
331 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000332
vapierd13d74b2006-02-11 07:24:00 +0000333 /*
334 * TEST : dm_get_config_events - invalid nelemp
335 * EXPECTED: rc = -1, errno = EFAULT
336 */
337 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 5)) {
338 void *hanp;
339 size_t hlen;
340 dm_eventset_t eventset;
341
342 /* Variation set up */
343 rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
344 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800345 DMLOG_PRINT(DMLVL_DEBUG,
346 "Unable to set up variation! (errno = %d)\n",
347 errno);
vapierd13d74b2006-02-11 07:24:00 +0000348 DMVAR_SKIP();
349 } else {
350 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800351 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
352 szFuncName);
353 rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
354 &eventset,
355 (u_int *) INVALID_ADDR);
subrata_modak4bb656a2009-02-26 12:02:09 +0000356 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +0000357
358 /* Variation clean up */
359 dm_handle_free(hanp, hlen);
360 }
361 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000362
vapierd13d74b2006-02-11 07:24:00 +0000363 /*
364 * TEST : dm_get_config_events - fs handle
365 * EXPECTED: rc = 0
366 *
367 * This variation uncovered XFS BUG #19 (DM_EVENT_USER not returned)
368 */
369 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 6)) {
370 void *hanp;
371 size_t hlen;
372 dm_eventset_t eventset;
373 u_int nelem;
374
375 /* Variation set up */
376 rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen);
377 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800378 DMLOG_PRINT(DMLVL_DEBUG,
379 "Unable to set up variation! (errno = %d)\n",
380 errno);
vapierd13d74b2006-02-11 07:24:00 +0000381 DMVAR_SKIP();
382 } else {
383 /* Variation */
384 DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
Wanlong Gao354ebb42012-12-07 10:10:04 +0800385 rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
386 &eventset, &nelem);
vapierd13d74b2006-02-11 07:24:00 +0000387 if (rc == 0) {
388 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
389 if (nelem == DM_EVENT_MAX) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800390 if (memcmp
391 (&eventset, &dmimpl_eventset,
392 sizeof(dm_eventset_t)) == 0) {
393 DMLOG_PRINT(DMLVL_DEBUG,
394 "%s passed with expected rc = %d\n",
395 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +0000396 DMVAR_PASS();
397 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800398 DMLOG_PRINT(DMLVL_ERR,
399 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
400 szFuncName, 0,
401 eventset,
402 dmimpl_eventset);
vapierd13d74b2006-02-11 07:24:00 +0000403 DMVAR_FAIL();
404 }
405 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800406 DMLOG_PRINT(DMLVL_ERR,
407 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
408 szFuncName, 0, nelem,
409 DM_EVENT_DESTROY + 1);
vapierd13d74b2006-02-11 07:24:00 +0000410 DMVAR_FAIL();
411 }
412 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800413 DMLOG_PRINT(DMLVL_ERR,
414 "%s failed with unexpected rc = %d (errno = %d)\n",
415 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +0000416 DMVAR_FAIL();
417 }
418
419 /* Variation clean up */
420 dm_handle_free(hanp, hlen);
421 }
422 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000423
vapierd13d74b2006-02-11 07:24:00 +0000424 /*
425 * TEST : dm_get_config_events - file handle
426 * EXPECTED: rc = 0
427 */
428 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 7)) {
429 void *hanp;
430 size_t hlen;
431 dm_eventset_t eventset;
432 u_int nelem;
433
434 /* Variation set up */
435 rc = dm_path_to_handle(DummyFile, &hanp, &hlen);
436 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800437 DMLOG_PRINT(DMLVL_DEBUG,
438 "Unable to set up variation! (errno = %d)\n",
439 errno);
vapierd13d74b2006-02-11 07:24:00 +0000440 DMVAR_SKIP();
441 } else {
442 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800443 DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
444 szFuncName);
445 rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
446 &eventset, &nelem);
vapierd13d74b2006-02-11 07:24:00 +0000447 if (rc == 0) {
448 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
449 if (nelem == DM_EVENT_MAX) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800450 if (memcmp
451 (&eventset, &dmimpl_eventset,
452 sizeof(dm_eventset_t)) == 0) {
453 DMLOG_PRINT(DMLVL_DEBUG,
454 "%s passed with expected rc = %d\n",
455 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +0000456 DMVAR_PASS();
457 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800458 DMLOG_PRINT(DMLVL_ERR,
459 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
460 szFuncName, 0,
461 eventset,
462 dmimpl_eventset);
vapierd13d74b2006-02-11 07:24:00 +0000463 DMVAR_FAIL();
464 }
465 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800466 DMLOG_PRINT(DMLVL_ERR,
467 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
468 szFuncName, 0, nelem,
469 DM_EVENT_DESTROY + 1);
vapierd13d74b2006-02-11 07:24:00 +0000470 DMVAR_FAIL();
471 }
472 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800473 DMLOG_PRINT(DMLVL_ERR,
474 "%s failed with unexpected rc = %d (errno = %d)\n",
475 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +0000476 DMVAR_FAIL();
477 }
478
479 /* Variation clean up */
480 dm_handle_free(hanp, hlen);
481 }
482 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000483
vapierd13d74b2006-02-11 07:24:00 +0000484 /*
485 * TEST : dm_get_config_events - dir handle
486 * EXPECTED: rc = 0
487 */
488 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 8)) {
489 void *hanp;
490 size_t hlen;
491 dm_eventset_t eventset;
492 u_int nelem;
493
494 /* Variation set up */
495 rc = dm_path_to_handle(DummySubdir, &hanp, &hlen);
496 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800497 DMLOG_PRINT(DMLVL_DEBUG,
498 "Unable to set up variation! (errno = %d)\n",
499 errno);
vapierd13d74b2006-02-11 07:24:00 +0000500 DMVAR_SKIP();
501 } else {
502 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800503 DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
504 szFuncName);
505 rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
506 &eventset, &nelem);
vapierd13d74b2006-02-11 07:24:00 +0000507 if (rc == 0) {
508 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
509 if (nelem == DM_EVENT_MAX) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800510 if (memcmp
511 (&eventset, &dmimpl_eventset,
512 sizeof(dm_eventset_t)) == 0) {
513 DMLOG_PRINT(DMLVL_DEBUG,
514 "%s passed with expected rc = %d\n",
515 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +0000516 DMVAR_PASS();
517 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800518 DMLOG_PRINT(DMLVL_ERR,
519 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
520 szFuncName, 0,
521 eventset,
522 dmimpl_eventset);
vapierd13d74b2006-02-11 07:24:00 +0000523 DMVAR_FAIL();
524 }
525 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800526 DMLOG_PRINT(DMLVL_ERR,
527 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
528 szFuncName, 0, nelem,
529 DM_EVENT_DESTROY + 1);
vapierd13d74b2006-02-11 07:24:00 +0000530 DMVAR_FAIL();
531 }
532 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800533 DMLOG_PRINT(DMLVL_ERR,
534 "%s failed with unexpected rc = %d (errno = %d)\n",
535 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +0000536 DMVAR_FAIL();
537 }
538
539 /* Variation clean up */
540 dm_handle_free(hanp, hlen);
541 }
542 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000543
vapierd13d74b2006-02-11 07:24:00 +0000544 /*
545 * TEST : dm_get_config_events - global handle
546 * EXPECTED: rc = -1, errno = EBADF
547 */
548 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 9)) {
549 dm_eventset_t eventset;
550 u_int nelem;
551
552 /* Variation set up */
Garrett Cooper2c282152010-12-16 00:55:50 -0800553
vapierd13d74b2006-02-11 07:24:00 +0000554 /* Variation */
555 DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
Wanlong Gao354ebb42012-12-07 10:10:04 +0800556 rc = dm_get_config_events(DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
557 DM_EVENT_MAX, &eventset, &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +0000558 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
vapierd13d74b2006-02-11 07:24:00 +0000559
560 /* Variation clean up */
561 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000562
vapierd13d74b2006-02-11 07:24:00 +0000563 /*
564 * TEST : dm_get_config_events - invalidated handle
565 * EXPECTED: rc = -1, errno = EBADF
566 */
567 if (DMVAR_EXEC(GET_CONFIG_EVENTS_BASE + 10)) {
568 void *hanp;
569 size_t hlen;
570 dm_eventset_t eventset;
571 u_int nelem;
572
573 /* Variation set up */
574 sprintf(command, "cp %s %s", DummyFile, DummyFile2);
575 if ((rc = system(command)) == -1) {
576 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800577 } else if ((rc = dm_path_to_handle(DummyFile2, &hanp, &hlen)) ==
578 -1) {
vapierd13d74b2006-02-11 07:24:00 +0000579 remove(DummyFile2);
580 } else if ((rc = remove(DummyFile2)) == -1) {
581 dm_handle_free(hanp, hlen);
582 }
583 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800584 DMLOG_PRINT(DMLVL_DEBUG,
585 "Unable to set up variation! (errno = %d)\n",
586 errno);
vapierd13d74b2006-02-11 07:24:00 +0000587 DMVAR_SKIP();
588 } else {
589 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800590 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
591 szFuncName);
592 rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX,
593 &eventset, &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +0000594 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
vapierd13d74b2006-02-11 07:24:00 +0000595
596 /* Variation clean up */
597 dm_handle_free(hanp, hlen);
598 }
599 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000600
vapierd13d74b2006-02-11 07:24:00 +0000601 szFuncName = "dm_set_disp";
602
603 /*
604 * TEST : dm_set_disp - DM_NO_SESSION sid
605 * EXPECTED: rc = -1, errno = EINVAL
606 */
607 if (DMVAR_EXEC(SET_DISP_BASE + 1)) {
608 dm_sessid_t newsid;
609 void *hanp;
610 size_t hlen;
611 dm_eventset_t eventset = minEvents;
612
613 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800614 if ((rc =
615 dm_create_session(DM_NO_SESSION, szSessionInfo,
616 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000617 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800618 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
619 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000620 dm_destroy_session(newsid);
621 }
622 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800623 DMLOG_PRINT(DMLVL_DEBUG,
624 "Unable to set up variation! (errno = %d)\n",
625 errno);
vapierd13d74b2006-02-11 07:24:00 +0000626 DMVAR_SKIP();
627 } else {
628 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800629 DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
630 szFuncName);
631 rc = dm_set_disp(DM_NO_SESSION, hanp, hlen, DM_NO_TOKEN,
632 &eventset, DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +0000633 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +0000634
635 /* Variation clean up */
636 rc = dm_destroy_session(newsid);
637 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800638 DMLOG_PRINT(DMLVL_DEBUG,
639 "Unable to clean up variation! (errno = %d)\n",
640 errno);
vapierd13d74b2006-02-11 07:24:00 +0000641 }
642 dm_handle_free(hanp, hlen);
643 }
644 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000645
vapierd13d74b2006-02-11 07:24:00 +0000646 /*
647 * TEST : dm_set_disp - invalid sid
648 * EXPECTED: rc = -1, errno = EINVAL
649 */
650 if (DMVAR_EXEC(SET_DISP_BASE + 2)) {
651 dm_sessid_t newsid;
652 void *hanp;
653 size_t hlen;
654 dm_eventset_t eventset = minEvents;
655
656 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800657 if ((rc =
658 dm_create_session(DM_NO_SESSION, szSessionInfo,
659 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000660 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800661 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
662 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000663 dm_destroy_session(newsid);
664 }
665 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800666 DMLOG_PRINT(DMLVL_DEBUG,
667 "Unable to set up variation! (errno = %d)\n",
668 errno);
vapierd13d74b2006-02-11 07:24:00 +0000669 DMVAR_SKIP();
670 } else {
671 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800672 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
673 szFuncName);
674 rc = dm_set_disp(INVALID_ADDR, hanp, hlen, DM_NO_TOKEN,
675 &eventset, DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +0000676 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +0000677
678 /* Variation clean up */
679 rc = dm_destroy_session(newsid);
680 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800681 DMLOG_PRINT(DMLVL_DEBUG,
682 "Unable to clean up variation! (errno = %d)\n",
683 errno);
vapierd13d74b2006-02-11 07:24:00 +0000684 }
685 dm_handle_free(hanp, hlen);
686 }
687 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000688
vapierd13d74b2006-02-11 07:24:00 +0000689 /*
690 * TEST : dm_set_disp - invalid hanp
691 * EXPECTED: rc = -1, errno = EFAULT
692 */
693 if (DMVAR_EXEC(SET_DISP_BASE + 3)) {
694 dm_sessid_t newsid;
695 void *hanp;
696 size_t hlen;
697 dm_eventset_t eventset = minEvents;
698
699 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800700 if ((rc =
701 dm_create_session(DM_NO_SESSION, szSessionInfo,
702 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000703 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800704 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
705 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000706 dm_destroy_session(newsid);
707 }
708 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800709 DMLOG_PRINT(DMLVL_DEBUG,
710 "Unable to set up variation! (errno = %d)\n",
711 errno);
vapierd13d74b2006-02-11 07:24:00 +0000712 DMVAR_SKIP();
713 } else {
714 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800715 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
716 szFuncName);
717 rc = dm_set_disp(newsid, (void *)INVALID_ADDR, hlen,
718 DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +0000719 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
720
721 /* Variation clean up */
722 rc = dm_destroy_session(newsid);
723 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800724 DMLOG_PRINT(DMLVL_DEBUG,
725 "Unable to clean up variation! (errno = %d)\n",
726 errno);
vapierd13d74b2006-02-11 07:24:00 +0000727 }
728 dm_handle_free(hanp, hlen);
729 }
730 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000731
vapierd13d74b2006-02-11 07:24:00 +0000732 /*
733 * TEST : dm_set_disp - invalid hlen
734 * EXPECTED: rc = -1, errno = EBADF
735 */
736 if (DMVAR_EXEC(SET_DISP_BASE + 4)) {
737 dm_sessid_t newsid;
738 void *hanp;
739 size_t hlen;
740 dm_eventset_t eventset = minEvents;
741
742 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800743 if ((rc =
744 dm_create_session(DM_NO_SESSION, szSessionInfo,
745 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000746 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800747 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
748 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000749 dm_destroy_session(newsid);
750 }
751 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800752 DMLOG_PRINT(DMLVL_DEBUG,
753 "Unable to set up variation! (errno = %d)\n",
754 errno);
vapierd13d74b2006-02-11 07:24:00 +0000755 DMVAR_SKIP();
756 } else {
757 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800758 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
759 szFuncName);
760 rc = dm_set_disp(newsid, hanp, INVALID_ADDR,
761 DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +0000762 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
vapierd13d74b2006-02-11 07:24:00 +0000763
764 /* Variation clean up */
765 rc = dm_destroy_session(newsid);
766 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800767 DMLOG_PRINT(DMLVL_DEBUG,
768 "Unable to clean up variation! (errno = %d)\n",
769 errno);
vapierd13d74b2006-02-11 07:24:00 +0000770 }
771 dm_handle_free(hanp, hlen);
772 }
773 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000774
vapierd13d74b2006-02-11 07:24:00 +0000775 /*
776 * TEST : dm_set_disp - invalid token
777 * EXPECTED: rc = -1, errno = EINVAL
778 */
779 if (DMVAR_EXEC(SET_DISP_BASE + 5)) {
780 dm_sessid_t newsid;
781 void *hanp;
782 size_t hlen;
783 dm_eventset_t eventset = minEvents;
784
785 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800786 if ((rc =
787 dm_create_session(DM_NO_SESSION, szSessionInfo,
788 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000789 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800790 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
791 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000792 dm_destroy_session(newsid);
793 }
794 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800795 DMLOG_PRINT(DMLVL_DEBUG,
796 "Unable to set up variation! (errno = %d)\n",
797 errno);
vapierd13d74b2006-02-11 07:24:00 +0000798 DMVAR_SKIP();
799 } else {
800 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800801 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
802 szFuncName);
803 rc = dm_set_disp(newsid, hanp, hlen, INVALID_ADDR,
804 &eventset, DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +0000805 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +0000806
807 /* Variation clean up */
808 rc = dm_destroy_session(newsid);
809 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800810 DMLOG_PRINT(DMLVL_DEBUG,
811 "Unable to clean up variation! (errno = %d)\n",
812 errno);
vapierd13d74b2006-02-11 07:24:00 +0000813 }
814 dm_handle_free(hanp, hlen);
815 }
816 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000817
vapierd13d74b2006-02-11 07:24:00 +0000818 /*
819 * TEST : dm_set_disp - invalid eventsetp
820 * EXPECTED: rc = -1, errno = EFAULT
821 */
822 if (DMVAR_EXEC(SET_DISP_BASE + 6)) {
823 dm_sessid_t newsid;
824 void *hanp;
825 size_t hlen;
826
827 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800828 if ((rc =
829 dm_create_session(DM_NO_SESSION, szSessionInfo,
830 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000831 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800832 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
833 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000834 dm_destroy_session(newsid);
835 }
836 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800837 DMLOG_PRINT(DMLVL_DEBUG,
838 "Unable to set up variation! (errno = %d)\n",
839 errno);
vapierd13d74b2006-02-11 07:24:00 +0000840 DMVAR_SKIP();
841 } else {
842 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800843 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
844 szFuncName);
845 rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
846 (dm_eventset_t *) INVALID_ADDR,
847 DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +0000848 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +0000849
850 /* Variation clean up */
851 rc = dm_destroy_session(newsid);
852 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800853 DMLOG_PRINT(DMLVL_DEBUG,
854 "Unable to clean up variation! (errno = %d)\n",
855 errno);
vapierd13d74b2006-02-11 07:24:00 +0000856 }
857 dm_handle_free(hanp, hlen);
858 }
859 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000860
vapierd13d74b2006-02-11 07:24:00 +0000861 /*
862 * TEST : dm_set_disp - invalid maxevent
863 * EXPECTED: rc = -1, errno = EINVAL
864 */
865 if (DMVAR_EXEC(SET_DISP_BASE + 7)) {
866 dm_sessid_t newsid;
867 void *hanp;
868 size_t hlen;
869 dm_eventset_t eventset = minEvents;
870
871 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800872 if ((rc =
873 dm_create_session(DM_NO_SESSION, szSessionInfo,
874 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000875 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800876 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
877 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000878 dm_destroy_session(newsid);
879 }
880 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800881 DMLOG_PRINT(DMLVL_DEBUG,
882 "Unable to set up variation! (errno = %d)\n",
883 errno);
vapierd13d74b2006-02-11 07:24:00 +0000884 DMVAR_SKIP();
885 } else {
886 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800887 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid maxevent)\n",
888 szFuncName);
889 rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
890 &eventset, DM_EVENT_MAX + 1);
subrata_modak4bb656a2009-02-26 12:02:09 +0000891 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +0000892
893 /* Variation clean up */
894 rc = dm_destroy_session(newsid);
895 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800896 DMLOG_PRINT(DMLVL_DEBUG,
897 "Unable to clean up variation! (errno = %d)\n",
898 errno);
vapierd13d74b2006-02-11 07:24:00 +0000899 }
900 dm_handle_free(hanp, hlen);
901 }
902 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000903
vapierd13d74b2006-02-11 07:24:00 +0000904 /*
905 * TEST : dm_set_disp - file handle
906 * EXPECTED: rc = -1, errno = EINVAL
907 */
908 if (DMVAR_EXEC(SET_DISP_BASE + 8)) {
909 dm_sessid_t newsid;
910 void *hanp;
911 size_t hlen;
912 dm_eventset_t eventset = minEvents;
913
914 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800915 if ((rc =
916 dm_create_session(DM_NO_SESSION, szSessionInfo,
917 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000918 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800919 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
920 -1) {
vapierd13d74b2006-02-11 07:24:00 +0000921 dm_destroy_session(newsid);
922 }
923 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800924 DMLOG_PRINT(DMLVL_DEBUG,
925 "Unable to set up variation! (errno = %d)\n",
926 errno);
vapierd13d74b2006-02-11 07:24:00 +0000927 DMVAR_SKIP();
928 } else {
929 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800930 DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
931 szFuncName);
932 rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
933 &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +0000934 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
935
936 /* Variation clean up */
937 rc = dm_destroy_session(newsid);
938 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800939 DMLOG_PRINT(DMLVL_DEBUG,
940 "Unable to clean up variation! (errno = %d)\n",
941 errno);
vapierd13d74b2006-02-11 07:24:00 +0000942 }
943 dm_handle_free(hanp, hlen);
944 }
945 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000946
vapierd13d74b2006-02-11 07:24:00 +0000947 /*
948 * TEST : dm_set_disp - directory handle
949 * EXPECTED: rc = -1, errno = EINVAL
950 */
951 if (DMVAR_EXEC(SET_DISP_BASE + 9)) {
952 dm_sessid_t newsid;
953 void *hanp;
954 size_t hlen;
955 dm_eventset_t eventset = minEvents;
956
957 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800958 if ((rc =
959 dm_create_session(DM_NO_SESSION, szSessionInfo,
960 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000961 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800962 } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
963 == -1) {
vapierd13d74b2006-02-11 07:24:00 +0000964 dm_destroy_session(newsid);
965 }
966 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800967 DMLOG_PRINT(DMLVL_DEBUG,
968 "Unable to set up variation! (errno = %d)\n",
969 errno);
vapierd13d74b2006-02-11 07:24:00 +0000970 DMVAR_SKIP();
971 } else {
972 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +0800973 DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
974 szFuncName);
975 rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
976 &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +0000977 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
978
979 /* Variation clean up */
980 rc = dm_destroy_session(newsid);
981 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +0800982 DMLOG_PRINT(DMLVL_DEBUG,
983 "Unable to clean up variation! (errno = %d)\n",
984 errno);
vapierd13d74b2006-02-11 07:24:00 +0000985 }
986 dm_handle_free(hanp, hlen);
987 }
988 }
subrata_modakbdbaec52009-02-26 12:14:51 +0000989
vapierd13d74b2006-02-11 07:24:00 +0000990 /*
991 * TEST : dm_set_disp - invalid global handle event
992 * EXPECTED: rc = -1, errno = EINVAL
993 */
994 if (DMVAR_EXEC(SET_DISP_BASE + 10)) {
995 dm_sessid_t newsid;
996 dm_eventset_t eventset;
997
998 /* Variation set up */
999 DMEV_ZERO(eventset);
1000 DMEV_SET(DM_EVENT_POSTCREATE, eventset);
1001 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1002 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001003 DMLOG_PRINT(DMLVL_DEBUG,
1004 "Unable to set up variation! (errno = %d)\n",
1005 errno);
vapierd13d74b2006-02-11 07:24:00 +00001006 DMVAR_SKIP();
1007 } else {
1008 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001009 DMLOG_PRINT(DMLVL_DEBUG,
1010 "%s(invalid global handle event)\n",
1011 szFuncName);
1012 rc = dm_set_disp(newsid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
1013 DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00001014 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
1015
1016 /* Variation clean up */
1017 rc = dm_destroy_session(newsid);
1018 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001019 DMLOG_PRINT(DMLVL_DEBUG,
1020 "Unable to clean up variation! (errno = %d)\n",
1021 errno);
vapierd13d74b2006-02-11 07:24:00 +00001022 }
1023 }
1024 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001025
vapierd13d74b2006-02-11 07:24:00 +00001026 /*
1027 * TEST : dm_set_disp - invalid fs handle event
1028 * EXPECTED: rc = -1, errno = EINVAL
1029 */
1030 if (DMVAR_EXEC(SET_DISP_BASE + 11)) {
1031 dm_sessid_t newsid;
1032 void *hanp;
1033 size_t hlen;
1034 dm_eventset_t eventset;
1035
1036 /* Variation set up */
1037 DMEV_ZERO(eventset);
1038 DMEV_SET(DM_EVENT_MOUNT, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001039 if ((rc =
1040 dm_create_session(DM_NO_SESSION, szSessionInfo,
1041 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001042 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001043 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1044 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001045 dm_destroy_session(newsid);
1046 }
1047 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001048 DMLOG_PRINT(DMLVL_DEBUG,
1049 "Unable to set up variation! (errno = %d)\n",
1050 errno);
vapierd13d74b2006-02-11 07:24:00 +00001051 DMVAR_SKIP();
1052 } else {
1053 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001054 DMLOG_PRINT(DMLVL_DEBUG,
1055 "%s(invalid fs handle event)\n",
1056 szFuncName);
1057 rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1058 &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00001059 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
1060
1061 /* Variation clean up */
1062 rc = dm_destroy_session(newsid);
1063 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001064 DMLOG_PRINT(DMLVL_DEBUG,
1065 "Unable to clean up variation! (errno = %d)\n",
1066 errno);
vapierd13d74b2006-02-11 07:24:00 +00001067 }
1068 dm_handle_free(hanp, hlen);
1069 }
1070 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001071
vapierd13d74b2006-02-11 07:24:00 +00001072 /*
1073 * TEST : dm_set_disp - valid global handle event
1074 * EXPECTED: rc = 0
1075 */
1076 if (DMVAR_EXEC(SET_DISP_BASE + 12)) {
1077 dm_sessid_t newsid;
1078 dm_eventset_t eventset;
1079
1080 /* Variation set up */
1081 DMEV_ZERO(eventset);
1082 DMEV_SET(DM_EVENT_MOUNT, eventset);
1083 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1084 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001085 DMLOG_PRINT(DMLVL_DEBUG,
1086 "Unable to set up variation! (errno = %d)\n",
1087 errno);
vapierd13d74b2006-02-11 07:24:00 +00001088 DMVAR_SKIP();
1089 } else {
1090 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001091 DMLOG_PRINT(DMLVL_DEBUG,
1092 "%s(valid global handle event)\n",
1093 szFuncName);
1094 rc = dm_set_disp(newsid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
1095 DM_NO_TOKEN, &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00001096 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
1097
1098 /* Variation clean up */
1099 rc = dm_destroy_session(newsid);
1100 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001101 DMLOG_PRINT(DMLVL_DEBUG,
1102 "Unable to clean up variation! (errno = %d)\n",
1103 errno);
vapierd13d74b2006-02-11 07:24:00 +00001104 }
1105 }
1106 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001107
vapierd13d74b2006-02-11 07:24:00 +00001108 /*
1109 * TEST : dm_set_disp - valid fs handle event
1110 * EXPECTED: rc = 0
1111 */
1112 if (DMVAR_EXEC(SET_DISP_BASE + 13)) {
1113 dm_sessid_t newsid;
1114 void *hanp;
1115 size_t hlen;
1116 dm_eventset_t eventset;
1117
1118 /* Variation set up */
1119 DMEV_ZERO(eventset);
1120 DMEV_SET(DM_EVENT_POSTCREATE, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001121 if ((rc =
1122 dm_create_session(DM_NO_SESSION, szSessionInfo,
1123 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001124 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001125 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1126 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001127 dm_destroy_session(newsid);
1128 }
1129 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001130 DMLOG_PRINT(DMLVL_DEBUG,
1131 "Unable to set up variation! (errno = %d)\n",
1132 errno);
vapierd13d74b2006-02-11 07:24:00 +00001133 DMVAR_SKIP();
1134 } else {
1135 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001136 DMLOG_PRINT(DMLVL_DEBUG, "%s(valid fs handle event)\n",
1137 szFuncName);
1138 rc = dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1139 &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00001140 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
1141
1142 /* Variation clean up */
1143 rc = dm_destroy_session(newsid);
1144 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001145 DMLOG_PRINT(DMLVL_DEBUG,
1146 "Unable to clean up variation! (errno = %d)\n",
1147 errno);
vapierd13d74b2006-02-11 07:24:00 +00001148 }
1149 dm_handle_free(hanp, hlen);
1150 }
1151 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001152
vapierd13d74b2006-02-11 07:24:00 +00001153 szFuncName = "dm_getall_disp";
1154
1155 /*
1156 * TEST : dm_getall_disp - DM_NO_SESSION sid
1157 * EXPECTED: rc = -1, errno = EINVAL
1158 */
1159 if (DMVAR_EXEC(GETALL_DISP_BASE + 1)) {
1160 char buf[64];
1161 size_t rlen;
1162
1163 /* Variation set up */
1164
1165 /* Variation */
1166 DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
1167 rc = dm_getall_disp(DM_NO_SESSION, sizeof(buf), buf, &rlen);
subrata_modak4bb656a2009-02-26 12:02:09 +00001168 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00001169
1170 /* Variation clean up */
1171 }
1172
1173 /*
1174 * TEST : dm_getall_disp - invalid sid
1175 * EXPECTED: rc = -1, errno = EINVAL
1176 */
1177 if (DMVAR_EXEC(GETALL_DISP_BASE + 2)) {
1178 char buf[64];
1179 size_t rlen;
1180
1181 /* Variation set up */
1182
1183 /* Variation */
1184 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
1185 rc = dm_getall_disp(INVALID_ADDR, sizeof(buf), buf, &rlen);
subrata_modak4bb656a2009-02-26 12:02:09 +00001186 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00001187
1188 /* Variation clean up */
1189 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001190
vapierd13d74b2006-02-11 07:24:00 +00001191 /*
1192 * TEST : dm_getall_disp - invalidated sid
1193 * EXPECTED: rc = -1, errno = EINVAL
1194 */
1195 if (DMVAR_EXEC(GETALL_DISP_BASE + 3)) {
1196 dm_sessid_t newsid;
1197 char buf[64];
1198 size_t rlen;
1199 void *hanp;
1200 size_t hlen;
1201
1202 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001203 if ((rc =
1204 dm_create_session(DM_NO_SESSION, szSessionInfo,
1205 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001206 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001207 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1208 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001209 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001210 } else
1211 if ((rc =
1212 dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1213 &maxEvents, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001214 dm_handle_free(hanp, hlen);
1215 dm_destroy_session(newsid);
1216 } else if ((rc = dm_destroy_session(newsid)) == -1) {
1217 dm_handle_free(hanp, hlen);
1218 }
1219 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001220 DMLOG_PRINT(DMLVL_DEBUG,
1221 "Unable to set up variation! (errno = %d)\n",
1222 errno);
vapierd13d74b2006-02-11 07:24:00 +00001223 DMVAR_SKIP();
1224 } else {
1225 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001226 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n",
1227 szFuncName);
vapierd13d74b2006-02-11 07:24:00 +00001228 rc = dm_getall_disp(newsid, sizeof(buf), buf, &rlen);
subrata_modak4bb656a2009-02-26 12:02:09 +00001229 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
subrata_modakbdbaec52009-02-26 12:14:51 +00001230
vapierd13d74b2006-02-11 07:24:00 +00001231 /* Variation clean up */
1232 dm_handle_free(hanp, hlen);
1233 }
1234 }
1235
1236 /*
1237 * TEST : dm_getall_disp - NULL bufp
1238 * EXPECTED: rc = -1, errno EFAULT
1239 */
1240 if (DMVAR_EXEC(GETALL_DISP_BASE + 4)) {
1241 dm_sessid_t newsid;
1242 char buf[64];
1243 size_t rlen;
1244 void *hanp;
1245 size_t hlen;
1246
1247 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001248 if ((rc =
1249 dm_create_session(DM_NO_SESSION, szSessionInfo,
1250 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001251 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001252 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1253 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001254 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001255 } else
1256 if ((rc =
1257 dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1258 &maxEvents, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001259 dm_handle_free(hanp, hlen);
1260 dm_destroy_session(newsid);
1261 }
1262 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001263 DMLOG_PRINT(DMLVL_DEBUG,
1264 "Unable to set up variation! (errno = %d)\n",
1265 errno);
vapierd13d74b2006-02-11 07:24:00 +00001266 DMVAR_SKIP();
1267 } else {
1268 /* Variation */
1269 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL bufp)\n", szFuncName);
1270 rc = dm_getall_disp(newsid, sizeof(buf), NULL, &rlen);
subrata_modak4bb656a2009-02-26 12:02:09 +00001271 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00001272
1273 /* Variation clean up */
1274 rc = dm_destroy_session(newsid);
1275 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001276 DMLOG_PRINT(DMLVL_DEBUG,
1277 "Unable to clean up variation! (errno = %d)\n",
1278 errno);
vapierd13d74b2006-02-11 07:24:00 +00001279 }
1280 dm_handle_free(hanp, hlen);
1281 }
1282 }
1283
1284 /*
1285 * TEST : dm_getall_disp - invalid bufp
1286 * EXPECTED: rc = -1, errno EFAULT
1287 */
1288 if (DMVAR_EXEC(GETALL_DISP_BASE + 5)) {
1289 dm_sessid_t newsid;
1290 char buf[64];
1291 size_t rlen;
1292 void *hanp;
1293 size_t hlen;
1294
1295 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001296 if ((rc =
1297 dm_create_session(DM_NO_SESSION, szSessionInfo,
1298 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001299 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001300 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1301 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001302 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001303 } else
1304 if ((rc =
1305 dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1306 &maxEvents, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001307 dm_handle_free(hanp, hlen);
1308 dm_destroy_session(newsid);
1309 }
1310 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001311 DMLOG_PRINT(DMLVL_DEBUG,
1312 "Unable to set up variation! (errno = %d)\n",
1313 errno);
vapierd13d74b2006-02-11 07:24:00 +00001314 DMVAR_SKIP();
1315 } else {
1316 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001317 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
1318 szFuncName);
1319 rc = dm_getall_disp(newsid, sizeof(buf),
1320 (void *)INVALID_ADDR, &rlen);
subrata_modak4bb656a2009-02-26 12:02:09 +00001321 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00001322
1323 /* Variation clean up */
1324 rc = dm_destroy_session(newsid);
1325 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001326 DMLOG_PRINT(DMLVL_DEBUG,
1327 "Unable to clean up variation! (errno = %d)\n",
1328 errno);
vapierd13d74b2006-02-11 07:24:00 +00001329 }
1330 dm_handle_free(hanp, hlen);
1331 }
1332 }
1333
1334 /*
1335 * TEST : dm_getall_disp - NULL rlenp
1336 * EXPECTED: rc = -1, errno EFAULT
1337 */
1338 if (DMVAR_EXEC(GETALL_DISP_BASE + 6)) {
1339 dm_sessid_t newsid;
1340 char buf[64];
1341 void *hanp;
1342 size_t hlen;
1343
1344 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001345 if ((rc =
1346 dm_create_session(DM_NO_SESSION, szSessionInfo,
1347 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001348 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001349 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1350 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001351 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001352 } else
1353 if ((rc =
1354 dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1355 &maxEvents, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001356 dm_handle_free(hanp, hlen);
1357 dm_destroy_session(newsid);
1358 }
1359 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001360 DMLOG_PRINT(DMLVL_DEBUG,
1361 "Unable to set up variation! (errno = %d)\n",
1362 errno);
vapierd13d74b2006-02-11 07:24:00 +00001363 DMVAR_SKIP();
1364 } else {
1365 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001366 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL rlenp)\n",
1367 szFuncName);
vapierd13d74b2006-02-11 07:24:00 +00001368 rc = dm_getall_disp(newsid, sizeof(buf), buf, NULL);
subrata_modak4bb656a2009-02-26 12:02:09 +00001369 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00001370
1371 /* Variation clean up */
1372 rc = dm_destroy_session(newsid);
1373 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001374 DMLOG_PRINT(DMLVL_DEBUG,
1375 "Unable to clean up variation! (errno = %d)\n",
1376 errno);
vapierd13d74b2006-02-11 07:24:00 +00001377 }
1378 dm_handle_free(hanp, hlen);
1379 }
1380 }
1381
1382 /*
1383 * TEST : dm_getall_disp - invalid rlenp
1384 * EXPECTED: rc = -1, errno EFAULT
1385 */
1386 if (DMVAR_EXEC(GETALL_DISP_BASE + 7)) {
1387 dm_sessid_t newsid;
1388 char buf[64];
1389 void *hanp;
1390 size_t hlen;
1391
1392 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001393 if ((rc =
1394 dm_create_session(DM_NO_SESSION, szSessionInfo,
1395 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001396 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001397 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1398 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001399 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001400 } else
1401 if ((rc =
1402 dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1403 &maxEvents, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001404 dm_handle_free(hanp, hlen);
1405 dm_destroy_session(newsid);
1406 }
1407 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001408 DMLOG_PRINT(DMLVL_DEBUG,
1409 "Unable to set up variation! (errno = %d)\n",
1410 errno);
vapierd13d74b2006-02-11 07:24:00 +00001411 DMVAR_SKIP();
1412 } else {
1413 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001414 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
1415 szFuncName);
1416 rc = dm_getall_disp(newsid, sizeof(buf), buf,
1417 (size_t *) INVALID_ADDR);
subrata_modak4bb656a2009-02-26 12:02:09 +00001418 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00001419
1420 /* Variation clean up */
1421 rc = dm_destroy_session(newsid);
1422 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001423 DMLOG_PRINT(DMLVL_DEBUG,
1424 "Unable to clean up variation! (errno = %d)\n",
1425 errno);
vapierd13d74b2006-02-11 07:24:00 +00001426 }
1427 dm_handle_free(hanp, hlen);
1428 }
1429 }
1430
1431 /*
1432 * TEST : dm_getall_disp - zero buflen
1433 * EXPECTED: rc = -1, errno = E2BIG
1434 */
1435 if (DMVAR_EXEC(GETALL_DISP_BASE + 8)) {
1436 dm_sessid_t newsid;
1437 char buf[64];
1438 size_t rlen;
1439 void *hanp;
1440 size_t hlen;
1441
1442 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001443 if ((rc =
1444 dm_create_session(DM_NO_SESSION, szSessionInfo,
1445 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001446 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001447 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1448 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001449 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001450 } else
1451 if ((rc =
1452 dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1453 &maxEvents, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001454 dm_handle_free(hanp, hlen);
1455 dm_destroy_session(newsid);
1456 }
1457 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001458 DMLOG_PRINT(DMLVL_DEBUG,
1459 "Unable to set up variation! (errno = %d)\n",
1460 errno);
vapierd13d74b2006-02-11 07:24:00 +00001461 DMVAR_SKIP();
1462 } else {
1463 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001464 DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen zero)\n",
1465 szFuncName);
vapierd13d74b2006-02-11 07:24:00 +00001466 rc = dm_getall_disp(newsid, 0, buf, &rlen);
1467 if (rc == -1 && errno == E2BIG) {
1468 DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
1469 }
subrata_modak4bb656a2009-02-26 12:02:09 +00001470 DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
subrata_modakbdbaec52009-02-26 12:14:51 +00001471
vapierd13d74b2006-02-11 07:24:00 +00001472 /* Variation clean up */
1473 rc = dm_destroy_session(newsid);
1474 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001475 DMLOG_PRINT(DMLVL_DEBUG,
1476 "Unable to clean up variation! (errno = %d)\n",
1477 errno);
vapierd13d74b2006-02-11 07:24:00 +00001478 }
1479 dm_handle_free(hanp, hlen);
1480 }
1481 }
1482
1483 /*
1484 * TEST : dm_getall_disp - valid
1485 * EXPECTED: rc = 0
1486 */
1487 if (DMVAR_EXEC(GETALL_DISP_BASE + 9)) {
1488 dm_sessid_t newsid;
1489 char buf[64];
1490 size_t rlen;
1491 void *hanp;
1492 size_t hlen;
1493
1494 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001495 if ((rc =
1496 dm_create_session(DM_NO_SESSION, szSessionInfo,
1497 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001498 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001499 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1500 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001501 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001502 } else
1503 if ((rc =
1504 dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN,
1505 &maxEvents, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001506 dm_handle_free(hanp, hlen);
1507 dm_destroy_session(newsid);
1508 }
1509 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001510 DMLOG_PRINT(DMLVL_DEBUG,
1511 "Unable to set up variation! (errno = %d)\n",
1512 errno);
vapierd13d74b2006-02-11 07:24:00 +00001513 DMVAR_SKIP();
1514 } else {
1515 /* Variation */
1516 DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
1517 rc = dm_getall_disp(newsid, sizeof(buf), buf, &rlen);
1518 if (rc == 0) {
1519 DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001520 dm_dispinfo_t *di = (dm_dispinfo_t *) buf;
vapierd13d74b2006-02-11 07:24:00 +00001521 if (rlen == sizeof(dm_dispinfo_t) + hlen) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001522 if (dm_handle_cmp
1523 (hanp, hlen,
1524 DM_GET_VALUE(di, di_fshandle,
1525 void *),
1526 DM_GET_LEN(di,
1527 di_fshandle)) == 0) {
1528 if (di->di_eventset ==
1529 maxEvents) {
1530 DMLOG_PRINT(DMLVL_DEBUG,
1531 "%s passed with expected rc = %d\n",
1532 szFuncName,
1533 0);
vapierd13d74b2006-02-11 07:24:00 +00001534 DMVAR_PASS();
1535 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001536 DMLOG_PRINT(DMLVL_ERR,
1537 "%s failed with expected rc = %d but unexpected eventset (%llx vs %llx)\n",
1538 szFuncName,
1539 0,
1540 di->
1541 di_eventset,
1542 maxEvents);
vapierd13d74b2006-02-11 07:24:00 +00001543 DMVAR_FAIL();
1544 }
1545 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001546 DMLOG_PRINT(DMLVL_ERR,
1547 "%s failed with expected rc = %d but unexpected fs handle (%llx vs %llx)\n",
1548 szFuncName, 0,
1549 *(__u64 *) hanp,
1550 *(__u64 *)
1551 DM_GET_VALUE(di,
1552 di_fshandle,
1553 void
1554 *));
vapierd13d74b2006-02-11 07:24:00 +00001555 DMVAR_FAIL();
1556 }
1557 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001558 DMLOG_PRINT(DMLVL_ERR,
1559 "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
1560 szFuncName, 0, rlen,
1561 sizeof(dm_dispinfo_t) +
1562 hlen);
vapierd13d74b2006-02-11 07:24:00 +00001563 DMVAR_FAIL();
1564 }
1565 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001566 DMLOG_PRINT(DMLVL_ERR,
1567 "%s failed with unexpected rc = %d (errno = %d)\n",
1568 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00001569 DMVAR_FAIL();
1570 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001571
vapierd13d74b2006-02-11 07:24:00 +00001572 /* Variation clean up */
1573 rc = dm_destroy_session(newsid);
1574 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001575 DMLOG_PRINT(DMLVL_DEBUG,
1576 "Unable to clean up variation! (errno = %d)\n",
1577 errno);
vapierd13d74b2006-02-11 07:24:00 +00001578 }
1579 dm_handle_free(hanp, hlen);
1580 }
1581 }
1582
1583 szFuncName = "dm_set_eventlist";
1584
1585 /*
1586 * TEST : dm_set_eventlist - DM_NO_SESSION sid
1587 * EXPECTED: rc = -1, errno = EINVAL
1588 */
1589 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 1)) {
1590 dm_sessid_t newsid;
1591 void *hanp;
1592 size_t hlen;
1593 dm_eventset_t eventset = minEvents;
1594
1595 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001596 if ((rc =
1597 dm_create_session(DM_NO_SESSION, szSessionInfo,
1598 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001599 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001600 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1601 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001602 dm_destroy_session(newsid);
1603 }
1604 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001605 DMLOG_PRINT(DMLVL_DEBUG,
1606 "Unable to set up variation! (errno = %d)\n",
1607 errno);
vapierd13d74b2006-02-11 07:24:00 +00001608 DMVAR_SKIP();
1609 } else {
1610 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001611 DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
1612 szFuncName);
1613 rc = dm_set_eventlist(DM_NO_SESSION, hanp, hlen,
1614 DM_NO_TOKEN, &eventset,
1615 DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +00001616 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00001617
1618 /* Variation clean up */
1619 rc = dm_destroy_session(newsid);
1620 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001621 DMLOG_PRINT(DMLVL_DEBUG,
1622 "Unable to clean up variation! (errno = %d)\n",
1623 errno);
vapierd13d74b2006-02-11 07:24:00 +00001624 }
1625 dm_handle_free(hanp, hlen);
1626 }
1627 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001628
vapierd13d74b2006-02-11 07:24:00 +00001629 /*
1630 * TEST : dm_set_eventlist - invalid sid
1631 * EXPECTED: rc = -1, errno = EINVAL
1632 */
1633 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 2)) {
1634 dm_sessid_t newsid;
1635 void *hanp;
1636 size_t hlen;
1637 dm_eventset_t eventset = minEvents;
1638
1639 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001640 if ((rc =
1641 dm_create_session(DM_NO_SESSION, szSessionInfo,
1642 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001643 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001644 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1645 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001646 dm_destroy_session(newsid);
1647 }
1648 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001649 DMLOG_PRINT(DMLVL_DEBUG,
1650 "Unable to set up variation! (errno = %d)\n",
1651 errno);
vapierd13d74b2006-02-11 07:24:00 +00001652 DMVAR_SKIP();
1653 } else {
1654 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001655 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
1656 szFuncName);
1657 rc = dm_set_eventlist(INVALID_ADDR, hanp, hlen,
1658 DM_NO_TOKEN, &eventset,
1659 DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +00001660 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00001661
1662 /* Variation clean up */
1663 rc = dm_destroy_session(newsid);
1664 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001665 DMLOG_PRINT(DMLVL_DEBUG,
1666 "Unable to clean up variation! (errno = %d)\n",
1667 errno);
vapierd13d74b2006-02-11 07:24:00 +00001668 }
1669 dm_handle_free(hanp, hlen);
1670 }
1671 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001672
vapierd13d74b2006-02-11 07:24:00 +00001673 /*
1674 * TEST : dm_set_eventlist - invalid hanp
1675 * EXPECTED: rc = -1, errno = EFAULT
1676 */
1677 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 3)) {
1678 dm_sessid_t newsid;
1679 void *hanp;
1680 size_t hlen;
1681 dm_eventset_t eventset = minEvents;
1682
1683 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001684 if ((rc =
1685 dm_create_session(DM_NO_SESSION, szSessionInfo,
1686 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001687 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001688 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1689 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001690 dm_destroy_session(newsid);
1691 }
1692 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001693 DMLOG_PRINT(DMLVL_DEBUG,
1694 "Unable to set up variation! (errno = %d)\n",
1695 errno);
vapierd13d74b2006-02-11 07:24:00 +00001696 DMVAR_SKIP();
1697 } else {
1698 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001699 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
1700 szFuncName);
1701 rc = dm_set_eventlist(newsid, (void *)INVALID_ADDR,
1702 hlen, DM_NO_TOKEN, &eventset,
1703 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00001704 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1705
1706 /* Variation clean up */
1707 rc = dm_destroy_session(newsid);
1708 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001709 DMLOG_PRINT(DMLVL_DEBUG,
1710 "Unable to clean up variation! (errno = %d)\n",
1711 errno);
vapierd13d74b2006-02-11 07:24:00 +00001712 }
1713 dm_handle_free(hanp, hlen);
1714 }
1715 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001716
vapierd13d74b2006-02-11 07:24:00 +00001717 /*
1718 * TEST : dm_set_eventlist - invalid hlen
1719 * EXPECTED: rc = -1, errno = EBADF
1720 */
1721 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 4)) {
1722 dm_sessid_t newsid;
1723 void *hanp;
1724 size_t hlen;
1725 dm_eventset_t eventset = minEvents;
1726
1727 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001728 if ((rc =
1729 dm_create_session(DM_NO_SESSION, szSessionInfo,
1730 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001731 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001732 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1733 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001734 dm_destroy_session(newsid);
1735 }
1736 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001737 DMLOG_PRINT(DMLVL_DEBUG,
1738 "Unable to set up variation! (errno = %d)\n",
1739 errno);
vapierd13d74b2006-02-11 07:24:00 +00001740 DMVAR_SKIP();
1741 } else {
1742 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001743 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
1744 szFuncName);
1745 rc = dm_set_eventlist(newsid, hanp, INVALID_ADDR,
1746 DM_NO_TOKEN, &eventset,
1747 DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +00001748 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
vapierd13d74b2006-02-11 07:24:00 +00001749
1750 /* Variation clean up */
1751 rc = dm_destroy_session(newsid);
1752 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001753 DMLOG_PRINT(DMLVL_DEBUG,
1754 "Unable to clean up variation! (errno = %d)\n",
1755 errno);
vapierd13d74b2006-02-11 07:24:00 +00001756 }
1757 dm_handle_free(hanp, hlen);
1758 }
1759 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001760
vapierd13d74b2006-02-11 07:24:00 +00001761 /*
1762 * TEST : dm_set_eventlist - invalid token
1763 * EXPECTED: rc = -1, errno = EINVAL
1764 */
1765 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 5)) {
1766 dm_sessid_t newsid;
1767 void *hanp;
1768 size_t hlen;
1769 dm_eventset_t eventset = minEvents;
1770
1771 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001772 if ((rc =
1773 dm_create_session(DM_NO_SESSION, szSessionInfo,
1774 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001775 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001776 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1777 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001778 dm_destroy_session(newsid);
1779 }
1780 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001781 DMLOG_PRINT(DMLVL_DEBUG,
1782 "Unable to set up variation! (errno = %d)\n",
1783 errno);
vapierd13d74b2006-02-11 07:24:00 +00001784 DMVAR_SKIP();
1785 } else {
1786 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001787 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
1788 szFuncName);
1789 rc = dm_set_eventlist(newsid, hanp, hlen, INVALID_ADDR,
1790 &eventset, DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +00001791 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00001792
1793 /* Variation clean up */
1794 rc = dm_destroy_session(newsid);
1795 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001796 DMLOG_PRINT(DMLVL_DEBUG,
1797 "Unable to clean up variation! (errno = %d)\n",
1798 errno);
vapierd13d74b2006-02-11 07:24:00 +00001799 }
1800 dm_handle_free(hanp, hlen);
1801 }
1802 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001803
vapierd13d74b2006-02-11 07:24:00 +00001804 /*
1805 * TEST : dm_set_eventlist - invalid eventsetp
1806 * EXPECTED: rc = -1, errno = EFAULT
1807 */
1808 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 6)) {
1809 dm_sessid_t newsid;
1810 void *hanp;
1811 size_t hlen;
1812
1813 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001814 if ((rc =
1815 dm_create_session(DM_NO_SESSION, szSessionInfo,
1816 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001817 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001818 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1819 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001820 dm_destroy_session(newsid);
1821 }
1822 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001823 DMLOG_PRINT(DMLVL_DEBUG,
1824 "Unable to set up variation! (errno = %d)\n",
1825 errno);
vapierd13d74b2006-02-11 07:24:00 +00001826 DMVAR_SKIP();
1827 } else {
1828 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001829 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
1830 szFuncName);
1831 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
1832 (dm_eventset_t *) INVALID_ADDR,
1833 DM_EVENT_MAX);
subrata_modak4bb656a2009-02-26 12:02:09 +00001834 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00001835
1836 /* Variation clean up */
1837 rc = dm_destroy_session(newsid);
1838 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001839 DMLOG_PRINT(DMLVL_DEBUG,
1840 "Unable to clean up variation! (errno = %d)\n",
1841 errno);
vapierd13d74b2006-02-11 07:24:00 +00001842 }
1843 dm_handle_free(hanp, hlen);
1844 }
1845 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001846
vapierd13d74b2006-02-11 07:24:00 +00001847 /*
1848 * TEST : dm_set_eventlist - invalid maxevent
1849 * EXPECTED: rc = -1, errno = EINVAL
1850 */
1851 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 7)) {
1852 dm_sessid_t newsid;
1853 void *hanp;
1854 size_t hlen;
1855 dm_eventset_t eventset = minEvents;
1856
1857 /* Variation set up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001858 if ((rc =
1859 dm_create_session(DM_NO_SESSION, szSessionInfo,
1860 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001861 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001862 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1863 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001864 dm_destroy_session(newsid);
1865 }
1866 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001867 DMLOG_PRINT(DMLVL_DEBUG,
1868 "Unable to set up variation! (errno = %d)\n",
1869 errno);
vapierd13d74b2006-02-11 07:24:00 +00001870 DMVAR_SKIP();
1871 } else {
1872 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001873 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid maxevent)\n",
1874 szFuncName);
1875 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
1876 &eventset, DM_EVENT_MAX + 1);
subrata_modak4bb656a2009-02-26 12:02:09 +00001877 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00001878
1879 /* Variation clean up */
1880 rc = dm_destroy_session(newsid);
1881 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001882 DMLOG_PRINT(DMLVL_DEBUG,
1883 "Unable to clean up variation! (errno = %d)\n",
1884 errno);
vapierd13d74b2006-02-11 07:24:00 +00001885 }
1886 dm_handle_free(hanp, hlen);
1887 }
1888 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001889
vapierd13d74b2006-02-11 07:24:00 +00001890 /*
1891 * TEST : dm_set_eventlist - maxevent < high set event
1892 * EXPECTED: rc = 0
1893 */
1894 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 8)) {
1895 dm_sessid_t newsid;
1896 void *hanp;
1897 size_t hlen;
1898 dm_eventset_t eventset;
1899 u_int nelem;
1900
1901 /* Variation set up */
1902 DMEV_ZERO(eventset);
1903 DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001904 if ((rc =
1905 dm_create_session(DM_NO_SESSION, szSessionInfo,
1906 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001907 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001908 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1909 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001910 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001911 } else
1912 if ((rc =
1913 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
1914 &eventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001915 dm_handle_free(hanp, hlen);
1916 dm_destroy_session(newsid);
1917 }
1918 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001919 DMLOG_PRINT(DMLVL_DEBUG,
1920 "Unable to set up variation! (errno = %d)\n",
1921 errno);
vapierd13d74b2006-02-11 07:24:00 +00001922 DMVAR_SKIP();
1923 } else {
1924 /* Variation */
1925 eventset = minEvents;
Wanlong Gao354ebb42012-12-07 10:10:04 +08001926 DMLOG_PRINT(DMLVL_DEBUG,
1927 "%s(maxevent < high set event)\n",
1928 szFuncName);
1929 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
1930 &eventset, DM_EVENT_ATTRIBUTE);
vapierd13d74b2006-02-11 07:24:00 +00001931 if (rc == 0) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001932 if ((dm_get_eventlist
1933 (newsid, hanp, hlen, DM_NO_TOKEN,
1934 DM_EVENT_MAX, &eventset, &nelem) == 0)
1935 && (nelem == DM_EVENT_ATTRIBUTE + 1)
1936 &&
1937 (DMEV_ISSET(DM_EVENT_ATTRIBUTE, eventset)))
1938 {
1939 DMLOG_PRINT(DMLVL_DEBUG,
1940 "%s passed with expected rc = %d\n",
1941 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00001942 DMVAR_PASS();
1943 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001944 DMLOG_PRINT(DMLVL_ERR,
1945 "%s failed with expected rc = %d but high set event cleared\n",
1946 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00001947 DMVAR_FAIL();
1948 }
1949 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001950 DMLOG_PRINT(DMLVL_ERR,
1951 "%s failed with unexpected rc = %d (errno = %d)\n",
1952 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00001953 DMVAR_FAIL();
1954 }
1955
1956 /* Variation clean up */
1957 rc = dm_destroy_session(newsid);
1958 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001959 DMLOG_PRINT(DMLVL_DEBUG,
1960 "Unable to clean up variation! (errno = %d)\n",
1961 errno);
vapierd13d74b2006-02-11 07:24:00 +00001962 }
1963 dm_handle_free(hanp, hlen);
1964 }
1965 }
subrata_modakbdbaec52009-02-26 12:14:51 +00001966
vapierd13d74b2006-02-11 07:24:00 +00001967 /*
1968 * TEST : dm_set_eventlist - maxevent > high set event
1969 * EXPECTED: rc = 0
1970 */
1971 if (DMVAR_EXEC(SET_EVENTLIST_BASE + 9)) {
1972 dm_sessid_t newsid;
1973 void *hanp;
1974 size_t hlen;
1975 dm_eventset_t eventset;
1976 u_int nelem;
1977
1978 /* Variation set up */
1979 DMEV_ZERO(eventset);
1980 DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001981 if ((rc =
1982 dm_create_session(DM_NO_SESSION, szSessionInfo,
1983 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001984 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08001985 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
1986 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001987 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08001988 } else
1989 if ((rc =
1990 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
1991 &eventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00001992 dm_handle_free(hanp, hlen);
1993 dm_destroy_session(newsid);
1994 }
1995 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08001996 DMLOG_PRINT(DMLVL_DEBUG,
1997 "Unable to set up variation! (errno = %d)\n",
1998 errno);
vapierd13d74b2006-02-11 07:24:00 +00001999 DMVAR_SKIP();
2000 } else {
2001 /* Variation */
2002 eventset = minEvents;
Wanlong Gao354ebb42012-12-07 10:10:04 +08002003 DMLOG_PRINT(DMLVL_DEBUG,
2004 "%s(maxevent > high set event)\n",
2005 szFuncName);
2006 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2007 &eventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002008 if (rc == 0) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002009 if ((dm_get_eventlist
2010 (newsid, hanp, hlen, DM_NO_TOKEN,
2011 DM_EVENT_MAX, &eventset, &nelem) == 0)
2012 && (nelem == DM_EVENT_UNMOUNT + 1)
2013 &&
2014 (!DMEV_ISSET(DM_EVENT_ATTRIBUTE, eventset)))
2015 {
2016 DMLOG_PRINT(DMLVL_DEBUG,
2017 "%s passed with expected rc = %d\n",
2018 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00002019 DMVAR_PASS();
2020 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002021 DMLOG_PRINT(DMLVL_ERR,
2022 "%s failed with expected rc = %d but high set event still set\n",
2023 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00002024 DMVAR_FAIL();
2025 }
2026 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002027 DMLOG_PRINT(DMLVL_ERR,
2028 "%s failed with unexpected rc = %d (errno = %d)\n",
2029 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00002030 DMVAR_FAIL();
2031 }
2032
2033 /* Variation clean up */
2034 rc = dm_destroy_session(newsid);
2035 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002036 DMLOG_PRINT(DMLVL_DEBUG,
2037 "Unable to clean up variation! (errno = %d)\n",
2038 errno);
vapierd13d74b2006-02-11 07:24:00 +00002039 }
2040 dm_handle_free(hanp, hlen);
2041 }
2042 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002043
vapierd13d74b2006-02-11 07:24:00 +00002044 /*
subrata_modak4bb656a2009-02-26 12:02:09 +00002045 * Global handle dm_set_eventlist variations
vapierd13d74b2006-02-11 07:24:00 +00002046 *
2047 * This variation uncovered XFS BUG #15 (EBADF errno returned instead
Garrett Cooper2c282152010-12-16 00:55:50 -08002048 * of EINVAL)
vapierd13d74b2006-02-11 07:24:00 +00002049 */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002050 for (i = 0, varNum = SET_EVENTLIST_BASE + 10; i < DM_EVENT_MAX;
2051 i++, varNum++) {
vapierd13d74b2006-02-11 07:24:00 +00002052 if (DMVAR_EXEC(varNum)) {
2053 dm_sessid_t newsid;
2054 dm_eventset_t eventset;
2055
2056 /* Variation set up */
2057 DMEV_ZERO(eventset);
2058 DMEV_SET(i, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002059 rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
2060 &newsid);
vapierd13d74b2006-02-11 07:24:00 +00002061 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002062 DMLOG_PRINT(DMLVL_DEBUG,
2063 "Unable to set up variation! (errno = %d)\n",
2064 errno);
vapierd13d74b2006-02-11 07:24:00 +00002065 DMVAR_SKIP();
2066 } else {
2067 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002068 DMLOG_PRINT(DMLVL_DEBUG,
2069 "%s(global handle, %s)\n",
2070 szFuncName,
2071 dmimpl_validEvents[i].name);
2072 rc = dm_set_eventlist(newsid, DM_GLOBAL_HANP,
2073 DM_GLOBAL_HLEN,
2074 DM_NO_TOKEN, &eventset,
2075 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002076 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
2077
2078 /* Variation clean up */
2079 rc = dm_destroy_session(newsid);
2080 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002081 DMLOG_PRINT(DMLVL_DEBUG,
2082 "Unable to clean up variation! (errno = %d)\n",
2083 errno);
vapierd13d74b2006-02-11 07:24:00 +00002084 }
2085 }
2086 }
2087 }
2088
2089 /*
subrata_modak4bb656a2009-02-26 12:02:09 +00002090 * File system handle dm_set_eventlist variations
vapierd13d74b2006-02-11 07:24:00 +00002091 */
2092 for (i = 0; i < DM_EVENT_MAX; i++, varNum++) {
2093 if (DMVAR_EXEC(varNum)) {
2094 dm_sessid_t newsid;
2095 void *hanp;
2096 size_t hlen;
2097 dm_eventset_t eventset;
2098
2099 /* Variation set up */
2100 DMEV_ZERO(eventset);
2101 DMEV_SET(i, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002102 if ((rc =
2103 dm_create_session(DM_NO_SESSION, szSessionInfo,
2104 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002105 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002106 } else
2107 if ((rc =
2108 dm_path_to_fshandle(DummyFile, &hanp,
2109 &hlen)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002110 dm_destroy_session(newsid);
2111 }
2112 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002113 DMLOG_PRINT(DMLVL_DEBUG,
2114 "Unable to set up variation! (errno = %d)\n",
2115 errno);
vapierd13d74b2006-02-11 07:24:00 +00002116 DMVAR_SKIP();
2117 } else {
2118 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002119 DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle, %s)\n",
2120 szFuncName,
2121 dmimpl_validEvents[i].name);
2122 rc = dm_set_eventlist(newsid, hanp, hlen,
2123 DM_NO_TOKEN, &eventset,
2124 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002125 if (dmimpl_validEvents[i].bFSHandle)
2126 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
2127 else
Wanlong Gao354ebb42012-12-07 10:10:04 +08002128 DMVAR_ENDFAILEXP(szFuncName, -1, rc,
2129 EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00002130
2131 /* Variation clean up */
2132 rc = dm_destroy_session(newsid);
2133 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002134 DMLOG_PRINT(DMLVL_DEBUG,
2135 "Unable to clean up variation! (errno = %d)\n",
2136 errno);
vapierd13d74b2006-02-11 07:24:00 +00002137 }
2138 dm_handle_free(hanp, hlen);
2139 }
2140 }
2141 }
2142
2143 /*
subrata_modak4bb656a2009-02-26 12:02:09 +00002144 * Directory handle dm_set_eventlist variations
vapierd13d74b2006-02-11 07:24:00 +00002145 */
2146 for (i = 0; i < DM_EVENT_MAX; i++, varNum++) {
2147 if (DMVAR_EXEC(varNum)) {
2148 dm_sessid_t newsid;
2149 void *hanp;
2150 size_t hlen;
2151 dm_eventset_t eventset;
2152
2153 /* Variation set up */
2154 DMEV_ZERO(eventset);
2155 DMEV_SET(i, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002156 if ((rc =
2157 dm_create_session(DM_NO_SESSION, szSessionInfo,
2158 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002159 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002160 } else
2161 if ((rc =
2162 dm_path_to_handle(DummySubdir, &hanp,
2163 &hlen)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002164 dm_destroy_session(newsid);
2165 }
2166 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002167 DMLOG_PRINT(DMLVL_DEBUG,
2168 "Unable to set up variation! (errno = %d)\n",
2169 errno);
vapierd13d74b2006-02-11 07:24:00 +00002170 DMVAR_SKIP();
2171 } else {
2172 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002173 DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle, %s)\n",
2174 szFuncName,
2175 dmimpl_validEvents[i].name);
2176 rc = dm_set_eventlist(newsid, hanp, hlen,
2177 DM_NO_TOKEN, &eventset,
2178 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002179 if (dmimpl_validEvents[i].bDirHandle)
2180 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
2181 else
Wanlong Gao354ebb42012-12-07 10:10:04 +08002182 DMVAR_ENDFAILEXP(szFuncName, -1, rc,
2183 EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00002184
2185 /* Variation clean up */
2186 rc = dm_destroy_session(newsid);
2187 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002188 DMLOG_PRINT(DMLVL_DEBUG,
2189 "Unable to clean up variation! (errno = %d)\n",
2190 errno);
vapierd13d74b2006-02-11 07:24:00 +00002191 }
2192 dm_handle_free(hanp, hlen);
2193 }
2194 }
2195 }
2196
2197 /*
subrata_modak4bb656a2009-02-26 12:02:09 +00002198 * File handle dm_set_eventlist variations
vapierd13d74b2006-02-11 07:24:00 +00002199 */
2200 for (i = 0; i < DM_EVENT_MAX; i++, varNum++) {
2201 if (DMVAR_EXEC(varNum)) {
2202 dm_sessid_t newsid;
2203 void *hanp;
2204 size_t hlen;
2205 dm_eventset_t eventset;
2206
2207 /* Variation set up */
2208 DMEV_ZERO(eventset);
2209 DMEV_SET(i, eventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002210 if ((rc =
2211 dm_create_session(DM_NO_SESSION, szSessionInfo,
2212 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002213 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002214 } else
2215 if ((rc =
2216 dm_path_to_handle(DummyFile, &hanp,
2217 &hlen)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002218 dm_destroy_session(newsid);
2219 }
2220 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002221 DMLOG_PRINT(DMLVL_DEBUG,
2222 "Unable to set up variation! (errno = %d)\n",
2223 errno);
vapierd13d74b2006-02-11 07:24:00 +00002224 DMVAR_SKIP();
2225 } else {
2226 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002227 DMLOG_PRINT(DMLVL_DEBUG,
2228 "%s(file handle, %s)\n", szFuncName,
2229 dmimpl_validEvents[i].name);
2230 rc = dm_set_eventlist(newsid, hanp, hlen,
2231 DM_NO_TOKEN, &eventset,
2232 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002233 if (dmimpl_validEvents[i].bFileHandle)
2234 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
2235 else
Wanlong Gao354ebb42012-12-07 10:10:04 +08002236 DMVAR_ENDFAILEXP(szFuncName, -1, rc,
2237 EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00002238
2239 /* Variation clean up */
2240 rc = dm_destroy_session(newsid);
2241 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002242 DMLOG_PRINT(DMLVL_DEBUG,
2243 "Unable to clean up variation! (errno = %d)\n",
2244 errno);
vapierd13d74b2006-02-11 07:24:00 +00002245 }
2246 dm_handle_free(hanp, hlen);
2247 }
2248 }
2249 }
2250
2251 szFuncName = "dm_get_eventlist";
2252
2253 /*
2254 * TEST : dm_get_eventlist - DM_NO_SESSION sid
2255 * EXPECTED: rc = -1, errno = EINVAL
2256 */
2257 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 1)) {
2258 dm_sessid_t newsid;
2259 void *hanp;
2260 size_t hlen;
2261 dm_eventset_t ineventset, outeventset;
2262 u_int nelem;
2263
2264 /* Variation set up */
2265 DMEV_ZERO(ineventset);
2266 DMEV_ZERO(outeventset);
2267 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002268 if ((rc =
2269 dm_create_session(DM_NO_SESSION, szSessionInfo,
2270 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002271 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002272 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2273 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002274 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002275 } else
2276 if ((rc =
2277 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2278 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002279 dm_handle_free(hanp, hlen);
2280 dm_destroy_session(newsid);
2281 }
2282 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002283 DMLOG_PRINT(DMLVL_DEBUG,
2284 "Unable to set up variation! (errno = %d)\n",
2285 errno);
vapierd13d74b2006-02-11 07:24:00 +00002286 DMVAR_SKIP();
2287 } else {
2288 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002289 DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
2290 szFuncName);
2291 rc = dm_get_eventlist(DM_NO_SESSION, hanp, hlen,
2292 DM_NO_TOKEN, DM_EVENT_MAX,
2293 &outeventset, &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +00002294 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00002295
2296 /* Variation clean up */
2297 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002298 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2299 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002300 rc |= dm_destroy_session(newsid);
2301 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002302 DMLOG_PRINT(DMLVL_DEBUG,
2303 "Unable to clean up variation! (errno = %d)\n",
2304 errno);
vapierd13d74b2006-02-11 07:24:00 +00002305 }
2306 dm_handle_free(hanp, hlen);
2307 }
2308 }
2309
2310 /*
2311 * TEST : dm_get_eventlist - invalid sid
2312 * EXPECTED: rc = -1, errno = EINVAL
2313 */
2314 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 2)) {
2315 dm_sessid_t newsid;
2316 void *hanp;
2317 size_t hlen;
2318 dm_eventset_t ineventset, outeventset;
2319 u_int nelem;
2320
2321 /* Variation set up */
2322 DMEV_ZERO(ineventset);
2323 DMEV_ZERO(outeventset);
2324 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002325 if ((rc =
2326 dm_create_session(DM_NO_SESSION, szSessionInfo,
2327 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002328 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002329 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2330 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002331 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002332 } else
2333 if ((rc =
2334 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2335 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002336 dm_handle_free(hanp, hlen);
2337 dm_destroy_session(newsid);
2338 }
2339 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002340 DMLOG_PRINT(DMLVL_DEBUG,
2341 "Unable to set up variation! (errno = %d)\n",
2342 errno);
vapierd13d74b2006-02-11 07:24:00 +00002343 DMVAR_SKIP();
2344 } else {
2345 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002346 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
2347 szFuncName);
2348 rc = dm_get_eventlist(INVALID_ADDR, hanp, hlen,
2349 DM_NO_TOKEN, DM_EVENT_MAX,
2350 &outeventset, &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +00002351 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00002352
2353 /* Variation clean up */
2354 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002355 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2356 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002357 rc |= dm_destroy_session(newsid);
2358 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002359 DMLOG_PRINT(DMLVL_DEBUG,
2360 "Unable to clean up variation! (errno = %d)\n",
2361 errno);
vapierd13d74b2006-02-11 07:24:00 +00002362 }
2363 dm_handle_free(hanp, hlen);
2364 }
2365 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002366
vapierd13d74b2006-02-11 07:24:00 +00002367 /*
2368 * TEST : dm_get_eventlist - invalid hanp
2369 * EXPECTED: rc = -1, errno = EFAULT
2370 */
2371 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 3)) {
2372 dm_sessid_t newsid;
2373 void *hanp;
2374 size_t hlen;
2375 dm_eventset_t ineventset, outeventset;
2376 u_int nelem;
2377
2378 /* Variation set up */
2379 DMEV_ZERO(ineventset);
2380 DMEV_ZERO(outeventset);
2381 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002382 if ((rc =
2383 dm_create_session(DM_NO_SESSION, szSessionInfo,
2384 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002385 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002386 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2387 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002388 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002389 } else
2390 if ((rc =
2391 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2392 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002393 dm_handle_free(hanp, hlen);
2394 dm_destroy_session(newsid);
2395 }
2396 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002397 DMLOG_PRINT(DMLVL_DEBUG,
2398 "Unable to set up variation! (errno = %d)\n",
2399 errno);
vapierd13d74b2006-02-11 07:24:00 +00002400 DMVAR_SKIP();
2401 } else {
2402 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002403 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
2404 szFuncName);
2405 rc = dm_get_eventlist(newsid, (void *)INVALID_ADDR,
2406 hlen, DM_NO_TOKEN, DM_EVENT_MAX,
2407 &outeventset, &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +00002408 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00002409
2410 /* Variation clean up */
2411 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002412 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2413 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002414 rc |= dm_destroy_session(newsid);
2415 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002416 DMLOG_PRINT(DMLVL_DEBUG,
2417 "Unable to clean up variation! (errno = %d)\n",
2418 errno);
vapierd13d74b2006-02-11 07:24:00 +00002419 }
2420 dm_handle_free(hanp, hlen);
2421 }
2422 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002423
vapierd13d74b2006-02-11 07:24:00 +00002424 /*
2425 * TEST : dm_get_eventlist - invalid hlen
2426 * EXPECTED: rc = -1, errno = EBADF
2427 */
2428 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 4)) {
2429 dm_sessid_t newsid;
2430 void *hanp;
2431 size_t hlen;
2432 dm_eventset_t ineventset, outeventset;
2433 u_int nelem;
2434
2435 /* Variation set up */
2436 DMEV_ZERO(ineventset);
2437 DMEV_ZERO(outeventset);
2438 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002439 if ((rc =
2440 dm_create_session(DM_NO_SESSION, szSessionInfo,
2441 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002442 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002443 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2444 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002445 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002446 } else
2447 if ((rc =
2448 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2449 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002450 dm_handle_free(hanp, hlen);
2451 dm_destroy_session(newsid);
2452 }
2453 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002454 DMLOG_PRINT(DMLVL_DEBUG,
2455 "Unable to set up variation! (errno = %d)\n",
2456 errno);
vapierd13d74b2006-02-11 07:24:00 +00002457 DMVAR_SKIP();
2458 } else {
2459 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002460 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
2461 szFuncName);
2462 rc = dm_get_eventlist(newsid, hanp, INVALID_ADDR,
2463 DM_NO_TOKEN, DM_EVENT_MAX,
2464 &outeventset, &nelem);
vapierd13d74b2006-02-11 07:24:00 +00002465 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
2466
2467 /* Variation clean up */
2468 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002469 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2470 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002471 rc |= dm_destroy_session(newsid);
2472 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002473 DMLOG_PRINT(DMLVL_DEBUG,
2474 "Unable to clean up variation! (errno = %d)\n",
2475 errno);
vapierd13d74b2006-02-11 07:24:00 +00002476 }
2477 dm_handle_free(hanp, hlen);
2478 }
2479 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002480
vapierd13d74b2006-02-11 07:24:00 +00002481 /*
2482 * TEST : dm_get_eventlist - invalid token
2483 * EXPECTED: rc = -1, errno = EINVAL
2484 */
2485 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 5)) {
2486 dm_sessid_t newsid;
2487 void *hanp;
2488 size_t hlen;
2489 dm_eventset_t ineventset, outeventset;
2490 u_int nelem;
2491
2492 /* Variation set up */
2493 DMEV_ZERO(ineventset);
2494 DMEV_ZERO(outeventset);
2495 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002496 if ((rc =
2497 dm_create_session(DM_NO_SESSION, szSessionInfo,
2498 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002499 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002500 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2501 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002502 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002503 } else
2504 if ((rc =
2505 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2506 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002507 dm_handle_free(hanp, hlen);
2508 dm_destroy_session(newsid);
2509 }
2510 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002511 DMLOG_PRINT(DMLVL_DEBUG,
2512 "Unable to set up variation! (errno = %d)\n",
2513 errno);
vapierd13d74b2006-02-11 07:24:00 +00002514 DMVAR_SKIP();
2515 } else {
2516 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002517 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
2518 szFuncName);
2519 rc = dm_get_eventlist(newsid, hanp, hlen, INVALID_ADDR,
2520 DM_EVENT_MAX, &outeventset,
2521 &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +00002522 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00002523
2524 /* Variation clean up */
2525 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002526 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2527 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002528 rc |= dm_destroy_session(newsid);
2529 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002530 DMLOG_PRINT(DMLVL_DEBUG,
2531 "Unable to clean up variation! (errno = %d)\n",
2532 errno);
vapierd13d74b2006-02-11 07:24:00 +00002533 }
2534 dm_handle_free(hanp, hlen);
2535 }
2536 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002537
vapierd13d74b2006-02-11 07:24:00 +00002538 /*
2539 * TEST : dm_get_eventlist - directory handle
2540 * EXPECTED: rc = -1, errno = EINVAL
2541 *
2542 * This variation uncovered XFS BUG #16 (0 returned instead of -1 and
Garrett Cooper2c282152010-12-16 00:55:50 -08002543 * errno EINVAL)
vapierd13d74b2006-02-11 07:24:00 +00002544 */
2545 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 6)) {
2546 dm_sessid_t newsid;
2547 void *hanp;
2548 size_t hlen;
2549 dm_eventset_t ineventset, outeventset;
2550 u_int nelem;
2551
2552 /* Variation set up */
2553 DMEV_ZERO(ineventset);
2554 DMEV_ZERO(outeventset);
2555 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002556 if ((rc =
2557 dm_create_session(DM_NO_SESSION, szSessionInfo,
2558 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002559 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002560 } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen))
2561 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002562 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002563 } else
2564 if ((rc =
2565 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2566 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002567 dm_handle_free(hanp, hlen);
2568 dm_destroy_session(newsid);
2569 }
2570 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002571 DMLOG_PRINT(DMLVL_DEBUG,
2572 "Unable to set up variation! (errno = %d)\n",
2573 errno);
vapierd13d74b2006-02-11 07:24:00 +00002574 DMVAR_SKIP();
2575 } else {
2576 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002577 DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
2578 szFuncName);
2579 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2580 DM_EVENT_MAX, &outeventset,
2581 &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +00002582 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
vapierd13d74b2006-02-11 07:24:00 +00002583
2584 /* Variation clean up */
2585 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002586 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2587 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002588 rc |= dm_destroy_session(newsid);
2589 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002590 DMLOG_PRINT(DMLVL_DEBUG,
2591 "Unable to clean up variation! (errno = %d)\n",
2592 errno);
vapierd13d74b2006-02-11 07:24:00 +00002593 }
2594 dm_handle_free(hanp, hlen);
2595 }
2596 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002597
vapierd13d74b2006-02-11 07:24:00 +00002598 /*
2599 * TEST : dm_get_eventlist - invalid nelem, fs handle
2600 * EXPECTED: rc = -1, errno = E2BIG
2601 *
2602 * This variation uncovered XFS BUG #17 (EINVAL errno returned instead
Garrett Cooper2c282152010-12-16 00:55:50 -08002603 * of E2BIG, nelemp not updated)
vapierd13d74b2006-02-11 07:24:00 +00002604 */
2605 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 7)) {
2606 dm_sessid_t newsid;
2607 void *hanp;
2608 size_t hlen;
2609 dm_eventset_t ineventset, outeventset;
2610 u_int nelem;
2611
2612 /* Variation set up */
2613 DMEV_ZERO(ineventset);
2614 DMEV_ZERO(outeventset);
2615 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002616 if ((rc =
2617 dm_create_session(DM_NO_SESSION, szSessionInfo,
2618 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002619 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002620 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2621 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002622 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002623 } else
2624 if ((rc =
2625 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2626 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002627 dm_handle_free(hanp, hlen);
2628 dm_destroy_session(newsid);
2629 }
2630 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002631 DMLOG_PRINT(DMLVL_DEBUG,
2632 "Unable to set up variation! (errno = %d)\n",
2633 errno);
vapierd13d74b2006-02-11 07:24:00 +00002634 DMVAR_SKIP();
2635 } else {
2636 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002637 DMLOG_PRINT(DMLVL_DEBUG,
2638 "%s(invalid nelem, fs handle)\n",
2639 szFuncName);
2640 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2641 0, &outeventset, &nelem);
vapierd13d74b2006-02-11 07:24:00 +00002642 if (rc == -1) {
2643 if (errno == E2BIG) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002644 if (nelem == DM_EVENT_ATTRIBUTE + 1) {
2645 DMLOG_PRINT(DMLVL_DEBUG,
2646 "%s passed with expected rc = %d and expected errno = %d (nelem = %d)\n",
2647 szFuncName, rc,
2648 errno, nelem);
vapierd13d74b2006-02-11 07:24:00 +00002649 DMVAR_PASS();
2650 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002651 DMLOG_PRINT(DMLVL_ERR,
2652 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
2653 szFuncName, rc,
2654 nelem,
2655 DM_EVENT_ATTRIBUTE +
2656 1);
vapierd13d74b2006-02-11 07:24:00 +00002657 DMVAR_FAIL();
2658 }
2659 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002660 DMLOG_PRINT(DMLVL_ERR,
2661 "%s failed with expected rc = %d but unexpected errno = %d\n",
2662 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00002663 DMVAR_FAIL();
2664 }
2665 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002666 DMLOG_PRINT(DMLVL_ERR,
2667 "%s failed with unexpected rc = %d\n",
2668 szFuncName, rc);
vapierd13d74b2006-02-11 07:24:00 +00002669 DMVAR_FAIL();
2670 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002671
vapierd13d74b2006-02-11 07:24:00 +00002672 /* Variation clean up */
2673 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002674 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2675 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002676 rc |= dm_destroy_session(newsid);
2677 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002678 DMLOG_PRINT(DMLVL_DEBUG,
2679 "Unable to clean up variation! (errno = %d)\n",
2680 errno);
vapierd13d74b2006-02-11 07:24:00 +00002681 }
2682 dm_handle_free(hanp, hlen);
2683 }
2684 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002685
vapierd13d74b2006-02-11 07:24:00 +00002686 /*
2687 * TEST : dm_get_eventlist - invalid nelem, file handle
2688 * EXPECTED: rc = -1, errno = E2BIG
2689 */
2690 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 8)) {
2691 dm_sessid_t newsid;
2692 void *hanp;
2693 size_t hlen;
2694 dm_eventset_t ineventset, outeventset;
2695 u_int nelem;
2696
2697 /* Variation set up */
2698 DMEV_ZERO(ineventset);
2699 DMEV_ZERO(outeventset);
2700 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002701 if ((rc =
2702 dm_create_session(DM_NO_SESSION, szSessionInfo,
2703 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002704 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002705 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
2706 -1) {
vapierd13d74b2006-02-11 07:24:00 +00002707 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002708 } else
2709 if ((rc =
2710 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2711 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002712 dm_handle_free(hanp, hlen);
2713 dm_destroy_session(newsid);
2714 }
2715 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002716 DMLOG_PRINT(DMLVL_DEBUG,
2717 "Unable to set up variation! (errno = %d)\n",
2718 errno);
vapierd13d74b2006-02-11 07:24:00 +00002719 DMVAR_SKIP();
2720 } else {
2721 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002722 DMLOG_PRINT(DMLVL_DEBUG,
2723 "%s(invalid nelem, file handle)\n",
2724 szFuncName);
2725 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2726 0, &outeventset, &nelem);
vapierd13d74b2006-02-11 07:24:00 +00002727 if (rc == -1) {
2728 if (errno == E2BIG) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002729 if (nelem == DM_EVENT_ATTRIBUTE + 1) {
2730 DMLOG_PRINT(DMLVL_DEBUG,
2731 "%s passed with expected rc = %d and expected errno = %d (nelem = %d)\n",
2732 szFuncName, rc,
2733 errno, nelem);
vapierd13d74b2006-02-11 07:24:00 +00002734 DMVAR_PASS();
2735 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002736 DMLOG_PRINT(DMLVL_ERR,
2737 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
2738 szFuncName, rc,
2739 nelem,
2740 DM_EVENT_ATTRIBUTE +
2741 1);
vapierd13d74b2006-02-11 07:24:00 +00002742 DMVAR_FAIL();
2743 }
2744 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002745 DMLOG_PRINT(DMLVL_ERR,
2746 "%s failed with expected rc = %d but unexpected errno = %d\n",
2747 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00002748 DMVAR_FAIL();
2749 }
2750 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002751 DMLOG_PRINT(DMLVL_ERR,
2752 "%s failed with unexpected rc = %d\n",
2753 szFuncName, rc);
vapierd13d74b2006-02-11 07:24:00 +00002754 DMVAR_FAIL();
2755 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002756
vapierd13d74b2006-02-11 07:24:00 +00002757 /* Variation clean up */
2758 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002759 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2760 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002761 rc |= dm_destroy_session(newsid);
2762 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002763 DMLOG_PRINT(DMLVL_DEBUG,
2764 "Unable to clean up variation! (errno = %d)\n",
2765 errno);
vapierd13d74b2006-02-11 07:24:00 +00002766 }
2767 dm_handle_free(hanp, hlen);
2768 }
2769 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002770
vapierd13d74b2006-02-11 07:24:00 +00002771 /*
2772 * TEST : dm_get_eventlist - invalid eventsetp
2773 * EXPECTED: rc = -1, errno = EFAULT
2774 */
2775 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 9)) {
2776 dm_sessid_t newsid;
2777 void *hanp;
2778 size_t hlen;
2779 dm_eventset_t ineventset, outeventset;
2780 u_int nelem;
2781
2782 /* Variation set up */
2783 DMEV_ZERO(ineventset);
2784 DMEV_ZERO(outeventset);
2785 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002786 if ((rc =
2787 dm_create_session(DM_NO_SESSION, szSessionInfo,
2788 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002789 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002790 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2791 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002792 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002793 } else
2794 if ((rc =
2795 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2796 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002797 dm_handle_free(hanp, hlen);
2798 dm_destroy_session(newsid);
2799 }
2800 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002801 DMLOG_PRINT(DMLVL_DEBUG,
2802 "Unable to set up variation! (errno = %d)\n",
2803 errno);
vapierd13d74b2006-02-11 07:24:00 +00002804 DMVAR_SKIP();
2805 } else {
2806 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002807 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid eventsetp)\n",
2808 szFuncName);
2809 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2810 DM_EVENT_MAX,
2811 (dm_eventset_t *) INVALID_ADDR,
2812 &nelem);
subrata_modak4bb656a2009-02-26 12:02:09 +00002813 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00002814
2815 /* Variation clean up */
2816 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002817 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2818 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002819 rc |= dm_destroy_session(newsid);
2820 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002821 DMLOG_PRINT(DMLVL_DEBUG,
2822 "Unable to clean up variation! (errno = %d)\n",
2823 errno);
vapierd13d74b2006-02-11 07:24:00 +00002824 }
2825 dm_handle_free(hanp, hlen);
2826 }
2827 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002828
vapierd13d74b2006-02-11 07:24:00 +00002829 /*
2830 * TEST : dm_get_eventlist - invalid nelemp
2831 * EXPECTED: rc = -1, errno = EFAULT
2832 */
2833 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 10)) {
2834 dm_sessid_t newsid;
2835 void *hanp;
2836 size_t hlen;
2837 dm_eventset_t ineventset, outeventset;
2838
2839 /* Variation set up */
2840 DMEV_ZERO(ineventset);
2841 DMEV_ZERO(outeventset);
2842 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002843 if ((rc =
2844 dm_create_session(DM_NO_SESSION, szSessionInfo,
2845 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002846 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002847 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2848 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002849 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002850 } else
2851 if ((rc =
2852 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2853 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002854 dm_handle_free(hanp, hlen);
2855 dm_destroy_session(newsid);
2856 }
2857 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002858 DMLOG_PRINT(DMLVL_DEBUG,
2859 "Unable to set up variation! (errno = %d)\n",
2860 errno);
vapierd13d74b2006-02-11 07:24:00 +00002861 DMVAR_SKIP();
2862 } else {
2863 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002864 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
2865 szFuncName);
2866 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2867 DM_EVENT_MAX, &outeventset,
2868 (u_int *) INVALID_ADDR);
subrata_modak4bb656a2009-02-26 12:02:09 +00002869 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
vapierd13d74b2006-02-11 07:24:00 +00002870
2871 /* Variation clean up */
2872 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002873 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2874 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00002875 rc |= dm_destroy_session(newsid);
2876 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002877 DMLOG_PRINT(DMLVL_DEBUG,
2878 "Unable to clean up variation! (errno = %d)\n",
2879 errno);
vapierd13d74b2006-02-11 07:24:00 +00002880 }
2881 dm_handle_free(hanp, hlen);
2882 }
2883 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002884
vapierd13d74b2006-02-11 07:24:00 +00002885 /*
2886 * TEST : dm_get_eventlist - zero event, fs handle
2887 * EXPECTED: rc = 0
2888 */
2889 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 11)) {
2890 dm_sessid_t newsid;
2891 void *hanp;
2892 size_t hlen;
2893 dm_eventset_t ineventset, outeventset;
2894 u_int nelem;
2895
2896 /* Variation set up */
2897 DMEV_ZERO(ineventset);
2898 DMEV_ZERO(outeventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002899 if ((rc =
2900 dm_create_session(DM_NO_SESSION, szSessionInfo,
2901 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002902 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002903 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
2904 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002905 dm_destroy_session(newsid);
2906 }
2907 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002908 DMLOG_PRINT(DMLVL_DEBUG,
2909 "Unable to set up variation! (errno = %d)\n",
2910 errno);
vapierd13d74b2006-02-11 07:24:00 +00002911 DMVAR_SKIP();
2912 } else {
2913 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002914 DMLOG_PRINT(DMLVL_DEBUG, "%s(zero event, fs handle)\n",
2915 szFuncName);
2916 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2917 DM_EVENT_MAX, &outeventset,
2918 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00002919 if (rc == 0) {
2920 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
2921 if (nelem == 0) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002922 if (memcmp
2923 (&ineventset, &outeventset,
2924 sizeof(dm_eventset_t)) == 0) {
2925 DMLOG_PRINT(DMLVL_DEBUG,
2926 "%s passed with expected rc = %d\n",
2927 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00002928 DMVAR_PASS();
2929 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002930 DMLOG_PRINT(DMLVL_ERR,
2931 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
2932 szFuncName, 0,
2933 ineventset,
2934 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00002935 DMVAR_FAIL();
2936 }
2937 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002938 DMLOG_PRINT(DMLVL_ERR,
2939 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
2940 szFuncName, 0, nelem, 0);
vapierd13d74b2006-02-11 07:24:00 +00002941 DMVAR_FAIL();
2942 }
2943 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002944 DMLOG_PRINT(DMLVL_ERR,
2945 "%s failed with unexpected rc = %d (errno = %d)\n",
2946 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00002947 DMVAR_FAIL();
2948 }
2949
2950 /* Variation clean up */
2951 rc = dm_destroy_session(newsid);
2952 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002953 DMLOG_PRINT(DMLVL_DEBUG,
2954 "Unable to clean up variation! (errno = %d)\n",
2955 errno);
vapierd13d74b2006-02-11 07:24:00 +00002956 }
2957 dm_handle_free(hanp, hlen);
2958 }
2959 }
subrata_modakbdbaec52009-02-26 12:14:51 +00002960
vapierd13d74b2006-02-11 07:24:00 +00002961 /*
2962 * TEST : dm_get_eventlist - zero event, file handle
2963 * EXPECTED: rc = 0
2964 */
2965 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 12)) {
2966 dm_sessid_t newsid;
2967 void *hanp;
2968 size_t hlen;
2969 dm_eventset_t ineventset, outeventset;
2970 u_int nelem;
2971
2972 /* Variation set up */
2973 DMEV_ZERO(ineventset);
2974 DMEV_ZERO(outeventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08002975 if ((rc =
2976 dm_create_session(DM_NO_SESSION, szSessionInfo,
2977 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00002978 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002979 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
2980 -1) {
vapierd13d74b2006-02-11 07:24:00 +00002981 dm_destroy_session(newsid);
2982 }
2983 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002984 DMLOG_PRINT(DMLVL_DEBUG,
2985 "Unable to set up variation! (errno = %d)\n",
2986 errno);
vapierd13d74b2006-02-11 07:24:00 +00002987 DMVAR_SKIP();
2988 } else {
2989 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08002990 DMLOG_PRINT(DMLVL_DEBUG,
2991 "%s(zero event, file handle)\n",
2992 szFuncName);
2993 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
2994 DM_EVENT_MAX, &outeventset,
2995 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00002996 if (rc == 0) {
2997 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
2998 if (nelem == 0) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08002999 if (memcmp
3000 (&ineventset, &outeventset,
3001 sizeof(dm_eventset_t)) == 0) {
3002 DMLOG_PRINT(DMLVL_DEBUG,
3003 "%s passed with expected rc = %d\n",
3004 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003005 DMVAR_PASS();
3006 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003007 DMLOG_PRINT(DMLVL_ERR,
3008 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3009 szFuncName, 0,
3010 ineventset,
3011 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003012 DMVAR_FAIL();
3013 }
3014 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003015 DMLOG_PRINT(DMLVL_ERR,
3016 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3017 szFuncName, 0, nelem, 0);
vapierd13d74b2006-02-11 07:24:00 +00003018 DMVAR_FAIL();
3019 }
3020 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003021 DMLOG_PRINT(DMLVL_ERR,
3022 "%s failed with unexpected rc = %d (errno = %d)\n",
3023 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003024 DMVAR_FAIL();
3025 }
3026
3027 /* Variation clean up */
3028 rc = dm_destroy_session(newsid);
3029 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003030 DMLOG_PRINT(DMLVL_DEBUG,
3031 "Unable to clean up variation! (errno = %d)\n",
3032 errno);
vapierd13d74b2006-02-11 07:24:00 +00003033 }
3034 dm_handle_free(hanp, hlen);
3035 }
3036 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003037
vapierd13d74b2006-02-11 07:24:00 +00003038 /*
3039 * TEST : dm_get_eventlist - one event, fs handle
3040 * EXPECTED: rc = 0
3041 */
3042 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 13)) {
3043 dm_sessid_t newsid;
3044 void *hanp;
3045 size_t hlen;
3046 dm_eventset_t ineventset, outeventset;
3047 u_int nelem;
3048
3049 /* Variation set up */
3050 DMEV_ZERO(ineventset);
3051 DMEV_ZERO(outeventset);
3052 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003053 if ((rc =
3054 dm_create_session(DM_NO_SESSION, szSessionInfo,
3055 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003056 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003057 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
3058 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003059 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003060 } else
3061 if ((rc =
3062 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3063 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003064 dm_handle_free(hanp, hlen);
3065 dm_destroy_session(newsid);
3066 }
3067 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003068 DMLOG_PRINT(DMLVL_DEBUG,
3069 "Unable to set up variation! (errno = %d)\n",
3070 errno);
vapierd13d74b2006-02-11 07:24:00 +00003071 DMVAR_SKIP();
3072 } else {
3073 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003074 DMLOG_PRINT(DMLVL_DEBUG, "%s(one event, fs handle)\n",
3075 szFuncName);
3076 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3077 DM_EVENT_MAX, &outeventset,
3078 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003079 if (rc == 0) {
3080 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003081 if (nelem == DM_EVENT_ATTRIBUTE + 1) {
3082 if (memcmp
3083 (&ineventset, &outeventset,
3084 sizeof(dm_eventset_t)) == 0) {
3085 DMLOG_PRINT(DMLVL_DEBUG,
3086 "%s passed with expected rc = %d\n",
3087 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003088 DMVAR_PASS();
3089 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003090 DMLOG_PRINT(DMLVL_ERR,
3091 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3092 szFuncName, 0,
3093 ineventset,
3094 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003095 DMVAR_FAIL();
3096 }
3097 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003098 DMLOG_PRINT(DMLVL_ERR,
3099 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3100 szFuncName, 0, nelem,
3101 DM_EVENT_ATTRIBUTE + 1);
vapierd13d74b2006-02-11 07:24:00 +00003102 DMVAR_FAIL();
3103 }
3104 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003105 DMLOG_PRINT(DMLVL_ERR,
3106 "%s failed with unexpected rc = %d (errno = %d)\n",
3107 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003108 DMVAR_FAIL();
3109 }
3110
3111 /* Variation clean up */
3112 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003113 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3114 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003115 rc |= dm_destroy_session(newsid);
3116 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003117 DMLOG_PRINT(DMLVL_DEBUG,
3118 "Unable to clean up variation! (errno = %d)\n",
3119 errno);
vapierd13d74b2006-02-11 07:24:00 +00003120 }
3121 dm_handle_free(hanp, hlen);
3122 }
3123 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003124
vapierd13d74b2006-02-11 07:24:00 +00003125 /*
3126 * TEST : dm_get_eventlist - one event, file handle
3127 * EXPECTED: rc = 0
3128 */
3129 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 14)) {
3130 dm_sessid_t newsid;
3131 void *hanp;
3132 size_t hlen;
3133 dm_eventset_t ineventset, outeventset;
3134 u_int nelem;
3135
3136 /* Variation set up */
3137 DMEV_ZERO(ineventset);
3138 DMEV_ZERO(outeventset);
3139 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003140 if ((rc =
3141 dm_create_session(DM_NO_SESSION, szSessionInfo,
3142 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003143 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003144 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
3145 -1) {
vapierd13d74b2006-02-11 07:24:00 +00003146 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003147 } else
3148 if ((rc =
3149 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3150 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003151 dm_handle_free(hanp, hlen);
3152 dm_destroy_session(newsid);
3153 }
3154 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003155 DMLOG_PRINT(DMLVL_DEBUG,
3156 "Unable to set up variation! (errno = %d)\n",
3157 errno);
vapierd13d74b2006-02-11 07:24:00 +00003158 DMVAR_SKIP();
3159 } else {
3160 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003161 DMLOG_PRINT(DMLVL_DEBUG, "%s(one event, file handle)\n",
3162 szFuncName);
3163 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3164 DM_EVENT_MAX, &outeventset,
3165 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003166 if (rc == 0) {
3167 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003168 if (nelem == DM_EVENT_ATTRIBUTE + 1) {
3169 if (memcmp
3170 (&ineventset, &outeventset,
3171 sizeof(dm_eventset_t)) == 0) {
3172 DMLOG_PRINT(DMLVL_DEBUG,
3173 "%s passed with expected rc = %d\n",
3174 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003175 DMVAR_PASS();
3176 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003177 DMLOG_PRINT(DMLVL_ERR,
3178 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3179 szFuncName, 0,
3180 ineventset,
3181 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003182 DMVAR_FAIL();
3183 }
3184 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003185 DMLOG_PRINT(DMLVL_ERR,
3186 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3187 szFuncName, 0, nelem,
3188 DM_EVENT_ATTRIBUTE + 1);
vapierd13d74b2006-02-11 07:24:00 +00003189 DMVAR_FAIL();
3190 }
3191 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003192 DMLOG_PRINT(DMLVL_ERR,
3193 "%s failed with unexpected rc = %d (errno = %d)\n",
3194 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003195 DMVAR_FAIL();
3196 }
3197
3198 /* Variation clean up */
3199 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003200 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3201 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003202 rc |= dm_destroy_session(newsid);
3203 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003204 DMLOG_PRINT(DMLVL_DEBUG,
3205 "Unable to clean up variation! (errno = %d)\n",
3206 errno);
vapierd13d74b2006-02-11 07:24:00 +00003207 }
3208 dm_handle_free(hanp, hlen);
3209 }
3210 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003211
vapierd13d74b2006-02-11 07:24:00 +00003212 /*
3213 * TEST : dm_get_eventlist - multi event, fs handle
3214 * EXPECTED: rc = 0
3215 */
3216 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 15)) {
3217 dm_sessid_t newsid;
3218 void *hanp;
3219 size_t hlen;
3220 dm_eventset_t ineventset, outeventset;
3221 u_int nelem;
3222
3223 /* Variation set up */
3224 DMEV_ZERO(ineventset);
3225 DMEV_ZERO(outeventset);
3226 DMEV_SET(DM_EVENT_CLOSE, ineventset);
3227 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
3228 DMEV_SET(DM_EVENT_DESTROY, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003229 if ((rc =
3230 dm_create_session(DM_NO_SESSION, szSessionInfo,
3231 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003232 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003233 } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen))
3234 == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003235 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003236 } else
3237 if ((rc =
3238 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3239 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003240 dm_handle_free(hanp, hlen);
3241 dm_destroy_session(newsid);
3242 }
3243 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003244 DMLOG_PRINT(DMLVL_DEBUG,
3245 "Unable to set up variation! (errno = %d)\n",
3246 errno);
vapierd13d74b2006-02-11 07:24:00 +00003247 DMVAR_SKIP();
3248 } else {
3249 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003250 DMLOG_PRINT(DMLVL_DEBUG, "%s(multi event, fs handle)\n",
3251 szFuncName);
3252 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3253 DM_EVENT_MAX, &outeventset,
3254 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003255 if (rc == 0) {
3256 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003257 if (nelem == DM_EVENT_DESTROY + 1) {
3258 if (memcmp
3259 (&ineventset, &outeventset,
3260 sizeof(dm_eventset_t)) == 0) {
3261 DMLOG_PRINT(DMLVL_DEBUG,
3262 "%s passed with expected rc = %d\n",
3263 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003264 DMVAR_PASS();
3265 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003266 DMLOG_PRINT(DMLVL_ERR,
3267 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3268 szFuncName, 0,
3269 ineventset,
3270 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003271 DMVAR_FAIL();
3272 }
3273 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003274 DMLOG_PRINT(DMLVL_ERR,
3275 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3276 szFuncName, 0, nelem,
3277 DM_EVENT_DESTROY + 1);
vapierd13d74b2006-02-11 07:24:00 +00003278 DMVAR_FAIL();
3279 }
3280 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003281 DMLOG_PRINT(DMLVL_ERR,
3282 "%s failed with unexpected rc = %d (errno = %d)\n",
3283 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003284 DMVAR_FAIL();
3285 }
3286
3287 /* Variation clean up */
3288 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003289 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3290 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003291 rc |= dm_destroy_session(newsid);
3292 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003293 DMLOG_PRINT(DMLVL_DEBUG,
3294 "Unable to clean up variation! (errno = %d)\n",
3295 errno);
vapierd13d74b2006-02-11 07:24:00 +00003296 }
3297 dm_handle_free(hanp, hlen);
3298 }
3299 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003300
vapierd13d74b2006-02-11 07:24:00 +00003301 /*
3302 * TEST : dm_get_eventlist - multi event, file handle
3303 * EXPECTED: rc = 0
3304 */
3305 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 16)) {
3306 dm_sessid_t newsid;
3307 void *hanp;
3308 size_t hlen;
3309 dm_eventset_t ineventset, outeventset;
3310 u_int nelem;
3311
3312 /* Variation set up */
3313 DMEV_ZERO(ineventset);
3314 DMEV_ZERO(outeventset);
3315 DMEV_SET(DM_EVENT_CLOSE, ineventset);
3316 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
3317 DMEV_SET(DM_EVENT_DESTROY, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003318 if ((rc =
3319 dm_create_session(DM_NO_SESSION, szSessionInfo,
3320 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003321 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003322 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
3323 -1) {
vapierd13d74b2006-02-11 07:24:00 +00003324 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003325 } else
3326 if ((rc =
3327 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3328 &ineventset, DM_EVENT_MAX)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003329 dm_handle_free(hanp, hlen);
3330 dm_destroy_session(newsid);
3331 }
3332 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003333 DMLOG_PRINT(DMLVL_DEBUG,
3334 "Unable to set up variation! (errno = %d)\n",
3335 errno);
vapierd13d74b2006-02-11 07:24:00 +00003336 DMVAR_SKIP();
3337 } else {
3338 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003339 DMLOG_PRINT(DMLVL_DEBUG,
3340 "%s(multi event, file handle)\n",
3341 szFuncName);
3342 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3343 DM_EVENT_MAX, &outeventset,
3344 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003345 if (rc == 0) {
3346 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003347 if (nelem == DM_EVENT_DESTROY + 1) {
3348 if (memcmp
3349 (&ineventset, &outeventset,
3350 sizeof(dm_eventset_t)) == 0) {
3351 DMLOG_PRINT(DMLVL_DEBUG,
3352 "%s passed with expected rc = %d\n",
3353 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003354 DMVAR_PASS();
3355 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003356 DMLOG_PRINT(DMLVL_ERR,
3357 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3358 szFuncName, 0,
3359 ineventset,
3360 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003361 DMVAR_FAIL();
3362 }
3363 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003364 DMLOG_PRINT(DMLVL_ERR,
3365 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3366 szFuncName, 0, nelem,
3367 DM_EVENT_DESTROY + 1);
vapierd13d74b2006-02-11 07:24:00 +00003368 DMVAR_FAIL();
3369 }
3370 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003371 DMLOG_PRINT(DMLVL_ERR,
3372 "%s failed with unexpected rc = %d (errno = %d)\n",
3373 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003374 DMVAR_FAIL();
3375 }
3376
3377 /* Variation clean up */
3378 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003379 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3380 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003381 rc |= dm_destroy_session(newsid);
3382 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003383 DMLOG_PRINT(DMLVL_DEBUG,
3384 "Unable to clean up variation! (errno = %d)\n",
3385 errno);
vapierd13d74b2006-02-11 07:24:00 +00003386 }
3387 dm_handle_free(hanp, hlen);
3388 }
3389 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003390
vapierd13d74b2006-02-11 07:24:00 +00003391 /*
3392 * TEST : dm_get_eventlist - read event
3393 * EXPECTED: rc = 0
3394 */
3395 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 17)) {
3396 dm_sessid_t newsid;
3397 void *hanp;
3398 size_t hlen;
3399 dm_eventset_t ineventset, outeventset;
3400 u_int nelem;
Wanlong Gao354ebb42012-12-07 10:10:04 +08003401 dm_region_t region = { 0, 0, DM_REGION_READ };
vapierd13d74b2006-02-11 07:24:00 +00003402 dm_boolean_t exactflag;
3403
3404 /* Variation set up */
3405 DMEV_ZERO(ineventset);
3406 DMEV_ZERO(outeventset);
3407 DMEV_SET(DM_EVENT_READ, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003408 if ((rc =
3409 dm_create_session(DM_NO_SESSION, szSessionInfo,
3410 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003411 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003412 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
3413 -1) {
vapierd13d74b2006-02-11 07:24:00 +00003414 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003415 } else
3416 if ((rc =
3417 dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
3418 &region, &exactflag)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003419 dm_handle_free(hanp, hlen);
3420 dm_destroy_session(newsid);
3421 }
3422 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003423 DMLOG_PRINT(DMLVL_DEBUG,
3424 "Unable to set up variation! (errno = %d)\n",
3425 errno);
vapierd13d74b2006-02-11 07:24:00 +00003426 DMVAR_SKIP();
3427 } else {
3428 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003429 DMLOG_PRINT(DMLVL_DEBUG, "%s(read event)\n",
3430 szFuncName);
3431 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3432 DM_EVENT_MAX, &outeventset,
3433 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003434 if (rc == 0) {
3435 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003436 if (nelem == DM_EVENT_READ + 1) {
3437 if (memcmp
3438 (&ineventset, &outeventset,
3439 sizeof(dm_eventset_t)) == 0) {
3440 DMLOG_PRINT(DMLVL_DEBUG,
3441 "%s passed with expected rc = %d\n",
3442 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003443 DMVAR_PASS();
3444 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003445 DMLOG_PRINT(DMLVL_ERR,
3446 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3447 szFuncName, 0,
3448 ineventset,
3449 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003450 DMVAR_FAIL();
3451 }
3452 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003453 DMLOG_PRINT(DMLVL_ERR,
3454 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3455 szFuncName, 0, nelem,
3456 DM_EVENT_READ + 1);
vapierd13d74b2006-02-11 07:24:00 +00003457 DMVAR_FAIL();
3458 }
3459 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003460 DMLOG_PRINT(DMLVL_ERR,
3461 "%s failed with unexpected rc = %d (errno = %d)\n",
3462 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003463 DMVAR_FAIL();
3464 }
3465
3466 /* Variation clean up */
3467 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003468 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3469 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003470 rc |= dm_destroy_session(newsid);
3471 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003472 DMLOG_PRINT(DMLVL_DEBUG,
3473 "Unable to clean up variation! (errno = %d)\n",
3474 errno);
vapierd13d74b2006-02-11 07:24:00 +00003475 }
3476 dm_handle_free(hanp, hlen);
3477 }
3478 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003479
vapierd13d74b2006-02-11 07:24:00 +00003480 /*
3481 * TEST : dm_get_eventlist - write event
3482 * EXPECTED: rc = 0
3483 */
3484 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 18)) {
3485 dm_sessid_t newsid;
3486 void *hanp;
3487 size_t hlen;
3488 dm_eventset_t ineventset, outeventset;
3489 u_int nelem;
Wanlong Gao354ebb42012-12-07 10:10:04 +08003490 dm_region_t region = { 0, 10, DM_REGION_WRITE };
vapierd13d74b2006-02-11 07:24:00 +00003491 dm_boolean_t exactflag;
3492
3493 /* Variation set up */
3494 DMEV_ZERO(ineventset);
3495 DMEV_ZERO(outeventset);
3496 DMEV_SET(DM_EVENT_WRITE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003497 if ((rc =
3498 dm_create_session(DM_NO_SESSION, szSessionInfo,
3499 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003500 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003501 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
3502 -1) {
vapierd13d74b2006-02-11 07:24:00 +00003503 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003504 } else
3505 if ((rc =
3506 dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
3507 &region, &exactflag)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003508 dm_handle_free(hanp, hlen);
3509 dm_destroy_session(newsid);
3510 }
3511 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003512 DMLOG_PRINT(DMLVL_DEBUG,
3513 "Unable to set up variation! (errno = %d)\n",
3514 errno);
vapierd13d74b2006-02-11 07:24:00 +00003515 DMVAR_SKIP();
3516 } else {
3517 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003518 DMLOG_PRINT(DMLVL_DEBUG, "%s(write event)\n",
3519 szFuncName);
3520 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3521 DM_EVENT_MAX, &outeventset,
3522 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003523 if (rc == 0) {
3524 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003525 if (nelem == DM_EVENT_WRITE + 1) {
3526 if (memcmp
3527 (&ineventset, &outeventset,
3528 sizeof(dm_eventset_t)) == 0) {
3529 DMLOG_PRINT(DMLVL_DEBUG,
3530 "%s passed with expected rc = %d\n",
3531 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003532 DMVAR_PASS();
3533 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003534 DMLOG_PRINT(DMLVL_ERR,
3535 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3536 szFuncName, 0,
3537 ineventset,
3538 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003539 DMVAR_FAIL();
3540 }
3541 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003542 DMLOG_PRINT(DMLVL_ERR,
3543 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3544 szFuncName, 0, nelem,
3545 DM_EVENT_WRITE + 1);
vapierd13d74b2006-02-11 07:24:00 +00003546 DMVAR_FAIL();
3547 }
3548 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003549 DMLOG_PRINT(DMLVL_ERR,
3550 "%s failed with unexpected rc = %d (errno = %d)\n",
3551 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003552 DMVAR_FAIL();
3553 }
3554
3555 /* Variation clean up */
3556 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003557 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3558 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003559 rc |= dm_destroy_session(newsid);
3560 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003561 DMLOG_PRINT(DMLVL_DEBUG,
3562 "Unable to clean up variation! (errno = %d)\n",
3563 errno);
vapierd13d74b2006-02-11 07:24:00 +00003564 }
3565 dm_handle_free(hanp, hlen);
3566 }
3567 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003568
vapierd13d74b2006-02-11 07:24:00 +00003569 /*
3570 * TEST : dm_get_eventlist - truncate event
3571 * EXPECTED: rc = 0
3572 */
3573 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 19)) {
3574 dm_sessid_t newsid;
3575 void *hanp;
3576 size_t hlen;
3577 dm_eventset_t ineventset, outeventset;
3578 u_int nelem;
Wanlong Gao354ebb42012-12-07 10:10:04 +08003579 dm_region_t region =
3580 { TMP_FILELEN - 10, 0, DM_REGION_TRUNCATE };
vapierd13d74b2006-02-11 07:24:00 +00003581 dm_boolean_t exactflag;
3582
3583 /* Variation set up */
3584 DMEV_ZERO(ineventset);
3585 DMEV_ZERO(outeventset);
3586 DMEV_SET(DM_EVENT_TRUNCATE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003587 if ((rc =
3588 dm_create_session(DM_NO_SESSION, szSessionInfo,
3589 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003590 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003591 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
3592 -1) {
vapierd13d74b2006-02-11 07:24:00 +00003593 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003594 } else
3595 if ((rc =
3596 dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
3597 &region, &exactflag)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003598 dm_handle_free(hanp, hlen);
3599 dm_destroy_session(newsid);
3600 }
3601 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003602 DMLOG_PRINT(DMLVL_DEBUG,
3603 "Unable to set up variation! (errno = %d)\n",
3604 errno);
vapierd13d74b2006-02-11 07:24:00 +00003605 DMVAR_SKIP();
3606 } else {
3607 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003608 DMLOG_PRINT(DMLVL_DEBUG, "%s(truncate event)\n",
3609 szFuncName);
3610 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3611 DM_EVENT_MAX, &outeventset,
3612 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003613 if (rc == 0) {
3614 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003615 if (nelem == DM_EVENT_TRUNCATE + 1) {
3616 if (memcmp
3617 (&ineventset, &outeventset,
3618 sizeof(dm_eventset_t)) == 0) {
3619 DMLOG_PRINT(DMLVL_DEBUG,
3620 "%s passed with expected rc = %d\n",
3621 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003622 DMVAR_PASS();
3623 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003624 DMLOG_PRINT(DMLVL_ERR,
3625 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3626 szFuncName, 0,
3627 ineventset,
3628 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003629 DMVAR_FAIL();
3630 }
3631 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003632 DMLOG_PRINT(DMLVL_ERR,
3633 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3634 szFuncName, 0, nelem,
3635 DM_EVENT_TRUNCATE + 1);
vapierd13d74b2006-02-11 07:24:00 +00003636 DMVAR_FAIL();
3637 }
3638 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003639 DMLOG_PRINT(DMLVL_ERR,
3640 "%s failed with unexpected rc = %d (errno = %d)\n",
3641 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003642 DMVAR_FAIL();
3643 }
3644
3645 /* Variation clean up */
3646 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003647 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3648 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003649 rc |= dm_destroy_session(newsid);
3650 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003651 DMLOG_PRINT(DMLVL_DEBUG,
3652 "Unable to clean up variation! (errno = %d)\n",
3653 errno);
vapierd13d74b2006-02-11 07:24:00 +00003654 }
3655 dm_handle_free(hanp, hlen);
3656 }
3657 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003658
vapierd13d74b2006-02-11 07:24:00 +00003659 /*
3660 * TEST : dm_get_eventlist - event union, file handle
3661 * EXPECTED: rc = 0
3662 */
3663 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 20)) {
3664 dm_sessid_t newsid;
3665 void *hanp;
3666 size_t hlen;
3667 dm_eventset_t ineventset, outeventset;
3668 u_int nelem;
Wanlong Gao354ebb42012-12-07 10:10:04 +08003669 dm_region_t region =
3670 { TMP_FILELEN - 10, 0, DM_REGION_TRUNCATE };
vapierd13d74b2006-02-11 07:24:00 +00003671 dm_boolean_t exactflag;
3672
3673 /* Variation set up */
3674 DMEV_ZERO(ineventset);
3675 DMEV_ZERO(outeventset);
3676 DMEV_SET(DM_EVENT_CLOSE, ineventset);
3677 DMEV_SET(DM_EVENT_ATTRIBUTE, ineventset);
3678 DMEV_SET(DM_EVENT_DESTROY, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003679 if ((rc =
3680 dm_create_session(DM_NO_SESSION, szSessionInfo,
3681 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003682 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003683 } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) ==
3684 -1) {
vapierd13d74b2006-02-11 07:24:00 +00003685 dm_destroy_session(newsid);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003686 } else
3687 if (((rc =
3688 dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3689 &ineventset, DM_EVENT_MAX)) == -1)
3690 ||
3691 ((rc =
3692 dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1,
3693 &region, &exactflag)) == -1)) {
vapierd13d74b2006-02-11 07:24:00 +00003694 dm_handle_free(hanp, hlen);
3695 dm_destroy_session(newsid);
Garrett Cooper2c282152010-12-16 00:55:50 -08003696 }
vapierd13d74b2006-02-11 07:24:00 +00003697 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003698 DMLOG_PRINT(DMLVL_DEBUG,
3699 "Unable to set up variation! (errno = %d)\n",
3700 errno);
vapierd13d74b2006-02-11 07:24:00 +00003701 DMVAR_SKIP();
3702 } else {
3703 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003704 DMLOG_PRINT(DMLVL_DEBUG,
3705 "%s(event union, file handle)\n",
3706 szFuncName);
3707 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3708 DM_EVENT_MAX, &outeventset,
3709 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003710 if (rc == 0) {
3711 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003712 if (nelem == DM_EVENT_DESTROY + 1) {
vapierd13d74b2006-02-11 07:24:00 +00003713 DMEV_SET(DM_EVENT_TRUNCATE, ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003714 if (memcmp
3715 (&ineventset, &outeventset,
3716 sizeof(dm_eventset_t)) == 0) {
3717 DMLOG_PRINT(DMLVL_DEBUG,
3718 "%s passed with expected rc = %d\n",
3719 szFuncName, 0);
vapierd13d74b2006-02-11 07:24:00 +00003720 DMVAR_PASS();
3721 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003722 DMLOG_PRINT(DMLVL_ERR,
3723 "%s failed with expected rc = %d but eventsets not same (%llx vs %llx)\n",
3724 szFuncName, 0,
3725 ineventset,
3726 outeventset);
vapierd13d74b2006-02-11 07:24:00 +00003727 DMVAR_FAIL();
3728 }
3729 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003730 DMLOG_PRINT(DMLVL_ERR,
3731 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
3732 szFuncName, 0, nelem,
3733 DM_EVENT_DESTROY + 1);
vapierd13d74b2006-02-11 07:24:00 +00003734 DMVAR_FAIL();
3735 }
3736 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003737 DMLOG_PRINT(DMLVL_ERR,
3738 "%s failed with unexpected rc = %d (errno = %d)\n",
3739 szFuncName, rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003740 DMVAR_FAIL();
3741 }
3742
3743 /* Variation clean up */
3744 DMEV_ZERO(ineventset);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003745 rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3746 &ineventset, DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003747 rc |= dm_destroy_session(newsid);
3748 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003749 DMLOG_PRINT(DMLVL_DEBUG,
3750 "Unable to clean up variation! (errno = %d)\n",
3751 errno);
vapierd13d74b2006-02-11 07:24:00 +00003752 }
3753 dm_handle_free(hanp, hlen);
3754 }
3755 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003756
vapierd13d74b2006-02-11 07:24:00 +00003757 /*
3758 * TEST : dm_get_eventlist - global handle
3759 * EXPECTED: rc = -1, errno = EBADF
3760 */
3761 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 21)) {
3762 dm_sessid_t newsid;
3763 dm_eventset_t outeventset;
3764 u_int nelem;
3765
3766 /* Variation set up */
3767 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
3768 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003769 DMLOG_PRINT(DMLVL_DEBUG,
3770 "Unable to set up variation! (errno = %d)\n",
3771 errno);
vapierd13d74b2006-02-11 07:24:00 +00003772 DMVAR_SKIP();
3773 } else {
3774 /* Variation */
3775
Wanlong Gao354ebb42012-12-07 10:10:04 +08003776 DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n",
3777 szFuncName);
3778 rc = dm_get_eventlist(newsid, DM_GLOBAL_HANP,
3779 DM_GLOBAL_HLEN, DM_NO_TOKEN,
3780 DM_EVENT_MAX, &outeventset,
3781 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003782 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
Garrett Cooper2c282152010-12-16 00:55:50 -08003783
vapierd13d74b2006-02-11 07:24:00 +00003784 /* Variation clean up */
3785 rc = dm_destroy_session(newsid);
3786 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003787 DMLOG_PRINT(DMLVL_DEBUG,
3788 "Unable to clean up variation! (errno = %d)\n",
3789 errno);
vapierd13d74b2006-02-11 07:24:00 +00003790 }
3791 }
3792 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003793
vapierd13d74b2006-02-11 07:24:00 +00003794 /*
3795 * TEST : dm_get_eventlist - invalidated file handle
3796 * EXPECTED: rc = -1, errno = EBADF
3797 */
3798 if (DMVAR_EXEC(GET_EVENTLIST_BASE + 22)) {
3799 dm_sessid_t newsid;
3800 void *hanp;
3801 size_t hlen;
3802 dm_eventset_t ineventset, outeventset;
3803 u_int nelem;
3804
3805 /* Variation set up */
3806 DMEV_ZERO(ineventset);
3807 DMEV_ZERO(outeventset);
3808
3809 sprintf(command, "cp %s %s", DummyFile, DummyFile2);
3810 if ((rc = system(command)) == -1) {
3811 /* No clean up */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003812 } else
3813 if ((rc =
3814 dm_create_session(DM_NO_SESSION, szSessionInfo,
3815 &newsid)) == -1) {
vapierd13d74b2006-02-11 07:24:00 +00003816 remove(DummyFile2);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003817 } else if ((rc = dm_path_to_handle(DummyFile2, &hanp, &hlen)) ==
3818 -1) {
vapierd13d74b2006-02-11 07:24:00 +00003819 dm_destroy_session(newsid);
3820 remove(DummyFile2);
3821 } else if ((rc = remove(DummyFile2)) == -1) {
3822 dm_handle_free(hanp, hlen);
3823 dm_destroy_session(newsid);
3824 }
3825 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003826 DMLOG_PRINT(DMLVL_DEBUG,
3827 "Unable to set up variation! (errno = %d)\n",
3828 errno);
vapierd13d74b2006-02-11 07:24:00 +00003829 DMVAR_SKIP();
3830 } else {
3831 /* Variation */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003832 DMLOG_PRINT(DMLVL_DEBUG,
3833 "%s(invalidated file handle)\n",
3834 szFuncName);
3835 rc = dm_get_eventlist(newsid, hanp, hlen, DM_NO_TOKEN,
3836 DM_EVENT_MAX, &outeventset,
3837 &nelem);
vapierd13d74b2006-02-11 07:24:00 +00003838 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
3839
3840 /* Variation clean up */
3841 rc = dm_destroy_session(newsid);
3842 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003843 DMLOG_PRINT(DMLVL_DEBUG,
3844 "Unable to clean up variation! (errno = %d)\n",
3845 errno);
vapierd13d74b2006-02-11 07:24:00 +00003846 }
3847 dm_handle_free(hanp, hlen);
3848 }
3849 }
subrata_modakbdbaec52009-02-26 12:14:51 +00003850
vapierd13d74b2006-02-11 07:24:00 +00003851 /* We now need to repoint preunmount/unmount back to original session */
3852 DMEV_ZERO(events);
3853 DMEV_SET(DM_EVENT_PREUNMOUNT, events);
3854 DMEV_SET(DM_EVENT_UNMOUNT, events);
3855 rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen);
3856 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003857 DMLOG_PRINT(DMLVL_ERR,
3858 "dm_path_to_fshandle failed! (rc = %d, errno = %d)\n",
3859 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003860 dm_destroy_session(sid);
3861 DM_EXIT();
3862 }
3863
Wanlong Gao354ebb42012-12-07 10:10:04 +08003864 rc = dm_set_disp(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
3865 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003866 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003867 DMLOG_PRINT(DMLVL_ERR,
3868 "dm_set_disp failed! (rc = %d, errno = %d)\n", rc,
3869 errno);
vapierd13d74b2006-02-11 07:24:00 +00003870 dm_destroy_session(sid);
3871 DM_EXIT();
3872 }
3873
Wanlong Gao354ebb42012-12-07 10:10:04 +08003874 rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events,
3875 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003876 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003877 DMLOG_PRINT(DMLVL_ERR,
3878 "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
3879 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003880 dm_destroy_session(sid);
3881 DM_EXIT();
3882 }
3883
3884 remove(DummyFile);
3885 rmdir(DummySubdir);
3886 dm_handle_free(fshanp, fshlen);
3887
3888 rc = umount(mountPt);
3889 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003890 DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n",
3891 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003892 }
3893
3894 pthread_join(tid, NULL);
3895
3896 rc = dm_destroy_session(sid);
3897 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003898 DMLOG_PRINT(DMLVL_ERR,
3899 "dm_destroy_session failed! (rc = %d, errno = %d)\n",
3900 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003901 }
3902
3903 DMLOG_STOP();
Garrett Cooper2c282152010-12-16 00:55:50 -08003904
3905 tst_exit();
vapierd13d74b2006-02-11 07:24:00 +00003906}
3907
3908void *Thread(void *parm)
3909{
3910 int rc;
3911 size_t dmMsgBufLen;
3912 dm_eventmsg_t *dmMsg;
3913 int bMounted = DM_FALSE;
3914 dm_eventtype_t type;
3915 dm_token_t token;
3916 dm_eventset_t events;
3917 dm_response_t response;
3918
3919 do {
3920 /* Loop until message received (wait could be interrupted) */
3921 do {
3922 DMLOG_PRINT(DMLVL_DEBUG, "Waiting for event...\n");
3923 dmMsgBufLen = 0;
3924
Wanlong Gao354ebb42012-12-07 10:10:04 +08003925 rc = dm_get_events(sid, 1, DM_EV_WAIT, sizeof(dmMsgBuf),
3926 dmMsgBuf, &dmMsgBufLen);
3927 DMLOG_PRINT(DMLVL_DEBUG,
3928 "... dm_get_events returned %d (errno %d)\n",
3929 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003930 } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0));
3931
3932 if (rc) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003933 DMLOG_PRINT(DMLVL_ERR,
3934 "dm_get_events failed with rc = %d, errno = %d\n",
3935 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003936 dm_destroy_session(sid);
3937 DM_EXIT();
3938 } else {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003939 dmMsg = (dm_eventmsg_t *) dmMsgBuf;
vapierd13d74b2006-02-11 07:24:00 +00003940 token = dmMsg->ev_token;
3941 type = dmMsg->ev_type;
3942
3943 DMLOG_PRINT(DMLVL_DEBUG, "Received message %d\n", type);
3944 }
3945
3946 if (type == DM_EVENT_MOUNT) {
3947 /* SPECIAL CASE: need to set disposition, events and response */
Wanlong Gao354ebb42012-12-07 10:10:04 +08003948 dm_mount_event_t *me =
3949 DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *);
vapierd13d74b2006-02-11 07:24:00 +00003950 void *lhanp = DM_GET_VALUE(me, me_handle1, void *);
3951 size_t lhlen = DM_GET_LEN(me, me_handle1);
3952
3953 DMLOG_PRINT(DMLVL_DEBUG, "Message is DM_EVENT_MOUNT\n");
3954 DMLOG_PRINT(DMLVL_DEBUG, " Mode: %x\n", me->me_mode);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003955 DMLOG_PRINT(DMLVL_DEBUG, " File system handle: %p\n",
3956 lhanp);
3957 DMLOG_PRINT(DMLVL_DEBUG,
3958 " File system handle length: %d\n", lhlen);
3959 DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint handle: %p\n",
3960 DM_GET_VALUE(me, me_handle2, void *));
3961 DMLOG_PRINT(DMLVL_DEBUG,
3962 " Mountpoint handle length: %d\n",
3963 DM_GET_LEN(me, me_handle2));
3964 DMLOG_PRINT(DMLVL_DEBUG, " Mountpoint path: %s\n",
3965 DM_GET_VALUE(me, me_name1, char *));
3966 DMLOG_PRINT(DMLVL_DEBUG, " Media designator: %s\n",
3967 DM_GET_VALUE(me, me_name2, char *));
3968 DMLOG_PRINT(DMLVL_DEBUG, " Root handle: %p\n",
3969 DM_GET_VALUE(me, me_roothandle, void *));
3970 DMLOG_PRINT(DMLVL_DEBUG, " Root handle length: %d\n",
3971 DM_GET_LEN(me, me_roothandle));
Garrett Cooper2c282152010-12-16 00:55:50 -08003972
Wanlong Gao354ebb42012-12-07 10:10:04 +08003973 bMounted = dm_handle_is_valid(lhanp, lhlen);
vapierd13d74b2006-02-11 07:24:00 +00003974
Wanlong Gao354ebb42012-12-07 10:10:04 +08003975 rc = dm_request_right(sid, lhanp, lhlen, token,
3976 DM_RR_WAIT, DM_RIGHT_EXCL);
vapierd13d74b2006-02-11 07:24:00 +00003977 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003978 DMLOG_PRINT(DMLVL_ERR,
3979 "dm_request_right failed! (rc = %d, errno = %d)\n",
3980 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003981 dm_destroy_session(sid);
3982 DM_EXIT();
3983 }
3984
3985 DMEV_ZERO(events);
3986 DMEV_SET(DM_EVENT_PREUNMOUNT, events);
3987 DMEV_SET(DM_EVENT_UNMOUNT, events);
Wanlong Gao354ebb42012-12-07 10:10:04 +08003988 rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events,
3989 DM_EVENT_MAX);
vapierd13d74b2006-02-11 07:24:00 +00003990 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08003991 DMLOG_PRINT(DMLVL_ERR,
3992 "dm_set_eventlist failed! (rc = %d, errno = %d)\n",
3993 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00003994 dm_destroy_session(sid);
3995 DM_EXIT();
3996 }
3997
Wanlong Gao354ebb42012-12-07 10:10:04 +08003998 rc = dm_release_right(sid, lhanp, lhlen, token);
vapierd13d74b2006-02-11 07:24:00 +00003999 if (rc == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08004000 DMLOG_PRINT(DMLVL_ERR,
4001 "dm_request_right failed! (rc = %d, errno = %d)\n",
4002 rc, errno);
vapierd13d74b2006-02-11 07:24:00 +00004003 dm_destroy_session(sid);
4004 DM_EXIT();
4005 }
4006
4007 response = DM_RESP_CONTINUE;
4008 } else if (type == DM_EVENT_UNMOUNT) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08004009 dm_namesp_event_t *nse =
4010 DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *);
vapierd13d74b2006-02-11 07:24:00 +00004011 if (nse->ne_retcode == 0) {
4012 bMounted = DM_FALSE;
4013 }
4014
4015 response = DM_RESP_CONTINUE;
4016 } else {
4017 switch (type) {
4018 case DM_EVENT_PREUNMOUNT:
4019 case DM_EVENT_READ:
4020 case DM_EVENT_WRITE:
4021 case DM_EVENT_TRUNCATE:
4022 case DM_EVENT_CREATE:
4023 case DM_EVENT_REMOVE:
4024 case DM_EVENT_RENAME:
4025 case DM_EVENT_LINK:
4026 case DM_EVENT_SYMLINK:
4027 response = DM_RESP_CONTINUE;
4028 break;
4029
4030 case DM_EVENT_POSTCREATE:
4031 case DM_EVENT_POSTREMOVE:
4032 case DM_EVENT_POSTRENAME:
4033 case DM_EVENT_POSTLINK:
4034 case DM_EVENT_POSTSYMLINK:
4035 case DM_EVENT_ATTRIBUTE:
4036 case DM_EVENT_CLOSE:
4037 response = DM_RESP_INVALID;
4038 break;
Garrett Cooper2c282152010-12-16 00:55:50 -08004039
vapierd13d74b2006-02-11 07:24:00 +00004040 default:
Wanlong Gao354ebb42012-12-07 10:10:04 +08004041 {
4042 DMLOG_PRINT(DMLVL_ERR,
4043 "Message is unexpected!\n");
4044 response = DM_RESP_ABORT;
4045 break;
4046 }
vapierd13d74b2006-02-11 07:24:00 +00004047 }
4048 }
4049
4050 if (response != DM_RESP_INVALID) {
Wanlong Gao354ebb42012-12-07 10:10:04 +08004051 DMLOG_PRINT(DMLVL_DEBUG,
4052 "Responding to message %d with %d\n", type,
4053 response);
4054 rc = dm_respond_event(sid, token, response,
4055 response ==
4056 DM_RESP_ABORT ? ABORT_ERRNO : 0,
4057 0, NULL);
vapierd13d74b2006-02-11 07:24:00 +00004058 }
4059 } while (bMounted);
4060
4061 pthread_exit(0);
Chris Dearmanec6edca2012-10-17 19:54:01 -07004062}