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