]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blob - t/81-suppressions-demangle.t
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/Test-Valgrind.git] / t / 81-suppressions-demangle.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 BEGIN { delete $ENV{PATH} }
7
8 use Test::More tests => 2 * 7;
9
10 use Test::Valgrind::Suppressions;
11
12 my @Z_tests = (
13  [ 'malloc'            => 'malloc', 'not encoded' ],
14  [ '_vgrZU_VG_Z_dongs' => qr/Symbol with a "VG_Z_" prefix is invalid/, 'VG_Z' ],
15  [ '_vgrZU_dongs'      => qr/Symbol doesn't contain a function name/,
16                                                            'no function name' ],
17  [ '_vgrZU_libcZdsoZa_malloc'   => 'malloc',   'soname encoded' ],
18  [ '_vgrZU_libcZdsoZa_arZZZAel' => 'arZZZAel', 'soname encoded 2' ],
19  [ '_vgrZZ_libcZdsoZa_arZZZAel' => 'arZ@el',   'function name encoded' ],
20  [ '_vgrZZ_libcZdsoZa_arZdZXZa' => qr/Invalid escape sequence/,
21                                          'function name with invalid escapes' ],
22 );
23
24 for (@Z_tests) {
25  my ($sym, $exp, $desc) = @$_;
26  my $res = eval { Test::Valgrind::Suppressions->maybe_z_demangle($sym) };
27  if (ref $exp) {
28   like $@,   $exp,  "$desc croaks as expected";
29   is   $res, undef, $desc;
30  } else {
31   is $@,   '',   "$desc does not croak as expected";
32   is $res, $exp, $desc;
33  }
34 }