test: new memleak test using valgrind

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-05-28 16:28:00 +02:00
parent 0892914581
commit 47a980728a
3 changed files with 41 additions and 3 deletions

View File

@ -1,6 +1,6 @@
EXTRA_DIST = lib.sh opts.sh
EXTRA_DIST += api.sh local.sh unicode.sh remote.sh fwd.sh mark.sh \
facility.sh notify.sh rotate_all.sh secure.sh
memleak.sh facility.sh notify.sh rotate_all.sh secure.sh
CLEANFILES = *~ *.trs *.log
TEST_EXTENSIONS = .sh
TESTS_ENVIRONMENT= unshare -mrun
@ -18,6 +18,7 @@ TESTS += remote.sh
TESTS += api.sh
TESTS += facility.sh
TESTS += fwd.sh
TESTS += memleak.sh
TESTS += mark.sh
TESTS += notify.sh
TESTS += rotate_all.sh

View File

@ -122,14 +122,20 @@ do_setup()
ip link set lo up
print "Starting $order syslogd ..."
../src/syslogd -dKF ${opts} &
if [ -z "$VALGRIND" ]; then
../src/syslogd -dKF ${opts} &
else
${VALGRIND} ../src/syslogd -KF ${opts} &
fi
sleep 2
[ -f "${pidfn}" ] || FAIL "Failed starting $order syslogd"
cat "${pidfn}" >> "$DIR/PIDs"
# Enable debugging ...
kill -USR1 $(cat "${pidfn}")
if [ -z "$VALGRIND" ]; then
kill -USR1 $(cat "${pidfn}")
fi
sleep 1
}

31
test/memleak.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
# Start, SIGHUP, and log a run of syslogd under Valgrind
# shellcheck disable=SC1090
set -x
if [ x"${srcdir}" = x ]; then
srcdir=.
fi
# shellcheck disable=SC2034
VALGRIND="valgrind --leak-check=full --show-leak-kinds=all"
. ${srcdir}/lib.sh
# Only needed for verifying correct RFC3164 parsing
cat <<-EOF >"${CONFD}/99-wall.conf"
*.=emerg *
EOF
setup
print "TEST: Starting"
#../src/logger -u "${SOCK}" ${MSG}
# Wait for any OS delays
#sleep 1
reload
sleep 1
OK