summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2018-04-22 19:23:00 -0700
committerRuss Allbery <eagle@eyrie.org>2018-04-22 19:32:47 -0700
commit1fb5ffe6cb47622c97630941a00ed0a828bee571 (patch)
tree2e18a44e275071c1f6ebd6ca939a9cd2c9a471f7 /tests
parentca1f45155f1cf60e31d0da2bf5f788c5e8448824 (diff)
Fix the check-valgrind target
Rework the check-valgrind target to use the new C TAP Harness valgrind support and automatically check the valgrind log files for errors at the end of the test suite. This catches the bad free that caused the security issue in 3.14.
Diffstat (limited to 'tests')
-rw-r--r--tests/TESTS104
-rwxr-xr-xtests/valgrind/logs-t74
2 files changed, 132 insertions, 46 deletions
diff --git a/tests/TESTS b/tests/TESTS
index 2da4dfa..41ff98e 100644
--- a/tests/TESTS
+++ b/tests/TESTS
@@ -1,55 +1,67 @@
-client/api
-client/ccache
-client/large
-client/open
+# Test list for remctl. -*- conf -*-
+#
+# Copyright 2006-2009, 2011-2016, 2018 Russ Allbery <eagle@eyrie.org>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without any warranty.
+#
+# SPDX-License-Identifier: FSFAP
+
+client/api valgrind libtool
+client/ccache valgrind libtool
+client/large valgrind libtool
+client/open valgrind libtool
client/remctl
-client/source-ip
-client/timeout
+client/source-ip valgrind libtool
+client/timeout valgrind libtool
docs/pod
docs/pod-spelling
perl/module-version
-portable/asprintf
-portable/daemon
-portable/getaddrinfo
-portable/getnameinfo
-portable/getopt
-portable/inet_aton
-portable/inet_ntoa
-portable/inet_ntop
-portable/mkstemp
+portable/asprintf valgrind
+portable/daemon valgrind
+portable/getaddrinfo valgrind
+portable/getnameinfo valgrind
+portable/getopt valgrind
+portable/inet_aton valgrind
+portable/inet_ntoa valgrind
+portable/inet_ntop valgrind
+portable/mkstemp valgrind
portable/setenv
-portable/snprintf
-server/accept
-server/acl
-server/acl/localgroup
-server/anonymous
-server/bind
-server/config
-server/continue
-server/empty
-server/env
-server/errors
-server/help
-server/invalid
-server/logging
+portable/snprintf valgrind
+server/accept valgrind
+server/acl valgrind
+server/acl/localgroup valgrind
+server/anonymous valgrind libtool
+server/bind valgrind libtool
+server/config valgrind
+server/continue valgrind libtool
+server/empty valgrind libtool
+server/env valgrind libtool
+server/errors valgrind libtool
+server/help valgrind libtool
+server/invalid valgrind libtool
+server/logging valgrind
server/misc
server/shell-misc
-server/ssh-parse
-server/stdin
-server/streaming
-server/sudo
-server/summary
+server/ssh-parse valgrind
+server/stdin valgrind libtool
+server/streaming valgrind libtool
+server/sudo valgrind
+server/summary valgrind libtool
server/user
-server/version
-util/buffer
-util/gss-tokens
-util/messages
-util/messages-krb5
-util/network/addr-ipv4
-util/network/addr-ipv6
-util/network/client
-util/network/server
-util/tokens
-util/vector
+server/version valgrind libtool
+util/buffer valgrind
+util/gss-tokens valgrind
+util/messages valgrind
+util/messages-krb5 valgrind
+util/network/addr-ipv4 valgrind
+util/network/addr-ipv6 valgrind
+util/network/client valgrind
+util/network/server valgrind
+util/tokens valgrind
+util/vector valgrind
util/xmalloc
-util/xwrite
+util/xwrite valgrind
+valgrind/logs
diff --git a/tests/valgrind/logs-t b/tests/valgrind/logs-t
new file mode 100755
index 0000000..addaeb0
--- /dev/null
+++ b/tests/valgrind/logs-t
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+#
+# Check for errors in valgrind logs.
+#
+# The canonical version of this file is maintained in the rra-c-util package,
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
+#
+# Copyright 2018 Russ Allbery <eagle@eyrie.org>
+#
+# 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.
+#
+# SPDX-License-Identifier: MIT
+
+use 5.006;
+use strict;
+use warnings;
+
+use lib "$ENV{C_TAP_SOURCE}/tap/perl";
+
+use File::Spec;
+use Test::More;
+use Test::RRA::Automake qw(automake_setup);
+
+# Skip this test if C_TAP_VALGRIND was not set.
+if (!exists $ENV{C_TAP_VALGRIND}) {
+ plan skip_all => 'Not testing under valgrind';
+}
+
+# Set up Automake testing.
+automake_setup({ chdir_build => 1 });
+
+# Gather the list of valgrind logs (and skip this test if there are none).
+opendir(my $logdir, File::Spec->catfile('tests', 'tmp', 'valgrind'))
+ or plan skip_all => 'No valgrind logs in tests/tmp/valgrind';
+my @logs = grep { m{ \A log [.] }xms } readdir $logdir;
+closedir($logdir) or BAIL_OUT("cannot close directory: $!");
+
+# Check each log file.
+plan tests => scalar(@logs);
+for my $file (@logs) {
+ my $path = File::Spec->catfile('tests', 'tmp', 'valgrind', $file);
+ open(my $log, '<', $path) or BAIL_OUT("cannot open $path: $!");
+ my $okay = 1;
+ while (defined(my $line = <$log>)) {
+ if ($line =~ m{ ERROR [ ] SUMMARY: [ ] (\d+) [ ] errors }xms) {
+ $okay = ($1 == 0);
+ }
+ }
+ close($log) or BAIL_OUT("cannot close $path: $!");
+ ok($okay, $path);
+ if ($okay) {
+ unlink($path);
+ }
+}
+
+# Remove tests/tmp/valgrind if it's now empty.
+rmdir(File::Spec->catfile('tests', 'tmp', 'valgrind'));
+rmdir(File::Spec->catfile('tests', 'tmp'));