Exemplo n.º 1
0
Arquivo: test.c Projeto: BIllli/mget
int main(int argc, const char * const *argv)
{
	// if VALGRIND testing is enabled, we have to call ourselves with valgrind checking
	const char *valgrind = getenv("VALGRIND_TESTS");

	if (!valgrind || !*valgrind || !strcmp(valgrind, "0")) {
		// fallthrough
	}
	else if (!strcmp(valgrind, "1")) {
		char cmd[strlen(argv[0]) + 256];

		snprintf(cmd, sizeof(cmd), "VALGRIND_TESTS=\"\" valgrind --error-exitcode=301 --leak-check=yes --show-reachable=yes --track-origins=yes %s", argv[0]);
		return system(cmd) != 0;
	} else {
		char cmd[strlen(valgrind) + strlen(argv[0]) + 32];

		snprintf(cmd, sizeof(cmd), "VALGRIND_TESTS="" %s %s", valgrind, argv[0]);
		return system(cmd) != 0;
	}

	init(argc, argv); // allows us to test with options (e.g. with --debug)

	srand((unsigned int) time(NULL));

	// testing basic library functionality
	test_buffer();
	test_buffer_printf();
	test_utils();
	test_strcasecmp_ascii();
	test_vector();
	test_stringmap();

	if (failed) {
		info_printf("ERROR: %d out of %d basic tests failed\n", failed, ok + failed);
		info_printf("This may completely break Mget functionality !!!\n");
		return 1;
	}

	test_iri_parse();
	test_iri_relative_to_absolute();
	test_iri_compare();
	test_parser();

	test_cookies();
	test_hsts();
	test_parse_challenge();

	selftest_options() ? failed++ : ok++;

	deinit(); // free resources allocated by init()

	if (failed) {
		info_printf("Summary: %d out of %d tests failed\n", failed, ok + failed);
		return 1;
	}

	info_printf("Summary: All %d tests passed\n", ok + failed);
	return 0;
}
Exemplo n.º 2
0
int main(void)
{
	plan_tests(14);
	
	test_trivial();
	ok1(test_stringmap(10000, stdout));
	
	return exit_status();
}