Skip to content
Snippets Groups Projects
Commit 9fab4635 authored by Simon McVittie's avatar Simon McVittie
Browse files

Add a script to wrap tests with valgrind


This should make it easier to find memory leaks in future.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 646d2a4b
No related branches found
No related tags found
1 merge request!8Add a script to wrap tests with valgrind
#!/bin/sh
# Copyright © 2019 Collabora Ltd.
#
# SPDX-License-Identifier: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Usage:
# meson test -C builddir -v --wrap=$(pwd)/tests/valgrind.sh
# or build with DEB_BUILD_OPTIONS=nostrip and use:
# $(pwd)/tests/valgrind.sh /usr/libexec/installed-tests/steam-runtime-tools-0/test-architecture
#
# Optionally run with these environment variables:
# VALGRIND_FATAL: if non-empty, valgrind errors cause tests to fail
# VALGRIND_OPTIONS: add more options to the valgrind command-line
# VALGRIND_VERBOSE: if non-empty, make valgrind more verbose
here="$(dirname "$0")"
export G_DEBUG="gc-friendly${G_DEBUG+",${G_DEBUG}"}"
export G_SLICE=always-malloc
exec valgrind \
${VALGRIND_FATAL:+--error-exitcode=1} \
--gen-suppressions=all \
--leak-check=full \
--num-callers=20 \
--show-reachable=yes \
--suppressions="${here}/valgrind.supp" \
--trace-children=yes \
${VALGRIND_VERBOSE:+--verbose} \
${VALGRIND_OPTIONS:+${VALGRIND_OPTIONS}} \
-- \
"$@"
# libsteam-runtime-tools itself
{
libsrt deliberate one-per-process leak
Memcheck:Leak
...
fun:g_build_filename
fun:_srt_get_helpers_path
}
# Dependencies
{
GTest
Memcheck:Leak
...
fun:g_test_add_vtable
}
{
GLib logging
Memcheck:Leak
...
fun:g_private_get
...
fun:g_logv
fun:g_log
}
{
GTest RNG
Memcheck:Leak
...
fun:g_rand_new_with_seed_array
obj:*/libglib-2.0.so.0*
obj:*/libglib-2.0.so.0*
fun:g_test_run_suite
}
{
GLib character set for printing
Memcheck:Leak
...
fun:g_get_charset
fun:g_print
}
{
GLib logging mutex
Memcheck:Leak
...
fun:g_mutex_lock
fun:g_log_set_always_fatal
fun:g_test_init
}
{
GLib test initialization
Memcheck:Leak
...
fun:g_test_init
}
{
GLib constructors
Memcheck:Leak
...
obj:*/libglib-2.0.so.0*
...
fun:_dl_init
}
{
GLib interned strings are allocated and never freed
Memcheck:Leak
...
fun:g_intern_static_string
}
{
GLib quarks are basically interned strings
Memcheck:Leak
...
fun:g_quark_from_string
}
{
GObject type classes are allocated and never freed
Memcheck:Leak
...
fun:g_type_class_ref
}
{
GObject static type structures are allocated and never freed
Memcheck:Leak
...
fun:g_type_register_static
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment