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
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 /*
20 * TEST CASE : session.c
21 *
22 * VARIATIONS : 35
23 *
24 * API'S TESTED : dm_create_session
25 * dm_destroy_session
26 * dm_getall_sessions
27 * dm_query_session
28 */
29 #include <string.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <errno.h>
33 #include "dm_test.h"
34
35 #define NUM_SESSIONS 8
36
37 char dmMsgBuf[4096];
38
LogSessions(dm_sessid_t * sid,u_int nelem)39 void LogSessions(dm_sessid_t * sid, u_int nelem)
40 {
41 int i;
42
43 DMLOG_PRINT(DMLVL_DEBUG, "Sessions:\n");
44 for (i = 0; i < nelem; i++) {
45 DMLOG_PRINT(DMLVL_DEBUG, " element %d: %d\n", i, sid[i]);
46 }
47 }
48
main(int argc,char ** argv)49 int main(int argc, char **argv)
50 {
51
52 char *szSessionInfo = "dm_test session info";
53 char *szFuncName;
54 char *varstr;
55 int i;
56 int rc;
57
58 DMOPT_PARSE(argc, argv);
59 DMLOG_START();
60
61 /* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
62 if ((rc = dm_init_service(&varstr)) != 0) {
63 DMLOG_PRINT(DMLVL_ERR,
64 "dm_init_service failed! (rc = %d, errno = %d)\n",
65 rc, errno);
66 DM_EXIT();
67 } else {
68 int nexist;
69 rc = dm_getall_sessions(0, NULL, &nexist);
70
71 if (rc == -1 && errno == E2BIG) {
72 dm_sessid_t *psid;
73
74 DMLOG_PRINT(DMLVL_DEBUG, "%d sessions already exist\n",
75 nexist);
76
77 if ((psid = malloc(nexist * sizeof(dm_sessid_t))) != NULL) {
78 if ((rc =
79 dm_getall_sessions(nexist, psid,
80 &nexist)) == 0) {
81 for (rc = 0, i = 0; i < nexist; i++) {
82 DMLOG_PRINT(DMLVL_DEBUG,
83 "destroying session %d\n",
84 psid[i]);
85 rc |=
86 dm_destroy_session(psid[i]);
87 }
88
89 if (rc == -1) {
90 DMLOG_PRINT(DMLVL_ERR,
91 "dm_destroy_session failed, unable to destroy existing sessions\n");
92 DM_EXIT();
93 }
94 } else {
95 DMLOG_PRINT(DMLVL_ERR,
96 "dm_getall_sessions failed, unable to destroy existing sessions\n");
97 DM_EXIT();
98 }
99
100 free(psid);
101 } else {
102 DMLOG_PRINT(DMLVL_ERR,
103 "malloc failed, unable to destroy existing sessions\n");
104 DM_EXIT();
105 }
106 }
107 }
108
109 DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI session tests\n");
110
111 szFuncName = "dm_create_session";
112
113 /*
114 * TEST : dm_create_session - invalid oldsid
115 * EXPECTED: rc = -1, errno = EINVAL
116 */
117 if (DMVAR_EXEC(CREATE_SESSION_BASE + 1)) {
118 dm_sessid_t newsid;
119
120 /* Variation set up */
121
122 /* Variation */
123 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid oldsid)\n", szFuncName);
124 rc = dm_create_session(INVALID_ADDR, szSessionInfo, &newsid);
125 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
126
127 /* Variation clean up */
128 }
129
130 /*
131 * TEST : dm_create_session - NULL sessinfop
132 * EXPECTED: rc = 0
133 */
134 if (DMVAR_EXEC(CREATE_SESSION_BASE + 2)) {
135 dm_sessid_t newsid;
136
137 /* Variation set up */
138
139 /* Variation */
140 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL sessinfop)\n", szFuncName);
141 rc = dm_create_session(DM_NO_SESSION, NULL, &newsid);
142 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
143
144 /* Variation clean up */
145 }
146
147 /*
148 * TEST : dm_create_session - invalid sessinfop
149 * EXPECTED: rc = -1, errno = EFAULT
150 *
151 * This variation uncovered XFS BUG #2 (0 return code from strnlen_user
152 * ignored, which indicated fault)
153 */
154 if (DMVAR_EXEC(CREATE_SESSION_BASE + 3)) {
155 dm_sessid_t newsid;
156
157 /* Variation set up */
158
159 /* Variation */
160 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sessinfop)\n", szFuncName);
161 rc = dm_create_session(DM_NO_SESSION, (char *)INVALID_ADDR,
162 &newsid);
163 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
164
165 /* Variation clean up */
166 }
167
168 /*
169 * TEST : dm_create_session - NULL newsidp
170 * EXPECTED: rc = -1, errno = EFAULT
171 */
172 if (DMVAR_EXEC(CREATE_SESSION_BASE + 4)) {
173 /* Variation set up */
174
175 /* Variation */
176 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL newsidp)\n", szFuncName);
177 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, NULL);
178 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
179
180 /* Variation clean up */
181 }
182
183 /*
184 * TEST : dm_create_session - invalid newsidp
185 * EXPECTED: rc = -1, errno = EFAULT
186 */
187 if (DMVAR_EXEC(CREATE_SESSION_BASE + 5)) {
188 /* Variation set up */
189
190 /* Variation */
191 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid newsidp)\n", szFuncName);
192 rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
193 (dm_sessid_t *) INVALID_ADDR);
194 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
195
196 /* Variation clean up */
197 }
198
199 /*
200 * TEST : dm_create_session - DM_NO_SESSION oldsid
201 * EXPECTED: rc = 0
202 */
203 if (DMVAR_EXEC(CREATE_SESSION_BASE + 6)) {
204 dm_sessid_t newsid;
205
206 /* Variation set up */
207
208 /* Variation */
209 DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION oldsid)\n",
210 szFuncName);
211 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
212 if (rc == 0) {
213 DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n", newsid);
214 }
215 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
216
217 /* Variation clean up */
218 rc = dm_destroy_session(newsid);
219 if (rc == -1) {
220 DMLOG_PRINT(DMLVL_DEBUG,
221 "Unable to clean up variation! (errno = %d)\n",
222 errno);
223 }
224 }
225
226 /*
227 * TEST : dm_create_session - valid oldsid
228 * EXPECTED: rc = 0
229 */
230 if (DMVAR_EXEC(CREATE_SESSION_BASE + 7)) {
231 dm_sessid_t newsid, oldsid;
232
233 /* Variation set up */
234 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
235 if (rc == -1) {
236 DMLOG_PRINT(DMLVL_DEBUG,
237 "Unable to set up variation! (errno = %d)\n",
238 errno);
239 DMVAR_SKIP();
240 } else {
241 oldsid = newsid;
242
243 /* Variation */
244 DMLOG_PRINT(DMLVL_DEBUG, "%s(valid oldsid)\n",
245 szFuncName);
246 rc = dm_create_session(oldsid, szSessionInfo, &newsid);
247 if (rc == 0) {
248 DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n",
249 newsid);
250 }
251 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
252
253 /* Variation clean up */
254 rc = dm_destroy_session(newsid);
255 if (rc == -1) {
256 DMLOG_PRINT(DMLVL_DEBUG,
257 "Unable to clean up variation! (errno = %d)\n",
258 errno);
259 }
260 }
261 }
262
263 /*
264 * TEST : dm_create_session - invalidated oldsid
265 * EXPECTED: rc = -1, errno = EINVAL
266 */
267 if (DMVAR_EXEC(CREATE_SESSION_BASE + 8)) {
268 dm_sessid_t newsid, oldsid, delsid;
269
270 /* Variation set up */
271 if ((rc =
272 dm_create_session(DM_NO_SESSION, szSessionInfo,
273 &newsid)) == -1) {
274 /* No clean up */
275 } else
276 if ((rc =
277 dm_create_session(oldsid =
278 newsid, szSessionInfo,
279 &newsid)) == -1) {
280 dm_destroy_session(oldsid);
281 }
282 if (rc == -1) {
283 DMLOG_PRINT(DMLVL_DEBUG,
284 "Unable to set up variation! (errno = %d)\n",
285 errno);
286 DMVAR_SKIP();
287 } else {
288 delsid = newsid;
289
290 /* Variation */
291 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated oldsid)\n",
292 szFuncName);
293 rc = dm_create_session(oldsid, szSessionInfo, &newsid);
294 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
295
296 /* Variation clean up */
297 rc = dm_destroy_session(delsid);
298 if (rc == -1) {
299 DMLOG_PRINT(DMLVL_DEBUG,
300 "Unable to clean up variation! (errno = %d)\n",
301 errno);
302 }
303 }
304 }
305
306 /*
307 * TEST : dm_create_session - maximum sessinfo
308 * EXPECTED: rc = 0
309 */
310 if (DMVAR_EXEC(CREATE_SESSION_BASE + 9)) {
311 dm_sessid_t newsid;
312 char *szBig =
313 "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
314
315 /* Variation set up */
316
317 /* Variation */
318 DMLOG_PRINT(DMLVL_DEBUG, "%s(max sessionfo)\n", szFuncName);
319 rc = dm_create_session(DM_NO_SESSION, szBig, &newsid);
320 if (rc == 0) {
321 DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n", newsid);
322 }
323 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
324
325 /* Variation clean up */
326 rc = dm_destroy_session(newsid);
327 if (rc == -1) {
328 DMLOG_PRINT(DMLVL_DEBUG,
329 "Unable to clean up variation! (errno = %d)\n",
330 errno);
331 }
332 }
333
334 /*
335 * TEST : dm_create_session - sessinfo too big
336 * EXPECTED: rc = -1, errno = E2BIG
337 *
338 * This variation uncovered XFS BUG #1 (sessinfo simply truncated, API
339 * passed)
340 */
341 if (DMVAR_EXEC(CREATE_SESSION_BASE + 10)) {
342 dm_sessid_t newsid;
343 char *szTooBig =
344 "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456";
345
346 /* Variation set up */
347
348 /* Variation */
349 DMLOG_PRINT(DMLVL_DEBUG, "%s(sessinfo too big)\n", szFuncName);
350 rc = dm_create_session(DM_NO_SESSION, szTooBig, &newsid);
351 DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
352
353 /* Variation clean up */
354 }
355
356 /*
357 * TEST : dm_create_session - multiple sessions with same sessinfo
358 * EXPECTED: rc = 0
359 */
360 if (DMVAR_EXEC(CREATE_SESSION_BASE + 11)) {
361 dm_sessid_t newsid1, newsid2;
362
363 /* Variation set up */
364 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid1);
365 if (rc == -1) {
366 DMLOG_PRINT(DMLVL_DEBUG,
367 "Unable to set up variation! (errno = %d)\n",
368 errno);
369 DMVAR_SKIP();
370 } else {
371 /* Variation */
372 DMLOG_PRINT(DMLVL_DEBUG, "%s(same sessinfo)\n",
373 szFuncName);
374 rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
375 &newsid2);
376 if (rc == 0) {
377 DMLOG_PRINT(DMLVL_DEBUG,
378 "1st newsid = %d, 2nd newsid = %d\n",
379 newsid1, newsid2);
380 if (newsid1 != newsid2) {
381 DMLOG_PRINT(DMLVL_DEBUG,
382 "%s passed with expected rc = %d\n",
383 szFuncName, 0);
384 DMVAR_PASS();
385 } else {
386 DMLOG_PRINT(DMLVL_ERR,
387 "%s failed with expected rc = %d but session IDs same\n",
388 szFuncName, 0);
389 DMVAR_FAIL();
390 }
391 } else {
392 DMLOG_PRINT(DMLVL_ERR,
393 "%s failed with unexpected rc = %d (errno = %d)\n",
394 szFuncName, rc, errno);
395 DMVAR_FAIL();
396 }
397
398 /* Variation clean up */
399 rc = dm_destroy_session(newsid1);
400 rc |= dm_destroy_session(newsid2);
401 if (rc == -1) {
402 DMLOG_PRINT(DMLVL_DEBUG,
403 "Unable to clean up variation! (errno = %d)\n",
404 errno);
405 }
406 }
407 }
408
409 szFuncName = "dm_destroy_session";
410
411 /*
412 * TEST : dm_destroy_session - DM_NO_SESSION sid
413 * EXPECTED: rc = -1, errno = EINVAL
414 */
415 if (DMVAR_EXEC(DESTROY_SESSION_BASE + 1)) {
416 /* Variation set up */
417
418 /* Variation */
419 DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
420 rc = dm_destroy_session(DM_NO_SESSION);
421 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
422
423 /* Variation clean up */
424 }
425
426 /*
427 * TEST : dm_destroy_session - invalid sid
428 * EXPECTED: rc = -1, errno = EINVAL
429 */
430 if (DMVAR_EXEC(DESTROY_SESSION_BASE + 2)) {
431 /* Variation set up */
432
433 /* Variation */
434 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
435 rc = dm_destroy_session(INVALID_ADDR);
436 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
437
438 /* Variation clean up */
439 }
440
441 /*
442 * TEST : dm_destroy_session - invalidated sid
443 * EXPECTED: rc = 0
444 */
445 if (DMVAR_EXEC(DESTROY_SESSION_BASE + 3)) {
446 dm_sessid_t newsid;
447
448 /* Variation set up */
449 if ((rc =
450 dm_create_session(DM_NO_SESSION, szSessionInfo,
451 &newsid)) != -1) {
452 rc = dm_destroy_session(newsid);
453 }
454 if (rc == -1) {
455 DMLOG_PRINT(DMLVL_DEBUG,
456 "Unable to set up variation! (errno = %d)\n",
457 errno);
458 DMVAR_SKIP();
459 } else {
460 /* Variation */
461 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n",
462 szFuncName);
463 rc = dm_destroy_session(newsid);
464 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
465
466 /* Variation clean up */
467 }
468 }
469
470 /*
471 * TEST : dm_destroy_session - valid sid
472 * EXPECTED: rc = 0
473 */
474 if (DMVAR_EXEC(DESTROY_SESSION_BASE + 4)) {
475 dm_sessid_t newsid;
476
477 /* Variation set up */
478 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
479 if (rc == -1) {
480 DMLOG_PRINT(DMLVL_DEBUG,
481 "Unable to set up variation! (errno = %d)\n",
482 errno);
483 DMVAR_SKIP();
484 } else {
485 /* Variation */
486 DMLOG_PRINT(DMLVL_DEBUG, "%s(valid sid)\n", szFuncName);
487 rc = dm_destroy_session(newsid);
488 DMVAR_ENDPASSEXP(szFuncName, 0, rc);
489
490 /* Variation clean up */
491 }
492 }
493
494 /*
495 * TEST : dm_destroy_session - sid with oustanding events
496 * EXPECTED: rc = -1, erno = EBUSY
497 */
498 if (DMVAR_EXEC(DESTROY_SESSION_BASE + 5)) {
499 dm_sessid_t newsid;
500 char buf[MSG_DATALEN];
501 size_t rlen;
502
503 /* Variation set up */
504 memcpy(buf, MSG_DATA, MSG_DATALEN);
505 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
506 rc |= dm_send_msg(newsid, DM_MSGTYPE_ASYNC, MSG_DATALEN, buf);
507 if (rc == -1) {
508 DMLOG_PRINT(DMLVL_DEBUG,
509 "Unable to set up variation! (errno = %d)\n",
510 errno);
511 DMVAR_SKIP();
512 } else {
513 /* Variation */
514 DMLOG_PRINT(DMLVL_DEBUG, "%s(valid sid)\n", szFuncName);
515 rc = dm_destroy_session(newsid);
516 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);
517
518 /* Variation clean up */
519 rc = dm_get_events(newsid, 1, 0, sizeof(dmMsgBuf),
520 dmMsgBuf, &rlen);
521 rc |= dm_destroy_session(newsid);
522 if (rc == -1) {
523 DMLOG_PRINT(DMLVL_DEBUG,
524 "Unable to clean up variation! (errno = %d)\n",
525 errno);
526 }
527 }
528 }
529
530 szFuncName = "dm_getall_sessions";
531
532 /*
533 * TEST : dm_getall_sessions - NULL sidbufp
534 * EXPECTED: rc = -1, errno EFAULT
535 */
536 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 1)) {
537 dm_sessid_t newsid;
538 int nelem;
539
540 /* Variation set up */
541 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
542 if (rc == -1) {
543 DMLOG_PRINT(DMLVL_DEBUG,
544 "Unable to set up variation! (errno = %d)\n",
545 errno);
546 DMVAR_SKIP();
547 } else {
548 /* Variation */
549 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL sidbufp)\n",
550 szFuncName);
551 rc = dm_getall_sessions(1, NULL, &nelem);
552 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
553
554 /* Variation clean up */
555 rc = dm_destroy_session(newsid);
556 if (rc == -1) {
557 DMLOG_PRINT(DMLVL_DEBUG,
558 "Unable to clean up variation! (errno = %d)\n",
559 errno);
560 }
561 }
562 }
563
564 /*
565 * TEST : dm_getall_sessions - invalid sidbufp
566 * EXPECTED: rc = -1, errno EFAULT
567 */
568 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 2)) {
569 dm_sessid_t newsid;
570 int nelem;
571
572 /* Variation set up */
573 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
574 if (rc == -1) {
575 DMLOG_PRINT(DMLVL_DEBUG,
576 "Unable to set up variation! (errno = %d)\n",
577 errno);
578 DMVAR_SKIP();
579 } else {
580 /* Variation */
581 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sidbufp)\n",
582 szFuncName);
583 rc = dm_getall_sessions(1, (dm_sessid_t *) INVALID_ADDR,
584 &nelem);
585 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
586
587 /* Variation clean up */
588 rc = dm_destroy_session(newsid);
589 if (rc == -1) {
590 DMLOG_PRINT(DMLVL_DEBUG,
591 "Unable to clean up variation! (errno = %d)\n",
592 errno);
593 }
594 }
595 }
596
597 /*
598 * TEST : dm_getall_sessions - NULL nelemp
599 * EXPECTED: rc = -1, errno EFAULT
600 */
601 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 3)) {
602 dm_sessid_t newsid, sidArray[1];
603
604 /* Variation set up */
605 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
606 if (rc == -1) {
607 DMLOG_PRINT(DMLVL_DEBUG,
608 "Unable to set up variation! (errno = %d)\n",
609 errno);
610 DMVAR_SKIP();
611 } else {
612 /* Variation */
613 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL nelemp)\n",
614 szFuncName);
615 rc = dm_getall_sessions(1, sidArray, NULL);
616 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
617
618 /* Variation clean up */
619 rc = dm_destroy_session(newsid);
620 if (rc == -1) {
621 DMLOG_PRINT(DMLVL_DEBUG,
622 "Unable to clean up variation! (errno = %d)\n",
623 errno);
624 }
625 }
626 }
627
628 /*
629 * TEST : dm_getall_sessions - invalid nelemp
630 * EXPECTED: rc = -1, errno EFAULT
631 */
632 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 4)) {
633 dm_sessid_t newsid, sidArray[1];
634
635 /* Variation set up */
636 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
637 if (rc == -1) {
638 DMLOG_PRINT(DMLVL_DEBUG,
639 "Unable to set up variation! (errno = %d)\n",
640 errno);
641 DMVAR_SKIP();
642 } else {
643 /* Variation */
644 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n",
645 szFuncName);
646 rc = dm_getall_sessions(1, sidArray,
647 (u_int *) INVALID_ADDR);
648 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
649
650 /* Variation clean up */
651 rc = dm_destroy_session(newsid);
652 if (rc == -1) {
653 DMLOG_PRINT(DMLVL_DEBUG,
654 "Unable to clean up variation! (errno = %d)\n",
655 errno);
656 }
657 }
658 }
659
660 /*
661 * TEST : dm_getall_sessions - zero nelem, zero sessions
662 * EXPECTED: rc = 0
663 */
664 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 5)) {
665 dm_sessid_t sidArray[1];
666 int nelem;
667
668 /* Variation set up */
669
670 /* Variation */
671 DMLOG_PRINT(DMLVL_DEBUG, "%s(zero nelem, zero sessions)\n",
672 szFuncName);
673 rc = dm_getall_sessions(0, sidArray, &nelem);
674 if (rc == 0) {
675 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
676 if (nelem == 0) {
677 DMLOG_PRINT(DMLVL_DEBUG,
678 "%s passed with expected rc = %d\n",
679 szFuncName, 0);
680 DMVAR_PASS();
681 } else {
682 DMLOG_PRINT(DMLVL_ERR,
683 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
684 szFuncName, 0, nelem, 0);
685 DMVAR_FAIL();
686 }
687 } else {
688 DMLOG_PRINT(DMLVL_ERR,
689 "%s failed with unexpected rc = %d (errno = %d)\n",
690 szFuncName, rc, errno);
691 DMVAR_FAIL();
692 }
693
694 /* Variation clean up */
695 }
696
697 /*
698 * TEST : dm_getall_sessions - zero nelem, one session
699 * EXPECTED: rc = -1, errno = E2BIG
700 */
701 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 6)) {
702 dm_sessid_t newsid, sidArray[1];
703 int nelem;
704
705 /* Variation set up */
706 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
707 if (rc == -1) {
708 DMLOG_PRINT(DMLVL_DEBUG,
709 "Unable to set up variation! (errno = %d)\n",
710 errno);
711 DMVAR_SKIP();
712 } else {
713 /* Variation */
714 DMLOG_PRINT(DMLVL_DEBUG,
715 "%s(zero nelem, one session)\n",
716 szFuncName);
717 rc = dm_getall_sessions(0, sidArray, &nelem);
718
719 if (rc == -1) {
720 if (errno == E2BIG) {
721 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n",
722 nelem);
723 if (nelem == 1) {
724 DMLOG_PRINT(DMLVL_DEBUG,
725 "%s passed with expected rc = %d and expected errno = %d\n",
726 szFuncName, -1,
727 E2BIG);
728 DMVAR_PASS();
729 } else {
730 DMLOG_PRINT(DMLVL_ERR,
731 "%s failed with expected rc = %d and expected errno = %d but unexpected nelem (%d vs %d)\n",
732 szFuncName, -1,
733 E2BIG, nelem, 1);
734 DMVAR_PASS();
735 }
736 } else {
737 DMLOG_PRINT(DMLVL_ERR,
738 "%s failed with expected rc = %d but unexpected errno = %d\n",
739 szFuncName, -1, errno);
740 DMVAR_FAIL();
741 }
742 } else {
743 DMLOG_PRINT(DMLVL_ERR,
744 "%s failed with unexpected rc = %d\n",
745 szFuncName, rc);
746 DMVAR_FAIL();
747 }
748
749 /* Variation clean up */
750 rc = dm_destroy_session(newsid);
751 if (rc == -1) {
752 DMLOG_PRINT(DMLVL_DEBUG,
753 "Unable to clean up variation! (errno = %d)\n",
754 errno);
755 }
756 }
757 }
758
759 /*
760 * TEST : dm_getall_sessions - one nelem, one session
761 * EXPECTED: rc = 0
762 */
763 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 7)) {
764 dm_sessid_t newsid, sidArray[1];
765 int nelem;
766
767 /* Variation set up */
768 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
769 if (rc == -1) {
770 DMLOG_PRINT(DMLVL_DEBUG,
771 "Unable to set up variation! (errno = %d)\n",
772 errno);
773 DMVAR_SKIP();
774 } else {
775 /* Variation */
776 DMLOG_PRINT(DMLVL_DEBUG, "%s(one nelem, one session)\n",
777 szFuncName);
778 rc = dm_getall_sessions(1, sidArray, &nelem);
779 if (rc == 0) {
780 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
781
782 if (nelem == 1) {
783 LogSessions(sidArray, nelem);
784
785 if (newsid == sidArray[0]) {
786 DMLOG_PRINT(DMLVL_DEBUG,
787 "%s passed with expected rc = %d\n",
788 szFuncName, 0);
789 DMVAR_PASS();
790 } else {
791 DMLOG_PRINT(DMLVL_ERR,
792 "%s failed with expected rc = %d and nelem = %d but unexpected session ID (%d vs %d)\n",
793 szFuncName, 0,
794 nelem, newsid,
795 sidArray[0]);
796 DMVAR_FAIL();
797 }
798 } else {
799 DMLOG_PRINT(DMLVL_ERR,
800 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
801 szFuncName, 0, nelem, 1);
802 DMVAR_FAIL();
803 }
804 } else {
805 DMLOG_PRINT(DMLVL_ERR,
806 "%s failed with unexpected rc = %d (errno = %d)\n",
807 szFuncName, rc, errno);
808 DMVAR_FAIL();
809 }
810
811 /* Variation clean up */
812 rc = dm_destroy_session(newsid);
813 if (rc == -1) {
814 DMLOG_PRINT(DMLVL_DEBUG,
815 "Unable to clean up variation! (errno = %d)\n",
816 errno);
817 }
818 }
819 }
820
821 /*
822 * TEST : dm_getall_sessions - two nelem, one session
823 * EXPECTED: rc = 0
824 */
825 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 8)) {
826 dm_sessid_t newsid, sidArray[2];
827 int nelem;
828
829 /* Variation set up */
830 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
831 if (rc == -1) {
832 DMLOG_PRINT(DMLVL_DEBUG,
833 "Unable to set up variation! (errno = %d)\n",
834 errno);
835 DMVAR_SKIP();
836 } else {
837 /* Variation */
838 DMLOG_PRINT(DMLVL_DEBUG, "%s(two nelem, one session)\n",
839 szFuncName);
840 rc = dm_getall_sessions(2, sidArray, &nelem);
841 if (rc == 0) {
842 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
843
844 if (nelem == 1) {
845 LogSessions(sidArray, nelem);
846
847 if (newsid == sidArray[0]) {
848 DMLOG_PRINT(DMLVL_DEBUG,
849 "%s passed with expected rc = %d\n",
850 szFuncName, 0);
851 DMVAR_PASS();
852 } else {
853 DMLOG_PRINT(DMLVL_ERR,
854 "%s failed with expected rc = %d and nelem = %d but unexpected session ID (%d vs %d)\n",
855 szFuncName, 0,
856 nelem, newsid,
857 sidArray[0]);
858 DMVAR_FAIL();
859 }
860 } else {
861 DMLOG_PRINT(DMLVL_ERR,
862 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
863 szFuncName, 0, nelem, 1);
864 DMVAR_FAIL();
865 }
866 } else {
867 DMLOG_PRINT(DMLVL_ERR,
868 "%s failed with unexpected rc = %d (errno = %d)\n",
869 szFuncName, rc, errno);
870 DMVAR_FAIL();
871 }
872
873 /* Variation clean up */
874 rc = dm_destroy_session(newsid);
875 if (rc == -1) {
876 DMLOG_PRINT(DMLVL_DEBUG,
877 "Unable to clean up variation! (errno = %d)\n",
878 errno);
879 }
880 }
881 }
882
883 /*
884 * TEST : dm_getall_sessions - ten nelem, eight sessions
885 * EXPECTED: rc = 0
886 */
887 if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 9)) {
888 dm_sessid_t sidExpected[NUM_SESSIONS], sidArray[10];
889 int nelem;
890
891 /* Variation set up */
892 for (i = 0, rc = 0; i < NUM_SESSIONS && rc == 0; i++) {
893 rc = dm_create_session(DM_NO_SESSION, szSessionInfo,
894 &sidExpected[i]);
895 }
896 if (rc == -1) {
897 DMLOG_PRINT(DMLVL_DEBUG,
898 "Unable to set up variation! (errno = %d)\n",
899 errno);
900 for (i--; i >= 0; i--) {
901 dm_destroy_session(sidExpected[i]);
902 }
903 DMVAR_SKIP();
904 } else {
905 /* Variation */
906 DMLOG_PRINT(DMLVL_DEBUG, "%s(%d nelem, %d sessions)\n",
907 szFuncName,
908 sizeof(sidArray) / sizeof(dm_sessid_t),
909 NUM_SESSIONS);
910 rc = dm_getall_sessions(sizeof(sidArray) /
911 sizeof(dm_sessid_t), sidArray,
912 &nelem);
913 if (rc == 0) {
914 DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
915
916 if (nelem == NUM_SESSIONS) {
917 LogSessions(sidArray, nelem);
918
919 if (memcmp
920 (sidArray, sidExpected,
921 NUM_SESSIONS *
922 sizeof(dm_sessid_t)) == 0) {
923 DMLOG_PRINT(DMLVL_DEBUG,
924 "%s passed with expected rc = %d\n",
925 szFuncName, 0);
926 DMVAR_PASS();
927 } else {
928 DMLOG_PRINT(DMLVL_ERR,
929 "%s failed with expected rc = %d and nelem = %d but unexpected session ID(s)\n",
930 szFuncName, 0,
931 nelem);
932 DMVAR_FAIL();
933 }
934 } else {
935 DMLOG_PRINT(DMLVL_ERR,
936 "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n",
937 szFuncName, 0, nelem,
938 NUM_SESSIONS);
939 DMVAR_FAIL();
940 }
941 } else {
942 DMLOG_PRINT(DMLVL_ERR,
943 "%s failed with unexpected rc = %d (errno = %d)\n",
944 szFuncName, rc, errno);
945 DMVAR_FAIL();
946 }
947
948 /* Variation clean up */
949 for (i = 0, rc = 0; i < NUM_SESSIONS; i++) {
950 rc |= dm_destroy_session(sidExpected[i]);
951 }
952 if (rc == -1) {
953 DMLOG_PRINT(DMLVL_DEBUG,
954 "Unable to clean up variation! (errno = %d)\n",
955 errno);
956 }
957 }
958 }
959
960 szFuncName = "dm_query_session";
961
962 /*
963 * TEST : dm_query_session - DM_NO_SESSION sid
964 * EXPECTED: rc = -1, errno = EINVAL
965 */
966 if (DMVAR_EXEC(QUERY_SESSION_BASE + 1)) {
967 char buf[64];
968 size_t rlen;
969
970 /* Variation set up */
971
972 /* Variation */
973 DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
974 rc = dm_query_session(DM_NO_SESSION, sizeof(buf), buf, &rlen);
975 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
976
977 /* Variation clean up */
978 }
979
980 /*
981 * TEST : dm_query_session - invalid sid
982 * EXPECTED: rc = -1, errno = EINVAL
983 */
984 if (DMVAR_EXEC(QUERY_SESSION_BASE + 2)) {
985 char buf[64];
986 size_t rlen;
987
988 /* Variation set up */
989
990 /* Variation */
991 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
992 rc = dm_query_session(INVALID_ADDR, sizeof(buf), buf, &rlen);
993 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
994
995 /* Variation clean up */
996 }
997
998 /*
999 * TEST : dm_query_session - invalidated sid
1000 * EXPECTED: rc = -1, errno = EINVAL
1001 */
1002 if (DMVAR_EXEC(QUERY_SESSION_BASE + 3)) {
1003 dm_sessid_t newsid;
1004 char buf[64];
1005 size_t rlen;
1006
1007 /* Variation set up */
1008 if ((rc =
1009 dm_create_session(DM_NO_SESSION, szSessionInfo,
1010 &newsid)) != -1) {
1011 rc = dm_destroy_session(newsid);
1012 }
1013 if (rc == -1) {
1014 DMLOG_PRINT(DMLVL_DEBUG,
1015 "Unable to set up variation! (errno = %d)\n",
1016 errno);
1017 DMVAR_SKIP();
1018 } else {
1019 /* Variation */
1020 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n",
1021 szFuncName);
1022 rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
1023 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
1024
1025 /* Variation clean up */
1026 }
1027 }
1028
1029 /*
1030 * TEST : dm_query_session - NULL bufp
1031 * EXPECTED: rc = -1, errno EFAULT
1032 */
1033 if (DMVAR_EXEC(QUERY_SESSION_BASE + 4)) {
1034 dm_sessid_t newsid;
1035 char buf[64];
1036 size_t rlen;
1037
1038 /* Variation set up */
1039 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1040 if (rc == -1) {
1041 DMLOG_PRINT(DMLVL_DEBUG,
1042 "Unable to set up variation! (errno = %d)\n",
1043 errno);
1044 DMVAR_SKIP();
1045 } else {
1046 /* Variation */
1047 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL bufp)\n", szFuncName);
1048 rc = dm_query_session(newsid, sizeof(buf), NULL, &rlen);
1049 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1050
1051 /* Variation clean up */
1052 rc = dm_destroy_session(newsid);
1053 if (rc == -1) {
1054 DMLOG_PRINT(DMLVL_DEBUG,
1055 "Unable to clean up variation! (errno = %d)\n",
1056 errno);
1057 }
1058 }
1059 }
1060
1061 /*
1062 * TEST : dm_query_session - invalid bufp
1063 * EXPECTED: rc = -1, errno EFAULT
1064 */
1065 if (DMVAR_EXEC(QUERY_SESSION_BASE + 5)) {
1066 dm_sessid_t newsid;
1067 char buf[64];
1068 size_t rlen;
1069
1070 /* Variation set up */
1071 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1072 if (rc == -1) {
1073 DMLOG_PRINT(DMLVL_DEBUG,
1074 "Unable to set up variation! (errno = %d)\n",
1075 errno);
1076 DMVAR_SKIP();
1077 } else {
1078 /* Variation */
1079 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
1080 szFuncName);
1081 rc = dm_query_session(newsid, sizeof(buf),
1082 (void *)INVALID_ADDR, &rlen);
1083 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1084
1085 /* Variation clean up */
1086 rc = dm_destroy_session(newsid);
1087 if (rc == -1) {
1088 DMLOG_PRINT(DMLVL_DEBUG,
1089 "Unable to clean up variation! (errno = %d)\n",
1090 errno);
1091 }
1092 }
1093 }
1094
1095 /*
1096 * TEST : dm_query_session - NULL rlenp
1097 * EXPECTED: rc = -1, errno EFAULT
1098 */
1099 if (DMVAR_EXEC(QUERY_SESSION_BASE + 6)) {
1100 dm_sessid_t newsid;
1101 char buf[64];
1102
1103 /* Variation set up */
1104 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1105 if (rc == -1) {
1106 DMLOG_PRINT(DMLVL_DEBUG,
1107 "Unable to set up variation! (errno = %d)\n",
1108 errno);
1109 DMVAR_SKIP();
1110 } else {
1111 /* Variation */
1112 DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL rlenp)\n",
1113 szFuncName);
1114 rc = dm_query_session(newsid, sizeof(buf), buf, NULL);
1115 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1116
1117 /* Variation clean up */
1118 rc = dm_destroy_session(newsid);
1119 if (rc == -1) {
1120 DMLOG_PRINT(DMLVL_DEBUG,
1121 "Unable to clean up variation! (errno = %d)\n",
1122 errno);
1123 }
1124 }
1125 }
1126
1127 /*
1128 * TEST : dm_query_session - invalid rlenp
1129 * EXPECTED: rc = -1, errno EFAULT
1130 */
1131 if (DMVAR_EXEC(QUERY_SESSION_BASE + 7)) {
1132 dm_sessid_t newsid;
1133 char buf[64];
1134
1135 /* Variation set up */
1136 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1137 if (rc == -1) {
1138 DMLOG_PRINT(DMLVL_DEBUG,
1139 "Unable to set up variation! (errno = %d)\n",
1140 errno);
1141 DMVAR_SKIP();
1142 } else {
1143 /* Variation */
1144 DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
1145 szFuncName);
1146 rc = dm_query_session(newsid, sizeof(buf), buf,
1147 (size_t *) INVALID_ADDR);
1148 DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1149
1150 /* Variation clean up */
1151 rc = dm_destroy_session(newsid);
1152 if (rc == -1) {
1153 DMLOG_PRINT(DMLVL_DEBUG,
1154 "Unable to clean up variation! (errno = %d)\n",
1155 errno);
1156 }
1157 }
1158 }
1159
1160 /*
1161 * TEST : dm_query_session - zero buflen
1162 * EXPECTED: rc = -1, errno = E2BIG
1163 */
1164 if (DMVAR_EXEC(QUERY_SESSION_BASE + 8)) {
1165 dm_sessid_t newsid;
1166 char buf[64];
1167 size_t rlen;
1168
1169 /* Variation set up */
1170 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1171 if (rc == -1) {
1172 DMLOG_PRINT(DMLVL_DEBUG,
1173 "Unable to set up variation! (errno = %d)\n",
1174 errno);
1175 DMVAR_SKIP();
1176 } else {
1177 /* Variation */
1178 DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen zero)\n",
1179 szFuncName);
1180 rc = dm_query_session(newsid, 0, buf, &rlen);
1181 if (rc == -1) {
1182 if (errno == E2BIG) {
1183 DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n",
1184 rlen);
1185
1186 if (rlen == strlen(szSessionInfo) + 1) {
1187 DMLOG_PRINT(DMLVL_DEBUG,
1188 "%s passed with expected rc = %d and expected errno = %d\n",
1189 szFuncName, -1,
1190 E2BIG);
1191 DMVAR_PASS();
1192 } else {
1193 DMLOG_PRINT(DMLVL_ERR,
1194 "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n",
1195 szFuncName, -1,
1196 E2BIG, rlen,
1197 strlen
1198 (szSessionInfo) +
1199 1);
1200 DMVAR_FAIL();
1201 }
1202 } else {
1203 DMLOG_PRINT(DMLVL_ERR,
1204 "%s failed with expected rc = %d but unexpected errno = %d\n",
1205 szFuncName, -1, errno);
1206 DMVAR_FAIL();
1207 }
1208 } else {
1209 DMLOG_PRINT(DMLVL_ERR,
1210 "%s failed with unexpected rc = %d\n",
1211 szFuncName, rc);
1212 DMVAR_FAIL();
1213 }
1214
1215 /* Variation clean up */
1216 rc = dm_destroy_session(newsid);
1217 if (rc == -1) {
1218 DMLOG_PRINT(DMLVL_DEBUG,
1219 "Unable to clean up variation! (errno = %d)\n",
1220 errno);
1221 }
1222 }
1223 }
1224
1225 /*
1226 * TEST : dm_query_session - valid
1227 * EXPECTED: rc = 0
1228 */
1229 if (DMVAR_EXEC(QUERY_SESSION_BASE + 9)) {
1230 dm_sessid_t newsid;
1231 char buf[64];
1232 size_t rlen;
1233
1234 /* Variation set up */
1235 rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
1236 if (rc == -1) {
1237 DMLOG_PRINT(DMLVL_DEBUG,
1238 "Unable to set up variation! (errno = %d)\n",
1239 errno);
1240 DMVAR_SKIP();
1241 } else {
1242 /* Variation */
1243 DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName,
1244 sizeof(buf));
1245 rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
1246 if (rc == 0) {
1247 DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
1248
1249 if (rlen == strlen(szSessionInfo) + 1) {
1250 DMLOG_PRINT(DMLVL_DEBUG,
1251 "buf = \"%s\"\n", buf);
1252
1253 if (strcmp(buf, szSessionInfo) == 0) {
1254 DMLOG_PRINT(DMLVL_DEBUG,
1255 "%s passed with expected rc = %d\n",
1256 szFuncName, 0);
1257 DMVAR_PASS();
1258 } else {
1259 DMLOG_PRINT(DMLVL_ERR,
1260 "%s failed with expected rc = %d and rlen = %d but unexpected session info (\"%s\" vs \"%s\")\n",
1261 szFuncName, 0, rlen,
1262 buf, szSessionInfo);
1263 DMVAR_FAIL();
1264 }
1265 } else {
1266 DMLOG_PRINT(DMLVL_ERR,
1267 "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
1268 szFuncName, 0, rlen,
1269 strlen(szSessionInfo) + 1);
1270 DMVAR_FAIL();
1271 }
1272 } else {
1273 DMLOG_PRINT(DMLVL_ERR,
1274 "%s failed with unexpected rc = %d (errno = %d)\n",
1275 szFuncName, rc, errno);
1276 DMVAR_FAIL();
1277 }
1278
1279 /* Variation clean up */
1280 rc = dm_destroy_session(newsid);
1281 if (rc == -1) {
1282 DMLOG_PRINT(DMLVL_DEBUG,
1283 "Unable to clean up variation! (errno = %d)\n",
1284 errno);
1285 }
1286 }
1287 }
1288
1289 /*
1290 * TEST : dm_query_session - maximum sessionfo
1291 * sessioninfo
1292 * EXPECTED: rc = 0
1293 */
1294 if (DMVAR_EXEC(QUERY_SESSION_BASE + 10)) {
1295 dm_sessid_t newsid;
1296 char buf[512];
1297 size_t rlen;
1298 char *szBig =
1299 "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
1300
1301 /* Variation set up */
1302 rc = dm_create_session(DM_NO_SESSION, szBig, &newsid);
1303 if (rc == -1) {
1304 DMLOG_PRINT(DMLVL_DEBUG,
1305 "Unable to set up variation! (errno = %d)\n",
1306 errno);
1307 DMVAR_SKIP();
1308 } else {
1309 /* Variation */
1310 DMLOG_PRINT(DMLVL_DEBUG, "%s(max sessinfo)\n",
1311 szFuncName, sizeof(buf));
1312 rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
1313 if (rc == 0) {
1314 DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
1315
1316 if (rlen == DM_SESSION_INFO_LEN) {
1317 DMLOG_PRINT(DMLVL_DEBUG,
1318 "buf = \"%s\"\n", buf);
1319
1320 if (strncmp
1321 (buf, szBig,
1322 DM_SESSION_INFO_LEN - 1) == 0) {
1323 DMLOG_PRINT(DMLVL_DEBUG,
1324 "%s passed with expected rc = %d\n",
1325 szFuncName, 0);
1326 DMVAR_PASS();
1327 } else {
1328 DMLOG_PRINT(DMLVL_ERR,
1329 "%s failed with expected rc = %d and rlen = %d but unexpected session info (\"%s\" vs \"%s\")\n",
1330 szFuncName, 0, rlen,
1331 buf, szSessionInfo);
1332 DMVAR_FAIL();
1333 }
1334 } else {
1335 DMLOG_PRINT(DMLVL_ERR,
1336 "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
1337 szFuncName, 0, rlen,
1338 DM_SESSION_INFO_LEN);
1339 DMVAR_FAIL();
1340 }
1341 } else {
1342 DMLOG_PRINT(DMLVL_ERR,
1343 "%s failed with unexpected rc = %d (errno = %d)\n",
1344 szFuncName, rc, errno);
1345 DMVAR_FAIL();
1346 }
1347
1348 /* Variation clean up */
1349 rc = dm_destroy_session(newsid);
1350 if (rc == -1) {
1351 DMLOG_PRINT(DMLVL_DEBUG,
1352 "Unable to clean up variation! (errno = %d)\n",
1353 errno);
1354 }
1355 }
1356 }
1357
1358 DMLOG_STOP();
1359
1360 tst_exit();
1361
1362 }
1363