2 * Copyright (c) 2011 Alex Hornung <alex@alexhornung.com>.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/resource.h>
32 #include <sys/types.h>
45 #include <libprop/proplib.h>
50 #include <dfregress.h>
52 static int count_by_result[10];
59 for (i = 0; i < 80; i++)
69 i = printf("Test case");
70 for (j = 60 - i; j > 0; j--)
77 static char *get_arg_string(prop_dictionary_t testcase)
79 static char buf[2048];
85 argv = testcase_get_args(testcase);
87 /* Skip the first argument, since it's just the test's name */
88 for (i = 1; argv[i] != NULL; i++) {
90 if (argv[i+1] != NULL)
94 return (i > 1) ? buf : NULL;
98 print_summary(prop_array_t runlist)
103 total_tests = 0.0 + prop_array_count(runlist);
104 total_run = 0.0 + total_tests - count_by_result[RESULT_BUILDFAIL] -
105 count_by_result[RESULT_PREFAIL] - count_by_result[RESULT_NOTRUN] -
106 count_by_result[RESULT_UNKNOWN];
110 printf("Summary:\n\n");
113 printf("Tests not built:\t%d\n", count_by_result[RESULT_BUILDFAIL]);
115 printf("Tests not run:\t\t%.0f\n", total_tests - total_run);
117 printf("Tests pre-failed:\t%d\n", count_by_result[RESULT_PREFAIL]);
119 printf("Tests post-failed:\t%d\n", count_by_result[RESULT_POSTFAIL]);
121 printf("Tests passed:\t\t%d\n", count_by_result[RESULT_PASS]);
123 printf("Tests failed:\t\t%d\n", count_by_result[RESULT_FAIL]);
125 printf("Tests crashed:\t\t%d\n", count_by_result[RESULT_SIGNALLED]);
127 printf("Tests timed out:\t%d\n", count_by_result[RESULT_TIMEOUT]);
132 printf("Run rate:\t\t%.2f\n", total_run/total_tests);
133 printf("Pass rate:\t\t%.2f\n", count_by_result[RESULT_PASS]/total_run);
137 runlist_parse_summary(void *arg __unused, prop_dictionary_t testcase)
142 ++count_by_result[testcase_get_result(testcase)];
143 args = get_arg_string(testcase);
145 i = printf("%s", testcase_get_name(testcase));
147 i+= printf(" (%s)", args);
149 for (j = 60 - i; j > 0; j--)
152 printf("%s\n", testcase_get_result_desc(testcase));
158 runlist_parse_detail(void *arg __unused, prop_dictionary_t testcase)
162 args = get_arg_string(testcase);
167 printf("Test: %s\n", testcase_get_name(testcase));
169 printf("Command line arguments: %s\n", args);
171 printf("Type: %s\n", testcase_get_type_desc(testcase));
172 printf("Result: %s\n", testcase_get_result_desc(testcase));
174 switch (testcase_get_result(testcase)) {
176 printf("Exit code: %d\n", testcase_get_exit_value(testcase));
179 case RESULT_SIGNALLED:
180 printf("Signal: %d\n", testcase_get_signal(testcase));
185 printf("driver sysbuf:\n%s\n", testcase_get_sys_buf(testcase));
187 printf("build log:\n%s\n", testcase_get_build_buf(testcase));
189 printf("'pre' log:\n%s\n", testcase_get_precmd_buf(testcase));
191 printf("testcase stdout:\n%s\n", testcase_get_stdout_buf(testcase));
193 printf("testcase stderr:\n%s\n", testcase_get_stderr_buf(testcase));
195 printf("'post' log:\n%s\n", testcase_get_postcmd_buf(testcase));
197 printf("cleanup log:\n%s\n", testcase_get_cleanup_buf(testcase));
203 main(int argc, char *argv[])
206 fprintf(stderr, "Usage: dfr2text <foo.plist>\n");
210 prop_array_t runlist = runlist_load(argv[1]);
212 memset(count_by_result, 0, sizeof(count_by_result));
214 runlist_iterate(runlist, runlist_parse_summary, runlist);
215 print_summary(runlist);
216 printf("\n\nDETAILED RESULTS:\n");
218 runlist_iterate(runlist, runlist_parse_detail, runlist);