Beispiel #1
0
int main(int argc, char **argv)
{

	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 {
		sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
		sprintf(DummyFile2, "%s/%s", mountPt, DUMMY_FILE2);
		sprintf(DummySubdir, "%s/%s", mountPt, DUMMY_SUBDIR);
		sprintf(DummySubdir2, "%s/%s", mountPt, DUMMY_SUBDIR2);
		sprintf(DummyLink, "%s/%s", mountPt, DUMMY_LINK);

		remove(DummyFile);
		remove(DummyFile2);
		unlink(DummyLink);
		rmdir(DummySubdir);
		rmdir(DummySubdir2);
	}

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

	/*
	 * TEST    : mkdir - DM_RESP_CONTINUE
	 * EXPECTED: DM_EVENT_CREATE
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 1)) {
		dm_ino_t ino;

		/* Variation set up */
		eventExpected = DM_EVENT_CREATE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;

		/* Variation */
		EVENT_DELIVERY_DELAY;
		DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir, rc);
		if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
			rc = dm_handle_to_ino(hanp1, hlen1, &ino);
		        if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
				varStatus = DMSTAT_FAIL;
			} else if (ino != ROOT_INODE) {
				DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
				varStatus = DMSTAT_FAIL;
			} else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR);
				varStatus = DMSTAT_FAIL;
			}
		}
		DMVAR_END(varStatus);

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

	/*
	 * TEST    : mkdir - DM_RESP_ABORT
	 * EXPECTED: DM_EVENT_CREATE
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 2)) {
		dm_ino_t ino;

		/* Variation set up */
		eventExpected = DM_EVENT_CREATE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_ABORT;

		/* Variation */
		EVENT_DELIVERY_DELAY;
		DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s)\n", DummySubdir);
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		DMLOG_PRINT(DMLVL_DEBUG, "mkdir(%s) returned %d\n", DummySubdir, rc);
		if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
			rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
				varStatus = DMSTAT_FAIL;
			} else if (ino != ROOT_INODE) {
				DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
				varStatus = DMSTAT_FAIL;
			} else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR);
				varStatus = DMSTAT_FAIL;
			}
		}
		DMVAR_END(varStatus);

		/* Variation clean up */
	}

	/*
	 * TEST    : rmdir - DM_RESP_CONTINUE
	 * EXPECTED: DM_EVENT_REMOVE
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 3)) {
		dm_ino_t ino;

		/* Variation set up */
		eventExpected = DM_EVENT_REMOVE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
			rc = rmdir(DummySubdir);
			DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n", DummySubdir, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : rmdir - DM_RESP_ABORT
	 * EXPECTED: DM_EVENT_REMOVE
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 4)) {
		dm_ino_t ino;

		/* Variation set up */
		eventExpected = DM_EVENT_REMOVE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s)\n", DummySubdir);
			rc = rmdir(DummySubdir);
			DMLOG_PRINT(DMLVL_DEBUG, "rmdir(%s) returned %d\n", DummySubdir, rc);
			if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : mv - DM_RESP_CONTINUE
	 * EXPECTED: DM_EVENT_RENAME
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 5)) {
		dm_ino_t ino1, ino2;

		/* Variation set up */
		eventExpected = DM_EVENT_RENAME;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
		EVENT_DELIVERY_DELAY;
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n", DummySubdir, DummySubdir2);
			rc = system(command);
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s) returned %d\n", DummySubdir, DummySubdir2, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "New parent handle NOT root! (%lld vs %d)\n", ino2, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (dm_handle_cmp(hanp1, hlen1, hanp2, hlen2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT equal to new parent handle!\n");
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DUMMY_SUBDIR2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "New entry name NOT correct! (%s vs %s)\n", name2, DUMMY_SUBDIR2);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : mv - DM_RESP_ABORT
	 * EXPECTED: DM_EVENT_RENAME
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 6)) {
		dm_ino_t ino1, ino2;

		/* Variation set up */
		eventExpected = DM_EVENT_RENAME;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		sprintf(command, "mv %s %s", DummySubdir, DummySubdir2);
		EVENT_DELIVERY_DELAY;
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n", DummySubdir, DummySubdir2);
			rc = system(command);
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s) returned %d\n", DummySubdir, DummySubdir2, rc);
			if ((varStatus = (rc == 0 ? DMSTAT_FAIL : DMSTAT_PASS)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "New parent handle NOT root! (%lld vs %d)\n", ino2, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (dm_handle_cmp(hanp1, hlen1, hanp2, hlen2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT equal to new parent handle!\n");
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_SUBDIR) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DUMMY_SUBDIR2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "New entry name NOT correct! (%s vs %s)\n", name2, DUMMY_SUBDIR2);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : symlink - DM_RESP_CONTINUE
	 * EXPECTED: DM_EVENT_SYMLINK
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 7)) {
		dm_ino_t ino;

		/* Variation set up */
		eventExpected = DM_EVENT_SYMLINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummySubdir, DummySubdir2);
			rc = symlink(DummySubdir, DummySubdir2);
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s) returned %d\n", DummySubdir, DummySubdir2, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_SUBDIR2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR2);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DummySubdir) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink contents NOT correct! (%s vs %s)\n", name2, DummySubdir);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : symlink - DM_RESP_ABORT
	 * EXPECTED: DM_EVENT_SYMLINK
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 8)) {
		dm_ino_t ino;

		/* Variation set up */
		eventExpected = DM_EVENT_SYMLINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		rc = mkdir(DummySubdir, DUMMY_DIR_RW_MODE);
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummySubdir, DummySubdir2);
			rc = symlink(DummySubdir, DummySubdir2);
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s) returned %d\n", DummySubdir, DummySubdir2, rc);
			EVENT_DELIVERY_DELAY;
			if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_SUBDIR2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink entry name NOT correct! (%s vs %s)\n", name1, DUMMY_SUBDIR2);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DummySubdir) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink contents NOT correct! (%s vs %s)\n", name2, DummySubdir);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : link - DM_RESP_CONTINUE
	 * EXPECTED: DM_EVENT_LINK
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 9)) {
#ifdef DIRECTORY_LINKS
		dm_ino_t ino1, ino2, ino3;
		void *hanp;
		size_t hlen;

		/* Variation set up */
		eventExpected = DM_EVENT_LINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		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 */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir, DummyLink);
			rc = link(DummySubdir, DummyLink);
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n", DummySubdir, DummyLink, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
				rc |= dm_handle_to_ino(hanp, hlen, &ino3);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ino3) {
					DMLOG_PRINT(DMLVL_ERR, "Source link handle NOT correct! (%lld vs %lld)\n", ino2, ino3);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_LINK) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Target entry name NOT correct! (%s vs %s)\n", name1, DUMMY_LINK);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			EVENT_DELIVERY_DELAY;
			rc = rmdir(DummySubdir);
			rc |= unlink(DummyLink);
			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 DIRECTORY_LINKS defined\n");
		DMVAR_SKIP();
#endif
	}

	/*
	 * TEST    : link - DM_RESP_ABORT
	 * EXPECTED: DM_EVENT_LINK
	 */
	if (DMVAR_EXEC(DIR_SYNC_NAMESP_EVENT_BASE + 10)) {
#ifdef DIRECTORY_LINKS
		dm_ino_t ino1, ino2, ino3;
		void *hanp;
		size_t hlen;

		/* Variation set up */
		eventExpected = DM_EVENT_LINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		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 */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummySubdir, DummyLink);
			rc = link(DummySubdir, DummyLink);
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n", DummySubdir, DummyLink, rc);
			if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
				rc |= dm_handle_to_ino(hanp, hlen, &ino3);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ino3) {
					DMLOG_PRINT(DMLVL_ERR, "Source link handle NOT correct! (%lld vs %lld)\n", ino2, ino3);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_LINK) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Target entry name NOT correct! (%s vs %s)\n", name1, DUMMY_LINK);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			eventResponse = DM_RESP_CONTINUE;
			EVENT_DELIVERY_DELAY;
			rc = rmdir(DummySubdir);
			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 DIRECTORY_LINKS defined\n");
		DMVAR_SKIP();
#endif
	}

	/*
	 * TEST    : open
	 * EXPECTED: DM_EVENT_CREATE, DM_RESP_CONTINUE
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 1)) {
		int fd;
		dm_ino_t ino;

		/* Variation set up */
		eventExpected = DM_EVENT_CREATE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;

		/* Variation */
		EVENT_DELIVERY_DELAY;
		DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
		fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
		DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile, fd);
		rc = (fd == -1) ? -1 : 0;
		if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
			rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
				varStatus = DMSTAT_FAIL;
			} else if (ino != ROOT_INODE) {
				DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
				varStatus = DMSTAT_FAIL;
			} else if (strcmp(name1, DUMMY_FILE) != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s %s)\n", name1, DUMMY_SUBDIR);
				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);
		}
	}

	/*
	 * TEST    : open
	 * EXPECTED: DM_EVENT_CREATE, DM_RESP_ABORT
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 2)) {
		dm_ino_t ino;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_CREATE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_ABORT;

		/* Variation */
		EVENT_DELIVERY_DELAY;
		DMLOG_PRINT(DMLVL_DEBUG, "open(%s)\n", DummyFile);
		fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
		DMLOG_PRINT(DMLVL_DEBUG, "open(%s) returned %d\n", DummyFile, fd);
		if ((varStatus = DMVAR_CHKFAILEXP(-1, fd, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
			rc = dm_handle_to_ino(hanp1, hlen1, &ino);
		        if (rc == -1) {
				DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
				varStatus = DMSTAT_FAIL;
			} else if (ino != ROOT_INODE) {
				DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
				varStatus = DMSTAT_FAIL;
			} else if (strcmp(name1, DUMMY_FILE) != 0) {
				DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s vs %s)\n", name1, DUMMY_FILE);
				varStatus = DMSTAT_FAIL;
			}
		}
		DMVAR_END(varStatus);

		/* Variation clean up */
	}

	/*
	 * TEST    : remove
	 * EXPECTED: DM_EVENT_REMOVE, DM_RESP_CONTINUE
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 3)) {
		dm_ino_t ino;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_REMOVE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) != -1) {
			rc = close(fd);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
			rc = remove(DummyFile);
			DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n", DummyFile, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_FILE) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s vs %s)\n", name1, DUMMY_FILE);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
		}
	}

	/*
	 * TEST    : remove
	 * EXPECTED: DM_EVENT_REMOVE, DM_RESP_ABORT
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 4)) {
		dm_ino_t ino;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_REMOVE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) != -1) {
			rc = close(fd);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "remove(%s)\n", DummyFile);
			rc = remove(DummyFile);
			DMLOG_PRINT(DMLVL_DEBUG, "remove(%s) returned %d\n", DummyFile, rc);
			if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_FILE) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Entry name NOT correct! (%s vs %s)\n", name1, DUMMY_FILE);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : mv
	 * EXPECTED: DM_EVENT_RENAME, DM_RESP_CONTINUE
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 5)) {
		dm_ino_t ino1, ino2;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_RENAME;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		sprintf(command, "mv %s %s", DummyFile, DummyFile2);
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) != -1) {
			rc = close(fd);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n", DummyFile, DummyFile2);
			rc = system(command);
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s) returned %d\n", DummyFile, DummyFile2, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "New parent handle NOT root! (%lld vs %d)\n", ino2, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (dm_handle_cmp(hanp1, hlen1, hanp2, hlen2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT equal to new parent handle!\n");
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_FILE) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old entry name NOT correct! (%s vs %s)\n", name1, DUMMY_FILE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DUMMY_FILE2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "New entry name NOT correct! (%s vs %s)\n", name2, DUMMY_FILE2);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : mv
	 * EXPECTED: DM_EVENT_RENAME, DM_RESP_ABORT
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 6)) {
		dm_ino_t ino1, ino2;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_RENAME;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		sprintf(command, "mv %s %s", DummyFile, DummyFile2);
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) != -1) {
			rc = close(fd);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s)\n", DummyFile, DummyFile2);
			rc = system(command);
			DMLOG_PRINT(DMLVL_DEBUG, "system(mv %s %s) returned %d\n", DummyFile, DummyFile2, rc);
			if ((varStatus = (rc == 0 ? DMSTAT_FAIL : DMSTAT_PASS)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "New parent handle NOT root! (%lld vs %d)\n", ino2, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (dm_handle_cmp(hanp1, hlen1, hanp2, hlen2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old parent handle NOT equal to new parent handle!\n");
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_FILE) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Old entry name NOT correct! (%s vs %s)\n", name1, DUMMY_FILE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DUMMY_FILE2) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "New entry name NOT correct! (%s vs %s)\n", name2, DUMMY_FILE2);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : symlink
	 * EXPECTED: DM_EVENT_SYMLINK, DM_RESP_CONTINUE
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 7)) {
		dm_ino_t ino;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_SYMLINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) != -1) {
			rc = close(fd);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile, DummyLink);
			rc = symlink(DummyFile, DummyLink);
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s) returned %d\n", DummyFile, DummyLink, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_LINK) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink entry name NOT correct! (%s vs %s)\n", name1, DUMMY_LINK);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DummyFile) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink contents NOT correct! (%s vs %s)\n", name2, DummyFile);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : symlink
	 * EXPECTED: DM_EVENT_SYMLINK, DM_RESP_ABORT
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 8)) {
		dm_ino_t ino;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_SYMLINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE)) != -1) {
			rc = close(fd);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s)\n", DummyFile, DummyLink);
			rc = symlink(DummyFile, DummyLink);
			DMLOG_PRINT(DMLVL_DEBUG, "symlink(%s, %s) returned %d\n", DummyFile, DummyLink, rc);
			if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino);
				if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_LINK) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink entry name NOT correct! (%s vs %s)\n", name1, DUMMY_LINK);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name2, DummyFile) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Symlink contents NOT correct! (%s vs %s)\n", name2, DummyFile);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : link
	 * EXPECTED: DM_EVENT_LINK, DM_RESP_CONTINUE
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 9)) {
		dm_ino_t ino1, ino2, ino3;
		void *hanp;
		size_t hlen;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_LINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, 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);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile, DummyLink);
			rc = link(DummyFile, DummyLink);
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n", DummyFile, DummyLink, rc);
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
				rc |= dm_handle_to_ino(hanp, hlen, &ino3);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ino3) {
					DMLOG_PRINT(DMLVL_ERR, "Source link handle NOT correct! (%lld vs %lld)\n", ino2, ino3);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_LINK) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Target entry name NOT correct! (%s vs %s)\n", name1, DUMMY_LINK);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

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

	/*
	 * TEST    : link
	 * EXPECTED: DM_EVENT_LINK, DM_RESP_ABORT
	 */
	if (DMVAR_EXEC(FILE_SYNC_NAMESP_EVENT_BASE + 10)) {
		dm_ino_t ino1, ino2, ino3;
		void *hanp;
		size_t hlen;
		int fd;

		/* Variation set up */
		eventExpected = DM_EVENT_LINK;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		EVENT_DELIVERY_DELAY;
		if ((fd = open(DummyFile, 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);
		}
		if (fd == -1 || rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			eventResponse = DM_RESP_ABORT;
			EVENT_DELIVERY_DELAY;
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s)\n", DummyFile, DummyLink);
			rc = link(DummyFile, DummyLink);
			DMLOG_PRINT(DMLVL_DEBUG, "link(%s, %s) returned %d\n", DummyFile, DummyLink, rc);
			if ((varStatus = DMVAR_CHKFAILEXP(-1, rc, ABORT_ERRNO, eventExpected, eventReceived)) == DMSTAT_PASS) {
				rc = dm_handle_to_ino(hanp1, hlen1, &ino1);
				rc |= dm_handle_to_ino(hanp2, hlen2, &ino2);
				rc |= dm_handle_to_ino(hanp, hlen, &ino3);
			        if (rc == -1) {
					DMLOG_PRINT(DMLVL_ERR, "Unable to obtain inode!\n");
					varStatus = DMSTAT_FAIL;
				} else if (ino1 != ROOT_INODE) {
					DMLOG_PRINT(DMLVL_ERR, "Parent handle NOT root! (%lld vs %d)\n", ino1, ROOT_INODE);
					varStatus = DMSTAT_FAIL;
				} else if (ino2 != ino3) {
					DMLOG_PRINT(DMLVL_ERR, "Source link handle NOT correct! (%lld vs %lld)\n", ino2, ino3);
					varStatus = DMSTAT_FAIL;
				} else if (strcmp(name1, DUMMY_LINK) != 0) {
					DMLOG_PRINT(DMLVL_ERR, "Target entry name NOT correct! (%s vs %s)\n", name1, DUMMY_LINK);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			eventResponse = DM_RESP_CONTINUE;
			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);
		}
	}

	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();

	tst_exit();
}
Beispiel #2
0
int main(int argc, char **argv)
{

	char *varstr;
	int   rc;
	int   i;
	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 {
		int fd;

		sprintf(DummyFile, "%s/%s", mountPt, DUMMY_FILE);
		sprintf(DummyTmp, "%s/%s", mountPt, DUMMY_TMP);

		remove(DummyFile);

		EVENT_DELIVERY_DELAY;
		fd = open(DummyTmp, O_RDWR | O_CREAT, DUMMY_FILE_RW_MODE);
		if (fd != -1) {
			for (i = 0; i < TMP_FILELEN/DUMMY_STRLEN; i++) {
				if (write(fd, DUMMY_STRING, DUMMY_STRLEN) != DUMMY_STRLEN) {
					rc = -1;
					break;
				}				
			}
		} else {
			rc = -1;
		}
		if (rc != -1) {
			rc = fsync(fd);
		}
		if (rc != -1) {
			rc = close(fd);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_ERR, "creating dummy file failed! (rc = %d, errno = %d)\n", rc, errno);
			dm_destroy_session(sid);
			DM_EXIT();
		}
	}

	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI memory mapped file synchronous event data tests\n") ;

	/*
	 * TEST    : mmap - no regions
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 1)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = 0;
		size_t inlen = DUMMY_STRLEN;

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_INVALID;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = close(fd)) == -1) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_REGION_WRITE
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 2)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = 0;
		size_t inlen = DUMMY_STRLEN;
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_INVALID;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_REGION_TRUNCATE
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 3)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = 0;
		size_t inlen = DUMMY_STRLEN;
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_INVALID;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_TRUNCATE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_READ, DM_RESP_CONTINUE
	 * EXPECTED: DM_EVENT_READ
	 *
	 * This variation uncovered XFS BUG #33 (entire file returned instead
	 * of mapped region only)
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 4)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(0);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int varStatus;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_READ;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_READ;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				if (inoff != offset) {
					DMLOG_PRINT(DMLVL_ERR, "Offset NOT correct! (%d vs %d)\n", inoff, offset);
					varStatus = DMSTAT_FAIL;
				} else if (inlen != length) {
					DMLOG_PRINT(DMLVL_ERR, "Length NOT correct! (%d vs %d)\n", inlen, length);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_READ, DM_RESP_ABORT
	 * EXPECTED: DM_EVENT_READ
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 5)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(0);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int varStatus;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_READ;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_ABORT;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_READ;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 0);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				if (inoff != offset) {
					DMLOG_PRINT(DMLVL_ERR, "Offset NOT correct! (%d vs %d)\n", inoff, offset);
					varStatus = DMSTAT_FAIL;
				} else if (inlen != length) {
					DMLOG_PRINT(DMLVL_ERR, "Length NOT correct! (%d vs %d)\n", inlen, length);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_READ
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 6)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(0);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = TMP_FILELEN/2;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_READ;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_READ
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 7)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(TMP_FILELEN/4);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = TMP_FILELEN/2;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_READ;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_READ
	 * EXPECTED: DM_EVENT_READ
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 8)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(TMP_FILELEN/4);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int varStatus;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_READ;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = TMP_FILELEN/4;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_READ;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				if (inoff != offset) {
					DMLOG_PRINT(DMLVL_ERR, "Offset NOT correct! (%d vs %d)\n", inoff, offset);
					varStatus = DMSTAT_FAIL;
				} else if (inlen != length) {
					DMLOG_PRINT(DMLVL_ERR, "Length NOT correct! (%d vs %d)\n", inlen, length);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_READ
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_READ_BASE + 9)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(TMP_FILELEN/4);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = DUMMY_STRLEN;
		Regions[0].rg_flags = DM_REGION_READ;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDONLY, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - no regions
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 1)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = 0;
		size_t inlen = DUMMY_STRLEN;

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_INVALID;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -1) {
			remove(DummyFile);
		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
			close(fd);
			remove(DummyFile);
		} else if ((rc = close(fd)) == -1) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_REGION_READ
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 2)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = 0;
		size_t inlen = DUMMY_STRLEN;
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_INVALID;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_READ;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_REGION_TRUNCATE
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 3)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = 0;
		size_t inlen = DUMMY_STRLEN;
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_INVALID;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_TRUNCATE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_WRITE, DM_RESP_CONTINUE
	 * EXPECTED: DM_EVENT_WRITE
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 4)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(0);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int varStatus;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_WRITE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				if (inoff != offset) {
					DMLOG_PRINT(DMLVL_ERR, "Offset NOT correct! (%d vs %d)\n", inoff, offset);
					varStatus = DMSTAT_FAIL;
				} else if (inlen != length) {
					DMLOG_PRINT(DMLVL_ERR, "Length NOT correct! (%d vs %d)\n", inlen, length);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_WRITE, DM_RESP_ABORT
	 * EXPECTED: DM_EVENT_WRITE
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 5)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(0);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int varStatus;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_WRITE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_ABORT;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 0);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				if (inoff != offset) {
					DMLOG_PRINT(DMLVL_ERR, "Offset NOT correct! (%d vs %d)\n", inoff, offset);
					varStatus = DMSTAT_FAIL;
				} else if (inlen != length) {
					DMLOG_PRINT(DMLVL_ERR, "Length NOT correct! (%d vs %d)\n", inlen, length);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_WRITE
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 6)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(0);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = TMP_FILELEN/2;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_WRITE
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 7)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(TMP_FILELEN/4);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = TMP_FILELEN/2;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_WRITE
	 * EXPECTED: DM_EVENT_WRITE
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 8)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(TMP_FILELEN/4);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int varStatus;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_WRITE;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = TMP_FILELEN/4;
		Regions[0].rg_size = 0;
		Regions[0].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			if ((varStatus = DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived)) == DMSTAT_PASS) {
				if (inoff != offset) {
					DMLOG_PRINT(DMLVL_ERR, "Offset NOT correct! (%d vs %d)\n", inoff, offset);
					varStatus = DMSTAT_FAIL;
				} else if (inlen != length) {
					DMLOG_PRINT(DMLVL_ERR, "Length NOT correct! (%d vs %d)\n", inlen, length);
					varStatus = DMSTAT_FAIL;
				}
			}
			DMVAR_END(varStatus);

			/* Variation clean up */
			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    : mmap - one region, DM_EVENT_WRITE
	 * EXPECTED: no event
	 */
	if (DMVAR_EXEC(MMAP_WRITE_BASE + 9)) {
		int fd;
		void *hanp;
		size_t hlen;
		off_t inoff = PAGEALIGN(TMP_FILELEN/4);
		size_t inlen = PAGEALIGN(DUMMY_STRLEN);
		dm_boolean_t exactflag;
		int numRegions;
		dm_region_t Regions[1];

		/* Variation set up */
		eventExpected = DM_EVENT_INVALID;
		eventReceived = DM_EVENT_INVALID;
		eventResponse = DM_RESP_CONTINUE;
		numRegions = 1;
		Regions[0].rg_offset = 0;
		Regions[0].rg_size = DUMMY_STRLEN;
		Regions[0].rg_flags = DM_REGION_WRITE;

		sprintf(command, "cp %s %s", DummyTmp, DummyFile);
		if ((rc = system(command)) == -1) {
			/* No clean up */
		} else if ((fd = open(DummyFile, O_RDONLY)) == -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, numRegions, Regions, &exactflag)) == -1) ||
			   ((rc = close(fd)) == -1)) {
			dm_handle_free(hanp, hlen);
			remove(DummyFile);
		}
		if (rc == -1) {
			DMLOG_PRINT(DMLVL_DEBUG, "Unable to set up variation! (errno = %d)\n", errno);
			DMVAR_SKIP();
		} else {
			/* Variation */
			sprintf(command, "./%s %s %d %ld %ld %d", MMAPFILE_EXE, DummyFile, O_RDWR, inoff, (long)inlen, 1);
			DMLOG_PRINT(DMLVL_DEBUG, "invoking %s\n", command);
			rc = system(command);
			EVENT_DELIVERY_DELAY;
			DMVAR_END(DMVAR_CHKPASSEXP(0, rc, eventExpected, eventReceived));

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

	remove(DummyFile);
	remove(DummyTmp);
	
	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;
}
Beispiel #3
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);
		}
	}

}
Beispiel #4
0
int
main(
	int	argc,
	char	**argv)
{
	dm_sessid_t	sid, oldsid, targetsid, *newsidp, *sidbufp;
	dm_token_t	token, *tokenp, *rtokenp, *tokenbufp;
	dm_attrname_t	*attrnamep;
	dm_off_t	off, *offp, *roffp;
	dm_extent_t	*extentp;
	dm_inherit_t	*inheritbufp;
	dm_stat_t	*statp;
	dm_size_t	len, *dmrlenp, *retvalp;
	dm_attrloc_t	*locp;
	dm_eventset_t	*eventsetp;
	dm_config_t	flagname;
	dm_region_t	*regbufp;
	dm_response_t	response;
	dm_right_t	right, *rightp;
	dm_igen_t	igen, *igenp;
	dm_msgtype_t	msgtype;
	dm_fileattr_t	*attrp;
	dm_boolean_t	enable, *exactflagp;
	dm_timestruct_t	*delay;
	mode_t		mode;
	size_t		hlen, dirhlen, hlen1, hlen2, targhlen, *fshlenp, *hlenp;
	size_t		msglen, buflen, *rlenp;
	u_int		nelem, mask, maxmsgs, uflags, *nelemp, maxevent;
	void		*hanp, *dirhanp, *hanp1, *hanp2, *targhanp;
	void		*msgdatap, *bufp, **hanpp, *respbufp, **fshanpp;
	dm_fsid_t	fsid, *fsidp;
	dm_ino_t	ino, *inop;
	char		*cname, *sessinfop, *path, *pathbufp, **versionstrpp;
	int		flags, fd, setdtime, reterror;
	u_int	urc;
	int	rc;
	dm_ssize_t	ssrc;

/* Definitions per the prototypes in dmport.h, in the same order. */

	rc = dm_clear_inherit(sid, hanp, hlen, token, attrnamep);
	rc = dm_create_by_handle(sid, dirhanp, dirhlen, token,
		hanp, hlen, cname);
	rc = dm_create_session(oldsid, sessinfop, newsidp);
	rc = dm_create_userevent(sid, msglen, msgdatap, tokenp);
	rc = dm_destroy_session(sid);
	rc = dm_downgrade_right(sid, hanp, hlen, token);
	rc = dm_fd_to_handle(fd, hanpp, hlenp);
	rc = dm_find_eventmsg(sid, token, buflen, bufp, rlenp);
	rc = dm_get_allocinfo(sid, hanp, hlen,
		token, offp, nelem, extentp, nelemp);
	rc = dm_get_bulkall(sid, hanp, hlen, token, mask, attrnamep,
		locp, buflen, bufp, rlenp);
	rc = dm_get_bulkattr(sid, hanp, hlen, token, mask, locp, buflen, 
		bufp, rlenp);
	rc = dm_get_config(hanp, hlen, flagname, retvalp);
	rc = dm_get_config_events(hanp, hlen, nelem, eventsetp, nelemp);
	rc = dm_get_dirattrs(sid, hanp, hlen, token, mask, locp, buflen,
		bufp, rlenp);
	rc = dm_get_dmattr(sid, hanp, hlen, token, attrnamep, buflen,
		bufp, rlenp);
	rc = dm_get_eventlist(sid, hanp, hlen, token, nelem, eventsetp, nelemp);
	rc = dm_get_events(sid, maxmsgs, flags, buflen, bufp, rlenp);
	rc = dm_get_fileattr(sid, hanp, hlen, token, mask, statp);
	rc = dm_get_mountinfo(sid, hanp, hlen, token, buflen, bufp, rlenp);
	rc = dm_get_region(sid, hanp, hlen, token, nelem, regbufp, nelemp);
	rc = dm_getall_disp(sid, buflen, bufp, rlenp);
	rc = dm_getall_dmattr(sid, hanp, hlen, token, buflen, bufp, rlenp);
	rc = dm_getall_inherit(sid, hanp, hlen,
		token, nelem, inheritbufp, nelemp);
	rc = dm_getall_sessions(nelem, sidbufp, nelemp);
	rc = dm_getall_tokens(sid, nelem, tokenbufp, nelemp);
	rc = dm_handle_cmp(hanp1, hlen1, hanp2, hlen2);
	dm_handle_free(hanp, hlen);
	urc = dm_handle_hash(hanp, hlen);
	rc = dm_handle_is_valid(hanp, hlen);
	rc = dm_handle_to_fshandle(hanp, hlen, fshanpp, fshlenp);
	rc = dm_handle_to_fsid(hanp, hlen, fsidp);
	rc = dm_handle_to_igen(hanp, hlen, igenp);
	rc = dm_handle_to_ino(hanp, hlen, inop);
	rc = dm_handle_to_path(dirhanp, dirhlen, targhanp, targhlen, 
		buflen, pathbufp, rlenp);
	rc = dm_init_attrloc(sid, hanp, hlen, token, locp);
	rc = dm_init_service(versionstrpp);
	rc = dm_make_handle(&fsid, &ino, &igen, hanpp, hlenp);
	rc = dm_make_fshandle(&fsid, hanpp, hlenp);
	rc = dm_mkdir_by_handle(sid, dirhanp, dirhlen, token,
		hanp, hlen, cname); 
	rc = dm_move_event(sid, token, targetsid, rtokenp);
	rc = dm_obj_ref_hold(sid, token, hanp, hlen);
	rc = dm_obj_ref_query(sid, token, hanp, hlen);
	rc = dm_obj_ref_rele(sid, token, hanp, hlen);
	rc = dm_path_to_fshandle(path, hanpp, hlenp);
	rc = dm_path_to_handle(path, hanpp, hlenp);
	rc = dm_pending(sid, token, delay);
	rc = dm_probe_hole(sid, hanp, hlen, token, off, len, roffp, dmrlenp);
	rc = dm_punch_hole(sid, hanp, hlen, token, off, len);
	rc = dm_query_right(sid, hanp, hlen, token, rightp);
	rc = dm_query_session(sid, buflen, bufp, rlenp);
	ssrc = dm_read_invis(sid, hanp, hlen, token, off, len, bufp);
	rc =  dm_release_right(sid, hanp, hlen, token);
	rc = dm_remove_dmattr(sid, hanp, hlen, token, setdtime, attrnamep);
	rc = dm_request_right(sid, hanp, hlen, token, uflags, right);
	rc = dm_respond_event(sid, token, response, reterror, buflen, respbufp);
	rc = dm_send_msg(sid, msgtype, buflen, bufp);
	rc = dm_set_disp(sid, hanp, hlen, token, eventsetp, maxevent);
	rc = dm_set_dmattr(sid, hanp, hlen,
		token, attrnamep, setdtime, buflen, bufp);
	rc = dm_set_eventlist(sid, hanp, hlen, token, eventsetp, maxevent);
	rc = dm_set_fileattr(sid, hanp, hlen, token, mask, attrp);
	rc = dm_set_inherit(sid, hanp, hlen, token, attrnamep, mode);
	rc = dm_set_region(sid, hanp, hlen, token, nelem, regbufp, exactflagp);
	rc = dm_set_return_on_destroy(sid, hanp, hlen,
		token,  attrnamep, enable);
	rc = dm_symlink_by_handle(sid, dirhanp, dirhlen, token,
		hanp, hlen, cname, path); 
	rc = dm_sync_by_handle(sid, hanp, hlen, token);
	rc = dm_upgrade_right(sid, hanp, hlen, token);
	ssrc = dm_write_invis(sid, hanp, hlen, flags, token, off, len, bufp);
	exit(0);
}
Beispiel #5
0
int
main(
    int		argc,
    char		**argv)
{
    char		*pathname;
    char		*name;
    void		*hanp1, *hanp2, *hanp3, *fshanp1, *fshanp2, *fshanp3;
    size_t		hlen1, hlen2, hlen3, fshlen1, fshlen2, fshlen3;
    u_int		hash1, hash2, hash3, fshash1, fshash2, fshash3;
    dm_fsid_t	fsid;
    dm_ino_t	ino;
    dm_igen_t	igen;
    char		buffer[100];
    char		buffer1[100];
    char		fsbuffer1[100];
    char		buffer2[100];
    char		fsbuffer2[100];
    char		buffer3[100];
    char		fsbuffer3[100];
    int		fd;

    if (Progname = strrchr(argv[0], '/')) {
        Progname++;
    } else {
        Progname = argv[0];
    }

    if (argc != 2) {
        fprintf(stderr, "usage:	%s path\n", argv[0]);
        exit(1);
    }
    pathname = argv[1];

    (void)dm_init_service(&name);

    if (dm_path_to_handle(pathname, &hanp1, &hlen1) != 0) {
        fprintf(stderr, "dm_path_to_handle failed, %s\n",
                strerror(errno));
        exit(1);
    }
    hash1 = dm_handle_hash(hanp1, hlen1);
    hantoa(hanp1, hlen1, buffer1);
    fprintf(stdout, "  han1:  hash %u  value %s  (dm_path_to_handle)\n",
            hash1, buffer1);
    if (dm_handle_is_valid(hanp1, hlen1) == DM_FALSE) {
        fprintf(stderr, "ERROR: han1 is not valid\n");
    }

    if (dm_path_to_fshandle(pathname, &fshanp1, &fshlen1) != 0) {
        fprintf(stderr, "dm_path_to_fshandle failed, %s\n",
                strerror(errno));
        exit(1);
    }
    fshash1 = dm_handle_hash(fshanp1, fshlen1);
    hantoa(fshanp1, fshlen1, fsbuffer1);
    fprintf(stdout, "fshan1:  hash %u  value %s  (dm_path_to_fshandle\n",
            fshash1, fsbuffer1);
    if (dm_handle_is_valid(fshanp1, fshlen1) == DM_FALSE) {
        fprintf(stderr, "ERROR: fshan1 is not valid\n");
    }

    if ((fd = open(pathname, O_RDONLY)) < 0) {
        fprintf(stderr, "open of %s failed, %s\n", pathname,
                strerror(errno));
        exit(1);
    }
    if (dm_fd_to_handle(fd, &hanp2, &hlen2) != 0) {
        fprintf(stderr, "dm_fd_to_handle failed, %s\n",
                strerror(errno));
        exit(1);
    }
    (void)close(fd);
    hash2 = dm_handle_hash(hanp2, hlen2);
    hantoa(hanp2, hlen2, buffer2);
    fprintf(stdout, "  han2:  hash %u  value %s  (dm_fd_to_handle)\n",
            hash2, buffer2);
    if (dm_handle_is_valid(hanp2, hlen2) == DM_FALSE) {
        fprintf(stderr, "ERROR: han2 is not valid\n");
    }

    if (dm_handle_to_fshandle(hanp2, hlen2, &fshanp2, &fshlen2) != 0) {
        fprintf(stderr, "dm_handle_to_fshandle failed, %s\n",
                strerror(errno));
        exit(1);
    }
    fshash2 = dm_handle_hash(fshanp2, fshlen2);
    hantoa(fshanp2, fshlen2, fsbuffer2);
    fprintf(stdout, "fshan2:  hash %u  value %s  (dm_handle_to_fshandle)\n",
            fshash2, fsbuffer2);
    if (dm_handle_is_valid(fshanp2, fshlen2) == DM_FALSE) {
        fprintf(stderr, "ERROR: fshan2 is not valid\n");
    }

    if (dm_handle_cmp(hanp1, hlen1, hanp2, hlen2)) {
        fprintf(stderr, "ERROR: han1 and han2 differ in dm_handle_cmp\n");
    }
    if (strcmp(buffer1, buffer2)) {
        fprintf(stderr, "ERROR: han1 and han2 differ in strcmp\n");
    }
    if (hash1 != hash2) {
        fprintf(stderr, "ERROR: hash1 and hash2 differ\n");
    }

    if (dm_handle_cmp(fshanp1, fshlen1, fshanp2, fshlen2)) {
        fprintf(stderr, "ERROR: fshan1 and fshan2 differ in dm_handle_cmp\n");
    }
    if (strcmp(fsbuffer1, fsbuffer2)) {
        fprintf(stderr, "ERROR: fshan1 and fshan2 differ in strcmp\n");
    }
    if (fshash1 != fshash2) {
        fprintf(stderr, "ERROR: fshash1 and fshash2 differ\n");
    }

    /* Break the handle into its component parts and display them.  Use
       hantoa() instead of printing the parts directly because some are
       32 bits on Veritas and 64 bits on SGI.
    */

    if (dm_handle_to_fsid(hanp1, hlen1, &fsid) != 0) {
        fprintf(stderr, "dm_handle_to_fsid failed, %s\n",
                strerror(errno));
        exit(1);
    }
    hantoa(&fsid, sizeof(fsid), buffer);
    fprintf(stdout, "fsid  %s	(dm_handle_to_fsid)\n", buffer);

    if (dm_handle_to_ino(hanp1, hlen1, &ino) != 0) {
        fprintf(stderr, "dm_handle_to_ino failed, %s\n",
                strerror(errno));
        exit(1);
    }
    hantoa(&ino, sizeof(ino), buffer);
    fprintf(stdout, "ino   %s	(dm_handle_to_ino)\n", buffer);

    if (dm_handle_to_igen(hanp1, hlen1, &igen) != 0) {
        fprintf(stderr, "dm_handle_to_igen failed, %s\n",
                strerror(errno));
        exit(1);
    }
    hantoa(&igen, sizeof(igen), buffer);
    fprintf(stdout, "igen  %s	(dm_handle_to_igen)\n", buffer);

    /* Now use the parts to remake the handle and verify we get the same
       answer.
    */

    if (dm_make_handle(&fsid, &ino, &igen, &hanp3, &hlen3) != 0) {
        fprintf(stderr, "dm_make_handle failed, %s\n",
                strerror(errno));
        exit(1);
    }
    hash3 = dm_handle_hash(hanp3, hlen3);
    hantoa(hanp3, hlen3, buffer3);
    fprintf(stdout, "  han3:  hash %u  value %s  (dm_make_handle)\n",
            hash3, buffer3);
    if (dm_handle_is_valid(hanp3, hlen3) == DM_FALSE) {
        fprintf(stderr, "ERROR: han3 is not valid\n");
    }

    if (dm_handle_cmp(hanp1, hlen1, hanp3, hlen3)) {
        fprintf(stderr, "ERROR: hanp1 and hanp3 differ in dm_handle_cmp\n");
    }
    if (strcmp(buffer1, buffer3)) {
        fprintf(stderr, "ERROR: hanp1 and hanp3 differ in strcmp\n");
    }
    if (hash1 != hash3) {
        fprintf(stderr, "ERROR: hash1 and hash3 differ\n");
    }

    if (dm_make_fshandle(&fsid, &fshanp3, &fshlen3) != 0) {
        fprintf(stderr, "dm_make_fshandle failed, %s\n",
                strerror(errno));
        exit(1);
    }
    fshash3 = dm_handle_hash(fshanp3, fshlen3);
    hantoa(fshanp3, fshlen3, fsbuffer3);
    fprintf(stdout, "fshan3:  hash %u  value %s  (dm_make_fshandle)\n",
            fshash3, fsbuffer3);
    if (dm_handle_is_valid(fshanp3, fshlen3) == DM_FALSE) {
        fprintf(stderr, "ERROR: fshan3 is not valid\n");
    }

    if (dm_handle_cmp(fshanp1, fshlen1, fshanp3, fshlen3)) {
        fprintf(stderr, "ERROR: fshan1 and fshan3 differ in dm_handle_cmp\n");
    }
    if (strcmp(fsbuffer1, fsbuffer3)) {
        fprintf(stderr, "ERROR: fshan1 and fshan3 differ in strcmp\n");
    }
    if (fshash1 != fshash3) {
        fprintf(stderr, "ERROR: fshash1 and fshash3 differ\n");
    }

    dm_handle_free(hanp1, hlen1);
    dm_handle_free(hanp2, hlen2);
    dm_handle_free(hanp3, hlen3);
    dm_handle_free(fshanp1, fshlen1);
    dm_handle_free(fshanp2, fshlen2);
    dm_handle_free(fshanp3, fshlen3);
    exit(0);
}
Beispiel #6
0
Datei: config.c Projekt: 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();

}
Beispiel #7
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);
		}
	}

}