Example #1
0
File: fcntl34.c Project: kraj/ltp
static void setup(void)
{
	thread_cnt = tst_ncpus_conf() * 3;
	if (thread_cnt > max_thread_cnt)
		thread_cnt = max_thread_cnt;
}
Example #2
0
/*
 * Function:    main - entry point of this program
 *
 * Description: Parses the arguments to each command. Most commands have in
 *              common atlest 2 arguments, type of test result, which is one of
 *              TPASS, TFAIL, TBROK, TCONF, etc, and a message that describes
 *              the result. Other arguments are a file, the contents of which
 *              are printed after the type of test result and associated message
 *              is printed, also a cleanup function that will be executed.
 *              Currently this function name is ignored but MUST be provided
 *              for compatability reasons.
 *
 *              The different commands are actually a hard link to this program
 *              the program invokes the appropriate function based on the
 *              command name with which it was invoked.
 *
 *              Set the values for TCID to the name of the test case.
 *              set the value for TST_TOTAL for total number of tests this is
 *              required in case one test breaks and all following tests also
 *              should be reported as broken.
 *              Set tst_count before every individual test.
 *
 * Exit:        0 on success
 *              -1 on failure
 */
int main(int argc, char *argv[])
{
	strcpy(cmd_name, SAFE_BASENAME(NULL, (argv++)[0]));

	TCID = getenv("TCID");
	tst_total = getenv("TST_TOTAL");
	tst_cntstr = getenv("TST_COUNT");
	if (TCID == NULL || tst_total == NULL || tst_cntstr == NULL) {
		if (!strcmp(cmd_name, "tst_kvercmp") &&
		    !strcmp(cmd_name, "tst_kvercmp2") &&
		    !strcmp(cmd_name, "tst_fs_has_free") &&
		    !strcmp(cmd_name, "tst_get_unused_port")) {
			fprintf(stderr,
				"\nSet variables TCID, TST_TOTAL, and TST_COUNT before each test:\n"
				"export TCID=<test name>\n"
				"export TST_TOTAL=<Total Number of Tests >\n"
				"export TST_COUNT=<Test case number>\n\n");
			/* Make sure the user knows there's an error. */
			abort();
		}
	} else {
		TST_TOTAL = atoi(tst_total);
		tst_count = atoi(tst_cntstr);
		if (tst_count > 0)
			tst_count--;

		if (strcmp(TCID, " ") == 0) {
			fprintf(stderr,
				"Variable TCID not set, use: TCID=<test name>\n");
			exit(1);
		}
		if (TST_TOTAL <= 0) {
			fprintf(stderr,
				"Variable TST_TOTAL is set to 0, must be "
				"greater than zero\n");
			exit(1);
		}
	}

	if (strcmp(cmd_name, "tst_brk") == 0) {
		apicmd_brk(argc, argv);
	} else if (strcmp(cmd_name, "tst_res") == 0) {
		apicmd_res(argc, argv);
	} else if (strcmp(cmd_name, "tst_brkm") == 0) {
		apicmd_brkm(argc, argv);
	} else if (strcmp(cmd_name, "tst_resm") == 0) {
		apicmd_resm(argc, argv);
	} else if (strcmp(cmd_name, "tst_exit") == 0) {
		tst_exit();
	} else if (strcmp(cmd_name, "tst_flush") == 0) {
		tst_flush();
	} else if (strcmp(cmd_name, "tst_kvercmp") == 0) {
		apicmd_kvercmp(argc, argv);
	} else if (strcmp(cmd_name, "tst_kvercmp2") == 0) {
		apicmd_kvercmp2(argc, argv);
	} else if (strcmp(cmd_name, "tst_ncpus") == 0) {
		printf("%li\n", tst_ncpus());
	} else if (strcmp(cmd_name, "tst_ncpus_conf") == 0) {
		printf("%li\n", tst_ncpus_conf());
	} else if (strcmp(cmd_name, "tst_ncpus_max") == 0) {
		printf("%li\n", tst_ncpus_max());
	} else if (strcmp(cmd_name, "tst_get_unused_port") == 0) {
		printf("%u\n", apicmd_get_unused_port(argc, argv));
	} else if (strcmp(cmd_name, "tst_fs_has_free") == 0) {
		apicmd_fs_has_free(argc, argv);
	}

	exit(0);
}