Example #1
0
void dm_EndVariation_SuccessExpected(char *funcname, int expectedRC, int actualRC)
{

	if (actualRC == expectedRC) {
	  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", funcname, expectedRC);
		DMVAR_PASS();
	} else {
		DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", funcname, actualRC, errno);
		DMVAR_FAIL();
	}

}	
Example #2
0
int main(int argc, char **argv)
{

	char *szSessionInfo = "dm_test session info";
	char *szFuncName;
	char *varstr;
	int   i;
	int   rc;

	DMOPT_PARSE(argc, argv);
	DMLOG_START();

	/* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
	if ((rc = dm_init_service(&varstr)) != 0) {
		DMLOG_PRINT(DMLVL_ERR, "dm_init_service failed! (rc = %d, errno = %d)\n", rc, errno);
		DM_EXIT();
	} else {
		int nexist;
		rc = dm_getall_sessions(0, NULL, &nexist);

		if (rc == -1 && errno == E2BIG) {
			dm_sessid_t *psid;

			DMLOG_PRINT(DMLVL_DEBUG, "%d sessions already exist\n", nexist);

			if ((psid = malloc(nexist * sizeof(dm_sessid_t))) != NULL) {
				if ((rc = dm_getall_sessions(nexist, psid, &nexist)) == 0) {
					for (rc = 0, i = 0; i < nexist; i++) {
						DMLOG_PRINT(DMLVL_DEBUG, "destroying session %d\n", psid[i]);
						rc |= dm_destroy_session(psid[i]);
					}

					if (rc == -1) {
						DMLOG_PRINT(DMLVL_ERR, "dm_destroy_session failed, unable to destroy existing sessions\n");
						DM_EXIT();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "dm_getall_sessions failed, unable to destroy existing sessions\n");
					DM_EXIT();
				}

				free(psid);
			} else {
				DMLOG_PRINT(DMLVL_ERR, "malloc failed, unable to destroy existing sessions\n");
				DM_EXIT();
			}
		}
	}

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI session tests\n") ;

	szFuncName = "dm_create_session";

	/*
	 * TEST    : dm_create_session - invalid oldsid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 1)) {
		dm_sessid_t newsid;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid oldsid)\n", szFuncName);
		rc = dm_create_session(INVALID_ADDR, szSessionInfo, &newsid);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_session - NULL sessinfop
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 2)) {
		dm_sessid_t newsid;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL sessinfop)\n", szFuncName);
		rc = dm_create_session(DM_NO_SESSION, NULL, &newsid);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_session - invalid sessinfop
	 * EXPECTED: rc = -1, errno = EFAULT
	 *
	 * This variation uncovered XFS BUG #2 (0 return code from strnlen_user
	 * ignored, which indicated fault)
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 3)) {
		dm_sessid_t newsid;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sessinfop)\n", szFuncName);
		rc = dm_create_session(DM_NO_SESSION, (char *)INVALID_ADDR, &newsid);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}


	/*
	 * TEST    : dm_create_session - NULL newsidp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 4)) {
		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL newsidp)\n", szFuncName);
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, NULL);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_session - invalid newsidp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 5)) {
		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid newsidp)\n", szFuncName);
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, (dm_sessid_t *)INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_session - DM_NO_SESSION oldsid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 6)) {
		dm_sessid_t newsid;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION oldsid)\n", szFuncName);
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == 0) {
			DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n", newsid);
		}
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
		rc = dm_destroy_session(newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
		}
	}

	/*
	 * TEST    : dm_create_session - valid oldsid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 7)) {
		dm_sessid_t newsid, oldsid;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			oldsid = newsid;

			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(valid oldsid)\n", szFuncName);
			rc = dm_create_session(oldsid, szSessionInfo, &newsid);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n", newsid);
			}
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_create_session - invalidated oldsid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 8)) {
		dm_sessid_t newsid, oldsid, delsid;

		/* Variation set up */
		if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid)) == -1) {
			/* No clean up */
		} else if ((rc = dm_create_session(oldsid = newsid, szSessionInfo, &newsid)) == -1) {
			dm_destroy_session(oldsid);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			delsid = newsid;
		
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated oldsid)\n", szFuncName);
			rc = dm_create_session(oldsid, szSessionInfo, &newsid);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_destroy_session(delsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_create_session - maximum sessinfo
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 9)) {
		dm_sessid_t newsid;
		char *szBig = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(max sessionfo)\n", szFuncName);
		rc = dm_create_session(DM_NO_SESSION, szBig, &newsid);
		if (rc == 0) {
			DMLOG_PRINT(DMLVL_DEBUG, "newsid = %d\n", newsid);
		}
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
		rc = dm_destroy_session(newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
		}
	}

	/*
	 * TEST    : dm_create_session - sessinfo too big
	 * EXPECTED: rc = -1, errno = E2BIG
	 *
	 * This variation uncovered XFS BUG #1 (sessinfo simply truncated, API
	 * passed)
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 10)) {
		dm_sessid_t newsid;
		char *szTooBig = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456";

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(sessinfo too big)\n", szFuncName);
		rc = dm_create_session(DM_NO_SESSION, szTooBig, &newsid);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_session - multiple sessions with same sessinfo
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(CREATE_SESSION_BASE + 11)) {
		dm_sessid_t newsid1, newsid2;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid1);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(same sessinfo)\n", szFuncName);
			rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid2);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "1st newsid = %d, 2nd newsid = %d\n", newsid1, newsid2);
				if (newsid1 != newsid2) {
				  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but session IDs same\n", szFuncName, 0);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_destroy_session(newsid1);
			rc |= dm_destroy_session(newsid2);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	szFuncName = "dm_destroy_session";

	/*
	 * TEST    : dm_destroy_session - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DESTROY_SESSION_BASE + 1)) {
		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_destroy_session(DM_NO_SESSION);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_destroy_session - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DESTROY_SESSION_BASE + 2)) {
		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_destroy_session(INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_destroy_session - invalidated sid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DESTROY_SESSION_BASE + 3)) {
		dm_sessid_t newsid;

		/* Variation set up */
		if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid)) != -1) {
			rc = dm_destroy_session(newsid);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n", szFuncName);
			rc = dm_destroy_session(newsid);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_destroy_session - valid sid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DESTROY_SESSION_BASE + 4)) {
		dm_sessid_t newsid;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(valid sid)\n", szFuncName);
			rc = dm_destroy_session(newsid);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_destroy_session - sid with oustanding events
	 * EXPECTED: rc = -1, erno = EBUSY
	 */
	if (DMVAR_EXEC(DESTROY_SESSION_BASE + 5)) {
		dm_sessid_t newsid;
		char buf[MSG_DATALEN];
		size_t rlen;

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		rc |= dm_send_msg(newsid, DM_MSGTYPE_ASYNC, MSG_DATALEN, buf);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(valid sid)\n", szFuncName);
			rc = dm_destroy_session(newsid);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);

			/* Variation clean up */
			rc = dm_get_events(newsid, 1, 0, sizeof(dmMsgBuf), dmMsgBuf, &rlen);
			rc |= dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	szFuncName = "dm_getall_sessions";

	/*
	 * TEST    : dm_getall_sessions - NULL sidbufp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 1)) {
		dm_sessid_t newsid;
		int nelem;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL sidbufp)\n", szFuncName);
			rc = dm_getall_sessions(1, NULL, &nelem);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_getall_sessions - invalid sidbufp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 2)) {
		dm_sessid_t newsid;
		int nelem;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sidbufp)\n", szFuncName);
			rc = dm_getall_sessions(1, (dm_sessid_t *)INVALID_ADDR, &nelem);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_getall_sessions - NULL nelemp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 3)) {
		dm_sessid_t newsid, sidArray[1];

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL nelemp)\n", szFuncName);
			rc = dm_getall_sessions(1, sidArray, NULL);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_getall_sessions - invalid nelemp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 4)) {
		dm_sessid_t newsid, sidArray[1];

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n", szFuncName);
			rc = dm_getall_sessions(1, sidArray, (u_int *)INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_getall_sessions - zero nelem, zero sessions
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 5)) {
		dm_sessid_t sidArray[1];
		int nelem;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(zero nelem, zero sessions)\n", szFuncName);
		rc = dm_getall_sessions(0, sidArray, &nelem);
		if (rc == 0) {
			DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
			if (nelem == 0) {
			  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
				DMVAR_PASS();
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n", szFuncName, 0, nelem, 0);
				DMVAR_FAIL();
			}
		} else {
			DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
			DMVAR_FAIL();
		}
	
		/* Variation clean up */
	}

	/*
	 * TEST    : dm_getall_sessions - zero nelem, one session
	 * EXPECTED: rc = -1, errno = E2BIG
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 6)) {
		dm_sessid_t newsid, sidArray[1];
		int nelem;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(zero nelem, one session)\n", szFuncName);
			rc = dm_getall_sessions(0, sidArray, &nelem);

			if (rc == -1) {
				if (errno == E2BIG) {
					DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
					if (nelem == 1) {
						DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d and expected errno = %d\n", szFuncName, -1, E2BIG);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and expected errno = %d but unexpected nelem (%d vs %d)\n", szFuncName, -1, E2BIG, nelem, 1);
						DMVAR_PASS();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected errno = %d\n", szFuncName, -1, errno);
					DMVAR_FAIL();
				}
			} else {
	  			DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d\n", szFuncName, rc);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_getall_sessions - one nelem, one session
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 7)) {
		dm_sessid_t newsid, sidArray[1];
		int nelem;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(one nelem, one session)\n", szFuncName);
			rc = dm_getall_sessions(1, sidArray, &nelem);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
			
				if (nelem == 1) { 
					LogSessions(sidArray, nelem);

					if (newsid == sidArray[0]) {
					  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and nelem = %d but unexpected session ID (%d vs %d)\n", szFuncName, 0, nelem, newsid, sidArray[0]);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n", szFuncName, 0, nelem, 1);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_getall_sessions - two nelem, one session
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 8)) {
		dm_sessid_t newsid, sidArray[2];
		int nelem;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(two nelem, one session)\n", szFuncName);
			rc = dm_getall_sessions(2, sidArray, &nelem);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);

				if (nelem == 1) {
					LogSessions(sidArray, nelem);

					if (newsid == sidArray[0]) {
					  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and nelem = %d but unexpected session ID (%d vs %d)\n", szFuncName, 0, nelem, newsid, sidArray[0]);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n", szFuncName, 0, nelem, 1);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_getall_sessions - ten nelem, eight sessions
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GETALL_SESSIONS_BASE + 9)) {
		dm_sessid_t sidExpected[NUM_SESSIONS], sidArray[10];
		int nelem;

		/* Variation set up */
		for (i = 0, rc = 0; i < NUM_SESSIONS && rc == 0; i++) {
			rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sidExpected[i]);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			for (i--; i >= 0; i--) {
				dm_destroy_session(sidExpected[i]);
			}
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(%d nelem, %d sessions)\n", szFuncName, sizeof(sidArray)/sizeof(dm_sessid_t), NUM_SESSIONS);
			rc = dm_getall_sessions(sizeof(sidArray)/sizeof(dm_sessid_t), sidArray, &nelem);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
			
				if (nelem == NUM_SESSIONS) {
					LogSessions(sidArray, nelem);

					if (memcmp(sidArray, sidExpected, NUM_SESSIONS * sizeof(dm_sessid_t)) == 0) {
					  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and nelem = %d but unexpected session ID(s)\n", szFuncName, 0, nelem);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected nelem (%d vs %d)\n", szFuncName, 0, nelem, NUM_SESSIONS);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			for (i = 0, rc = 0; i < NUM_SESSIONS; i++) {
				rc |= dm_destroy_session(sidExpected[i]);
			}
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	szFuncName = "dm_query_session";

	/*
	 * TEST    : dm_query_session - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 1)) {
		char buf[64];
		size_t rlen;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_query_session(DM_NO_SESSION, sizeof(buf), buf, &rlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_session - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 2)) {
		char buf[64];
		size_t rlen;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_query_session(INVALID_ADDR, sizeof(buf), buf, &rlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_session - invalidated sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 3)) {
		dm_sessid_t newsid;
		char buf[64];
		size_t rlen;

		/* Variation set up */
		if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid)) != -1) {
			rc = dm_destroy_session(newsid);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated sid)\n", szFuncName);
			rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_query_session - NULL bufp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 4)) {
		dm_sessid_t newsid;
		char buf[64];
		size_t rlen;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL bufp)\n", szFuncName);
			rc = dm_query_session(newsid, sizeof(buf), NULL, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_session - invalid bufp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 5)) {
		dm_sessid_t newsid;
		char buf[64];
		size_t rlen;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n", szFuncName);
			rc = dm_query_session(newsid, sizeof(buf), (void *)INVALID_ADDR, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_session - NULL rlenp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 6)) {
		dm_sessid_t newsid;
		char buf[64];

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(NULL rlenp)\n", szFuncName);
			rc = dm_query_session(newsid, sizeof(buf), buf, NULL);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_session - invalid rlenp
	 * EXPECTED: rc = -1, errno EFAULT
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 7)) {
		dm_sessid_t newsid;
		char buf[64];

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n", szFuncName);
			rc = dm_query_session(newsid, sizeof(buf), buf, (size_t *)INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_session - zero buflen
	 * EXPECTED: rc = -1, errno = E2BIG
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 8)) {
		dm_sessid_t newsid;
		char buf[64];
		size_t rlen;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen zero)\n", szFuncName);
			rc = dm_query_session(newsid, 0, buf, &rlen);
			if (rc == -1) {
				if (errno == E2BIG) {
					DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
				
					if (rlen == strlen(szSessionInfo)+1) {
						DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d and expected errno = %d\n", szFuncName, -1, E2BIG);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n", szFuncName, -1, E2BIG, rlen, strlen(szSessionInfo)+1);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected errno = %d\n", szFuncName, -1, errno);
					DMVAR_FAIL();
				}
			} else {
	  			DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d\n", szFuncName, rc);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_session - valid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 9)) {
		dm_sessid_t newsid;
		char buf[64];
		size_t rlen;

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName, sizeof(buf));
			rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);

				if (rlen == strlen(szSessionInfo)+1) {
					DMLOG_PRINT(DMLVL_DEBUG, "buf = \"%s\"\n", buf);

					if (strcmp(buf, szSessionInfo) == 0) {
					  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and rlen = %d but unexpected session info (\"%s\" vs \"%s\")\n", szFuncName, 0, rlen, buf, szSessionInfo);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n", szFuncName, 0, rlen, strlen(szSessionInfo)+1);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_session - maximum sessionfo
	 *           sessioninfo
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_SESSION_BASE + 10)) {
		dm_sessid_t newsid;
		char buf[512];
		size_t rlen;
		char *szBig = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";

		/* Variation set up */
		rc = dm_create_session(DM_NO_SESSION, szBig, &newsid);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(max sessinfo)\n", szFuncName, sizeof(buf));
			rc = dm_query_session(newsid, sizeof(buf), buf, &rlen);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
			
				if (rlen == DM_SESSION_INFO_LEN) {
					DMLOG_PRINT(DMLVL_DEBUG, "buf = \"%s\"\n", buf);

					if (strncmp(buf, szBig, DM_SESSION_INFO_LEN-1) == 0) {
					  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and rlen = %d but unexpected session info (\"%s\" vs \"%s\")\n", szFuncName, 0, rlen, buf, szSessionInfo);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n", szFuncName, 0, rlen, DM_SESSION_INFO_LEN);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_destroy_session(newsid);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	DMLOG_STOP();
		
	return 0;

}
Example #3
0
int main(int argc, char **argv)
{

	char *szFuncName;
	char *varstr;
	int   rc;
	int   varStatus;
	char *szSessionInfo = "dm_test session info";
	dm_eventset_t events;

	DMOPT_PARSE(argc, argv);
	DMLOG_START();

	DMEV_ZERO(events);
	DMEV_SET(DM_EVENT_MOUNT, events);

	/* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
	if ((rc = dm_init_service(&varstr)) != 0) {
		DMLOG_PRINT(DMLVL_ERR, "dm_init_service failed! (rc = %d, errno = %d)\n", rc, errno);
		DM_EXIT();
	} else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid)) == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dm_create_session failed! (rc = %d, errno = %d)\n", rc, errno);
		DM_EXIT();
	} else if ((rc = dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN, &events, DM_EVENT_MAX)) == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dm_set_disp failed! (rc = %d, errno = %d)\n", rc, errno);
		dm_destroy_session(sid);
		DM_EXIT();
	} else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
		DMLOG_PRINT(DMLVL_ERR, "pthread_create failed! (rc = %d, errno = %d)\n", rc, errno);
		dm_destroy_session(sid);
		DM_EXIT();
	} else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc, errno);
		dm_destroy_session(sid);
		DM_EXIT();
	} else {
		rc = dm_get_config(fshanp, fshlen, DM_CONFIG_MAX_MESSAGE_DATA, &maxMsgDat);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_ERR, "dm_get_config failed! (rc = %d, errno = %d)\n", rc, errno);
			umount(mountPt);
			dm_destroy_session(sid);
			DM_EXIT();
		}
	}

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI user event tests\n") ;

	szFuncName = "dm_create_userevent";

	/*
	 * TEST    : dm_create_uservent - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 1)) {
		char buf[MSG_DATALEN];
		dm_token_t token;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_create_userevent(INVALID_ADDR, MSG_DATALEN, buf, &token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_uservent - invalid msglen
	 * EXPECTED: rc = -1, errno = E2BIG
	 */
	if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 2)) {
		char buf[MSG_DATALEN];
		dm_token_t token;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid msglen)\n", szFuncName);
		rc = dm_create_userevent(sid, maxMsgDat+1, buf, &token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_uservent - invalid msgdatap
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 3)) {
		dm_token_t token;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid msgdatap)\n", szFuncName);
		rc = dm_create_userevent(sid, MSG_DATALEN, (void *)INVALID_ADDR, &token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_uservent - invalid tokenp
	 * EXPECTED: rc = -1, errno = EFAULT
	 *
	 * This variation uncovered XFS BUG #11 (unused tevp left on queue)
	 */
	if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 4)) {
		char buf[MSG_DATALEN];

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid tokenp)\n", szFuncName);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, (dm_token_t *)INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_create_uservent - valid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 5)) {
		char buf[MSG_DATALEN];
		dm_token_t token;

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
		rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
		}
	}

	/*
	 * TEST    : dm_create_uservent - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(CREATE_USEREVENT_BASE + 6)) {
		char buf[MSG_DATALEN];
		dm_token_t token;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_create_userevent(DM_NO_SESSION, MSG_DATALEN, buf, &token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	szFuncName = "dm_send_msg";

	/*
	 * TEST    : dm_send_msg - invalid targetsid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 1)) {
		char buf[MSG_DATALEN];

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid targetsid)\n", szFuncName);
		rc = dm_send_msg(INVALID_ADDR, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_send_msg - invalid msgtype
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 2)) {
		char buf[MSG_DATALEN];

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid msgtype)\n", szFuncName);
		rc = dm_send_msg(sid, INVALID_ADDR, MSG_DATALEN, buf);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_send_msg - invalid buflen
	 * EXPECTED: rc = -1, errno = E2BIG
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 3)) {
		char buf[MSG_DATALEN];

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n", szFuncName);
		rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, maxMsgDat+1, buf);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_send_msg - invalid bufp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 4)) {
		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n", szFuncName);
		rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, (void *)INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_send_msg - DM_RESP_CONTINUE
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 5)) {
		char buf[MSG_DATALEN];

		/* Variation set up */
		eventExpected = DM_EVENT_USER;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		memcpy(buf, MSG_DATA, MSG_DATALEN);

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(continue response)\n", szFuncName);
		rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
		if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
			if (tokenReceived == 0) {
				DMLOG_PRINT(DMLVL_ERR, "Token NOT correct! (%d vs non-zero)\n", tokenReceived);
				varStatus = DMSTAT_FAIL;
			}
			if (msgDataLenReceived != MSG_DATALEN) {
				DMLOG_PRINT(DMLVL_ERR, "Message lengths NOT same! (%d vs %d)\n", msgDataLenReceived, MSG_DATALEN);
				varStatus = DMSTAT_FAIL;
			} else if (memcmp(msgDataReceived, buf, MSG_DATALEN) != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Message data NOT same! (%s vs %s)\n", msgDataReceived, buf);
				varStatus = DMSTAT_FAIL;
			}
		}
		DMVAR_END(varStatus);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_send_msg - DM_RESP_ABORT
	 * EXPECTED: rc = -1, errno = ABORT_ERRNO
	 *
	 * This variation uncovered XFS BUG #39 (response reterror returned
	 * instead of -1 and errno set to reterror)
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 6)) {
		char buf[MSG_DATALEN];

		/* Variation set up */
		eventExpected = DM_EVENT_USER;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_ABORT;
		memcpy(buf, MSG_DATA, MSG_DATALEN);

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(abort response)\n", szFuncName);
		rc = dm_send_msg(sid, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
		if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
			if (tokenReceived == 0) {
				DMLOG_PRINT(DMLVL_ERR, "Token NOT correct! (%d vs non-zero)\n", tokenReceived);
				varStatus = DMSTAT_FAIL;
			}
			if (msgDataLenReceived != MSG_DATALEN) {
				DMLOG_PRINT(DMLVL_ERR, "Message lengths NOT same! (%d vs %d)\n", msgDataLenReceived, MSG_DATALEN);
				varStatus = DMSTAT_FAIL;
			} else if (memcmp(msgDataReceived, buf, MSG_DATALEN) != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Message data NOT same! (%s vs %s)\n", msgDataReceived, buf);
				varStatus = DMSTAT_FAIL;
			}
		}
		DMVAR_END(varStatus);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_send_msg - DM_MSGTYPE_ASYNC
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 7)) {
		char buf[MSG_DATALEN];

		/* Variation set up */
		eventExpected = DM_EVENT_USER;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		memcpy(buf, MSG_DATA, MSG_DATALEN);

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_MSGTYPE_ASYNC)\n", szFuncName);
		rc = dm_send_msg(sid, DM_MSGTYPE_ASYNC, MSG_DATALEN, buf);
		EVENT_DELIVERY_DELAY;
		if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
			if (tokenReceived != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Token NOT correct! (%d vs %d)\n", tokenReceived, 0);
				varStatus = DMSTAT_FAIL;
			}
			if (msgDataLenReceived != MSG_DATALEN) {
				DMLOG_PRINT(DMLVL_ERR, "Message lengths NOT same! (%d vs %d)\n", msgDataLenReceived, MSG_DATALEN);
				varStatus = DMSTAT_FAIL;
			} else if (memcmp(msgDataReceived, buf, MSG_DATALEN) != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Message data NOT same! (%s vs %s)\n", msgDataReceived, buf);
				varStatus = DMSTAT_FAIL;
			}
		}
		DMVAR_END(varStatus);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_send_msg - DM_NO_SESSION targetsid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(SEND_MSG_BASE + 8)) {
		char buf[MSG_DATALEN];

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION targetsid)\n", szFuncName);
		rc = dm_send_msg(DM_NO_SESSION, DM_MSGTYPE_SYNC, MSG_DATALEN, buf);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	szFuncName = "dm_find_eventmsg";

	/*
	 * TEST    : dm_find_eventmsg - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 1)) {
		dm_token_t token;
		char buf[MSG_DATALEN];
		size_t rlen;

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to initialize variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
			rc = dm_find_eventmsg(INVALID_ADDR, token, MSG_DATALEN, buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_find_eventmsg - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 2)) {
		dm_token_t token;
		char buf[MSG_DATALEN];
		size_t rlen;

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to initialize variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
			rc = dm_find_eventmsg(sid, INVALID_ADDR, MSG_DATALEN, buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_find_eventmsg - invalid buflen
	 * EXPECTED: rc = -1, errno = E2BIG
	 */
	if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 3)) {
		dm_token_t token;
		char buf[MSG_DATALEN];
		size_t rlen;

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to initialize variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n", szFuncName);
			rc = dm_find_eventmsg(sid, token, MSG_DATALEN-1, buf, &rlen);
			if (rc == -1) {
				if (errno == E2BIG) {
					DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
					if (rlen == MSG_DATALEN+sizeof(dm_eventmsg_t)) {
						DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d, expected errno = %d, and expected rlen = %d\n", szFuncName, rc, errno, rlen);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n", szFuncName, rc, errno, rlen, MSG_DATALEN);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected errno = %d\n", szFuncName, rc, errno);
					DMVAR_FAIL();
				}
			} else {
	  			DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d\n", szFuncName, rc);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_find_eventmsg - invalid bufp
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 4)) {
		dm_token_t token;
		char buf[MSG_DATALEN];
		size_t rlen;

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to initialize variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n", szFuncName);
			rc = dm_find_eventmsg(sid, token, MSG_DATALEN, (void *)INVALID_ADDR, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_find_eventmsg - invalid rlenp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 5)) {
		dm_token_t token;
		char buf[MSG_DATALEN];

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to initialize variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n", szFuncName);
			rc = dm_find_eventmsg(sid, token, MSG_DATALEN, buf, (size_t *)INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_find_eventmsg - valid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 6)) {
		dm_token_t token;
		char bufin[MSG_DATALEN], bufout[MSG_DATALEN+sizeof(dm_eventmsg_t)];
		size_t rlen;

		/* Variation set up */
		memcpy(bufin, MSG_DATA, MSG_DATALEN);
		rc = dm_create_userevent(sid, MSG_DATALEN, bufin, &token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to initialize variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
			rc = dm_find_eventmsg(sid, token, sizeof(bufout), bufout, &rlen);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
				if (rlen == MSG_DATALEN+sizeof(dm_eventmsg_t)) {
					if (memcmp(bufin, bufout+sizeof(dm_eventmsg_t), MSG_DATALEN) == 0) {
				  		DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d, expected rlen %d, and expected buffer %s\n", szFuncName, rc, rlen, bufout+sizeof(dm_eventmsg_t));
						DMVAR_PASS();
					} else {
				  		DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and expected rlen %d but expected buffer %s\n", szFuncName, rc, rlen, bufout);
						DMVAR_FAIL();
					}
				} else {
			  		DMLOG_PRINT(DMLVL_ERR, "%s passed with expected rc = %d but unexpected rlen %d\n", szFuncName, rc, rlen);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_find_eventmsg - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(FIND_EVENTMSG_BASE + 7)) {
		dm_token_t token;
		char buf[MSG_DATALEN];
		size_t rlen;

		/* Variation set up */
		memcpy(buf, MSG_DATA, MSG_DATALEN);
		rc = dm_create_userevent(sid, MSG_DATALEN, buf, &token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to initialize variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_find_eventmsg(DM_NO_SESSION, token, MSG_DATALEN, buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_respond_event(sid, token, DM_RESP_CONTINUE, 0, 0, NULL);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	rc = umount(mountPt);
	if (rc == -1) {
		DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n", rc, errno);
	}

	EVENT_DELIVERY_DELAY;
	pthread_join(tid, NULL);

	rc = dm_destroy_session(sid);
	if (rc == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dm_destroy_session failed! (rc = %d, errno = %d)\n", rc, errno);
	}

	DMLOG_STOP();

	tst_exit();
}
Example #4
0
void DoTest(dm_token_t token, void *hanp, size_t hlen)
{

	char *szFuncName;
	int   rc;

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI object reference tests\n") ;

	szFuncName = "dm_obj_ref_hold";

	/*
	 * TEST    : dm_obj_ref_hold - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 1)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_obj_ref_hold(INVALID_ADDR, token, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_hold - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 2)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_obj_ref_hold(sid, INVALID_ADDR, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_hold - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 3)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_obj_ref_hold(sid, token, (void *)INVALID_ADDR, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_hold - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 4)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_obj_ref_hold(sid, token, hanp, INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_hold - multiple holds
	 * EXPECTED: rc = -1, errno = EBUSY
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 5)) {

		/* Variation set up */
		rc = dm_obj_ref_hold(sid, token, hanp, hlen);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(multiple holds)\n", szFuncName);
			rc = dm_obj_ref_hold(sid, token, hanp, hlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBUSY);

			/* Variation clean up */
			rc = dm_obj_ref_rele(sid, token, hanp, hlen);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_obj_ref_hold - valid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 6)) {
		int rc2;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
		rc = dm_obj_ref_hold(sid, token, hanp, hlen);
		if (rc == 0) {
			if ((rc2 = dm_obj_ref_query(sid, token, hanp, hlen)) == 1) {
				DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
				DMVAR_PASS();
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected dm_obj_ref_query rc = %d\n", szFuncName, 0, rc2);
				DMVAR_FAIL();
			}
		} else {
			DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
			DMVAR_FAIL();
		}

		/* Variation clean up */
		rc = dm_obj_ref_rele(sid, token, hanp, hlen);
	}

	/*
	 * TEST    : dm_obj_ref_hold - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 7)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_obj_ref_hold(DM_NO_SESSION, token, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_hold - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(OBJ_REF_HOLD_BASE + 8)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_obj_ref_hold(sid, token, DM_GLOBAL_HANP, DM_GLOBAL_HLEN);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	szFuncName = "dm_obj_ref_rele";

	/*
	 * TEST    : dm_obj_ref_rele - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 1)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_obj_ref_rele(INVALID_ADDR, token, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_rele - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 2)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_obj_ref_rele(sid, INVALID_ADDR, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_rele - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 3)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_obj_ref_rele(sid, token, (void *)INVALID_ADDR, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_rele - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 4)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_obj_ref_rele(sid, token, hanp, INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_rele - no hold
	 * EXPECTED: rc = -1, errno = EACCES
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(no hold)\n", szFuncName);
		rc = dm_obj_ref_rele(sid, token, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_rele - valid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 6)) {
		int rc2;

		/* Variation set up */
		rc = dm_obj_ref_hold(sid, token, hanp, hlen);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
			rc = dm_obj_ref_rele(sid, token, hanp, hlen);
			if (rc == 0) {
				if ((rc2 = dm_obj_ref_query(sid, token, hanp, hlen)) == 0) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected dm_obj_ref_query rc = %d\n", szFuncName, 0, rc2);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}
		}
	}

	/*
	 * TEST    : dm_obj_ref_rele - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 7)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_obj_ref_rele(DM_NO_SESSION, token, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_rele - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(OBJ_REF_RELE_BASE + 8)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_obj_ref_rele(sid, token, DM_GLOBAL_HANP, DM_GLOBAL_HLEN);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	szFuncName = "dm_obj_ref_query";

	/*
	 * TEST    : dm_obj_ref_query - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 1)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_obj_ref_query(INVALID_ADDR, token, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_query - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 2)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_obj_ref_query(sid, INVALID_ADDR, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_query - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 3)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_obj_ref_query(sid, token, (void *)INVALID_ADDR, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_query - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 4)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_obj_ref_query(sid, token, hanp, INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_query - not held
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(not held)\n", szFuncName);
		rc = dm_obj_ref_query(sid, token, hanp, hlen);
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_query - held
	 * EXPECTED: rc = 1
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 6)) {

		/* Variation set up */
		rc = dm_obj_ref_hold(sid, token, hanp, hlen);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(held)\n", szFuncName);
			rc = dm_obj_ref_query(sid, token, hanp, hlen);
			DMVAR_ENDPASSEXP(szFuncName, 1, rc);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_obj_ref_query - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 7)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_obj_ref_query(DM_NO_SESSION, token, hanp, hlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_obj_ref_query - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(OBJ_REF_QUERY_BASE + 8)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_obj_ref_query(sid, token, DM_GLOBAL_HANP, DM_GLOBAL_HLEN);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

}
Example #5
0
void DoTest()
{

	int   rc;
	char *szFuncName;

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI persistent managed regions test\n") ;

	szFuncName = "dm_get_region";

	/*
	 * TEST    : dm_get_region - persistent, Part II
	 * EXPECTED: rc = 0, nelem = 5
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 1)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelem;
		dm_region_t regbuf[PMR_NUM_REGIONS];
		int varStatus;
		int i;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR)) == -1) {
			/* No clean up */
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(persistent, Part II)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, sizeof(regbuf)/sizeof(dm_region_t), regbuf, &nelem);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelem);
			}
			varStatus = DMSTAT_PASS;
			if (rc != 0) {
				DMLOG_PRINT(DMLVL_ERR, "%s returned unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				varStatus = DMSTAT_FAIL;
			} else if (nelem != PMR_NUM_REGIONS) {
				DMLOG_PRINT(DMLVL_ERR, "Number of regions NOT correct! (%d vs %d)\n", nelem, PMR_NUM_REGIONS);
				varStatus = DMSTAT_FAIL;
			} else {
				DMLOG_PRINT(DMLVL_DEBUG, "%s returned expected rc = %d\n", szFuncName, rc, errno);
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", rc, errno);
				LogRegions(regbuf, nelem);

				for (i = 0; i < PMR_NUM_REGIONS; i++) {
					if (regbuf[i].rg_offset != dm_PMR_regbuf[i].rg_offset) {
						DMLOG_PRINT(DMLVL_ERR, "region %d offset NOT correct! (%lld vs %d)\n", i, regbuf[i].rg_offset, dm_PMR_regbuf[i].rg_offset);
						varStatus = DMSTAT_FAIL;
					}
					if (regbuf[i].rg_size != dm_PMR_regbuf[i].rg_size) {
						DMLOG_PRINT(DMLVL_ERR, "region %d size NOT correct! (%lld vs %d)\n", i, regbuf[i].rg_size, dm_PMR_regbuf[i].rg_size);
						varStatus = DMSTAT_FAIL;
					}
					if (regbuf[i].rg_flags != dm_PMR_regbuf[i].rg_flags) {
						DMLOG_PRINT(DMLVL_ERR, "region %d flags NOT correct! (%lld vs %d)\n", i, regbuf[i].rg_flags, dm_PMR_regbuf[i].rg_flags);
						varStatus = DMSTAT_FAIL;
					}
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			EVENT_DELIVERY_DELAY;
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 2)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
			rc = dm_get_region(INVALID_ADDR, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 3)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
			rc = dm_get_region(sid, (void *)INVALID_ADDR, hlen, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 4)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
			rc = dm_get_region(sid, hanp, INVALID_ADDR, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 5)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, INVALID_ADDR, nelemin, &regbuf, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - invalid regbufp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 6)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid regbufp)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, (dm_region_t *)INVALID_ADDR, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - invalid nelemp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 7)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid nelemp)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, (u_int *)INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - DM_SO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 8)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_get_region(DM_NO_SESSION, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 9)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
			rc = dm_get_region(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			if (rc == -1 && errno == EBADF) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelemout);
			}
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - directory handle
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 10)) {
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen)) == -1) {
			rmdir(DummySubdir);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = rmdir(DummySubdir);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - fs handle
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 11)) {
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;

		/* Variation set up */
		nelemin = 1;
		memset(&regbuf, 0, sizeof(regbuf));

		if ((rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummySubdir, &hanp, &hlen)) == -1) {
			rmdir(DummySubdir);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = rmdir(DummySubdir);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - nelem 0
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 11)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbuf;

		/* Variation set up */
		nelemin = 0;

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 0)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbuf, &nelemout);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelemout);
				if (nelemin == nelemout) {
				  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
				  	DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected nelemp (%d vs %d)\n", szFuncName, 0, nelemin, nelemout);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - nelem 1
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 12)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbufin, regbufout;
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 1;
		memset(&regbufin, 0, sizeof(regbufin));

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbufin, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 1)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, &regbufout, &nelemout);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelemout);
				if (nelemin == nelemout) {
					if (memcmp(&regbufin, &regbufout, sizeof(dm_region_t)) == 0) {
					  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
					  	DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected regions\n", szFuncName, 0);
						DMLOG_PRINT(DMLVL_DEBUG, "Region in:\n");
						LogRegions(&regbufin, nelemin);
						DMLOG_PRINT(DMLVL_DEBUG, "Region out:\n");
						LogRegions(&regbufout, nelemout);
						DMVAR_FAIL();
					}
				} else {
				  	DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected nelemp (%d vs %d)\n", szFuncName, 0, nelemin, nelemout);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_region - nelem 2
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 13)) {
#ifdef MULTIPLE_REGIONS
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbufin[2], regbufout[2];
		dm_boolean_t exactflag;

		/* Variation set up */
		nelemin = 2;
		regbufin[0].rg_offset = 0;
		regbufin[0].rg_size = 1000;
		regbufin[0].rg_flags = DM_REGION_READ;
		regbufin[1].rg_offset = 2000;
		regbufin[1].rg_size = 1000;
		regbufin[1].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, regbufin, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(nelem 2)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, regbufout, &nelemout);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelemout);
				if (nelemin == nelemout) {
					if (memcmp(&regbufin, &regbufout, sizeof(dm_region_t)) == 0) {
					  	DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
					  	DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected regions\n", szFuncName, 0);
						DMLOG_PRINT(DMLVL_DEBUG, "Region in:\n");
						LogRegions(regbufin, nelemin);
						DMLOG_PRINT(DMLVL_DEBUG, "Region out:\n");
						LogRegions(regbufout, nelemout);
						DMVAR_FAIL();
					}
				} else {
				  	DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected nelemp (%d vs %d)\n", szFuncName, 0, nelemin, nelemout);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
#else
		DMLOG_PRINT(DMLVL_WARN, "Test case not built with MULTIPLE_REGIONS defined\n");
		DMVAR_SKIP();
#endif
	}

	/*
	 * TEST    : dm_get_region - regbuf too small
	 * EXPECTED: rc = -1, errno = E2BIG
	 */
	if (DMVAR_EXEC(GET_REGION_BASE + 14)) {
		int fd;
		void *hanp;
		size_t hlen;
		u_int nelemin, nelemout;
		dm_region_t regbufin[2], regbufout[1];
		dm_boolean_t exactflag;

		/* Variation set up */
#ifdef MULTIPLE_REGIONS
		nelemin = 2;
		regbufin[0].rg_offset = 0;
		regbufin[0].rg_size = 1000;
		regbufin[0].rg_flags = DM_REGION_READ;
		regbufin[1].rg_offset = 2000;
		regbufin[1].rg_size = 1000;
		regbufin[1].rg_flags = DM_REGION_WRITE;
#else
		nelemin = 1;
		regbufin[0].rg_offset = 0;
		regbufin[0].rg_size = 1000;
		regbufin[0].rg_flags = DM_REGION_READ;
#endif

		sprintf(command, "cp %s %s", DUMMY_FILE, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin, regbufin, &exactflag)) == -1) {
			close(fd);
			remove(DummyFile);
			dm_handle_free(hanp, hlen);
		}
		if (rc == -1 || fd == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(regbuf too small)\n", szFuncName);
			rc = dm_get_region(sid, hanp, hlen, DM_NO_TOKEN, nelemin-1, regbufout, &nelemout);
			if (rc == -1) {
				if (errno == E2BIG) {
					DMLOG_PRINT(DMLVL_DEBUG, "nelem = %d\n", nelemout);
					if (nelemout == nelemin) {
						DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d and expected errno = %d\n", szFuncName, rc, errno);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and expected errno = %d but unexpected nelemp (%d vs %d)\n", szFuncName, rc, errno, nelemout, nelemin);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected errno = %d\n", szFuncName, rc, errno);
					DMVAR_FAIL();
				}
			} else {
	  			DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d\n", szFuncName, rc);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

}
Example #6
0
int main(int argc, char **argv)
{

	char *szFuncName;
	char *varstr;
	int   rc;
	char *szSessionInfo = "dm_test session info";
	dm_eventset_t events;

	DMOPT_PARSE(argc, argv);
	DMLOG_START();

	DMEV_ZERO(events);
	DMEV_SET(DM_EVENT_MOUNT, events);

	/* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
	if ((rc = dm_init_service(&varstr)) != 0) {
		DMLOG_PRINT(DMLVL_ERR, "dm_init_service failed! (rc = %d, errno = %d)\n", rc, errno);
		DM_EXIT();
	} else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid)) == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dm_create_session failed! (rc = %d, errno = %d)\n", rc, errno);
		DM_EXIT();
	} else if ((rc = dm_set_disp(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN, &events, DM_EVENT_MAX)) == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dm_set_disp failed! (rc = %d, errno = %d)\n", rc, errno);
		dm_destroy_session(sid);
		DM_EXIT();
	} else if ((rc = pthread_create(&tid, NULL, Thread, NULL)) != 0) {
		DMLOG_PRINT(DMLVL_ERR, "pthread_create failed! (rc = %d, errno = %d)\n", rc, errno);
		dm_destroy_session(sid);
		DM_EXIT();
	} else if ((rc = dmimpl_mount(&mountPt, &deviceNm)) == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dmimpl_mount failed! (rc = %d, errno = %d)\n", rc, errno);
		dm_destroy_session(sid);
		DM_EXIT();
	} else {
		sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
		sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);

		remove(DummyFile);
		rmdir(DummySubdir);
	}

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI mount tests\n") ;

	szFuncName = "dm_set_dmattr";

	/*
	 * TEST    : dm_get_mountinfo - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 1)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
			rc = dm_get_mountinfo(INVALID_ADDR, hanp, hlen, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 2)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
			rc = dm_get_mountinfo(sid, (void *)INVALID_ADDR, hlen, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 3)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, INVALID_ADDR, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 4)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, hlen, INVALID_ADDR, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - invalid buflen
	 * EXPECTED: rc = -1, errno = E2BIG
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 5)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN, 0, buf, &rlen);
			if (rc == -1) {
				if (errno == E2BIG) {
					DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
					if (rlen == me_len) {
						DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d and expected errno = %d\n", szFuncName, -1, E2BIG);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n", szFuncName, -1, E2BIG, rlen, me_len);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected errno = %d\n", szFuncName, -1, errno);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d\n", szFuncName, rc);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - invalid bufp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 6)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN, sizeof(buf), (void *)INVALID_ADDR, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - invalid rlenp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 7)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN, sizeof(buf), buf, (size_t *)INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - valid
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 8)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(valid)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
			if (rc == 0) {
				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
				if (rlen == me_len) {
					if (memcmp(buf, me_ptr, rlen) == 0) {
						DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but mount info not same\n", szFuncName, 0);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but mount info len not same (%d vs %d)\n", szFuncName, 0, rlen, me_len);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 9)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_get_mountinfo(DM_NO_SESSION, hanp, hlen, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 10)) {
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_get_mountinfo(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_get_mountinfo - file handle
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 11)) {
		int fd;
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((fd = open(DummyFile, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_handle(DummyFile, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DummyFile);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_mountinfo - dir handle
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_MOUNTINFO_BASE + 12)) {
		void *hanp;
		size_t hlen;
		char buf[MOUNTEVENT_LEN];
		size_t rlen;

		/* Variation set up */
		if ((rc = mkdir(DummySubdir, O_RDWR | O_CREAT)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_handle(DummySubdir, &hanp, &hlen)) == -1) {
			rmdir(DummySubdir);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n", szFuncName);
			rc = dm_get_mountinfo(sid, hanp, hlen, DM_NO_TOKEN, sizeof(buf), buf, &rlen);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = rmdir(DummySubdir);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	if (me_ptr != NULL) {
		free(me_ptr);
	}

	rc = umount(mountPt);
	if (rc == -1) {
		DMLOG_PRINT(DMLVL_ERR, "umount failed! (rc = %d, errno = %d)\n", rc, errno);
	}

	pthread_join(tid, NULL);

	rc = dm_destroy_session(sid);
	if (rc == -1) {
		DMLOG_PRINT(DMLVL_ERR, "dm_destroy_session failed! (rc = %d, errno = %d)\n", rc, errno);
	}

	DMLOG_STOP();

	return 0;
}
Example #7
0
File: config.c Project: 1587/ltp
int main(int argc, char **argv)
{

	char *szFuncName;
	char *varstr;
	int rc;
	int i;

	DMOPT_PARSE(argc, argv);
	DMLOG_START();

	/* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION AND NO PREEXISTING FILES!!! */
	if ((rc = dm_init_service(&varstr)) != 0) {
		DMLOG_PRINT(DMLVL_ERR,
			    "dm_init_service failed! (rc = %d, errno = %d)\n",
			    rc, errno);
		DM_EXIT();
	}

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI configuration tests\n");

	szFuncName = "dm_get_config";

	/*
	 * TEST    : dm_get_config - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 1)) {
		int fd;
		void *hanp;
		size_t hlen;
		dm_size_t retval;

		/* Variation set up */
		if ((fd =
		     open(DUMMY_FILE, O_RDWR | O_CREAT,
			  DUMMY_FILE_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DUMMY_FILE);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
				    szFuncName);
			rc = dm_get_config((void *)INVALID_ADDR, hlen,
					   DM_CONFIG_BULKALL, &retval);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DUMMY_FILE);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to clean up variation! (errno = %d)\n",
					    errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 2)) {
		int fd;
		void *hanp;
		size_t hlen;
		dm_size_t retval;

		/* Variation set up */
		if ((fd =
		     open(DUMMY_FILE, O_RDWR | O_CREAT,
			  DUMMY_FILE_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DUMMY_FILE);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
				    szFuncName);
			rc = dm_get_config(hanp, INVALID_ADDR,
					   DM_CONFIG_BULKALL, &retval);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DUMMY_FILE);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to clean up variation! (errno = %d)\n",
					    errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config - invalid flagname
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 3)) {
		int fd;
		void *hanp;
		size_t hlen;
		dm_size_t retval;

		/* Variation set up */
		if ((fd =
		     open(DUMMY_FILE, O_RDWR | O_CREAT,
			  DUMMY_FILE_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DUMMY_FILE);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid flagname)\n",
				    szFuncName);
			rc = dm_get_config(hanp, hlen, INVALID_ADDR, &retval);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DUMMY_FILE);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to clean up variation! (errno = %d)\n",
					    errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config - invalid retvalp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 4)) {
		int fd;
		void *hanp;
		size_t hlen;

		/* Variation set up */
		if ((fd =
		     open(DUMMY_FILE, O_RDWR | O_CREAT,
			  DUMMY_FILE_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DUMMY_FILE);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid retvalp)\n",
				    szFuncName);
			rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
					   (dm_size_t *) INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DUMMY_FILE);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to clean up variation! (errno = %d)\n",
					    errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 5)) {
		dm_size_t retval;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_get_config(DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
				   DM_CONFIG_BULKALL, &retval);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_get_config - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 6)) {
		int fd;
		void *hanp;
		size_t hlen;
		dm_size_t retval;

		/* Variation set up */
		if ((fd =
		     open(DUMMY_FILE, O_RDWR | O_CREAT,
			  DUMMY_FILE_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DUMMY_FILE);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
				    szFuncName);
			rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
					   &retval);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DUMMY_FILE);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to clean up variation! (errno = %d)\n",
					    errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config - directory handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 7)) {
		int fd;
		void *hanp;
		size_t hlen;
		dm_size_t retval;

		/* Variation set up */
		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
			   == -1) {
			rmdir(DUMMY_SUBDIR);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
				    szFuncName);
			rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
					   &retval);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = rmdir(DUMMY_SUBDIR);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to clean up variation! (errno = %d)\n",
					    errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 8)) {
		int fd;
		void *hanp;
		size_t hlen;
		dm_size_t retval;

		/* Variation set up */
		if ((fd =
		     open(DUMMY_FILE, O_RDWR | O_CREAT,
			  DUMMY_FILE_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
			   == -1) {
			close(fd);
			remove(DUMMY_FILE);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
					   &retval);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = close(fd);
			rc |= remove(DUMMY_FILE);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to clean up variation! (errno = %d)\n",
					    errno);
			}
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config - invalidated handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(GET_CONFIG_BASE + 9)) {
		int fd;
		void *hanp;
		size_t hlen;
		dm_size_t retval;

		/* Variation set up */
		if ((fd =
		     open(DUMMY_FILE, O_RDWR | O_CREAT,
			  DUMMY_FILE_RW_MODE)) == -1) {
			/* No clean up */
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DUMMY_FILE);
		} else if ((rc = close(fd)) == -1) {
			dm_handle_free(hanp, hlen);
			remove(DUMMY_FILE);
		} else if ((rc = remove(DUMMY_FILE)) == -1) {
			dm_handle_free(hanp, hlen);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG,
				    "Unable to set up variation! (errno = %d)\n",
				    errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
				    szFuncName);
			rc = dm_get_config(hanp, hlen, DM_CONFIG_BULKALL,
					   &retval);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			dm_handle_free(hanp, hlen);
		}
	}

	/*
	 * TEST    : dm_get_config
	 * EXPECTED: rc = 0
	 */
	for (i = 1; i < CONFIG_MAX; i++) {
		if (DMVAR_EXEC(GET_CONFIG_BASE + 9 + i)) {
			int fd;
			void *hanp;
			size_t hlen;
			dm_size_t retval;

			/* Variation set up */
			if ((fd =
			     open(DUMMY_FILE, O_RDWR | O_CREAT,
				  DUMMY_FILE_RW_MODE)) == -1) {
				/* No clean up */
			} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) ==
				   -1) {
				close(fd);
				remove(DUMMY_FILE);
			}
			if (fd == -1 || rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG,
					    "Unable to set up variation! (errno = %d)\n",
					    errno);
				DMVAR_SKIP();
			} else {
				/* Variation */
				DMLOG_PRINT(DMLVL_DEBUG, "%s(%s)\n", szFuncName,
					    dmimpl_expectedResults[i].name);
				rc = dm_get_config(hanp, hlen, i, &retval);
				if (rc == 0) {
					if (retval ==
					    dmimpl_expectedResults[i].result) {
						DMLOG_PRINT(DMLVL_DEBUG,
							    "%s passed with expected rc = %d\n",
							    szFuncName, 0);
						DMVAR_PASS();
					} else {
						DMLOG_PRINT(DMLVL_ERR,
							    "%s failed with expected rc = %d but unexpected retval (%lld vs %lld)\n",
							    szFuncName, 0,
							    retval,
							    dmimpl_expectedResults
							    [i].result);
						DMVAR_FAIL();
					}
				} else {
					DMLOG_PRINT(DMLVL_ERR,
						    "%s failed with unexpected rc = %d (errno = %d)\n",
						    szFuncName, rc, errno);
					DMVAR_FAIL();
				}

				/* Variation clean up */
				rc = close(fd);
				rc |= remove(DUMMY_FILE);
				if (rc == -1) {
					DMLOG_PRINT(DMLVL_DEBUG,
						    "Unable to clean up variation! (errno = %d)\n",
						    errno);
				}
				dm_handle_free(hanp, hlen);
			}
		}
	}

	DMLOG_STOP();

	tst_exit();

}
Example #8
0
void DoTest(dm_token_t token, void *hanp, size_t hlen)
{

	char *szFuncName;
	int   rc;

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI rights tests\n") ;

	szFuncName = "dm_request_right";

	/*
	 * TEST    : dm_request_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 1)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_request_right(INVALID_ADDR, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 2)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_request_right(sid, (void *)INVALID_ADDR, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 3)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_request_right(sid, hanp, INVALID_ADDR, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 4)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, INVALID_ADDR, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - invalid right
	 * EXPECTED: rc = -1, errno = EINVAL
	 *
	 * This variation uncovered XFS BUG #29 (0 returned instead of -1 and
	 * errno EINVAL)
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid right)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, token, 0, INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - DM_NO_TOKEN
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 6)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, DM_NO_TOKEN, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_NULL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 7)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL -> DM_RIGHT_SHARED)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
		rc = dm_release_right(sid, hanp, hlen, token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_NULL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 8)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL -> DM_RIGHT_EXCL)\n", szFuncName);
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		DMVAR_ENDPASSEXP(szFuncName, 0, rc);

		/* Variation clean up */
		rc = dm_release_right(sid, hanp, hlen, token);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 9)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED -> DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_SHARED,
	 *		DM_RR_WAIT clear
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 10)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED -> DM_RIGHT_EXCL, DM_RR_WAIT clear)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_SHARED,
	 *		DM_RR_WAIT set
	 * EXPECTED: rc = -1, errno = EACCES
	 *
	 * This variation uncovered XFS BUG #30 (0 returned instead of -1 and
	 * errno EACCES)
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 11)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED -> DM_RIGHT_EXCL, DM_RR_WAIT set)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, DM_RR_WAIT, DM_RIGHT_EXCL);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_EXCL from DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 12)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL -> DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_RIGHT_SHARED from DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 13)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL -> DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_request_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 14)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_request_right(DM_NO_SESSION, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 15)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_request_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token, 0, DM_RIGHT_SHARED);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_request_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 16)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_request_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(REQUEST_RIGHT_BASE + 17)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_release_right";

	/*
	 * TEST    : dm_release_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 1)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_release_right(INVALID_ADDR, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 2)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_release_right(sid, (void *)INVALID_ADDR, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 3)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_release_right(sid, hanp, INVALID_ADDR, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 4)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_release_right(sid, hanp, hlen, INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - DM_NO_TOKEN
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
		rc = dm_release_right(sid, hanp, hlen, DM_NO_TOKEN);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - DM_RIGHT_NULL
	 * EXPECTED: rc = -1, errno = EACCES
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 6)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
		rc = dm_release_right(sid, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EACCES);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 7)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_release_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_release_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 8)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_release_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : dm_release_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 9)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_release_right(DM_NO_SESSION, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 10)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_release_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_release_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 11)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		if ((rc == dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_release_right(sid, fhanp, fhlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_release_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(RELEASE_RIGHT_BASE + 12)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		if ((rc == dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_release_right(sid, fshanp, fshlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_query_right";

	/*
	 * TEST    : dm_query_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 1)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
		rc = dm_query_right(INVALID_ADDR, hanp, hlen, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 2)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
		rc = dm_query_right(sid, (void *)INVALID_ADDR, hlen, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 3)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
		rc = dm_query_right(sid, hanp, INVALID_ADDR, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 4)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
		rc = dm_query_right(sid, hanp, hlen, INVALID_ADDR, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - invalid rightp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rightp)\n", szFuncName);
		rc = dm_query_right(sid, hanp, hlen, token, (dm_right_t *)INVALID_ADDR);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - DM_NO_TOKEN
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 6)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_TOKEN)\n", szFuncName);
		rc = dm_query_right(sid, hanp, hlen, DM_NO_TOKEN, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 7)) {
		dm_right_t right;

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_query_right(sid, hanp, hlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_SHARED) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_SHARED);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 8)) {
		dm_right_t right;

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_query_right(sid, hanp, hlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_EXCL) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_EXCL);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_query_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 9)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
		rc = dm_query_right(DM_NO_SESSION, hanp, hlen, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 10)) {
		dm_right_t right;

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
		rc = dm_query_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token, &right);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_query_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 11)) {
		void *fhanp;
		size_t fhlen;
		dm_right_t right;

		/* Variation set up */
		if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_query_right(sid, fhanp, fhlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_SHARED) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_SHARED);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_query_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(QUERY_RIGHT_BASE + 12)) {
		void *fshanp;
		size_t fshlen;
		dm_right_t right;

		/* Variation set up */
		if ((rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_query_right(sid, fshanp, fshlen, token, &right);
			if (rc == 0) {
				if (right == DM_RIGHT_SHARED) {
					DMLOG_PRINT(DMLVL_DEBUG, "%s passed with expected rc = %d\n", szFuncName, 0);
					DMVAR_PASS();
				} else {
					DMLOG_PRINT(DMLVL_ERR, "%s failed with expected rc = %d but unexpected right (%d vs %d)\n", szFuncName, 0, right, DM_RIGHT_SHARED);
					DMVAR_FAIL();
				}
			} else {
				DMLOG_PRINT(DMLVL_ERR, "%s failed with unexpected rc = %d (errno = %d)\n", szFuncName, rc, errno);
				DMVAR_FAIL();
			}

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_upgrade_right";

	/*
	 * TEST    : dm_upgrade_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 1)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
			rc = dm_upgrade_right(INVALID_ADDR, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 2)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
			rc = dm_upgrade_right(sid, (void *)INVALID_ADDR, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 3)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, INVALID_ADDR, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 4)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, hlen, INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - DM_RIGHT_NULL
	 * EXPECTED: rc = -1, errno = EPERM
	 *
	 * This variation uncovered XFS BUG #31 (EACCES returned instead of
	 * EPERM)
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
		rc = dm_upgrade_right(sid, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_upgrade_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 6)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 7)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_upgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 8)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_upgrade_right(DM_NO_SESSION, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 9)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
			rc = dm_upgrade_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_upgrade_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 10)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_upgrade_right(sid, fhanp, fhlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_upgrade_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(UPGRADE_RIGHT_BASE + 11)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		if ((rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_SHARED)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_upgrade_right(sid, fshanp, fshlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

	szFuncName = "dm_downgrade_right";

	/*
	 * TEST    : dm_downgrade_right - invalid sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 1)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n", szFuncName);
			rc = dm_downgrade_right(INVALID_ADDR, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - invalid hanp
	 * EXPECTED: rc = -1, errno = EFAULT
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 2)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n", szFuncName);
			rc = dm_downgrade_right(sid, (void *)INVALID_ADDR, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - invalid hlen
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 3)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, INVALID_ADDR, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - invalid token
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 4)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, hlen, INVALID_ADDR);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - DM_RIGHT_NULL
	 * EXPECTED: rc = -1, errno = EPERM
	 *
	 * This variation uncovered XFS BUG #32 (EACCES returned instead of
	 * EPERM)
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 5)) {

		/* Variation set up */

		/* Variation */
		DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_NULL)\n", szFuncName);
		rc = dm_downgrade_right(sid, hanp, hlen, token);
		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);

		/* Variation clean up */
	}

	/*
	 * TEST    : dm_downgrade_right - DM_RIGHT_SHARED
	 * EXPECTED: rc = -1, errno = EPERM
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 6)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_SHARED)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EPERM);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - DM_RIGHT_EXCL
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 7)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_EXCL);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_RIGHT_EXCL)\n", szFuncName);
			rc = dm_downgrade_right(sid, hanp, hlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - DM_NO_SESSION sid
	 * EXPECTED: rc = -1, errno = EINVAL
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 8)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_downgrade_right(DM_NO_SESSION, hanp, hlen, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - global handle
	 * EXPECTED: rc = -1, errno = EBADF
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 9)) {

		/* Variation set up */
		rc = dm_request_right(sid, hanp, hlen, token, 0, DM_RIGHT_SHARED);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n", szFuncName);
			rc = dm_downgrade_right(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN, token);
			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);

			/* Variation clean up */
			rc = dm_release_right(sid, hanp, hlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
		}
	}

	/*
	 * TEST    : dm_downgrade_right - file handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 10)) {
		void *fhanp;
		size_t fhlen;

		/* Variation set up */
		if ((rc = dm_fd_to_handle(fd_f, &fhanp, &fhlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fhanp, fhlen, token, 0, DM_RIGHT_EXCL)) == -1) {
			dm_handle_free(fhanp, fhlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n", szFuncName);
			rc = dm_downgrade_right(sid, fhanp, fhlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fhanp, fhlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fhanp, fhlen);
		}
	}

	/*
	 * TEST    : dm_downgrade_right - fs handle
	 * EXPECTED: rc = 0
	 */
	if (DMVAR_EXEC(DOWNGRADE_RIGHT_BASE + 11)) {
		void *fshanp;
		size_t fshlen;

		/* Variation set up */
		if ((rc = dm_path_to_fshandle(DummyFile, &fshanp, &fshlen)) == -1) {
			/* No clean up */
		} else if ((rc = dm_request_right(sid, fshanp, fshlen, token, 0, DM_RIGHT_EXCL)) == -1) {
			dm_handle_free(fshanp, fshlen);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
			rc = dm_downgrade_right(sid, fshanp, fshlen, token);
			DMVAR_ENDPASSEXP(szFuncName, 0, rc);

			/* Variation clean up */
			rc = dm_release_right(sid, fshanp, fshlen, token);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_DEBUG, "Unable to clean up variation! (errno = %d)\n", errno);
			}
			dm_handle_free(fshanp, fshlen);
		}
	}

}