Lines Matching +full:valgrind +full:- +full:out
8 * should be sent to the e-mail address below. This program is part of C TAP
9 * Harness <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
11 * Copyright 2000-2001, 2004, 2006-2019 Russ Allbery <eagle@eyrie.org>
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31 * SPDX-License-Identifier: MIT
37 * runtests [-hv] [-b <build-dir>] [-s <source-dir>] -l <test-list>
38 * runtests [-hv] [-b <build-dir>] [-s <source-dir>] <test> [<test> ...]
39 * runtests -o [-h] [-b <build-dir>] [-s <source-dir>] <test>
42 * one line per executable, possibly followed by a space-separated list of
79 * If the -o option is given, instead run a single test and display all of its
86 * both directories. These paths can also be set with the -b and -s
87 * command-line options, which will override anything set at build time.
89 * If the -v option is given, or the C_TAP_VERBOSE environment variable is set,
167 /* Really, just a boolean, but this is more self-documenting. */
221 Usage: %s [-hv] [-b <build-dir>] [-s <source-dir>] <test> ...\n\
222 %s [-hv] [-b <build-dir>] [-s <source-dir>] -l <test-list>\n\
223 %s -o [-h] [-b <build-dir>] [-s <source-dir>] <test>\n\
226 -b <build-dir> Set the build directory to <build-dir>\n\
229 -l <list> Take the list of tests to run from <test-list>\n\
230 -o Run a single test rather than a list of tests\n\
231 -s <source-dir> Set the source directory to <source-dir>\n\
232 -v Show the full output of each test\n\
234 runtests normally runs each test listed on the command line. With the -l\n\
235 option, it instead runs every test listed in a file. With the -o option,\n\
244 test program with runtests -o to see more details.\n\n";
249 -------------------------- -------------- ---- ---- ------------------------";
293 # pragma GCC diagnostic ignored "-Wattributes"
448 /* Don't assume that the source string is nul-terminated. */ in x_strndup()
449 for (p = s; (size_t)(p - s) < size && *p != '\0'; p++) in x_strndup()
451 len = (size_t)(p - s); in x_strndup()
469 * length. When those constraints are relaxed, this should be ripped out and
488 if (length >= UINT_MAX - strlen(string)) { in concat()
518 return difftime(tv->tv_sec, 0) + (double) tv->tv_usec * 1e-6; in tv_seconds()
528 return tv_seconds(tv1) - tv_seconds(tv0); in tv_diff()
544 * pointer to the first non-whitespace character.
556 * Given a pointer to a string, skip any non-whitespace characters and return
580 if (pipe(fds) == -1) { in test_start()
589 case -1: in test_start()
625 if (execv(command[0], command) == -1) in test_start()
649 for (i = 0; i < ts->length; i++) in test_backspace()
651 for (i = 0; i < ts->length; i++) in test_backspace()
653 for (i = 0; i < ts->length; i++) in test_backspace()
655 ts->length = 0; in test_backspace()
670 if (n <= ts->allocated) in resize_results()
678 if (ts->allocated == 0) { in resize_results()
680 ts->results = xcalloc(s, enum test_status); in resize_results()
682 s = (n > ts->allocated + 1024) ? n : ts->allocated + 1024; in resize_results()
683 ts->results = xreallocarray(ts->results, s, enum test_status); in resize_results()
686 /* Set the results for the newly-allocated test array. */ in resize_results()
687 for (i = ts->allocated; i < s; i++) in resize_results()
688 ts->results[i] = TEST_INVALID; in resize_results()
689 ts->allocated = s; in resize_results()
703 ts->aborted = 1; in invalid_test_number()
704 ts->reported = 1; in invalid_test_number()
732 * skipped; record that. If we do skip the whole file, zero out all of in test_plan()
746 ts->reason = xstrdup(line); in test_plan()
747 ts->reason[strlen(ts->reason) - 1] = '\0'; in test_plan()
749 ts->all_skipped = 1; in test_plan()
750 ts->aborted = 1; in test_plan()
751 ts->count = 0; in test_plan()
752 ts->passed = 0; in test_plan()
753 ts->skipped = 0; in test_plan()
754 ts->failed = 0; in test_plan()
761 ts->aborted = 1; in test_plan()
762 ts->reported = 1; in test_plan()
771 if (ts->plan == PLAN_PENDING && (unsigned long) n < ts->count) { in test_plan()
772 invalid_test_number(ts, (long) ts->count, verbose); in test_plan()
781 ts->count = (unsigned long) n; in test_plan()
782 if (ts->plan == PLAN_INIT) in test_plan()
783 ts->plan = PLAN_FIRST; in test_plan()
784 else if (ts->plan == PLAN_PENDING) in test_plan()
785 ts->plan = PLAN_FINAL; in test_plan()
793 * /^(not )?ok \d+/ is ignored. Sets ts->current to the test number that just
807 bail = strstr(line, "Bail out!"); in test_checkline()
809 bail = skip_whitespace(bail + strlen("Bail out!")); in test_checkline()
814 if (bail[length - 1] == '\n') in test_checkline()
815 length--; in test_checkline()
819 ts->reported = 1; in test_checkline()
821 ts->aborted = 1; in test_checkline()
826 * If the given line isn't newline-terminated, it was too big for an in test_checkline()
829 if (line[strlen(line) - 1] != '\n') in test_checkline()
837 if (ts->plan == PLAN_INIT && isdigit((unsigned char) (*line))) { in test_checkline()
841 if (ts->plan == PLAN_PENDING) { in test_checkline()
848 ts->aborted = 1; in test_checkline()
849 ts->reported = 1; in test_checkline()
865 current = ts->current + 1; in test_checkline()
871 if (current > ts->count && ts->plan == PLAN_FIRST) { in test_checkline()
877 if (ts->plan == PLAN_INIT || ts->plan == PLAN_PENDING) { in test_checkline()
878 ts->plan = PLAN_PENDING; in test_checkline()
880 if (current > ts->count) in test_checkline()
881 ts->count = current; in test_checkline()
900 if (ts->results[current - 1] != TEST_INVALID) { in test_checkline()
904 ts->aborted = 1; in test_checkline()
905 ts->reported = 1; in test_checkline()
912 ts->passed++; in test_checkline()
915 ts->failed++; in test_checkline()
918 ts->skipped++; in test_checkline()
923 ts->current = current; in test_checkline()
924 ts->results[current - 1] = status; in test_checkline()
927 if (ts->plan == PLAN_PENDING) in test_checkline()
930 outlen = printf("%lu/%lu", current, ts->count); in test_checkline()
931 ts->length = (outlen >= 0) ? (unsigned int) outlen : 0; in test_checkline()
938 * Print out a range of test numbers, returning the number of characters it
976 printf("%lu-", first); in test_print_range()
986 * with a non-zero status, and a negative integer representing the signal
998 if (ts->aborted) { in test_summarize()
1000 if (ts->count > 0) in test_summarize()
1001 printf(" (passed %lu/%lu)", ts->passed, ts->count - ts->skipped); in test_summarize()
1003 for (i = 0; i < ts->count; i++) { in test_summarize()
1004 if (ts->results[i] == TEST_INVALID) { in test_summarize()
1011 test_print_range(first, last, missing - 1, 0); in test_summarize()
1019 test_print_range(first, last, missing - 1, 0); in test_summarize()
1022 for (i = 0; i < ts->count; i++) { in test_summarize()
1023 if (ts->results[i] == TEST_FAIL) { in test_summarize()
1032 test_print_range(first, last, failed - 1, 0); in test_summarize()
1040 test_print_range(first, last, failed - 1, 0); in test_summarize()
1043 if (ts->skipped > 0) { in test_summarize()
1044 if (ts->skipped == 1) in test_summarize()
1045 printf(" (skipped %lu test)", ts->skipped); in test_summarize()
1047 printf(" (skipped %lu tests)", ts->skipped); in test_summarize()
1054 printf(" (killed by signal %d%s)", -status, in test_summarize()
1055 WCOREDUMP(ts->status) ? ", core dumped" : ""); in test_summarize()
1069 if (ts->reported) in test_analyze()
1071 if (ts->all_skipped) { in test_analyze()
1072 if (ts->reason == NULL) in test_analyze()
1075 printf("skipped (%s)\n", ts->reason); in test_analyze()
1077 } else if (WIFEXITED(ts->status) && WEXITSTATUS(ts->status) != 0) { in test_analyze()
1078 switch (WEXITSTATUS(ts->status)) { in test_analyze()
1080 if (!ts->reported) in test_analyze()
1084 if (!ts->reported) in test_analyze()
1085 puts("ABORTED (execution failed -- not found?)"); in test_analyze()
1089 if (!ts->reported) in test_analyze()
1093 test_summarize(ts, WEXITSTATUS(ts->status)); in test_analyze()
1097 } else if (WIFSIGNALED(ts->status)) { in test_analyze()
1098 test_summarize(ts, -WTERMSIG(ts->status)); in test_analyze()
1100 } else if (ts->plan != PLAN_FIRST && ts->plan != PLAN_FINAL) { in test_analyze()
1102 ts->aborted = 1; in test_analyze()
1106 return (ts->failed == 0); in test_analyze()
1126 testpid = test_start(ts->command, &outfd); in test_run()
1138 while (!ts->aborted && fgets(buffer, sizeof(buffer), output)) { in test_run()
1143 if (ferror(output) || ts->plan == PLAN_INIT) in test_run()
1144 ts->aborted = 1; in test_run()
1157 child = waitpid(testpid, &ts->status, 0); in test_run()
1158 if (child == (pid_t) -1) { in test_run()
1159 if (!ts->reported) { in test_run()
1165 if (ts->all_skipped) in test_run()
1166 ts->aborted = 0; in test_run()
1170 for (i = 0; i < ts->count; i++) { in test_run()
1171 if (ts->results[i] == TEST_INVALID) { in test_run()
1172 ts->failed++; in test_run()
1173 ts->results[i] = TEST_FAIL; in test_run()
1193 -------------------------- -------------- ---- ---- -------------- */ in test_fail_summary()
1194 for (; fails; fails = fails->next) { in test_fail_summary()
1195 ts = fails->ts; in test_fail_summary()
1196 total = ts->count - ts->skipped; in test_fail_summary()
1197 failed = (double) ts->failed; in test_fail_summary()
1198 printf("%-26.26s %4lu/%-4lu %3.0f%% %4lu ", ts->file, ts->failed, in test_fail_summary()
1200 ts->skipped); in test_fail_summary()
1201 if (WIFEXITED(ts->status)) in test_fail_summary()
1202 printf("%4d ", WEXITSTATUS(ts->status)); in test_fail_summary()
1204 printf(" -- "); in test_fail_summary()
1205 if (ts->aborted) { in test_fail_summary()
1212 for (i = 0; i < ts->count; i++) { in test_fail_summary()
1213 if (ts->results[i] == TEST_FAIL) { in test_fail_summary()
1254 * directory. In each of those directories, we first try a "-t" extension and
1268 const char *suffixes[3] = {"-t", ".t", ""}; in find_test()
1301 * have whitespace-separated options, which change the command that's run.
1304 * valgrind
1305 * Run the test under valgrind if C_TAP_VALGRIND is set. The contents
1306 * of that environment variable are taken as the valgrind command (with
1311 * If running under valgrind, use libtool to invoke valgrind. This avoids
1312 * running valgrind on the wrapper shell script generated by libtool. If
1314 * to use to run valgrind and thus the test. Ignored if the test isn't
1315 * being run under valgrind.
1322 const char *valgrind = NULL; in parse_test_list_line() local
1329 ts->file = xstrndup(line, p - line); in parse_test_list_line()
1335 if (strncmp(p, "libtool", end - p) == 0) { in parse_test_list_line()
1337 } else if (strncmp(p, "valgrind", end - p) == 0) { in parse_test_list_line()
1338 valgrind = getenv("C_TAP_VALGRIND"); in parse_test_list_line()
1339 use_valgrind = (valgrind != NULL); in parse_test_list_line()
1341 option = xstrndup(p, end - p); in parse_test_list_line()
1349 if (use_valgrind && valgrind != NULL) { in parse_test_list_line()
1350 p = skip_whitespace(valgrind); in parse_test_list_line()
1360 ts->command = xcalloc(len + 1, char *); in parse_test_list_line()
1362 if (use_valgrind && valgrind != NULL) { in parse_test_list_line()
1366 die("valgrind with libtool requested, but C_TAP_LIBTOOL is not" in parse_test_list_line()
1368 ts->command[i++] = xstrdup(libtool); in parse_test_list_line()
1369 ts->command[i++] = xstrdup("--mode=execute"); in parse_test_list_line()
1371 p = skip_whitespace(valgrind); in parse_test_list_line()
1374 ts->command[i++] = xstrndup(p, end - p); in parse_test_list_line()
1378 if (i != len - 1) in parse_test_list_line()
1380 ts->command[i++] = find_test(ts->file, source, build); in parse_test_list_line()
1381 ts->command[i] = NULL; in parse_test_list_line()
1415 length = strlen(buffer) - 1; in read_test_list()
1433 current->next = xcalloc(1, struct testlist); in read_test_list()
1434 current = current->next; in read_test_list()
1436 current->ts = xcalloc(1, struct testset); in read_test_list()
1437 current->ts->plan = PLAN_INIT; in read_test_list()
1440 parse_test_list_line(start, current->ts, source, build); in read_test_list()
1476 current->next = xcalloc(1, struct testlist); in build_test_list()
1477 current = current->next; in build_test_list()
1479 current->ts = xcalloc(1, struct testset); in build_test_list()
1480 current->ts->plan = PLAN_INIT; in build_test_list()
1481 current->ts->file = xstrdup(argv[i]); in build_test_list()
1482 current->ts->command = xcalloc(2, char *); in build_test_list()
1483 current->ts->command[0] = find_test(current->ts->file, source, build); in build_test_list()
1484 current->ts->command[1] = NULL; in build_test_list()
1504 free(ts->file); in free_testset()
1505 for (i = 0; ts->command[i] != NULL; i++) in free_testset()
1506 free(ts->command[i]); in free_testset()
1507 free(ts->command); in free_testset()
1508 free(ts->results); in free_testset()
1509 free(ts->reason); in free_testset()
1541 for (current = tests; current != NULL; current = current->next) { in test_batch()
1542 length = strlen(current->ts->file); in test_batch()
1553 longest += 8 - (longest % 8); in test_batch()
1559 for (current = tests; current != NULL; current = current->next) { in test_batch()
1560 ts = current->ts; in test_batch()
1562 /* Print out the name of the test file. */ in test_batch()
1563 fputs(ts->file, stdout); in test_batch()
1567 for (i = strlen(ts->file); i < longest; i++) in test_batch()
1579 aborted += ts->aborted; in test_batch()
1580 total += ts->count + ts->all_skipped; in test_batch()
1581 passed += ts->passed; in test_batch()
1582 skipped += ts->skipped + ts->all_skipped; in test_batch()
1583 failed += ts->failed; in test_batch()
1592 failtail->next = xcalloc(1, struct testlist); in test_batch()
1593 failtail = failtail->next; in test_batch()
1595 failtail->ts = ts; in test_batch()
1596 failtail->next = NULL; in test_batch()
1599 total -= skipped; in test_batch()
1609 next = failhead->next; in test_batch()
1617 next = tests->next; in test_batch()
1618 free_testset(tests->ts); in test_batch()
1623 /* Print out the final test summary. */ in test_batch()
1635 (double) (total - failed) * 100.0 / (double) total); in test_batch()
1662 if (execl(path, path, (char *) 0) == -1) in test_single()
1716 argc -= optind; in main()
1768 /* For valgrind cleanliness, free all our memory. */ in main()