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