6 use Test::More tests => 4;
8 use Test::Valgrind::Command;
9 use Test::Valgrind::Tool;
10 use Test::Valgrind::Session;
13 use Test::Valgrind::FakeValgrind;
15 my $cmd = Test::Valgrind::Command->new(
21 package Test::Valgrind::Parser::Dummy;
23 use base 'Test::Valgrind::Parser';
29 package Test::Valgrind::Tool::Dummy;
31 use base 'Test::Valgrind::Tool::memcheck';
33 sub parser_class { 'Test::Valgrind::Parser::Dummy' }
36 my $tool = Test::Valgrind::Tool::Dummy->new();
39 package Test::Valgrind::Action::Dummy;
41 use base 'Test::Valgrind::Action';
43 sub do_suppressions { 0 }
46 my ($self, $sess, $report) = @_;
48 if ($report->is_diag) {
49 my $contents = $report->data;
50 if ($contents !~ /^(?:Using valgrind |No suppressions used)/) {
55 $self->SUPER::report($sess, $report);
60 my $dummy_action = Test::Valgrind::Action::Dummy->new();
63 my $sess = eval { Test::Valgrind::Session->new(
64 min_version => $tool->requires_version,
67 if ($err =~ /^(Empty valgrind candidates list|No appropriate valgrind executable could be found)\s+at.*/) {
76 my $file = $sess->def_supp_file;
77 my $VERSION = quotemeta $Test::Valgrind::Session::VERSION;
78 my $exp = qr!$VERSION/memcheck-\d+(?:\.\d+)*-[0-9a-f]{32}\.supp$!;
79 like $file, $exp, 'default suppression file is correctly named';
81 my $res = open my $supp_fh, '<', $file;
83 ok $res, 'default suppression file can be opened';
84 diag "open($file): $err" unless $res;
87 my ($count, $non_empty, $perl_related) = (0, 0, 0);
88 my ($in, $valid_frames, $seen_perl);
93 if (!$in && $_ eq '{') {
100 ++$non_empty if $valid_frames;
101 ++$perl_related if $seen_perl;
104 ++$valid_frames if /^\s*fun:/;
105 ++$seen_perl if /^\s*fun:(Perl|S|XS)_/
110 diag "The default suppression file contains $count suppressions, of which $non_empty are not empty and $perl_related apply to perl";
118 my $dummy_vg = Test::Valgrind::FakeValgrind->new();
119 skip $dummy_vg => 2 unless ref $dummy_vg;
121 eval { Test::Valgrind::Session->new(
122 valgrind => $dummy_vg->path,
124 extra_supp => [ 't/supp/no_perl' ],
128 action => $dummy_action,
130 like $@, qr/No compatible suppressions available/,
131 'incompatible suppression file';
133 eval { Test::Valgrind::Session->new(
134 valgrind => $dummy_vg->path,
137 extra_supp => [ 't/supp/no_perl' ],
141 action => $dummy_action,
143 is $@, '', 'incompatible suppression file, but forced';