From 70606ded9df78ad55aec37da051316a514dffe02 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 7 Mar 2012 14:45:38 +1100 Subject: [PATCH] make into a proper regress test --- regress/Makefile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ regress/README | 4 ---- regress/leaky.c | 12 +++++----- 3 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 regress/Makefile delete mode 100644 regress/README diff --git a/regress/Makefile b/regress/Makefile new file mode 100644 index 0000000..491715c --- /dev/null +++ b/regress/Makefile @@ -0,0 +1,57 @@ +# $OpenBSD$ + +.include +.include + +CDIAGFLAGS= -Wall +CDIAGFLAGS+= -Werror +CDIAGFLAGS+= -Wpointer-arith +CDIAGFLAGS+= -Wstrict-prototypes +CDIAGFLAGS+= -Wmissing-prototypes +CDIAGFLAGS+= -Wunused +CDIAGFLAGS+= -Wsign-compare +CDIAGFLAGS+= -Wshadow +CDIAGFLAGS+= -Wformat +.if (${CC:L} == "gcc" || ${CC:L} == "cc") +CDIAGFLAGS+= -Wbounded +.endif +DEBUG=-g +COPTS=-O0 + +CPPFLAGS+=-I${.CURDIR}/../leakmalloc + +.if exists(${.CURDIR}/../leakmalloc/${__objdir}) +LDADD+=-L${.CURDIR}/../leakmalloc/${__objdir} -lleakmalloc +DPADD+=${.CURDIR}/../leakmalloc/${__objdir}/libleakmalloc.a +.else +LDADD+=-L${.CURDIR}/../leakmalloc -lleakmalloc +DPADD+=${.CURDIR}/../leakmalloc/libleakmalloc.a +.endif + +LDFLAGS+=-L/usr/local/lib +LDADD+=-lexecinfo + +PROG=leaky +SRCS=leaky.c +REGRESS_TARGETS=does-leak outfile exit-leak summary + +does-leak: ${PROG} + ./${PROG} | grep -q "^LEAK " + +outfile: ${PROG} + rm -f leakmalloc.out + env LEAKMALLOC_OPTIONS=D ./${PROG} + grep -q "^LEAK " leakmalloc.out + +exit-leak: ${PROG} + sh -c 'export LEAKMALLOC_OPTIONS=XQ ; ./${PROG} ; test $$? -eq 99' + +summary: ${PROG} + test `./${PROG} | ${.CURDIR}/../leakresolve.py -p ${PROG} | \ + grep "^Total:" | cut -d' ' -f 2` -eq 22 + +clean: + rm ${PROG} *.o *.core leakmalloc.out + +.include + diff --git a/regress/README b/regress/README deleted file mode 100644 index ae4934c..0000000 --- a/regress/README +++ /dev/null @@ -1,4 +0,0 @@ -Here's how you do it: - -gcc -Wall -O0 -ggdb3 -I.. -c leaky.c && gcc -ggdb3 -Wall -I.. -c leaky.c && gcc -L ../obj -L /usr/local/lib leaky.o -lleakmalloc -lexecinfo -./a.out | ../leakresolve.py -p a.out diff --git a/regress/leaky.c b/regress/leaky.c index 02474ab..9f37797 100644 --- a/regress/leaky.c +++ b/regress/leaky.c @@ -5,21 +5,21 @@ static void *a, *b, *c, *d, *e, *f; -void +static void f6(void) { d = strdup("hello"); e = malloc(789); } -void +static void f5(void) { c = calloc(1, 678); f6(); } -void +static void f4(void) { b = malloc(456); @@ -27,21 +27,21 @@ f4(void) free(e); } -void +static void f3(void) { a = malloc(123); f = realloc(NULL, 321); } -void +static void f2(void) { f4(); b = realloc(b, 567); } -void +static void f1(void) { int i;