| 1 | #!/bin/bash |
| 2 | # test if there is much memory leaking. |
| 3 | set -ex |
| 4 | |
| 5 | TESTDIR=$(mktemp -d ) |
| 6 | TESTCODE=$(readlink -f tests/016_memleakcheck.c) |
| 7 | COW_SHELL=$(readlink -f cow-shell) |
| 8 | gcc ${TESTCODE} -o ${TESTDIR}/tracer -g |
| 9 | |
| 10 | ( |
| 11 | set -ex |
| 12 | cd ${TESTDIR} |
| 13 | mkdir 1/ |
| 14 | # make a few files for testing. |
| 15 | touch 1/a 1/b 1/c 1/d |
| 16 | dd if=/dev/zero of=1/e bs=512 count=2 |
| 17 | |
| 18 | cp -al 1 2 |
| 19 | |
| 20 | # undefine LD_PRELOAD because it seems like loading cowdancer lib twice is causing memory leak? |
| 21 | LD_PRELOAD= MALLOC_TRACE="log" ${COW_SHELL} ${TESTDIR}/tracer |
| 22 | ) |
| 23 | RESULT=$? |
| 24 | |
| 25 | mtrace ${TESTDIR}/tracer ${TESTDIR}/log |
| 26 | rm -rf ${TESTDIR} |
| 27 | |
| 28 | exit $RESULT |
| 29 |