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; }
int main() { axutil_env_t *env = cut_setup_env("util"); CUT_ASSERT(env != NULL); if (env) { test_utils(env); axutil_env_free(env); } CUT_RETURN_ON_FAILURE(-1); return 0; }
int main() { OFSTREAM out(NTEXT("debug-log")); OFSTREAM err(NTEXT("err.log")); // Debug::setOutputStream( out ); // Debug::setErrStream( err ); Debug::setCurrentModule( NTEXT("FILETEST") ); test_fiterator(); test_utils(); return 0; }
static void test_provider_funcs(void) { static GUID generic_verify_v2 = WINTRUST_ACTION_GENERIC_VERIFY_V2; SAFE_PROVIDER_FUNCTIONS funcs = { sizeof(SAFE_PROVIDER_FUNCTIONS), 0 }; BOOL ret; ret = WintrustLoadFunctionPointers(&generic_verify_v2, (CRYPT_PROVIDER_FUNCTIONS *)&funcs); if (!ret) skip("WintrustLoadFunctionPointers failed\n"); else { test_utils(&funcs); testInitialize(&funcs, &generic_verify_v2); testObjTrust(&funcs, &generic_verify_v2); testCertTrust(&funcs, &generic_verify_v2); } }
int Test::all() { clock_t begin = clock(); exeTime = 0; test_general(); test_types(); test_booleans(); test_numbers(); test_strings(); test_arrays(); test_intervals(); test_map(); test_set(); test_objects(); test_functions(); test_classes(); test_loops(); test_operators(); test_references(); test_exceptions(); test_operations(); test_system(); test_json(); test_files(); test_doc(); test_utils(); double elapsed_secs = double(clock() - begin) / CLOCKS_PER_SEC; int errors = (total - success_count); int leaks = (obj_created - obj_deleted); int mpz_leaks = (mpz_obj_created - mpz_obj_deleted); std::ostringstream line1, line2, line3, line4; line1 << "Total : " << total << ", success : " << success_count << ", errors : " << errors; line2 << "Total time : " << elapsed_secs * 1000 << " ms"; line3 << "Objects destroyed : " << obj_deleted << " / " << obj_created << " (" << leaks << " leaked)"; line4 << "MPZ objects destroyed : " << mpz_obj_deleted << " / " << mpz_obj_created << " (" << mpz_leaks << " leaked)"; unsigned w = std::max(line1.str().size(), std::max(line2.str().size(), std::max(line3.str().size(), line4.str().size()))); auto pad = [](std::string s, int l) { l -= s.size(); while (l-- > 0) s += " "; return s; }; std::cout << "┌"; for (unsigned i = 0; i < w + 2; ++i) std::cout << "─"; std::cout << "┐" << std::endl; std::cout << "│ " << pad(line1.str(), w) << " │" << std::endl; std::cout << "│ " << pad(line2.str(), w) << " │" << std::endl; std::cout << "│ " << pad(line3.str(), w) << " │" << std::endl; std::cout << "│ " << pad(line4.str(), w) << " │" << std::endl; std::cout << "├"; for (unsigned i = 0; i < w + 2; ++i) std::cout << "─"; std::cout << "┤"; std::cout << std::endl; int result = abs(errors) + abs(leaks) + abs(mpz_leaks); if (result == 0) { std::cout << "│ " << pad("GOOD! ✔", w + 2) << " │" << std::endl; } else { std::cout << "│ " << pad("BAD! : " + std::to_string(result) + " error(s) ✘", w + 2) << " │" << std::endl; } std::cout << "└"; for (unsigned i = 0; i < w + 2; ++i) std::cout << "─"; std::cout << "┘" << std::endl; for (const auto& error : failed_tests) { std::cout << " " << error << std::endl; } if (failed_tests.size()) { std::cout << std::endl; } return result; }