Example #1
0
int main(int argc, char *argv[])
{
	int lc, i;
	char *msg;

	msg = parse_opts(argc, argv, options, &help);
	if (msg != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	/* Check for mandatory option of the testcase */
	if (!dflag)
		tst_brkm(TBROK, NULL,
			 "you must specify the device used for mounting with -D "
			 "option");

	if (tflag)
		fs_type = fstype;


	if (STD_COPIES != 1) {
		tst_resm(TINFO, "-c option has no effect for this testcase - "
			 "%s doesn't allow running more than one instance "
			 "at a time", TCID);
		STD_COPIES = 1;
	}

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		tst_count = 0;

		for (i = 0; i < TST_TOTAL; ++i) {

			TEST(mount(device, mntpoint, fs_type, rwflags[i],
				   NULL));

			if (TEST_RETURN != 0) {
				tst_resm(TFAIL | TTERRNO, "mount(2) failed");
				continue;
			}

			/* Validate the rwflag */
			if (test_rwflag(i, lc) == 1)
				tst_resm(TFAIL, "mount(2) failed while"
					 " validating %ld", rwflags[i]);
			else
				tst_resm(TPASS, "mount(2) passed with "
					 "rwflag = %ld", rwflags[i]);

			TEST(umount(mntpoint));
			if (TEST_RETURN != 0)
				tst_brkm(TBROK | TTERRNO, cleanup,
					 "umount(2) failed for %s", mntpoint);
		}
	}

	cleanup();
	tst_exit();
}
Example #2
0
File: mount03.c Project: 1587/ltp
int main(int argc, char *argv[])
{
	int lc, i;

	tst_parse_opts(argc, argv, NULL, NULL);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		tst_count = 0;

		for (i = 0; i < TST_TOTAL; ++i) {

			TEST(mount(device, mntpoint, fs_type, rwflags[i],
				   NULL));

			if (TEST_RETURN != 0) {
				tst_resm(TFAIL | TTERRNO, "mount(2) failed");
				continue;
			}

			/* Validate the rwflag */
			if (test_rwflag(i, lc) == 1)
				tst_resm(TFAIL, "mount(2) failed while"
					 " validating %ld", rwflags[i]);
			else
				tst_resm(TPASS, "mount(2) passed with "
					 "rwflag = %ld", rwflags[i]);

			TEST(tst_umount(mntpoint));
			if (TEST_RETURN != 0)
				tst_brkm(TBROK | TTERRNO, cleanup,
					 "umount(2) failed for %s", mntpoint);
		}
	}

	cleanup();
	tst_exit();
}
Example #3
0
int main(int ac, char **av)
{
	int lc, i;
	char *msg;

	if ((msg = parse_opts(ac, av, options, &help)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	/* Check for mandatory option of the testcase */
	if (!Dflag) {
		tst_brkm(TBROK, NULL,
		    "you must specify the device used for mounting with -D "
		    "option");
	}

	if (Tflag) {
		Fstype = (char *)malloc(strlen(fstype)+1);
		if (Fstype == NULL) {
			tst_brkm(TBROK|TERRNO, NULL, "malloc failed");
		}
		Fstype[strlen(fstype)] = '\0';
		strncpy(Fstype, fstype, strlen(fstype));
	} else {
		Fstype = (char *)malloc(strlen(DEFAULT_FSTYPE)+1);
		if (Fstype == NULL) {
			tst_brkm(TBROK|TERRNO, NULL, "malloc failed");
		}
		strncpy(Fstype, DEFAULT_FSTYPE, strlen(DEFAULT_FSTYPE));
		Fstype[strlen(DEFAULT_FSTYPE)] = '\0';
	}

	if (STD_COPIES != 1) {
		tst_resm(TINFO, "-c option has no effect for this testcase - "
			 "%s doesn't allow running more than one instance "
			 "at a time", TCID);
		STD_COPIES = 1;
	}

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		Tst_count = 0;

		for (i = 0; i < TST_TOTAL; ++i) {

			/* Call mount(2) */
			TEST(mount(device, mntpoint, Fstype, rwflags[i], NULL));

			/* check return code */
			if (TEST_RETURN != 0) {
				tst_resm(TFAIL|TTERRNO, "mount(2) failed");
				continue;
			}

			/* Validate the rwflag */
			if (test_rwflag(i, lc) == 1) {
				tst_resm(TFAIL, "mount(2) failed while"
				    " validating %ld", rwflags[i]);
			} else {
				tst_resm(TPASS, "mount(2) passed with "
				    "rwflag = %ld", rwflags[i]);
			}
			TEST(umount(mntpoint));
			if (TEST_RETURN != 0) {
				tst_brkm(TBROK|TTERRNO, cleanup,
				    "umount(2) failed for %s", mntpoint);
			}
		}
	}

	/* cleanup and exit */
	cleanup();

	tst_exit();
}