Пример #1
0
int main(int ac, char **av)
{

	int lc, i;		/* loop counter */
	char *msg;		/* message returned from parse_opts */

	/* parse standard options */
	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL))
	    != (char *)NULL) {
		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
	}

	/* perform global setup for test */
	setup();

	/* check looping state if -i option given */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		/* reset Tst_count in case we are looping. */
		Tst_count = 0;

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

			if (i == 2) {
				param1.sched_priority = 0;
			} else {
				param1.sched_priority = 1;
			}
			if ((sched_setscheduler(0, testcases[i].policy,
						&param1)) == -1) {
				tst_brkm(TBROK, cleanup, "sched_setscheduler()"
					 "  failed");
			}
			param.sched_priority = testcases[i].priority;
			/*
			 * Call sched_setparam(2) with pid=0 sothat it will
			 * set the scheduling parameters for the calling process
			 */
			TEST(sched_setparam(0, &param));

			if ((TEST_RETURN == 0) && (verify_priority(i))) {
				tst_resm(TPASS, "%s Passed", testcases[i].desc);
			} else {
				tst_resm(TFAIL|TTERRNO, "%s Failed. sched_setparam()"
					 " returned %ld",
					 testcases[i].desc, TEST_RETURN);
			}
		}
	}			/* End for TEST_LOOPING */

	/* cleanup and exit */
	cleanup();

	 /*NOTREACHED*/ return 0;

}				/* End main */
Пример #2
0
int main(int ac, char **av)
{

	int lc, i;
	char *msg;

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

	setup();

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

		Tst_count = 0;

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

			if (i == 2) {
				param1.sched_priority = 0;
			} else {
				param1.sched_priority = 1;
			}
			if ((sched_setscheduler(0, testcases[i].policy,
						&param1)) == -1) {
				tst_brkm(TBROK, cleanup, "sched_setscheduler()"
					 "  failed");
			}
			param.sched_priority = testcases[i].priority;
			/*
			 * Call sched_setparam(2) with pid=0 sothat it will
			 * set the scheduling parameters for the calling process
			 */
			TEST(sched_setparam(0, &param));

			if ((TEST_RETURN == 0) && (verify_priority(i))) {
				tst_resm(TPASS, "%s Passed", testcases[i].desc);
			} else {
				tst_resm(TFAIL | TTERRNO,
					 "%s Failed. sched_setparam()"
					 " returned %ld", testcases[i].desc,
					 TEST_RETURN);
			}
		}
	}

	/* cleanup and exit */
	cleanup();

	tst_exit();

}
Пример #3
0
int main(int ac, char **av)
{

	int lc;
	int status;
	pid_t child_pid;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

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

		tst_count = 0;

		switch (child_pid = FORK_OR_VFORK()) {

		case -1:
			/* fork() failed */
			tst_resm(TFAIL, "fork() failed");
			continue;

		case 0:
			/* Child */

			/*
			 * Call sched_setparam(2) with pid = getppid() so that
			 * it will set the scheduling parameters for parent
			 * process
			 */
			TEST(sched_setparam(getppid(), &param));

			if (TEST_RETURN == -1) {
				err(0, "sched_setparam returned %ld",
				    TEST_RETURN);
			}
			exit(1);

		default:
			/* Parent */
			if ((waitpid(child_pid, &status, 0)) < 0) {
				tst_resm(TFAIL, "wait() failed");
				continue;
			}

			/*
			 * Verify that parent's scheduling priority has
			 * changed.
			 */
			if ((WIFEXITED(status)) && (WEXITSTATUS(status)) &&
			    (verify_priority())) {
				tst_resm(TPASS, "Test Passed");
			} else {
				tst_resm(TFAIL, "Test Failed");
			}
		}
	}

	cleanup();
	tst_exit();
}