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();
62 my $sess = eval { Test::Valgrind::Session->new(
63 min_version => $tool->requires_version,
67 $err =~ s/^(Empty valgrind candidates list|No appropriate valgrind executable could be found)\s+at.*/$1/;
68 plan skip_all => $err;
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_/;
109 diag "The default suppression file contains $count suppressions, of which $non_empty are not empty and $perl_related apply to perl";
114 my $dummy_vg = Test::Valgrind::FakeValgrind->new();
115 skip $dummy_vg => 2 unless ref $dummy_vg;
117 $sess = eval { Test::Valgrind::Session->new(
118 valgrind => $dummy_vg->path,
120 extra_supp => [ 't/supp/no_perl' ],
124 action => $dummy_action,
126 like $@, qr/No compatible suppressions available/,
127 'incompatible suppression file';
129 $sess = eval { Test::Valgrind::Session->new(
130 valgrind => $dummy_vg->path,
133 extra_supp => [ 't/supp/no_perl' ],
137 action => $dummy_action,
139 is $@, '', 'incompatible suppression file, but forced';