]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - t/81-suppressions-demangle.t
Z-demangle symbol names in suppressions
[perl/modules/Test-Valgrind.git] / t / 81-suppressions-demangle.t
diff --git a/t/81-suppressions-demangle.t b/t/81-suppressions-demangle.t
new file mode 100644 (file)
index 0000000..232306b
--- /dev/null
@@ -0,0 +1,32 @@
+#!perl -T
+
+use strict;
+use warnings;
+
+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;
+ }
+}