echo "valgrind found memory in use at exit"; cat .tmp.valg ; exit 1 ; fi; \
echo " passed"; \
done
+ ## valgrind test code
@[ -n "$$SKIP_COVERAGE_CHECK" ] || awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
if (ran < (ran + skip) *0.968) exit(1) }' \
echo "passed"; \
./coverage_oceani $${1+"$$@"} > /dev/null 2>&1 ;\
done || true
+###### valgrind test code
+ @[ -n "$$SKIP_VALGRIND" ] || for t in $(oceani_special_tests); do\
+ echo -n "Valgrind $$t.. "; \
+ i="$$IFS"; IFS=,; set $$t; IFS="$$i"; shift ;\
+ if valgrind --error-exitcode=42 --log-file=.tmp.valg ./oceani $${1+"$$@"} > .tmp.have 2>&1 ;\
+ [ $$? -eq 42 ]; then \
+ echo "FAILED"; cat .tmp.valg; exit 1; fi ; \
+ if grep 'LEAK SUMMARY' .tmp.valg > /dev/null; then \
+ echo "valgrind found LEAKS"; cat .tmp.valg ; exit 1 ; fi; \
+ if grep 'in use at exit [1-9]' .tmp.valg > /dev/null; then \
+ echo "valgrind found memory in use at exit"; cat .tmp.valg ; exit 1 ; fi; \
+ echo " passed"; \
+ done
###### test list
oceani_special_tests += "cmd"
int fd;
int len;
char *file;
- struct section *s, *ss;
+ struct section *s = NULL, *ss;
char *section = NULL;
struct parse_context context = {
.config = {
if (!ss) {
fprintf(stderr, "oceani: cannot find section %s\n",
section);
- exit(1);
+ goto cleanup;
}
} else
ss = s; // NOTEST
if (!ss->code) {
fprintf(stderr, "oceani: no code found in requested section\n"); // NOTEST
- exit(1); // NOTEST
+ goto cleanup; // NOTEST
}
parse_oceani(ss->code, &context.config, dotrace ? stderr : NULL);
}
if (doexec && !context.parse_error)
interp_main(&context, argc - optind, argv + optind);
-
+ cleanup:
while (s) {
struct section *t = s->next;
code_free(s->code);