2 * Run a set of tests, reporting results.
8 * Expects a list of executables located in the given file, one line per
9 * executable. For each one, runs it as part of a test suite, reporting
10 * results. Test output should start with a line containing the number of
11 * tests (numbered from 1 to this number), optionally preceded by "1..",
12 * although that line may be given anywhere in the output. Each additional
13 * line should be in the following format:
18 * not ok <number> # todo
20 * where <number> is the number of the test. An optional comment is permitted
21 * after the number if preceded by whitespace. ok indicates success, not ok
22 * indicates failure. "# skip" and "# todo" are a special cases of a comment,
23 * and must start with exactly that formatting. They indicate the test was
24 * skipped for some reason (maybe because it doesn't apply to this platform)
25 * or is testing something known to currently fail. The text following either
26 * "# skip" or "# todo" and whitespace is the reason.
28 * As a special case, the first line of the output may be in the form:
30 * 1..0 # skip some reason
32 * which indicates that this entire test case should be skipped and gives a
35 * Any other lines are ignored, although for compliance with the TAP protocol
36 * all lines other than the ones in the above format should be sent to
37 * standard error rather than standard output and start with #.
39 * This is a subset of TAP as documented in Test::Harness::TAP or
40 * TAP::Parser::Grammar, which comes with Perl.
42 * Any bug reports, bug fixes, and improvements are very much welcome and
43 * should be sent to the e-mail address below.
45 * Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010
46 * Russ Allbery <rra@stanford.edu>
48 * Permission is hereby granted, free of charge, to any person obtaining a
49 * copy of this software and associated documentation files (the "Software"),
50 * to deal in the Software without restriction, including without limitation
51 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
52 * and/or sell copies of the Software, and to permit persons to whom the
53 * Software is furnished to do so, subject to the following conditions:
55 * The above copyright notice and this permission notice shall be included in
56 * all copies or substantial portions of the Software.
58 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
61 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
63 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
64 * DEALINGS IN THE SOFTWARE.
76 #include <sys/types.h>
81 /* sys/time.h must be included before sys/resource.h on some platforms. */
82 #include <sys/resource.h>
84 /* AIX doesn't have WCOREDUMP. */
86 # define WCOREDUMP(status) ((unsigned)(status) & 0x80)
90 * The source and build versions of the tests directory. This is used to set
91 * the SOURCE and BUILD environment variables and find test programs, if set.
92 * Normally, this should be set as part of the build process to the test
93 * subdirectories of $(abs_top_srcdir) and $(abs_top_builddir) respectively.
102 /* Test status codes. */
110 /* Indicates the state of our plan. */
112 PLAN_INIT, /* Nothing seen yet. */
113 PLAN_FIRST, /* Plan seen before any tests. */
114 PLAN_PENDING, /* Test seen and no plan yet. */
115 PLAN_FINAL /* Plan seen after some tests. */
118 /* Error exit statuses for test processes. */
119 #define CHILDERR_DUP 100 /* Couldn't redirect stderr or stdout. */
120 #define CHILDERR_EXEC 101 /* Couldn't exec child process. */
121 #define CHILDERR_STDERR 102 /* Couldn't open stderr file. */
123 /* Structure to hold data for a set of tests. */
125 char *file; /* The file name of the test. */
126 char *path; /* The path to the test program. */
127 enum plan_status plan; /* The status of our plan. */
128 unsigned long count; /* Expected count of tests. */
129 unsigned long current; /* The last seen test number. */
130 unsigned int length; /* The length of the last status message. */
131 unsigned long passed; /* Count of passing tests. */
132 unsigned long failed; /* Count of failing lists. */
133 unsigned long skipped; /* Count of skipped tests (passed). */
134 unsigned long allocated; /* The size of the results table. */
135 enum test_status *results; /* Table of results by test number. */
136 int aborted; /* Whether the set as aborted. */
137 int reported; /* Whether the results were reported. */
138 int status; /* The exit status of the test. */
139 int all_skipped; /* Whether all tests were skipped. */
140 char *reason; /* Why all tests were skipped. */
143 /* Structure to hold a linked list of test sets. */
146 struct testlist *next;
150 * Header used for test output. %s is replaced by the file name of the list
153 static const char banner[] = "\n\
154 Running all tests listed in %s. If any tests fail, run the failing\n\
155 test program with runtests -o to see more details.\n\n";
157 /* Header for reports of failed tests. */
158 static const char header[] = "\n\
159 Failed Set Fail/Total (%) Skip Stat Failing Tests\n\
160 -------------------------- -------------- ---- ---- ------------------------";
162 /* Include the file name and line number in malloc failures. */
163 #define xmalloc(size) x_malloc((size), __FILE__, __LINE__)
164 #define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__)
165 #define xstrdup(p) x_strdup((p), __FILE__, __LINE__)
169 * Report a fatal error, including the results of strerror, and exit.
172 sysdie(const char *format, ...)
179 fprintf(stderr, "runtests: ");
180 va_start(args, format);
181 vfprintf(stderr, format, args);
183 fprintf(stderr, ": %s\n", strerror(oerrno));
189 * Allocate memory, reporting a fatal error and exiting on failure.
192 x_malloc(size_t size, const char *file, int line)
198 sysdie("failed to malloc %lu bytes at %s line %d",
199 (unsigned long) size, file, line);
205 * Reallocate memory, reporting a fatal error and exiting on failure.
208 x_realloc(void *p, size_t size, const char *file, int line)
210 p = realloc(p, size);
212 sysdie("failed to realloc %lu bytes at %s line %d",
213 (unsigned long) size, file, line);
219 * Copy a string, reporting a fatal error and exiting on failure.
222 x_strdup(const char *s, const char *file, int line)
230 sysdie("failed to strdup %lu bytes at %s line %d",
231 (unsigned long) len, file, line);
238 * Given a struct timeval, return the number of seconds it represents as a
239 * double. Use difftime() to convert a time_t to a double.
242 tv_seconds(const struct timeval *tv)
244 return difftime(tv->tv_sec, 0) + tv->tv_usec * 1e-6;
249 * Given two struct timevals, return the difference in seconds.
252 tv_diff(const struct timeval *tv1, const struct timeval *tv0)
254 return tv_seconds(tv1) - tv_seconds(tv0);
259 * Given two struct timevals, return the sum in seconds as a double.
262 tv_sum(const struct timeval *tv1, const struct timeval *tv2)
264 return tv_seconds(tv1) + tv_seconds(tv2);
269 * Given a pointer to a string, skip any leading whitespace and return a
270 * pointer to the first non-whitespace character.
273 skip_whitespace(const char *p)
275 while (isspace((unsigned char)(*p)))
282 * Start a program, connecting its stdout to a pipe on our end and its stderr
283 * to /dev/null, and storing the file descriptor to read from in the two
284 * argument. Returns the PID of the new process. Errors are fatal.
287 test_start(const char *path, int *fd)
292 if (pipe(fds) == -1) {
295 sysdie("can't create pipe");
298 if (child == (pid_t) -1) {
301 sysdie("can't fork");
302 } else if (child == 0) {
303 /* In child. Set up our stdout and stderr. */
304 errfd = open("/dev/null", O_WRONLY);
306 _exit(CHILDERR_STDERR);
307 if (dup2(errfd, 2) == -1)
310 if (dup2(fds[1], 1) == -1)
313 /* Now, exec our process. */
314 if (execl(path, path, (char *) 0) == -1)
315 _exit(CHILDERR_EXEC);
317 /* In parent. Close the extra file descriptor. */
326 * Back up over the output saying what test we were executing.
329 test_backspace(struct testset *ts)
333 if (!isatty(STDOUT_FILENO))
335 for (i = 0; i < ts->length; i++)
337 for (i = 0; i < ts->length; i++)
339 for (i = 0; i < ts->length; i++)
346 * Read the plan line of test output, which should contain the range of test
347 * numbers. We may initialize the testset structure here if we haven't yet
348 * seen a test. Return true if initialization succeeded and the test should
349 * continue, false otherwise.
352 test_plan(const char *line, struct testset *ts)
358 * Accept a plan without the leading 1.. for compatibility with older
359 * versions of runtests. This will only be allowed if we've not yet seen
362 line = skip_whitespace(line);
363 if (strncmp(line, "1..", 3) == 0)
367 * Get the count, check it for validity, and initialize the struct. If we
368 * have something of the form "1..0 # skip foo", the whole file was
369 * skipped; record that. If we do skip the whole file, zero out all of
370 * our statistics, since they're no longer relevant.
372 n = strtol(line, (char **) &line, 10);
374 line = skip_whitespace(line);
376 line = skip_whitespace(line + 1);
377 if (strncasecmp(line, "skip", 4) == 0) {
378 line = skip_whitespace(line + 4);
380 ts->reason = xstrdup(line);
381 ts->reason[strlen(ts->reason) - 1] = '\0';
394 puts("ABORTED (invalid test count)");
399 if (ts->plan == PLAN_INIT && ts->allocated == 0) {
402 ts->plan = PLAN_FIRST;
403 ts->results = xmalloc(ts->count * sizeof(enum test_status));
404 for (i = 0; i < ts->count; i++)
405 ts->results[i] = TEST_INVALID;
406 } else if (ts->plan == PLAN_PENDING) {
407 if ((unsigned long) n < ts->count) {
408 printf("ABORTED (invalid test number %lu)\n", ts->count);
414 if ((unsigned long) n > ts->allocated) {
415 ts->results = xrealloc(ts->results, n * sizeof(enum test_status));
416 for (i = ts->allocated; i < ts->count; i++)
417 ts->results[i] = TEST_INVALID;
420 ts->plan = PLAN_FINAL;
427 * Given a single line of output from a test, parse it and return the success
428 * status of that test. Anything printed to stdout not matching the form
429 * /^(not )?ok \d+/ is ignored. Sets ts->current to the test number that just
433 test_checkline(const char *line, struct testset *ts)
435 enum test_status status = TEST_PASS;
439 unsigned long i, current;
441 /* Before anything, check for a test abort. */
442 bail = strstr(line, "Bail out!");
444 bail = skip_whitespace(bail + strlen("Bail out!"));
448 length = strlen(bail);
449 if (bail[length - 1] == '\n')
452 printf("ABORTED (%.*s)\n", (int)length, bail);
460 * If the given line isn't newline-terminated, it was too big for an
461 * fgets(), which means ignore it.
463 if (line[strlen(line) - 1] != '\n')
466 /* If the line begins with a hash mark, ignore it. */
470 /* If we haven't yet seen a plan, look for one. */
471 if (ts->plan == PLAN_INIT && isdigit((unsigned char)(*line))) {
472 if (!test_plan(line, ts))
474 } else if (strncmp(line, "1..", 3) == 0) {
475 if (ts->plan == PLAN_PENDING) {
476 if (!test_plan(line, ts))
479 puts("ABORTED (multiple plans)");
486 /* Parse the line, ignoring something we can't parse. */
487 if (strncmp(line, "not ", 4) == 0) {
491 if (strncmp(line, "ok", 2) != 0)
493 line = skip_whitespace(line + 2);
495 number = strtol(line, &end, 10);
496 if (errno != 0 || end == line)
497 number = ts->current + 1;
499 if (number <= 0 || (current > ts->count && ts->plan == PLAN_FIRST)) {
501 printf("ABORTED (invalid test number %lu)\n", current);
507 /* We have a valid test result. Tweak the results array if needed. */
508 if (ts->plan == PLAN_INIT || ts->plan == PLAN_PENDING) {
509 ts->plan = PLAN_PENDING;
510 if (current > ts->count)
512 if (current > ts->allocated) {
515 n = (ts->allocated == 0) ? 32 : ts->allocated * 2;
518 ts->results = xrealloc(ts->results, n * sizeof(enum test_status));
519 for (i = ts->allocated; i < n; i++)
520 ts->results[i] = TEST_INVALID;
526 * Handle directives. We should probably do something more interesting
527 * with unexpected passes of todo tests.
529 while (isdigit((unsigned char)(*line)))
531 line = skip_whitespace(line);
533 line = skip_whitespace(line + 1);
534 if (strncasecmp(line, "skip", 4) == 0)
536 if (strncasecmp(line, "todo", 4) == 0)
537 status = (status == TEST_FAIL) ? TEST_SKIP : TEST_FAIL;
540 /* Make sure that the test number is in range and not a duplicate. */
541 if (ts->results[current - 1] != TEST_INVALID) {
543 printf("ABORTED (duplicate test number %lu)\n", current);
549 /* Good results. Increment our various counters. */
551 case TEST_PASS: ts->passed++; break;
552 case TEST_FAIL: ts->failed++; break;
553 case TEST_SKIP: ts->skipped++; break;
556 ts->current = current;
557 ts->results[current - 1] = status;
559 if (isatty(STDOUT_FILENO)) {
560 ts->length = printf("%lu/%lu", current, ts->count);
567 * Print out a range of test numbers, returning the number of characters it
568 * took up. Add a comma and a space before the range if chars indicates that
569 * something has already been printed on the line, and print ... instead if
570 * chars plus the space needed would go over the limit (use a limit of 0 to
574 test_print_range(unsigned long first, unsigned long last, unsigned int chars,
577 unsigned int needed = 0;
578 unsigned int out = 0;
583 if (!limit || chars <= limit) out += printf(", ");
585 for (n = first; n > 0; n /= 10)
588 for (n = last; n > 0; n /= 10)
592 if (limit && chars + needed > limit) {
594 out += printf("...");
597 out += printf("%lu-", first);
598 out += printf("%lu", last);
605 * Summarize a single test set. The second argument is 0 if the set exited
606 * cleanly, a positive integer representing the exit status if it exited
607 * with a non-zero status, and a negative integer representing the signal
608 * that terminated it if it was killed by a signal.
611 test_summarize(struct testset *ts, int status)
614 unsigned long missing = 0;
615 unsigned long failed = 0;
616 unsigned long first = 0;
617 unsigned long last = 0;
620 fputs("ABORTED", stdout);
622 printf(" (passed %lu/%lu)", ts->passed, ts->count - ts->skipped);
624 for (i = 0; i < ts->count; i++) {
625 if (ts->results[i] == TEST_INVALID) {
627 fputs("MISSED ", stdout);
628 if (first && i == last)
632 test_print_range(first, last, missing - 1, 0);
640 test_print_range(first, last, missing - 1, 0);
643 for (i = 0; i < ts->count; i++) {
644 if (ts->results[i] == TEST_FAIL) {
645 if (missing && !failed)
648 fputs("FAILED ", stdout);
649 if (first && i == last)
653 test_print_range(first, last, failed - 1, 0);
661 test_print_range(first, last, failed - 1, 0);
662 if (!missing && !failed) {
663 fputs(!status ? "ok" : "dubious", stdout);
664 if (ts->skipped > 0) {
665 if (ts->skipped == 1)
666 printf(" (skipped %lu test)", ts->skipped);
668 printf(" (skipped %lu tests)", ts->skipped);
673 printf(" (exit status %d)", status);
675 printf(" (killed by signal %d%s)", -status,
676 WCOREDUMP(ts->status) ? ", core dumped" : "");
682 * Given a test set, analyze the results, classify the exit status, handle a
683 * few special error messages, and then pass it along to test_summarize() for
684 * the regular output. Returns true if the test set ran successfully and all
685 * tests passed or were skipped, false otherwise.
688 test_analyze(struct testset *ts)
692 if (ts->all_skipped) {
693 if (ts->reason == NULL)
696 printf("skipped (%s)\n", ts->reason);
698 } else if (WIFEXITED(ts->status) && WEXITSTATUS(ts->status) != 0) {
699 switch (WEXITSTATUS(ts->status)) {
702 puts("ABORTED (can't dup file descriptors)");
706 puts("ABORTED (execution failed -- not found?)");
708 case CHILDERR_STDERR:
710 puts("ABORTED (can't open /dev/null)");
713 test_summarize(ts, WEXITSTATUS(ts->status));
717 } else if (WIFSIGNALED(ts->status)) {
718 test_summarize(ts, -WTERMSIG(ts->status));
720 } else if (ts->plan != PLAN_FIRST && ts->plan != PLAN_FINAL) {
721 puts("ABORTED (no valid test plan)");
725 test_summarize(ts, 0);
726 return (ts->failed == 0);
732 * Runs a single test set, accumulating and then reporting the results.
733 * Returns true if the test set was successfully run and all tests passed,
737 test_run(struct testset *ts)
739 pid_t testpid, child;
745 /* Run the test program. */
746 testpid = test_start(ts->path, &outfd);
747 output = fdopen(outfd, "r");
751 sysdie("fdopen failed");
754 /* Pass each line of output to test_checkline(). */
755 while (!ts->aborted && fgets(buffer, sizeof(buffer), output))
756 test_checkline(buffer, ts);
757 if (ferror(output) || ts->plan == PLAN_INIT)
762 * Consume the rest of the test output, close the output descriptor,
763 * retrieve the exit status, and pass that information to test_analyze()
764 * for eventual output.
766 while (fgets(buffer, sizeof(buffer), output))
769 child = waitpid(testpid, &ts->status, 0);
770 if (child == (pid_t) -1) {
775 sysdie("waitpid for %u failed", (unsigned int) testpid);
779 status = test_analyze(ts);
781 /* Convert missing tests to failed tests. */
782 for (i = 0; i < ts->count; i++) {
783 if (ts->results[i] == TEST_INVALID) {
785 ts->results[i] = TEST_FAIL;
793 /* Summarize a list of test failures. */
795 test_fail_summary(const struct testlist *fails)
799 unsigned long i, first, last, total;
803 /* Failed Set Fail/Total (%) Skip Stat Failing (25)
804 -------------------------- -------------- ---- ---- -------------- */
805 for (; fails; fails = fails->next) {
807 total = ts->count - ts->skipped;
808 printf("%-26.26s %4lu/%-4lu %3.0f%% %4lu ", ts->file, ts->failed,
809 total, total ? (ts->failed * 100.0) / total : 0,
811 if (WIFEXITED(ts->status))
812 printf("%4d ", WEXITSTATUS(ts->status));
822 for (i = 0; i < ts->count; i++) {
823 if (ts->results[i] == TEST_FAIL) {
824 if (first != 0 && i == last)
828 chars += test_print_range(first, last, chars, 20);
835 test_print_range(first, last, chars, 20);
840 if (ts->reason != NULL)
848 * Given the name of a test, a pointer to the testset struct, and the source
849 * and build directories, find the test. We try first relative to the current
850 * directory, then in the build directory (if not NULL), then in the source
851 * directory. In each of those directories, we first try a "-t" extension and
852 * then a ".t" extension. When we find an executable program, we fill in the
853 * path member of the testset struct. If none of those paths are executable,
854 * just fill in the name of the test with "-t" appended.
856 * The caller is responsible for freeing the path member of the testset
860 find_test(const char *name, struct testset *ts, const char *source,
864 const char *bases[] = { ".", build, source, NULL };
867 for (i = 0; bases[i] != NULL; i++) {
868 path = xmalloc(strlen(bases[i]) + strlen(name) + 4);
869 sprintf(path, "%s/%s-t", bases[i], name);
870 if (access(path, X_OK) != 0)
871 path[strlen(path) - 2] = '.';
872 if (access(path, X_OK) == 0)
878 path = xmalloc(strlen(name) + 3);
879 sprintf(path, "%s-t", name);
886 * Run a batch of tests from a given file listing each test on a line by
887 * itself. Takes two additional parameters: the root of the source directory
888 * and the root of the build directory. Test programs will be first searched
889 * for in the current directory, then the build directory, then the source
890 * directory. The file must be rewindable. Returns true iff all tests
894 test_batch(const char *testlist, const char *source, const char *build)
897 unsigned int length, i;
898 unsigned int longest = 0;
901 struct testset ts, *tmp;
902 struct timeval start, end;
904 struct testlist *failhead = NULL;
905 struct testlist *failtail = NULL;
906 struct testlist *next;
907 unsigned long total = 0;
908 unsigned long passed = 0;
909 unsigned long skipped = 0;
910 unsigned long failed = 0;
911 unsigned long aborted = 0;
914 * Open our file of tests to run and scan it, checking for lines that
915 * are too long and searching for the longest line.
917 tests = fopen(testlist, "r");
919 sysdie("can't open %s", testlist);
921 while (fgets(buffer, sizeof(buffer), tests)) {
923 length = strlen(buffer) - 1;
924 if (buffer[length] != '\n') {
925 fprintf(stderr, "%s:%u: line too long\n", testlist, line);
928 if (length > longest)
931 if (fseek(tests, 0, SEEK_SET) == -1)
932 sysdie("can't rewind %s", testlist);
935 * Add two to longest and round up to the nearest tab stop. This is how
936 * wide the column for printing the current test name will be.
940 longest += 8 - (longest % 8);
942 /* Start the wall clock timer. */
943 gettimeofday(&start, NULL);
946 * Now, plow through our tests again, running each one. Check line
947 * length again out of paranoia.
950 while (fgets(buffer, sizeof(buffer), tests)) {
952 length = strlen(buffer) - 1;
953 if (buffer[length] != '\n') {
954 fprintf(stderr, "%s:%u: line too long\n", testlist, line);
957 buffer[length] = '\0';
958 fputs(buffer, stdout);
959 for (i = length; i < longest; i++)
961 if (isatty(STDOUT_FILENO))
963 memset(&ts, 0, sizeof(ts));
965 ts.file = xstrdup(buffer);
966 find_test(buffer, &ts, source, build);
972 if (ts.reason != NULL)
975 tmp = xmalloc(sizeof(struct testset));
976 memcpy(tmp, &ts, sizeof(struct testset));
978 failhead = xmalloc(sizeof(struct testset));
980 failhead->next = NULL;
983 failtail->next = xmalloc(sizeof(struct testset));
984 failtail = failtail->next;
986 failtail->next = NULL;
989 aborted += ts.aborted;
990 total += ts.count + ts.all_skipped;
992 skipped += ts.skipped + ts.all_skipped;
997 /* Stop the timer and get our child resource statistics. */
998 gettimeofday(&end, NULL);
999 getrusage(RUSAGE_CHILDREN, &stats);
1001 /* Print out our final results. */
1002 if (failhead != NULL) {
1003 test_fail_summary(failhead);
1004 while (failhead != NULL) {
1005 next = failhead->next;
1013 printf("Aborted %lu test set", aborted);
1015 printf("Aborted %lu test sets", aborted);
1016 printf(", passed %lu/%lu tests", passed, total);
1018 else if (failed == 0)
1019 fputs("All tests successful", stdout);
1021 printf("Failed %lu/%lu tests, %.2f%% okay", failed, total,
1022 (total - failed) * 100.0 / total);
1025 printf(", %lu test skipped", skipped);
1027 printf(", %lu tests skipped", skipped);
1030 printf("Files=%u, Tests=%lu", line, total);
1031 printf(", %.2f seconds", tv_diff(&end, &start));
1032 printf(" (%.2f usr + %.2f sys = %.2f CPU)\n",
1033 tv_seconds(&stats.ru_utime), tv_seconds(&stats.ru_stime),
1034 tv_sum(&stats.ru_utime, &stats.ru_stime));
1035 return (failed == 0 && aborted == 0);
1040 * Run a single test case. This involves just running the test program after
1041 * having done the environment setup and finding the test program.
1044 test_single(const char *program, const char *source, const char *build)
1048 memset(&ts, 0, sizeof(ts));
1049 find_test(program, &ts, source, build);
1050 if (execl(ts.path, ts.path, (char *) 0) == -1)
1051 sysdie("cannot exec %s", ts.path);
1056 * Main routine. Set the SOURCE and BUILD environment variables and then,
1057 * given a file listing tests, run each test listed.
1060 main(int argc, char *argv[])
1066 const char *source = SOURCE;
1067 const char *build = BUILD;
1069 while ((option = getopt(argc, argv, "b:os:")) != EOF) {
1087 fprintf(stderr, "Usage: runtests <test-list>\n");
1091 if (source != NULL) {
1092 setting = xmalloc(strlen("SOURCE=") + strlen(source) + 1);
1093 sprintf(setting, "SOURCE=%s", source);
1094 if (putenv(setting) != 0)
1095 sysdie("cannot set SOURCE in the environment");
1097 if (build != NULL) {
1098 setting = xmalloc(strlen("BUILD=") + strlen(build) + 1);
1099 sprintf(setting, "BUILD=%s", build);
1100 if (putenv(setting) != 0)
1101 sysdie("cannot set BUILD in the environment");
1105 test_single(argv[0], source, build);
1108 list = strrchr(argv[0], '/');
1113 printf(banner, list);
1114 exit(test_batch(argv[0], source, build) ? 0 : 1);