2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 #include <sys/types.h>
43 Test that the new session ID is correctly returned to the caller on
44 dm_create_session when the oldsid parameter is not DM_NO_SESSION.
46 Test to make sure that DM_NO_TOKEN does not work if the session ID
49 Both are needed so that session assumption works correctly. The
50 test creates a session, queries the session, assumes the session,
51 then attempts to check the event list of the old session ID while
54 The only parameter is the pathname of a DMAPI filesystem. If it is
55 working correctly, you should get the error message:
59 Any message containing the word FAILURE indicates a problem.
63 dm_sessid_t sid = DM_NO_SESSION; /* session ID of original session */
64 dm_sessid_t newsid = DM_NO_SESSION; /* session ID after session resumed */
65 dm_eventset_t eventlist;
72 char buffer[DM_SESSION_INFO_LEN];
81 fprintf(stderr, "usage:\t%s filesystem\n", Progname);
85 /* Initialize the DMAPI interface and obtain a session ID, then verify
86 that the filesystem supports DMAPI.
89 if (setup_dmapi(&sid))
92 if (dm_path_to_handle(argv[1], &hanp, &hlen)) {
93 perror("FAILURE: can't get handle for filesystem");
97 /* Query the session just to make sure things are working okay. */
99 if (dm_query_session(sid, sizeof(buffer), buffer, &rlen)) {
100 errno_msg("FAILURE: can't query the original session ID %d",
104 fprintf(stdout, "Initial session ID: %d\n", sid);
105 fprintf(stdout, "Initial session message length: '%d'\n", rlen);
107 fprintf(stdout, "Initial session message: '%s'\n", buffer);
110 /* Now try to assume the session. */
112 if (dm_create_session(sid, "this is a new message", &newsid)) {
113 fprintf(stderr, "FAILURE: can't assume session %d\n", sid);
117 /* Now query the new session. */
119 if (dm_query_session(newsid, sizeof(buffer), buffer, &rlen)) {
120 errno_msg("FAILURE: can't query the assumed session ID %d",
124 fprintf(stdout, "Assumed session ID: %d\n", newsid);
125 fprintf(stdout, "Assumed session message length: '%d'\n", rlen);
127 fprintf(stdout, "Assumed session message: '%s'\n", buffer);
130 /* Get rid of the new session as we are done with it. */
132 if (dm_destroy_session(newsid)) {
133 fprintf(stderr, "FAILURE: Can't shut down assumed session %d\n",
138 /* Now verify that DM_NO_TOKEN will not work with the old session ID,
139 which is now invalid.
142 DMEV_ZERO(eventlist);
144 if (dm_get_eventlist(sid, hanp, hlen, DM_NO_TOKEN, DM_EVENT_MAX,
145 &eventlist, &nelem) == 0) {
146 fprintf(stderr, "FAILURE: dm_get_eventlist() worked when it "
147 "should have failed!\n");
150 if (errno != ESRCH) {
152 if (errno != EINVAL) {
154 errno_msg("FAILURE: unexpected errno");
157 fprintf(stdout, "SUCCESS!\n");