int main(int argc, const char * const *argv) { /* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */ if (argc == 1) { const char *valgrind = getenv("TESTS_VALGRIND"); if (valgrind && *valgrind) { size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32; char *cmd = alloca(cmdsize); snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } } test_psl(); if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } printf("Summary: All %d tests passed\n", ok + failed); return 0; }
int main(int argc, const char * const *argv) { #ifdef HAVE_CLOCK_GETTIME long ns; #endif /* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */ if (argc == 1) { const char *valgrind = getenv("TESTS_VALGRIND"); if (valgrind && *valgrind) { size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32; char *cmd = alloca(cmdsize); snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } } test_psl(); if (failed) { printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } #ifdef HAVE_CLOCK_GETTIME if (ts1.tv_sec == ts2.tv_sec) ns = ts2.tv_nsec - ts1.tv_nsec; else if (ts1.tv_sec == ts2.tv_sec - 1) ns = 1000000000L - (ts2.tv_nsec - ts1.tv_nsec); else ns = 0; /* let's assume something is wrong and skip outputting measured time */ if (ns) printf("Summary: All %d tests passed in %ld.%06ld ms\n", ok, ns / 1000000, ns % 1000000000); else printf("Summary: All %d tests passed\n", ok); #else printf("Summary: All %d tests passed\n", ok); #endif return 0; }