vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1 | /* |
| 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 Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 17 | */ |
| 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 | |
| 43 | pthread_t tid; |
| 44 | dm_sessid_t sid; |
| 45 | char dmMsgBuf[4096]; |
| 46 | char command[4096]; |
| 47 | char *mountPt; |
| 48 | char *deviceNm; |
| 49 | char DummyFile[FILENAME_MAX]; |
| 50 | char DummyFile2[FILENAME_MAX]; |
| 51 | char DummySubdir[FILENAME_MAX]; |
| 52 | |
| 53 | void *Thread(void *); |
| 54 | |
| 55 | int main(int argc, char **argv) |
| 56 | { |
| 57 | |
| 58 | char *szFuncName; |
| 59 | char *varstr; |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 60 | int i; |
| 61 | int rc; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 62 | 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_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 73 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 74 | /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */ |
| 75 | if ((rc = dm_init_service(&varstr)) != 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 76 | DMLOG_PRINT(DMLVL_ERR, |
| 77 | "dm_init_service failed! (rc = %d, errno = %d)\n", |
| 78 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 79 | DM_EXIT(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 80 | } 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 85 | DM_EXIT(); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 86 | } 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 93 | dm_destroy_session(sid); |
| 94 | DM_EXIT(); |
| 95 | } else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 96 | DMLOG_PRINT(DMLVL_ERR, |
| 97 | "pthread_create failed! (rc = %d, errno = %d)\n", |
| 98 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 99 | dm_destroy_session(sid); |
| 100 | DM_EXIT(); |
| 101 | } else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 102 | DMLOG_PRINT(DMLVL_ERR, |
| 103 | "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc, |
| 104 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 105 | 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_modak | e753fd7 | 2008-07-11 10:56:34 +0000 | [diff] [blame] | 119 | fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 120 | if (fd != -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 121 | for (i = 0; i < TMP_FILELEN / DUMMY_STRLEN; i++) { |
| 122 | if (write(fd, DUMMY_STRING, DUMMY_STRLEN) != |
| 123 | DUMMY_STRLEN) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 124 | rc = -1; |
| 125 | break; |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 126 | } |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 127 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 138 | DMLOG_PRINT(DMLVL_ERR, |
| 139 | "creating dummy file failed! (rc = %d, errno = %d)\n", |
| 140 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 141 | dm_destroy_session(sid); |
| 142 | DM_EXIT(); |
| 143 | } |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 144 | |
subrata_modak | e753fd7 | 2008-07-11 10:56:34 +0000 | [diff] [blame] | 145 | rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 146 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 147 | DMLOG_PRINT(DMLVL_ERR, |
| 148 | "creating dummy dir failed! (rc = %d, errno = %d)\n", |
| 149 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 150 | dm_destroy_session(sid); |
| 151 | DM_EXIT(); |
| 152 | } |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 153 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 154 | 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_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 171 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 172 | DMEV_ZERO(minEvents); |
| 173 | DMEV_SET(DM_EVENT_PREUNMOUNT, minEvents); |
| 174 | DMEV_SET(DM_EVENT_UNMOUNT, minEvents); |
| 175 | } |
| 176 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 177 | DMLOG_PRINT(DMLVL_DEBUG, |
| 178 | "Starting DMAPI disposition/eventlist tests\n"); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 179 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 180 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 195 | DMLOG_PRINT(DMLVL_DEBUG, |
| 196 | "Unable to set up variation! (errno = %d)\n", |
| 197 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 198 | DMVAR_SKIP(); |
| 199 | } else { |
| 200 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 201 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 206 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 207 | |
| 208 | /* Variation clean up */ |
| 209 | dm_handle_free(hanp, hlen); |
| 210 | } |
| 211 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 212 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 213 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 226 | DMLOG_PRINT(DMLVL_DEBUG, |
| 227 | "Unable to set up variation! (errno = %d)\n", |
| 228 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 229 | DMVAR_SKIP(); |
| 230 | } else { |
| 231 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 232 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 237 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 238 | |
| 239 | /* Variation clean up */ |
| 240 | dm_handle_free(hanp, hlen); |
| 241 | } |
| 242 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 243 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 244 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 259 | DMLOG_PRINT(DMLVL_DEBUG, |
| 260 | "Unable to set up variation! (errno = %d)\n", |
| 261 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 262 | DMVAR_SKIP(); |
| 263 | } else { |
| 264 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 265 | DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelem)\n", |
| 266 | szFuncName); |
| 267 | rc = dm_get_config_events(hanp, hlen, 0, &eventset, |
| 268 | &nelem); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 269 | if (rc == -1) { |
| 270 | if (errno == E2BIG) { |
| 271 | if (nelem == DM_EVENT_MAX) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 272 | DMLOG_PRINT(DMLVL_DEBUG, |
| 273 | "%s passed with expected rc = %d and expected errno = %d (nelem = %d)\n", |
| 274 | szFuncName, rc, |
| 275 | errno, nelem); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 276 | DMVAR_PASS(); |
| 277 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 278 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 283 | DMVAR_FAIL(); |
| 284 | } |
| 285 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 286 | DMLOG_PRINT(DMLVL_ERR, |
| 287 | "%s failed with expected rc = %d but unexpected errno = %d\n", |
| 288 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 289 | DMVAR_FAIL(); |
| 290 | } |
| 291 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 292 | DMLOG_PRINT(DMLVL_ERR, |
| 293 | "%s failed with unexpected rc = %d\n", |
| 294 | szFuncName, rc); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 295 | DMVAR_FAIL(); |
| 296 | } |
| 297 | |
| 298 | /* Variation clean up */ |
| 299 | dm_handle_free(hanp, hlen); |
| 300 | } |
| 301 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 302 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 303 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 315 | DMLOG_PRINT(DMLVL_DEBUG, |
| 316 | "Unable to set up variation! (errno = %d)\n", |
| 317 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 318 | DMVAR_SKIP(); |
| 319 | } else { |
| 320 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 321 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 326 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 327 | |
| 328 | /* Variation clean up */ |
| 329 | dm_handle_free(hanp, hlen); |
| 330 | } |
| 331 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 332 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 333 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 345 | DMLOG_PRINT(DMLVL_DEBUG, |
| 346 | "Unable to set up variation! (errno = %d)\n", |
| 347 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 348 | DMVAR_SKIP(); |
| 349 | } else { |
| 350 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 351 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 356 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 357 | |
| 358 | /* Variation clean up */ |
| 359 | dm_handle_free(hanp, hlen); |
| 360 | } |
| 361 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 362 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 363 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 378 | DMLOG_PRINT(DMLVL_DEBUG, |
| 379 | "Unable to set up variation! (errno = %d)\n", |
| 380 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 381 | DMVAR_SKIP(); |
| 382 | } else { |
| 383 | /* Variation */ |
| 384 | DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 385 | rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX, |
| 386 | &eventset, &nelem); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 387 | if (rc == 0) { |
| 388 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
| 389 | if (nelem == DM_EVENT_MAX) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 390 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 396 | DMVAR_PASS(); |
| 397 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 398 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 403 | DMVAR_FAIL(); |
| 404 | } |
| 405 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 406 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 410 | DMVAR_FAIL(); |
| 411 | } |
| 412 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 413 | DMLOG_PRINT(DMLVL_ERR, |
| 414 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 415 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 416 | DMVAR_FAIL(); |
| 417 | } |
| 418 | |
| 419 | /* Variation clean up */ |
| 420 | dm_handle_free(hanp, hlen); |
| 421 | } |
| 422 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 423 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 424 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 437 | DMLOG_PRINT(DMLVL_DEBUG, |
| 438 | "Unable to set up variation! (errno = %d)\n", |
| 439 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 440 | DMVAR_SKIP(); |
| 441 | } else { |
| 442 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 443 | DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", |
| 444 | szFuncName); |
| 445 | rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX, |
| 446 | &eventset, &nelem); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 447 | if (rc == 0) { |
| 448 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
| 449 | if (nelem == DM_EVENT_MAX) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 450 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 456 | DMVAR_PASS(); |
| 457 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 458 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 463 | DMVAR_FAIL(); |
| 464 | } |
| 465 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 466 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 470 | DMVAR_FAIL(); |
| 471 | } |
| 472 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 473 | DMLOG_PRINT(DMLVL_ERR, |
| 474 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 475 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 476 | DMVAR_FAIL(); |
| 477 | } |
| 478 | |
| 479 | /* Variation clean up */ |
| 480 | dm_handle_free(hanp, hlen); |
| 481 | } |
| 482 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 483 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 484 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 497 | DMLOG_PRINT(DMLVL_DEBUG, |
| 498 | "Unable to set up variation! (errno = %d)\n", |
| 499 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 500 | DMVAR_SKIP(); |
| 501 | } else { |
| 502 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 503 | DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n", |
| 504 | szFuncName); |
| 505 | rc = dm_get_config_events(hanp, hlen, DM_EVENT_MAX, |
| 506 | &eventset, &nelem); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 507 | if (rc == 0) { |
| 508 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
| 509 | if (nelem == DM_EVENT_MAX) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 510 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 516 | DMVAR_PASS(); |
| 517 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 518 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 523 | DMVAR_FAIL(); |
| 524 | } |
| 525 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 526 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 530 | DMVAR_FAIL(); |
| 531 | } |
| 532 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 533 | DMLOG_PRINT(DMLVL_ERR, |
| 534 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 535 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 536 | DMVAR_FAIL(); |
| 537 | } |
| 538 | |
| 539 | /* Variation clean up */ |
| 540 | dm_handle_free(hanp, hlen); |
| 541 | } |
| 542 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 543 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 544 | /* |
| 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 Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 553 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 554 | /* Variation */ |
| 555 | DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 556 | rc = dm_get_config_events(DM_GLOBAL_HANP, DM_GLOBAL_HLEN, |
| 557 | DM_EVENT_MAX, &eventset, &nelem); |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 558 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 559 | |
| 560 | /* Variation clean up */ |
| 561 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 562 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 563 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 577 | } else if ((rc = dm_path_to_handle(DummyFile2, &hanp, &hlen)) == |
| 578 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 579 | remove(DummyFile2); |
| 580 | } else if ((rc = remove(DummyFile2)) == -1) { |
| 581 | dm_handle_free(hanp, hlen); |
| 582 | } |
| 583 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 584 | DMLOG_PRINT(DMLVL_DEBUG, |
| 585 | "Unable to set up variation! (errno = %d)\n", |
| 586 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 587 | DMVAR_SKIP(); |
| 588 | } else { |
| 589 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 590 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 594 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 595 | |
| 596 | /* Variation clean up */ |
| 597 | dm_handle_free(hanp, hlen); |
| 598 | } |
| 599 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 600 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 601 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 614 | if ((rc = |
| 615 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 616 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 617 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 618 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 619 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 620 | dm_destroy_session(newsid); |
| 621 | } |
| 622 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 623 | DMLOG_PRINT(DMLVL_DEBUG, |
| 624 | "Unable to set up variation! (errno = %d)\n", |
| 625 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 626 | DMVAR_SKIP(); |
| 627 | } else { |
| 628 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 629 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 633 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 634 | |
| 635 | /* Variation clean up */ |
| 636 | rc = dm_destroy_session(newsid); |
| 637 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 638 | DMLOG_PRINT(DMLVL_DEBUG, |
| 639 | "Unable to clean up variation! (errno = %d)\n", |
| 640 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 641 | } |
| 642 | dm_handle_free(hanp, hlen); |
| 643 | } |
| 644 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 645 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 646 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 657 | if ((rc = |
| 658 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 659 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 660 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 661 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 662 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 663 | dm_destroy_session(newsid); |
| 664 | } |
| 665 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 666 | DMLOG_PRINT(DMLVL_DEBUG, |
| 667 | "Unable to set up variation! (errno = %d)\n", |
| 668 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 669 | DMVAR_SKIP(); |
| 670 | } else { |
| 671 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 672 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 676 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 677 | |
| 678 | /* Variation clean up */ |
| 679 | rc = dm_destroy_session(newsid); |
| 680 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 681 | DMLOG_PRINT(DMLVL_DEBUG, |
| 682 | "Unable to clean up variation! (errno = %d)\n", |
| 683 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 684 | } |
| 685 | dm_handle_free(hanp, hlen); |
| 686 | } |
| 687 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 688 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 689 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 700 | if ((rc = |
| 701 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 702 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 703 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 704 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 705 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 706 | dm_destroy_session(newsid); |
| 707 | } |
| 708 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 709 | DMLOG_PRINT(DMLVL_DEBUG, |
| 710 | "Unable to set up variation! (errno = %d)\n", |
| 711 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 712 | DMVAR_SKIP(); |
| 713 | } else { |
| 714 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 715 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 719 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
| 720 | |
| 721 | /* Variation clean up */ |
| 722 | rc = dm_destroy_session(newsid); |
| 723 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 724 | DMLOG_PRINT(DMLVL_DEBUG, |
| 725 | "Unable to clean up variation! (errno = %d)\n", |
| 726 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 727 | } |
| 728 | dm_handle_free(hanp, hlen); |
| 729 | } |
| 730 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 731 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 732 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 743 | if ((rc = |
| 744 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 745 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 746 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 747 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 748 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 749 | dm_destroy_session(newsid); |
| 750 | } |
| 751 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 752 | DMLOG_PRINT(DMLVL_DEBUG, |
| 753 | "Unable to set up variation! (errno = %d)\n", |
| 754 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 755 | DMVAR_SKIP(); |
| 756 | } else { |
| 757 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 758 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 762 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 763 | |
| 764 | /* Variation clean up */ |
| 765 | rc = dm_destroy_session(newsid); |
| 766 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 767 | DMLOG_PRINT(DMLVL_DEBUG, |
| 768 | "Unable to clean up variation! (errno = %d)\n", |
| 769 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 770 | } |
| 771 | dm_handle_free(hanp, hlen); |
| 772 | } |
| 773 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 774 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 775 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 786 | if ((rc = |
| 787 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 788 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 789 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 790 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 791 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 792 | dm_destroy_session(newsid); |
| 793 | } |
| 794 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 795 | DMLOG_PRINT(DMLVL_DEBUG, |
| 796 | "Unable to set up variation! (errno = %d)\n", |
| 797 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 798 | DMVAR_SKIP(); |
| 799 | } else { |
| 800 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 801 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 805 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 806 | |
| 807 | /* Variation clean up */ |
| 808 | rc = dm_destroy_session(newsid); |
| 809 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 810 | DMLOG_PRINT(DMLVL_DEBUG, |
| 811 | "Unable to clean up variation! (errno = %d)\n", |
| 812 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 813 | } |
| 814 | dm_handle_free(hanp, hlen); |
| 815 | } |
| 816 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 817 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 818 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 828 | if ((rc = |
| 829 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 830 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 831 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 832 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 833 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 834 | dm_destroy_session(newsid); |
| 835 | } |
| 836 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 837 | DMLOG_PRINT(DMLVL_DEBUG, |
| 838 | "Unable to set up variation! (errno = %d)\n", |
| 839 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 840 | DMVAR_SKIP(); |
| 841 | } else { |
| 842 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 843 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 848 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 849 | |
| 850 | /* Variation clean up */ |
| 851 | rc = dm_destroy_session(newsid); |
| 852 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 853 | DMLOG_PRINT(DMLVL_DEBUG, |
| 854 | "Unable to clean up variation! (errno = %d)\n", |
| 855 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 856 | } |
| 857 | dm_handle_free(hanp, hlen); |
| 858 | } |
| 859 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 860 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 861 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 872 | if ((rc = |
| 873 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 874 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 875 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 876 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 877 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 878 | dm_destroy_session(newsid); |
| 879 | } |
| 880 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 881 | DMLOG_PRINT(DMLVL_DEBUG, |
| 882 | "Unable to set up variation! (errno = %d)\n", |
| 883 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 884 | DMVAR_SKIP(); |
| 885 | } else { |
| 886 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 887 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 891 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 892 | |
| 893 | /* Variation clean up */ |
| 894 | rc = dm_destroy_session(newsid); |
| 895 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 896 | DMLOG_PRINT(DMLVL_DEBUG, |
| 897 | "Unable to clean up variation! (errno = %d)\n", |
| 898 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 899 | } |
| 900 | dm_handle_free(hanp, hlen); |
| 901 | } |
| 902 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 903 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 904 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 915 | if ((rc = |
| 916 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 917 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 918 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 919 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 920 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 921 | dm_destroy_session(newsid); |
| 922 | } |
| 923 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 924 | DMLOG_PRINT(DMLVL_DEBUG, |
| 925 | "Unable to set up variation! (errno = %d)\n", |
| 926 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 927 | DMVAR_SKIP(); |
| 928 | } else { |
| 929 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 930 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 934 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
| 935 | |
| 936 | /* Variation clean up */ |
| 937 | rc = dm_destroy_session(newsid); |
| 938 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 939 | DMLOG_PRINT(DMLVL_DEBUG, |
| 940 | "Unable to clean up variation! (errno = %d)\n", |
| 941 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 942 | } |
| 943 | dm_handle_free(hanp, hlen); |
| 944 | } |
| 945 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 946 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 947 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 958 | if ((rc = |
| 959 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 960 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 961 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 962 | } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen)) |
| 963 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 964 | dm_destroy_session(newsid); |
| 965 | } |
| 966 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 967 | DMLOG_PRINT(DMLVL_DEBUG, |
| 968 | "Unable to set up variation! (errno = %d)\n", |
| 969 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 970 | DMVAR_SKIP(); |
| 971 | } else { |
| 972 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 973 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 977 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
| 978 | |
| 979 | /* Variation clean up */ |
| 980 | rc = dm_destroy_session(newsid); |
| 981 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 982 | DMLOG_PRINT(DMLVL_DEBUG, |
| 983 | "Unable to clean up variation! (errno = %d)\n", |
| 984 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 985 | } |
| 986 | dm_handle_free(hanp, hlen); |
| 987 | } |
| 988 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 989 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 990 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1003 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1004 | "Unable to set up variation! (errno = %d)\n", |
| 1005 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1006 | DMVAR_SKIP(); |
| 1007 | } else { |
| 1008 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1009 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1014 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
| 1015 | |
| 1016 | /* Variation clean up */ |
| 1017 | rc = dm_destroy_session(newsid); |
| 1018 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1019 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1020 | "Unable to clean up variation! (errno = %d)\n", |
| 1021 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1022 | } |
| 1023 | } |
| 1024 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1025 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1026 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1039 | if ((rc = |
| 1040 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1041 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1042 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1043 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1044 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1045 | dm_destroy_session(newsid); |
| 1046 | } |
| 1047 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1048 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1049 | "Unable to set up variation! (errno = %d)\n", |
| 1050 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1051 | DMVAR_SKIP(); |
| 1052 | } else { |
| 1053 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1054 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1059 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
| 1060 | |
| 1061 | /* Variation clean up */ |
| 1062 | rc = dm_destroy_session(newsid); |
| 1063 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1064 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1065 | "Unable to clean up variation! (errno = %d)\n", |
| 1066 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1067 | } |
| 1068 | dm_handle_free(hanp, hlen); |
| 1069 | } |
| 1070 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1071 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1072 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1085 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1086 | "Unable to set up variation! (errno = %d)\n", |
| 1087 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1088 | DMVAR_SKIP(); |
| 1089 | } else { |
| 1090 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1091 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1096 | DMVAR_ENDPASSEXP(szFuncName, 0, rc); |
| 1097 | |
| 1098 | /* Variation clean up */ |
| 1099 | rc = dm_destroy_session(newsid); |
| 1100 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1101 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1102 | "Unable to clean up variation! (errno = %d)\n", |
| 1103 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1104 | } |
| 1105 | } |
| 1106 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1107 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1108 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1121 | if ((rc = |
| 1122 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1123 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1124 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1125 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1126 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1127 | dm_destroy_session(newsid); |
| 1128 | } |
| 1129 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1130 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1131 | "Unable to set up variation! (errno = %d)\n", |
| 1132 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1133 | DMVAR_SKIP(); |
| 1134 | } else { |
| 1135 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1136 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1140 | DMVAR_ENDPASSEXP(szFuncName, 0, rc); |
| 1141 | |
| 1142 | /* Variation clean up */ |
| 1143 | rc = dm_destroy_session(newsid); |
| 1144 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1145 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1146 | "Unable to clean up variation! (errno = %d)\n", |
| 1147 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1148 | } |
| 1149 | dm_handle_free(hanp, hlen); |
| 1150 | } |
| 1151 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1152 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1153 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1168 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1169 | |
| 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1186 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1187 | |
| 1188 | /* Variation clean up */ |
| 1189 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1190 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1191 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1203 | if ((rc = |
| 1204 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1205 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1206 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1207 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1208 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1209 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1210 | } else |
| 1211 | if ((rc = |
| 1212 | dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1213 | &maxEvents, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1214 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1220 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1221 | "Unable to set up variation! (errno = %d)\n", |
| 1222 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1223 | DMVAR_SKIP(); |
| 1224 | } else { |
| 1225 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1226 | DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n", |
| 1227 | szFuncName); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1228 | rc = dm_getall_disp(newsid, sizeof(buf), buf, &rlen); |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1229 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1230 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1231 | /* 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1248 | if ((rc = |
| 1249 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1250 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1251 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1252 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1253 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1254 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1255 | } else |
| 1256 | if ((rc = |
| 1257 | dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1258 | &maxEvents, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1259 | dm_handle_free(hanp, hlen); |
| 1260 | dm_destroy_session(newsid); |
| 1261 | } |
| 1262 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1263 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1264 | "Unable to set up variation! (errno = %d)\n", |
| 1265 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1266 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1271 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1272 | |
| 1273 | /* Variation clean up */ |
| 1274 | rc = dm_destroy_session(newsid); |
| 1275 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1276 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1277 | "Unable to clean up variation! (errno = %d)\n", |
| 1278 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1279 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1296 | if ((rc = |
| 1297 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1298 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1299 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1300 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1301 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1302 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1303 | } else |
| 1304 | if ((rc = |
| 1305 | dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1306 | &maxEvents, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1307 | dm_handle_free(hanp, hlen); |
| 1308 | dm_destroy_session(newsid); |
| 1309 | } |
| 1310 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1311 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1312 | "Unable to set up variation! (errno = %d)\n", |
| 1313 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1314 | DMVAR_SKIP(); |
| 1315 | } else { |
| 1316 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1317 | DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n", |
| 1318 | szFuncName); |
| 1319 | rc = dm_getall_disp(newsid, sizeof(buf), |
| 1320 | (void *)INVALID_ADDR, &rlen); |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1321 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1322 | |
| 1323 | /* Variation clean up */ |
| 1324 | rc = dm_destroy_session(newsid); |
| 1325 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1326 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1327 | "Unable to clean up variation! (errno = %d)\n", |
| 1328 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1329 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1345 | if ((rc = |
| 1346 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1347 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1348 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1349 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1350 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1351 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1352 | } else |
| 1353 | if ((rc = |
| 1354 | dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1355 | &maxEvents, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1356 | dm_handle_free(hanp, hlen); |
| 1357 | dm_destroy_session(newsid); |
| 1358 | } |
| 1359 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1360 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1361 | "Unable to set up variation! (errno = %d)\n", |
| 1362 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1363 | DMVAR_SKIP(); |
| 1364 | } else { |
| 1365 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1366 | DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL rlenp)\n", |
| 1367 | szFuncName); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1368 | rc = dm_getall_disp(newsid, sizeof(buf), buf, NULL); |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1369 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1370 | |
| 1371 | /* Variation clean up */ |
| 1372 | rc = dm_destroy_session(newsid); |
| 1373 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1374 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1375 | "Unable to clean up variation! (errno = %d)\n", |
| 1376 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1377 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1393 | if ((rc = |
| 1394 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1395 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1396 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1397 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1398 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1399 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1400 | } else |
| 1401 | if ((rc = |
| 1402 | dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1403 | &maxEvents, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1404 | dm_handle_free(hanp, hlen); |
| 1405 | dm_destroy_session(newsid); |
| 1406 | } |
| 1407 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1408 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1409 | "Unable to set up variation! (errno = %d)\n", |
| 1410 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1411 | DMVAR_SKIP(); |
| 1412 | } else { |
| 1413 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1414 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1418 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1419 | |
| 1420 | /* Variation clean up */ |
| 1421 | rc = dm_destroy_session(newsid); |
| 1422 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1423 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1424 | "Unable to clean up variation! (errno = %d)\n", |
| 1425 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1426 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1443 | if ((rc = |
| 1444 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1445 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1446 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1447 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1448 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1449 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1450 | } else |
| 1451 | if ((rc = |
| 1452 | dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1453 | &maxEvents, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1454 | dm_handle_free(hanp, hlen); |
| 1455 | dm_destroy_session(newsid); |
| 1456 | } |
| 1457 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1458 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1459 | "Unable to set up variation! (errno = %d)\n", |
| 1460 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1461 | DMVAR_SKIP(); |
| 1462 | } else { |
| 1463 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1464 | DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen zero)\n", |
| 1465 | szFuncName); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1466 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1470 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1471 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1472 | /* Variation clean up */ |
| 1473 | rc = dm_destroy_session(newsid); |
| 1474 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1475 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1476 | "Unable to clean up variation! (errno = %d)\n", |
| 1477 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1478 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1495 | if ((rc = |
| 1496 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1497 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1498 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1499 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1500 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1501 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1502 | } else |
| 1503 | if ((rc = |
| 1504 | dm_set_disp(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1505 | &maxEvents, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1506 | dm_handle_free(hanp, hlen); |
| 1507 | dm_destroy_session(newsid); |
| 1508 | } |
| 1509 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1510 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1511 | "Unable to set up variation! (errno = %d)\n", |
| 1512 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1513 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1520 | dm_dispinfo_t *di = (dm_dispinfo_t *) buf; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1521 | if (rlen == sizeof(dm_dispinfo_t) + hlen) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1522 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1534 | DMVAR_PASS(); |
| 1535 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1536 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1543 | DMVAR_FAIL(); |
| 1544 | } |
| 1545 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1546 | 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 | *)); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1555 | DMVAR_FAIL(); |
| 1556 | } |
| 1557 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1558 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1563 | DMVAR_FAIL(); |
| 1564 | } |
| 1565 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1566 | DMLOG_PRINT(DMLVL_ERR, |
| 1567 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 1568 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1569 | DMVAR_FAIL(); |
| 1570 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1571 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1572 | /* Variation clean up */ |
| 1573 | rc = dm_destroy_session(newsid); |
| 1574 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1575 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1576 | "Unable to clean up variation! (errno = %d)\n", |
| 1577 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1578 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1596 | if ((rc = |
| 1597 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1598 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1599 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1600 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1601 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1602 | dm_destroy_session(newsid); |
| 1603 | } |
| 1604 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1605 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1606 | "Unable to set up variation! (errno = %d)\n", |
| 1607 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1608 | DMVAR_SKIP(); |
| 1609 | } else { |
| 1610 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1611 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1616 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1617 | |
| 1618 | /* Variation clean up */ |
| 1619 | rc = dm_destroy_session(newsid); |
| 1620 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1621 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1622 | "Unable to clean up variation! (errno = %d)\n", |
| 1623 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1624 | } |
| 1625 | dm_handle_free(hanp, hlen); |
| 1626 | } |
| 1627 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1628 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1629 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1640 | if ((rc = |
| 1641 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1642 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1643 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1644 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1645 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1646 | dm_destroy_session(newsid); |
| 1647 | } |
| 1648 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1649 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1650 | "Unable to set up variation! (errno = %d)\n", |
| 1651 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1652 | DMVAR_SKIP(); |
| 1653 | } else { |
| 1654 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1655 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1660 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1661 | |
| 1662 | /* Variation clean up */ |
| 1663 | rc = dm_destroy_session(newsid); |
| 1664 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1665 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1666 | "Unable to clean up variation! (errno = %d)\n", |
| 1667 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1668 | } |
| 1669 | dm_handle_free(hanp, hlen); |
| 1670 | } |
| 1671 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1672 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1673 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1684 | if ((rc = |
| 1685 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1686 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1687 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1688 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1689 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1690 | dm_destroy_session(newsid); |
| 1691 | } |
| 1692 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1693 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1694 | "Unable to set up variation! (errno = %d)\n", |
| 1695 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1696 | DMVAR_SKIP(); |
| 1697 | } else { |
| 1698 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1699 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1704 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
| 1705 | |
| 1706 | /* Variation clean up */ |
| 1707 | rc = dm_destroy_session(newsid); |
| 1708 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1709 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1710 | "Unable to clean up variation! (errno = %d)\n", |
| 1711 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1712 | } |
| 1713 | dm_handle_free(hanp, hlen); |
| 1714 | } |
| 1715 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1716 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1717 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1728 | if ((rc = |
| 1729 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1730 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1731 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1732 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1733 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1734 | dm_destroy_session(newsid); |
| 1735 | } |
| 1736 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1737 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1738 | "Unable to set up variation! (errno = %d)\n", |
| 1739 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1740 | DMVAR_SKIP(); |
| 1741 | } else { |
| 1742 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1743 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1748 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1749 | |
| 1750 | /* Variation clean up */ |
| 1751 | rc = dm_destroy_session(newsid); |
| 1752 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1753 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1754 | "Unable to clean up variation! (errno = %d)\n", |
| 1755 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1756 | } |
| 1757 | dm_handle_free(hanp, hlen); |
| 1758 | } |
| 1759 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1760 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1761 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1772 | if ((rc = |
| 1773 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1774 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1775 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1776 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1777 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1778 | dm_destroy_session(newsid); |
| 1779 | } |
| 1780 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1781 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1782 | "Unable to set up variation! (errno = %d)\n", |
| 1783 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1784 | DMVAR_SKIP(); |
| 1785 | } else { |
| 1786 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1787 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1791 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1792 | |
| 1793 | /* Variation clean up */ |
| 1794 | rc = dm_destroy_session(newsid); |
| 1795 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1796 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1797 | "Unable to clean up variation! (errno = %d)\n", |
| 1798 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1799 | } |
| 1800 | dm_handle_free(hanp, hlen); |
| 1801 | } |
| 1802 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1803 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1804 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1814 | if ((rc = |
| 1815 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1816 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1817 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1818 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1819 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1820 | dm_destroy_session(newsid); |
| 1821 | } |
| 1822 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1823 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1824 | "Unable to set up variation! (errno = %d)\n", |
| 1825 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1826 | DMVAR_SKIP(); |
| 1827 | } else { |
| 1828 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1829 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1834 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1835 | |
| 1836 | /* Variation clean up */ |
| 1837 | rc = dm_destroy_session(newsid); |
| 1838 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1839 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1840 | "Unable to clean up variation! (errno = %d)\n", |
| 1841 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1842 | } |
| 1843 | dm_handle_free(hanp, hlen); |
| 1844 | } |
| 1845 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1846 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1847 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1858 | if ((rc = |
| 1859 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1860 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1861 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1862 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1863 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1864 | dm_destroy_session(newsid); |
| 1865 | } |
| 1866 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1867 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1868 | "Unable to set up variation! (errno = %d)\n", |
| 1869 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1870 | DMVAR_SKIP(); |
| 1871 | } else { |
| 1872 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1873 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 1877 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1878 | |
| 1879 | /* Variation clean up */ |
| 1880 | rc = dm_destroy_session(newsid); |
| 1881 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1882 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1883 | "Unable to clean up variation! (errno = %d)\n", |
| 1884 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1885 | } |
| 1886 | dm_handle_free(hanp, hlen); |
| 1887 | } |
| 1888 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1889 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1890 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1904 | if ((rc = |
| 1905 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1906 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1907 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1908 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1909 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1910 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1911 | } else |
| 1912 | if ((rc = |
| 1913 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1914 | &eventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1915 | dm_handle_free(hanp, hlen); |
| 1916 | dm_destroy_session(newsid); |
| 1917 | } |
| 1918 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1919 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1920 | "Unable to set up variation! (errno = %d)\n", |
| 1921 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1922 | DMVAR_SKIP(); |
| 1923 | } else { |
| 1924 | /* Variation */ |
| 1925 | eventset = minEvents; |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1926 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1931 | if (rc == 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1932 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1942 | DMVAR_PASS(); |
| 1943 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1944 | DMLOG_PRINT(DMLVL_ERR, |
| 1945 | "%s failed with expected rc = %d but high set event cleared\n", |
| 1946 | szFuncName, 0); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1947 | DMVAR_FAIL(); |
| 1948 | } |
| 1949 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1950 | DMLOG_PRINT(DMLVL_ERR, |
| 1951 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 1952 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1953 | DMVAR_FAIL(); |
| 1954 | } |
| 1955 | |
| 1956 | /* Variation clean up */ |
| 1957 | rc = dm_destroy_session(newsid); |
| 1958 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1959 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1960 | "Unable to clean up variation! (errno = %d)\n", |
| 1961 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1962 | } |
| 1963 | dm_handle_free(hanp, hlen); |
| 1964 | } |
| 1965 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 1966 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1967 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1981 | if ((rc = |
| 1982 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 1983 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1984 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1985 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 1986 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1987 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1988 | } else |
| 1989 | if ((rc = |
| 1990 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 1991 | &eventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1992 | dm_handle_free(hanp, hlen); |
| 1993 | dm_destroy_session(newsid); |
| 1994 | } |
| 1995 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 1996 | DMLOG_PRINT(DMLVL_DEBUG, |
| 1997 | "Unable to set up variation! (errno = %d)\n", |
| 1998 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1999 | DMVAR_SKIP(); |
| 2000 | } else { |
| 2001 | /* Variation */ |
| 2002 | eventset = minEvents; |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2003 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2008 | if (rc == 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2009 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2019 | DMVAR_PASS(); |
| 2020 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2021 | DMLOG_PRINT(DMLVL_ERR, |
| 2022 | "%s failed with expected rc = %d but high set event still set\n", |
| 2023 | szFuncName, 0); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2024 | DMVAR_FAIL(); |
| 2025 | } |
| 2026 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2027 | DMLOG_PRINT(DMLVL_ERR, |
| 2028 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 2029 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2030 | DMVAR_FAIL(); |
| 2031 | } |
| 2032 | |
| 2033 | /* Variation clean up */ |
| 2034 | rc = dm_destroy_session(newsid); |
| 2035 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2036 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2037 | "Unable to clean up variation! (errno = %d)\n", |
| 2038 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2039 | } |
| 2040 | dm_handle_free(hanp, hlen); |
| 2041 | } |
| 2042 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2043 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2044 | /* |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2045 | * Global handle dm_set_eventlist variations |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2046 | * |
| 2047 | * This variation uncovered XFS BUG #15 (EBADF errno returned instead |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 2048 | * of EINVAL) |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2049 | */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2050 | for (i = 0, varNum = SET_EVENTLIST_BASE + 10; i < DM_EVENT_MAX; |
| 2051 | i++, varNum++) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2052 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2059 | rc = dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2060 | &newsid); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2061 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2062 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2063 | "Unable to set up variation! (errno = %d)\n", |
| 2064 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2065 | DMVAR_SKIP(); |
| 2066 | } else { |
| 2067 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2068 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2076 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
| 2077 | |
| 2078 | /* Variation clean up */ |
| 2079 | rc = dm_destroy_session(newsid); |
| 2080 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2081 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2082 | "Unable to clean up variation! (errno = %d)\n", |
| 2083 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2084 | } |
| 2085 | } |
| 2086 | } |
| 2087 | } |
| 2088 | |
| 2089 | /* |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2090 | * File system handle dm_set_eventlist variations |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2091 | */ |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2102 | if ((rc = |
| 2103 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2104 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2105 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2106 | } else |
| 2107 | if ((rc = |
| 2108 | dm_path_to_fshandle(DummyFile, &hanp, |
| 2109 | &hlen)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2110 | dm_destroy_session(newsid); |
| 2111 | } |
| 2112 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2113 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2114 | "Unable to set up variation! (errno = %d)\n", |
| 2115 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2116 | DMVAR_SKIP(); |
| 2117 | } else { |
| 2118 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2119 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2125 | if (dmimpl_validEvents[i].bFSHandle) |
| 2126 | DMVAR_ENDPASSEXP(szFuncName, 0, rc); |
| 2127 | else |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2128 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, |
| 2129 | EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2130 | |
| 2131 | /* Variation clean up */ |
| 2132 | rc = dm_destroy_session(newsid); |
| 2133 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2134 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2135 | "Unable to clean up variation! (errno = %d)\n", |
| 2136 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2137 | } |
| 2138 | dm_handle_free(hanp, hlen); |
| 2139 | } |
| 2140 | } |
| 2141 | } |
| 2142 | |
| 2143 | /* |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2144 | * Directory handle dm_set_eventlist variations |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2145 | */ |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2156 | if ((rc = |
| 2157 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2158 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2159 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2160 | } else |
| 2161 | if ((rc = |
| 2162 | dm_path_to_handle(DummySubdir, &hanp, |
| 2163 | &hlen)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2164 | dm_destroy_session(newsid); |
| 2165 | } |
| 2166 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2167 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2168 | "Unable to set up variation! (errno = %d)\n", |
| 2169 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2170 | DMVAR_SKIP(); |
| 2171 | } else { |
| 2172 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2173 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2179 | if (dmimpl_validEvents[i].bDirHandle) |
| 2180 | DMVAR_ENDPASSEXP(szFuncName, 0, rc); |
| 2181 | else |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2182 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, |
| 2183 | EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2184 | |
| 2185 | /* Variation clean up */ |
| 2186 | rc = dm_destroy_session(newsid); |
| 2187 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2188 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2189 | "Unable to clean up variation! (errno = %d)\n", |
| 2190 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2191 | } |
| 2192 | dm_handle_free(hanp, hlen); |
| 2193 | } |
| 2194 | } |
| 2195 | } |
| 2196 | |
| 2197 | /* |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2198 | * File handle dm_set_eventlist variations |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2199 | */ |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2210 | if ((rc = |
| 2211 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2212 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2213 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2214 | } else |
| 2215 | if ((rc = |
| 2216 | dm_path_to_handle(DummyFile, &hanp, |
| 2217 | &hlen)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2218 | dm_destroy_session(newsid); |
| 2219 | } |
| 2220 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2221 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2222 | "Unable to set up variation! (errno = %d)\n", |
| 2223 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2224 | DMVAR_SKIP(); |
| 2225 | } else { |
| 2226 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2227 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2233 | if (dmimpl_validEvents[i].bFileHandle) |
| 2234 | DMVAR_ENDPASSEXP(szFuncName, 0, rc); |
| 2235 | else |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2236 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, |
| 2237 | EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2238 | |
| 2239 | /* Variation clean up */ |
| 2240 | rc = dm_destroy_session(newsid); |
| 2241 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2242 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2243 | "Unable to clean up variation! (errno = %d)\n", |
| 2244 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2245 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2268 | if ((rc = |
| 2269 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2270 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2271 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2272 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2273 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2274 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2275 | } else |
| 2276 | if ((rc = |
| 2277 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2278 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2279 | dm_handle_free(hanp, hlen); |
| 2280 | dm_destroy_session(newsid); |
| 2281 | } |
| 2282 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2283 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2284 | "Unable to set up variation! (errno = %d)\n", |
| 2285 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2286 | DMVAR_SKIP(); |
| 2287 | } else { |
| 2288 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2289 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2294 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2295 | |
| 2296 | /* Variation clean up */ |
| 2297 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2298 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2299 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2300 | rc |= dm_destroy_session(newsid); |
| 2301 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2302 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2303 | "Unable to clean up variation! (errno = %d)\n", |
| 2304 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2305 | } |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2325 | if ((rc = |
| 2326 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2327 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2328 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2329 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2330 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2331 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2332 | } else |
| 2333 | if ((rc = |
| 2334 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2335 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2336 | dm_handle_free(hanp, hlen); |
| 2337 | dm_destroy_session(newsid); |
| 2338 | } |
| 2339 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2340 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2341 | "Unable to set up variation! (errno = %d)\n", |
| 2342 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2343 | DMVAR_SKIP(); |
| 2344 | } else { |
| 2345 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2346 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2351 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2352 | |
| 2353 | /* Variation clean up */ |
| 2354 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2355 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2356 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2357 | rc |= dm_destroy_session(newsid); |
| 2358 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2359 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2360 | "Unable to clean up variation! (errno = %d)\n", |
| 2361 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2362 | } |
| 2363 | dm_handle_free(hanp, hlen); |
| 2364 | } |
| 2365 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2366 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2367 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2382 | if ((rc = |
| 2383 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2384 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2385 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2386 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2387 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2388 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2389 | } else |
| 2390 | if ((rc = |
| 2391 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2392 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2393 | dm_handle_free(hanp, hlen); |
| 2394 | dm_destroy_session(newsid); |
| 2395 | } |
| 2396 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2397 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2398 | "Unable to set up variation! (errno = %d)\n", |
| 2399 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2400 | DMVAR_SKIP(); |
| 2401 | } else { |
| 2402 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2403 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2408 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2409 | |
| 2410 | /* Variation clean up */ |
| 2411 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2412 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2413 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2414 | rc |= dm_destroy_session(newsid); |
| 2415 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2416 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2417 | "Unable to clean up variation! (errno = %d)\n", |
| 2418 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2419 | } |
| 2420 | dm_handle_free(hanp, hlen); |
| 2421 | } |
| 2422 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2423 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2424 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2439 | if ((rc = |
| 2440 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2441 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2442 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2443 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2444 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2445 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2446 | } else |
| 2447 | if ((rc = |
| 2448 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2449 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2450 | dm_handle_free(hanp, hlen); |
| 2451 | dm_destroy_session(newsid); |
| 2452 | } |
| 2453 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2454 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2455 | "Unable to set up variation! (errno = %d)\n", |
| 2456 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2457 | DMVAR_SKIP(); |
| 2458 | } else { |
| 2459 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2460 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2465 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
| 2466 | |
| 2467 | /* Variation clean up */ |
| 2468 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2469 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2470 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2471 | rc |= dm_destroy_session(newsid); |
| 2472 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2473 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2474 | "Unable to clean up variation! (errno = %d)\n", |
| 2475 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2476 | } |
| 2477 | dm_handle_free(hanp, hlen); |
| 2478 | } |
| 2479 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2480 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2481 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2496 | if ((rc = |
| 2497 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2498 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2499 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2500 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2501 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2502 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2503 | } else |
| 2504 | if ((rc = |
| 2505 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2506 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2507 | dm_handle_free(hanp, hlen); |
| 2508 | dm_destroy_session(newsid); |
| 2509 | } |
| 2510 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2511 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2512 | "Unable to set up variation! (errno = %d)\n", |
| 2513 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2514 | DMVAR_SKIP(); |
| 2515 | } else { |
| 2516 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2517 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2522 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2523 | |
| 2524 | /* Variation clean up */ |
| 2525 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2526 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2527 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2528 | rc |= dm_destroy_session(newsid); |
| 2529 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2530 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2531 | "Unable to clean up variation! (errno = %d)\n", |
| 2532 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2533 | } |
| 2534 | dm_handle_free(hanp, hlen); |
| 2535 | } |
| 2536 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2537 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2538 | /* |
| 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 Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 2543 | * errno EINVAL) |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2544 | */ |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2556 | if ((rc = |
| 2557 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2558 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2559 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2560 | } else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen)) |
| 2561 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2562 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2563 | } else |
| 2564 | if ((rc = |
| 2565 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2566 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2567 | dm_handle_free(hanp, hlen); |
| 2568 | dm_destroy_session(newsid); |
| 2569 | } |
| 2570 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2571 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2572 | "Unable to set up variation! (errno = %d)\n", |
| 2573 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2574 | DMVAR_SKIP(); |
| 2575 | } else { |
| 2576 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2577 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2582 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2583 | |
| 2584 | /* Variation clean up */ |
| 2585 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2586 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2587 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2588 | rc |= dm_destroy_session(newsid); |
| 2589 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2590 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2591 | "Unable to clean up variation! (errno = %d)\n", |
| 2592 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2593 | } |
| 2594 | dm_handle_free(hanp, hlen); |
| 2595 | } |
| 2596 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2597 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2598 | /* |
| 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 Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 2603 | * of E2BIG, nelemp not updated) |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2604 | */ |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2616 | if ((rc = |
| 2617 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2618 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2619 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2620 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2621 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2622 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2623 | } else |
| 2624 | if ((rc = |
| 2625 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2626 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2627 | dm_handle_free(hanp, hlen); |
| 2628 | dm_destroy_session(newsid); |
| 2629 | } |
| 2630 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2631 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2632 | "Unable to set up variation! (errno = %d)\n", |
| 2633 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2634 | DMVAR_SKIP(); |
| 2635 | } else { |
| 2636 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2637 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2642 | if (rc == -1) { |
| 2643 | if (errno == E2BIG) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2644 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2649 | DMVAR_PASS(); |
| 2650 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2651 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2657 | DMVAR_FAIL(); |
| 2658 | } |
| 2659 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2660 | DMLOG_PRINT(DMLVL_ERR, |
| 2661 | "%s failed with expected rc = %d but unexpected errno = %d\n", |
| 2662 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2663 | DMVAR_FAIL(); |
| 2664 | } |
| 2665 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2666 | DMLOG_PRINT(DMLVL_ERR, |
| 2667 | "%s failed with unexpected rc = %d\n", |
| 2668 | szFuncName, rc); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2669 | DMVAR_FAIL(); |
| 2670 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2671 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2672 | /* Variation clean up */ |
| 2673 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2674 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2675 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2676 | rc |= dm_destroy_session(newsid); |
| 2677 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2678 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2679 | "Unable to clean up variation! (errno = %d)\n", |
| 2680 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2681 | } |
| 2682 | dm_handle_free(hanp, hlen); |
| 2683 | } |
| 2684 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2685 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2686 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2701 | if ((rc = |
| 2702 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2703 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2704 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2705 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 2706 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2707 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2708 | } else |
| 2709 | if ((rc = |
| 2710 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2711 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2712 | dm_handle_free(hanp, hlen); |
| 2713 | dm_destroy_session(newsid); |
| 2714 | } |
| 2715 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2716 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2717 | "Unable to set up variation! (errno = %d)\n", |
| 2718 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2719 | DMVAR_SKIP(); |
| 2720 | } else { |
| 2721 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2722 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2727 | if (rc == -1) { |
| 2728 | if (errno == E2BIG) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2729 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2734 | DMVAR_PASS(); |
| 2735 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2736 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2742 | DMVAR_FAIL(); |
| 2743 | } |
| 2744 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2745 | DMLOG_PRINT(DMLVL_ERR, |
| 2746 | "%s failed with expected rc = %d but unexpected errno = %d\n", |
| 2747 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2748 | DMVAR_FAIL(); |
| 2749 | } |
| 2750 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2751 | DMLOG_PRINT(DMLVL_ERR, |
| 2752 | "%s failed with unexpected rc = %d\n", |
| 2753 | szFuncName, rc); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2754 | DMVAR_FAIL(); |
| 2755 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2756 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2757 | /* Variation clean up */ |
| 2758 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2759 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2760 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2761 | rc |= dm_destroy_session(newsid); |
| 2762 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2763 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2764 | "Unable to clean up variation! (errno = %d)\n", |
| 2765 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2766 | } |
| 2767 | dm_handle_free(hanp, hlen); |
| 2768 | } |
| 2769 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2770 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2771 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2786 | if ((rc = |
| 2787 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2788 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2789 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2790 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2791 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2792 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2793 | } else |
| 2794 | if ((rc = |
| 2795 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2796 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2797 | dm_handle_free(hanp, hlen); |
| 2798 | dm_destroy_session(newsid); |
| 2799 | } |
| 2800 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2801 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2802 | "Unable to set up variation! (errno = %d)\n", |
| 2803 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2804 | DMVAR_SKIP(); |
| 2805 | } else { |
| 2806 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2807 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2813 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2814 | |
| 2815 | /* Variation clean up */ |
| 2816 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2817 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2818 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2819 | rc |= dm_destroy_session(newsid); |
| 2820 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2821 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2822 | "Unable to clean up variation! (errno = %d)\n", |
| 2823 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2824 | } |
| 2825 | dm_handle_free(hanp, hlen); |
| 2826 | } |
| 2827 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2828 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2829 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2843 | if ((rc = |
| 2844 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2845 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2846 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2847 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2848 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2849 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2850 | } else |
| 2851 | if ((rc = |
| 2852 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2853 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2854 | dm_handle_free(hanp, hlen); |
| 2855 | dm_destroy_session(newsid); |
| 2856 | } |
| 2857 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2858 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2859 | "Unable to set up variation! (errno = %d)\n", |
| 2860 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2861 | DMVAR_SKIP(); |
| 2862 | } else { |
| 2863 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2864 | 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_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 2869 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2870 | |
| 2871 | /* Variation clean up */ |
| 2872 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2873 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 2874 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2875 | rc |= dm_destroy_session(newsid); |
| 2876 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2877 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2878 | "Unable to clean up variation! (errno = %d)\n", |
| 2879 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2880 | } |
| 2881 | dm_handle_free(hanp, hlen); |
| 2882 | } |
| 2883 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2884 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2885 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2899 | if ((rc = |
| 2900 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2901 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2902 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2903 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 2904 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2905 | dm_destroy_session(newsid); |
| 2906 | } |
| 2907 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2908 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2909 | "Unable to set up variation! (errno = %d)\n", |
| 2910 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2911 | DMVAR_SKIP(); |
| 2912 | } else { |
| 2913 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2914 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2919 | if (rc == 0) { |
| 2920 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
| 2921 | if (nelem == 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2922 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2928 | DMVAR_PASS(); |
| 2929 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2930 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2935 | DMVAR_FAIL(); |
| 2936 | } |
| 2937 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2938 | DMLOG_PRINT(DMLVL_ERR, |
| 2939 | "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n", |
| 2940 | szFuncName, 0, nelem, 0); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2941 | DMVAR_FAIL(); |
| 2942 | } |
| 2943 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2944 | DMLOG_PRINT(DMLVL_ERR, |
| 2945 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 2946 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2947 | DMVAR_FAIL(); |
| 2948 | } |
| 2949 | |
| 2950 | /* Variation clean up */ |
| 2951 | rc = dm_destroy_session(newsid); |
| 2952 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2953 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2954 | "Unable to clean up variation! (errno = %d)\n", |
| 2955 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2956 | } |
| 2957 | dm_handle_free(hanp, hlen); |
| 2958 | } |
| 2959 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 2960 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2961 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2975 | if ((rc = |
| 2976 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 2977 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2978 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2979 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 2980 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2981 | dm_destroy_session(newsid); |
| 2982 | } |
| 2983 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2984 | DMLOG_PRINT(DMLVL_DEBUG, |
| 2985 | "Unable to set up variation! (errno = %d)\n", |
| 2986 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2987 | DMVAR_SKIP(); |
| 2988 | } else { |
| 2989 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2990 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 2996 | if (rc == 0) { |
| 2997 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
| 2998 | if (nelem == 0) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 2999 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3005 | DMVAR_PASS(); |
| 3006 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3007 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3012 | DMVAR_FAIL(); |
| 3013 | } |
| 3014 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3015 | DMLOG_PRINT(DMLVL_ERR, |
| 3016 | "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n", |
| 3017 | szFuncName, 0, nelem, 0); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3018 | DMVAR_FAIL(); |
| 3019 | } |
| 3020 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3021 | DMLOG_PRINT(DMLVL_ERR, |
| 3022 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3023 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3024 | DMVAR_FAIL(); |
| 3025 | } |
| 3026 | |
| 3027 | /* Variation clean up */ |
| 3028 | rc = dm_destroy_session(newsid); |
| 3029 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3030 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3031 | "Unable to clean up variation! (errno = %d)\n", |
| 3032 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3033 | } |
| 3034 | dm_handle_free(hanp, hlen); |
| 3035 | } |
| 3036 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3037 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3038 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3053 | if ((rc = |
| 3054 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3055 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3056 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3057 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 3058 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3059 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3060 | } else |
| 3061 | if ((rc = |
| 3062 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3063 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3064 | dm_handle_free(hanp, hlen); |
| 3065 | dm_destroy_session(newsid); |
| 3066 | } |
| 3067 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3068 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3069 | "Unable to set up variation! (errno = %d)\n", |
| 3070 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3071 | DMVAR_SKIP(); |
| 3072 | } else { |
| 3073 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3074 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3079 | if (rc == 0) { |
| 3080 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3081 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3088 | DMVAR_PASS(); |
| 3089 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3090 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3095 | DMVAR_FAIL(); |
| 3096 | } |
| 3097 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3098 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3102 | DMVAR_FAIL(); |
| 3103 | } |
| 3104 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3105 | DMLOG_PRINT(DMLVL_ERR, |
| 3106 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3107 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3108 | DMVAR_FAIL(); |
| 3109 | } |
| 3110 | |
| 3111 | /* Variation clean up */ |
| 3112 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3113 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3114 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3115 | rc |= dm_destroy_session(newsid); |
| 3116 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3117 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3118 | "Unable to clean up variation! (errno = %d)\n", |
| 3119 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3120 | } |
| 3121 | dm_handle_free(hanp, hlen); |
| 3122 | } |
| 3123 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3124 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3125 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3140 | if ((rc = |
| 3141 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3142 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3143 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3144 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 3145 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3146 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3147 | } else |
| 3148 | if ((rc = |
| 3149 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3150 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3151 | dm_handle_free(hanp, hlen); |
| 3152 | dm_destroy_session(newsid); |
| 3153 | } |
| 3154 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3155 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3156 | "Unable to set up variation! (errno = %d)\n", |
| 3157 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3158 | DMVAR_SKIP(); |
| 3159 | } else { |
| 3160 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3161 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3166 | if (rc == 0) { |
| 3167 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3168 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3175 | DMVAR_PASS(); |
| 3176 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3177 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3182 | DMVAR_FAIL(); |
| 3183 | } |
| 3184 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3185 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3189 | DMVAR_FAIL(); |
| 3190 | } |
| 3191 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3192 | DMLOG_PRINT(DMLVL_ERR, |
| 3193 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3194 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3195 | DMVAR_FAIL(); |
| 3196 | } |
| 3197 | |
| 3198 | /* Variation clean up */ |
| 3199 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3200 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3201 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3202 | rc |= dm_destroy_session(newsid); |
| 3203 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3204 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3205 | "Unable to clean up variation! (errno = %d)\n", |
| 3206 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3207 | } |
| 3208 | dm_handle_free(hanp, hlen); |
| 3209 | } |
| 3210 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3211 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3212 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3229 | if ((rc = |
| 3230 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3231 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3232 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3233 | } else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) |
| 3234 | == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3235 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3236 | } else |
| 3237 | if ((rc = |
| 3238 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3239 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3240 | dm_handle_free(hanp, hlen); |
| 3241 | dm_destroy_session(newsid); |
| 3242 | } |
| 3243 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3244 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3245 | "Unable to set up variation! (errno = %d)\n", |
| 3246 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3247 | DMVAR_SKIP(); |
| 3248 | } else { |
| 3249 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3250 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3255 | if (rc == 0) { |
| 3256 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3257 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3264 | DMVAR_PASS(); |
| 3265 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3266 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3271 | DMVAR_FAIL(); |
| 3272 | } |
| 3273 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3274 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3278 | DMVAR_FAIL(); |
| 3279 | } |
| 3280 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3281 | DMLOG_PRINT(DMLVL_ERR, |
| 3282 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3283 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3284 | DMVAR_FAIL(); |
| 3285 | } |
| 3286 | |
| 3287 | /* Variation clean up */ |
| 3288 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3289 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3290 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3291 | rc |= dm_destroy_session(newsid); |
| 3292 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3293 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3294 | "Unable to clean up variation! (errno = %d)\n", |
| 3295 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3296 | } |
| 3297 | dm_handle_free(hanp, hlen); |
| 3298 | } |
| 3299 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3300 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3301 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3318 | if ((rc = |
| 3319 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3320 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3321 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3322 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 3323 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3324 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3325 | } else |
| 3326 | if ((rc = |
| 3327 | dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3328 | &ineventset, DM_EVENT_MAX)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3329 | dm_handle_free(hanp, hlen); |
| 3330 | dm_destroy_session(newsid); |
| 3331 | } |
| 3332 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3333 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3334 | "Unable to set up variation! (errno = %d)\n", |
| 3335 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3336 | DMVAR_SKIP(); |
| 3337 | } else { |
| 3338 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3339 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3345 | if (rc == 0) { |
| 3346 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3347 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3354 | DMVAR_PASS(); |
| 3355 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3356 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3361 | DMVAR_FAIL(); |
| 3362 | } |
| 3363 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3364 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3368 | DMVAR_FAIL(); |
| 3369 | } |
| 3370 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3371 | DMLOG_PRINT(DMLVL_ERR, |
| 3372 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3373 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3374 | DMVAR_FAIL(); |
| 3375 | } |
| 3376 | |
| 3377 | /* Variation clean up */ |
| 3378 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3379 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3380 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3381 | rc |= dm_destroy_session(newsid); |
| 3382 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3383 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3384 | "Unable to clean up variation! (errno = %d)\n", |
| 3385 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3386 | } |
| 3387 | dm_handle_free(hanp, hlen); |
| 3388 | } |
| 3389 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3390 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3391 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3401 | dm_region_t region = { 0, 0, DM_REGION_READ }; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3402 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3408 | if ((rc = |
| 3409 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3410 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3411 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3412 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 3413 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3414 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3415 | } else |
| 3416 | if ((rc = |
| 3417 | dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1, |
| 3418 | ®ion, &exactflag)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3419 | dm_handle_free(hanp, hlen); |
| 3420 | dm_destroy_session(newsid); |
| 3421 | } |
| 3422 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3423 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3424 | "Unable to set up variation! (errno = %d)\n", |
| 3425 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3426 | DMVAR_SKIP(); |
| 3427 | } else { |
| 3428 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3429 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3434 | if (rc == 0) { |
| 3435 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3436 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3443 | DMVAR_PASS(); |
| 3444 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3445 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3450 | DMVAR_FAIL(); |
| 3451 | } |
| 3452 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3453 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3457 | DMVAR_FAIL(); |
| 3458 | } |
| 3459 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3460 | DMLOG_PRINT(DMLVL_ERR, |
| 3461 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3462 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3463 | DMVAR_FAIL(); |
| 3464 | } |
| 3465 | |
| 3466 | /* Variation clean up */ |
| 3467 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3468 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3469 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3470 | rc |= dm_destroy_session(newsid); |
| 3471 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3472 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3473 | "Unable to clean up variation! (errno = %d)\n", |
| 3474 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3475 | } |
| 3476 | dm_handle_free(hanp, hlen); |
| 3477 | } |
| 3478 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3479 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3480 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3490 | dm_region_t region = { 0, 10, DM_REGION_WRITE }; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3491 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3497 | if ((rc = |
| 3498 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3499 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3500 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3501 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 3502 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3503 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3504 | } else |
| 3505 | if ((rc = |
| 3506 | dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1, |
| 3507 | ®ion, &exactflag)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3508 | dm_handle_free(hanp, hlen); |
| 3509 | dm_destroy_session(newsid); |
| 3510 | } |
| 3511 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3512 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3513 | "Unable to set up variation! (errno = %d)\n", |
| 3514 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3515 | DMVAR_SKIP(); |
| 3516 | } else { |
| 3517 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3518 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3523 | if (rc == 0) { |
| 3524 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3525 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3532 | DMVAR_PASS(); |
| 3533 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3534 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3539 | DMVAR_FAIL(); |
| 3540 | } |
| 3541 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3542 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3546 | DMVAR_FAIL(); |
| 3547 | } |
| 3548 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3549 | DMLOG_PRINT(DMLVL_ERR, |
| 3550 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3551 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3552 | DMVAR_FAIL(); |
| 3553 | } |
| 3554 | |
| 3555 | /* Variation clean up */ |
| 3556 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3557 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3558 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3559 | rc |= dm_destroy_session(newsid); |
| 3560 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3561 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3562 | "Unable to clean up variation! (errno = %d)\n", |
| 3563 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3564 | } |
| 3565 | dm_handle_free(hanp, hlen); |
| 3566 | } |
| 3567 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3568 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3569 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3579 | dm_region_t region = |
| 3580 | { TMP_FILELEN - 10, 0, DM_REGION_TRUNCATE }; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3581 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3587 | if ((rc = |
| 3588 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3589 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3590 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3591 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 3592 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3593 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3594 | } else |
| 3595 | if ((rc = |
| 3596 | dm_set_region(newsid, hanp, hlen, DM_NO_TOKEN, 1, |
| 3597 | ®ion, &exactflag)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3598 | dm_handle_free(hanp, hlen); |
| 3599 | dm_destroy_session(newsid); |
| 3600 | } |
| 3601 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3602 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3603 | "Unable to set up variation! (errno = %d)\n", |
| 3604 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3605 | DMVAR_SKIP(); |
| 3606 | } else { |
| 3607 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3608 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3613 | if (rc == 0) { |
| 3614 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3615 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3622 | DMVAR_PASS(); |
| 3623 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3624 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3629 | DMVAR_FAIL(); |
| 3630 | } |
| 3631 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3632 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3636 | DMVAR_FAIL(); |
| 3637 | } |
| 3638 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3639 | DMLOG_PRINT(DMLVL_ERR, |
| 3640 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3641 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3642 | DMVAR_FAIL(); |
| 3643 | } |
| 3644 | |
| 3645 | /* Variation clean up */ |
| 3646 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3647 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3648 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3649 | rc |= dm_destroy_session(newsid); |
| 3650 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3651 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3652 | "Unable to clean up variation! (errno = %d)\n", |
| 3653 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3654 | } |
| 3655 | dm_handle_free(hanp, hlen); |
| 3656 | } |
| 3657 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3658 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3659 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3669 | dm_region_t region = |
| 3670 | { TMP_FILELEN - 10, 0, DM_REGION_TRUNCATE }; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3671 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3679 | if ((rc = |
| 3680 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3681 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3682 | /* No clean up */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3683 | } else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == |
| 3684 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3685 | dm_destroy_session(newsid); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3686 | } 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 | ®ion, &exactflag)) == -1)) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3694 | dm_handle_free(hanp, hlen); |
| 3695 | dm_destroy_session(newsid); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 3696 | } |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3697 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3698 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3699 | "Unable to set up variation! (errno = %d)\n", |
| 3700 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3701 | DMVAR_SKIP(); |
| 3702 | } else { |
| 3703 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3704 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3710 | if (rc == 0) { |
| 3711 | DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3712 | if (nelem == DM_EVENT_DESTROY + 1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3713 | DMEV_SET(DM_EVENT_TRUNCATE, ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3714 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3720 | DMVAR_PASS(); |
| 3721 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3722 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3727 | DMVAR_FAIL(); |
| 3728 | } |
| 3729 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3730 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3734 | DMVAR_FAIL(); |
| 3735 | } |
| 3736 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3737 | DMLOG_PRINT(DMLVL_ERR, |
| 3738 | "%s failed with unexpected rc = %d (errno = %d)\n", |
| 3739 | szFuncName, rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3740 | DMVAR_FAIL(); |
| 3741 | } |
| 3742 | |
| 3743 | /* Variation clean up */ |
| 3744 | DMEV_ZERO(ineventset); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3745 | rc = dm_set_eventlist(newsid, hanp, hlen, DM_NO_TOKEN, |
| 3746 | &ineventset, DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3747 | rc |= dm_destroy_session(newsid); |
| 3748 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3749 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3750 | "Unable to clean up variation! (errno = %d)\n", |
| 3751 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3752 | } |
| 3753 | dm_handle_free(hanp, hlen); |
| 3754 | } |
| 3755 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3756 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3757 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3769 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3770 | "Unable to set up variation! (errno = %d)\n", |
| 3771 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3772 | DMVAR_SKIP(); |
| 3773 | } else { |
| 3774 | /* Variation */ |
| 3775 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3776 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3782 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 3783 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3784 | /* Variation clean up */ |
| 3785 | rc = dm_destroy_session(newsid); |
| 3786 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3787 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3788 | "Unable to clean up variation! (errno = %d)\n", |
| 3789 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3790 | } |
| 3791 | } |
| 3792 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3793 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3794 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3812 | } else |
| 3813 | if ((rc = |
| 3814 | dm_create_session(DM_NO_SESSION, szSessionInfo, |
| 3815 | &newsid)) == -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3816 | remove(DummyFile2); |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3817 | } else if ((rc = dm_path_to_handle(DummyFile2, &hanp, &hlen)) == |
| 3818 | -1) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3819 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3826 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3827 | "Unable to set up variation! (errno = %d)\n", |
| 3828 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3829 | DMVAR_SKIP(); |
| 3830 | } else { |
| 3831 | /* Variation */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3832 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3838 | DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF); |
| 3839 | |
| 3840 | /* Variation clean up */ |
| 3841 | rc = dm_destroy_session(newsid); |
| 3842 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3843 | DMLOG_PRINT(DMLVL_DEBUG, |
| 3844 | "Unable to clean up variation! (errno = %d)\n", |
| 3845 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3846 | } |
| 3847 | dm_handle_free(hanp, hlen); |
| 3848 | } |
| 3849 | } |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 3850 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3851 | /* 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3857 | DMLOG_PRINT(DMLVL_ERR, |
| 3858 | "dm_path_to_fshandle failed! (rc = %d, errno = %d)\n", |
| 3859 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3860 | dm_destroy_session(sid); |
| 3861 | DM_EXIT(); |
| 3862 | } |
| 3863 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3864 | rc = dm_set_disp(sid, fshanp, fshlen, DM_NO_TOKEN, &events, |
| 3865 | DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3866 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3867 | DMLOG_PRINT(DMLVL_ERR, |
| 3868 | "dm_set_disp failed! (rc = %d, errno = %d)\n", rc, |
| 3869 | errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3870 | dm_destroy_session(sid); |
| 3871 | DM_EXIT(); |
| 3872 | } |
| 3873 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3874 | rc = dm_set_eventlist(sid, fshanp, fshlen, DM_NO_TOKEN, &events, |
| 3875 | DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3876 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3877 | DMLOG_PRINT(DMLVL_ERR, |
| 3878 | "dm_set_eventlist failed! (rc = %d, errno = %d)\n", |
| 3879 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3880 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3890 | DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n", |
| 3891 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3892 | } |
| 3893 | |
| 3894 | pthread_join(tid, NULL); |
| 3895 | |
| 3896 | rc = dm_destroy_session(sid); |
| 3897 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3898 | DMLOG_PRINT(DMLVL_ERR, |
| 3899 | "dm_destroy_session failed! (rc = %d, errno = %d)\n", |
| 3900 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3901 | } |
| 3902 | |
| 3903 | DMLOG_STOP(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 3904 | |
| 3905 | tst_exit(); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3906 | } |
| 3907 | |
| 3908 | void *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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3925 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3930 | } while ((rc == -1) && (errno == EINTR) && (dmMsgBufLen == 0)); |
| 3931 | |
| 3932 | if (rc) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3933 | DMLOG_PRINT(DMLVL_ERR, |
| 3934 | "dm_get_events failed with rc = %d, errno = %d\n", |
| 3935 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3936 | dm_destroy_session(sid); |
| 3937 | DM_EXIT(); |
| 3938 | } else { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3939 | dmMsg = (dm_eventmsg_t *) dmMsgBuf; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3940 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3948 | dm_mount_event_t *me = |
| 3949 | DM_GET_VALUE(dmMsg, ev_data, dm_mount_event_t *); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3950 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3955 | 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 Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 3972 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3973 | bMounted = dm_handle_is_valid(lhanp, lhlen); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3974 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3975 | rc = dm_request_right(sid, lhanp, lhlen, token, |
| 3976 | DM_RR_WAIT, DM_RIGHT_EXCL); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3977 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3978 | DMLOG_PRINT(DMLVL_ERR, |
| 3979 | "dm_request_right failed! (rc = %d, errno = %d)\n", |
| 3980 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3981 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3988 | rc = dm_set_eventlist(sid, lhanp, lhlen, token, &events, |
| 3989 | DM_EVENT_MAX); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3990 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3991 | DMLOG_PRINT(DMLVL_ERR, |
| 3992 | "dm_set_eventlist failed! (rc = %d, errno = %d)\n", |
| 3993 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3994 | dm_destroy_session(sid); |
| 3995 | DM_EXIT(); |
| 3996 | } |
| 3997 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 3998 | rc = dm_release_right(sid, lhanp, lhlen, token); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 3999 | if (rc == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 4000 | DMLOG_PRINT(DMLVL_ERR, |
| 4001 | "dm_request_right failed! (rc = %d, errno = %d)\n", |
| 4002 | rc, errno); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 4003 | dm_destroy_session(sid); |
| 4004 | DM_EXIT(); |
| 4005 | } |
| 4006 | |
| 4007 | response = DM_RESP_CONTINUE; |
| 4008 | } else if (type == DM_EVENT_UNMOUNT) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 4009 | dm_namesp_event_t *nse = |
| 4010 | DM_GET_VALUE(dmMsg, ev_data, dm_namesp_event_t *); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 4011 | 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 Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 4039 | |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 4040 | default: |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 4041 | { |
| 4042 | DMLOG_PRINT(DMLVL_ERR, |
| 4043 | "Message is unexpected!\n"); |
| 4044 | response = DM_RESP_ABORT; |
| 4045 | break; |
| 4046 | } |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 4047 | } |
| 4048 | } |
| 4049 | |
| 4050 | if (response != DM_RESP_INVALID) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame^] | 4051 | 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); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 4058 | } |
| 4059 | } while (bMounted); |
| 4060 | |
| 4061 | pthread_exit(0); |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 4062 | } |