Пример #1
0
int main(int argc, char **argv)
{
	TestData::InitTestData();

	int numTotalRuns = (argc >= 2) ? atoi(argv[1]) : 100;
	int numTrialsPerTimedBlock = (argc >= 3) ? atoi(argv[2]) : 100;
#ifdef EMSCRIPTEN
	numTotalRuns = numTrialsPerTimedBlock = 10;
#endif
	// A list of test prefixes to include in the run.
	std::vector<const char *>prefixesArray;
	for(int i = 3; i < argc; ++i)
	{
		if (argv[i][0] != '-' && argv[i][0] != '/')
			prefixesArray.push_back(argv[i]);
	}
	if (prefixesArray.empty())
		prefixesArray.push_back(""); // Empty prefix runs all tests.
	prefixesArray.push_back(0); // Sentinel to terminate prefix string list.
	const char * const *prefixes = &prefixesArray[0];

	if (numTotalRuns == 0 || numTrialsPerTimedBlock == 0)
	{
		LOGI("Usage: %s <numTotalRuns> <numTrialsPerTimedBlock>", argv[0]); 
		LOGI("   Runs all tests.");
		LOGI("       %s <numTotalRuns> <numTrialsPerTimedBlock> prefix1 prefix2 prefix3...", argv[0]); 
		LOGI("   Runs all tests starting with one of the given prefixes, or residing in one of the named code files.");
		return 0;
	}

	JSONReport jsonReport;
	std::string jsonFilename = "test_results.json";
	for(int i = 1; i+1 < argc; ++i)
		if (!strcmp(argv[i], "--json"))
			jsonFilename = argv[i+1]; // Allow overriding the output file name from command line.
	jsonReport.Create(jsonFilename.c_str());

	int numFailures = RunTests(numTotalRuns, numTrialsPerTimedBlock, prefixes, jsonReport);
	LOGI("%d", globalPokedData);

	// When --exit0 is passed, we forcibly return 0 and not the number of failed tests.
	// Used by buildbot in valgrind runs to ignore any failures - the failures are detected
	// in a "real" run instead that carry more randomized trial runs.
	for(int i = 1; i < argc; ++i)
		if (!strcmp(argv[i], "--exit0"))
			return 0;

	return numFailures; // exit code of 0 denotes a successful run.
}
Пример #2
0
int main(int argc, char **argv)
{
	int numTotalRuns = (argc >= 2) ? atoi(argv[1]) : 100;
	int numTrialsPerTimedBlock = (argc >= 3) ? atoi(argv[2]) : 100;
#ifdef EMSCRIPTEN
	numTotalRuns = numTrialsPerTimedBlock = 10;
#endif
	const char * const noPrefixes[] = { "", 0 };
	const char * const *prefixes = (argc >= 4) ? &argv[3] : noPrefixes;

	if (numTotalRuns == 0 || numTrialsPerTimedBlock == 0)
	{
		LOGI("Usage: %s <numTotalRuns> <numTrialsPerTimedBlock>", argv[0]); 
		LOGI("   Runs all tests.");
		LOGI("       %s <numTotalRuns> <numTrialsPerTimedBlock> prefix1 prefix2 prefix3...", argv[0]); 
		LOGI("   Runs all tests starting with one of the given prefixes, or residing in one of the named code files.");
		return 0;
	}

	JSONReport jsonReport;
	std::string jsonFilename = "test_results.json";
	for(int i = 1; i+1 < argc; ++i)
		if (!strcmp(argv[i], "--json"))
			jsonFilename = argv[i+1]; // Allow overriding the output file name from command line.
	jsonReport.Create(jsonFilename.c_str());

	int numFailures = RunTests(numTotalRuns, numTrialsPerTimedBlock, prefixes, jsonReport);
	LOGI("%d", globalPokedData);

	// When --exit0 is passed, we forcibly return 0 and not the number of failed tests.
	// Used by buildbot in valgrind runs to ignore any failures - the failures are detected
	// in a "real" run instead that carry more randomized trial runs.
	for(int i = 1; i < argc; ++i)
		if (!strcmp(argv[i], "--exit0"))
			return 0;

	return numFailures; // exit code of 0 denotes a successful run.
}