- list_head_init(list);
-
- list_for_each(&m->run_tests, i, list) {
- run_tests_vg.total_score++;
- cmdout = run_command(m, timeleft,
- "valgrind -q --error-exitcode=100 %s",
- i->compiled);
- if (cmdout) {
- res = talloc(list, struct run_tests_result);
- res->file = i;
- res->output = talloc_steal(res, cmdout);
- list_add_tail(list, &res->list);
+static char *get_leaks(const char *output, char **errs)
+{
+ char *leaks = talloc_strdup(output, "");
+ unsigned int i, num;
+ char **lines = strsplit(output, output, "\n", &num);
+
+ *errs = talloc_strdup(output, "");
+ for (i = 0; i < num; i++) {
+ if (strstr(lines[i], " lost ")) {
+ /* A leak... */
+ if (strstr(lines[i], " definitely lost ")) {
+ /* Definite leak, report. */
+ while (lines[i] && !blank_line(lines[i])) {
+ leaks = talloc_append_string(leaks,
+ lines[i]);
+ leaks = talloc_append_string(leaks,
+ "\n");
+ i++;
+ }
+ } else
+ /* Not definite, ignore. */
+ while (lines[i] && !blank_line(lines[i]))
+ i++;
+ } else {
+ /* A real error. */
+ while (lines[i] && !blank_line(lines[i])) {
+ *errs = talloc_append_string(*errs, lines[i]);
+ *errs = talloc_append_string(*errs, "\n");
+ i++;
+ }