Пример #1
0
int wmain(int argc, wchar_t **argv) {
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);

	wprintf(L"VirtualDub test harness utility for " BUILD L"\n");
	wprintf(L"Copyright (C) 2005-2008 Avery Lee. Licensed under GNU General Public License\n\n");

	Tests selectedTests;

	if (argc <= 1) {
		help();
		exit(0);
	} else {
		for(int i=1; i<argc; ++i) {
			const wchar_t *test = argv[i];

			if (!_wcsicmp(test, L"all")) {
				for(Tests::const_iterator it(g_tests.begin()), itEnd(g_tests.end()); it!=itEnd; ++it) {
					const TestInfo& ent = *it;

					if (ent.mbAutoRun)
						selectedTests.push_back(ent);
				}
				break;
			}

			for(Tests::const_iterator it(g_tests.begin()), itEnd(g_tests.end()); it!=itEnd; ++it) {
				const TestInfo& ent = *it;

				if (!_wcsicmp(VDTextAToW(ent.mpName).c_str(), test)) {
					selectedTests.push_back(ent);
					goto next;
				}
			}

			wprintf(L"\nUnknown test: %ls\n", test);
			help();
			exit(5);
next:
			;
		}
	}

	long exts = CPUCheckForExtensions();
	int failedTests = 0;

	for(;;) {
		CPUEnableExtensions(exts);
		wprintf(L"Setting CPU extensions: %08x\n", exts);

		for(Tests::const_iterator it(selectedTests.begin()), itEnd(selectedTests.end()); it!=itEnd; ++it) {
			const Tests::value_type& ent = *it;

			wprintf(L"Running test: %hs\n", ent.mpName);

			try {
				ent.mpTestFn();
			} catch(const AssertionException& e) {
				wprintf(L"    TEST FAILED: %hs\n", e.gets());
				++failedTests;
			}
		}

		if (!exts)
			break;

		exts &= ~(1 << VDFindHighestSetBitFast(exts));
	}

	return failedTests;
}