This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_goto: SvREFCNT_dec(oldcv) *after* undef test
[perl5.git] / t / perf / taint.t
1 #!./perl -T
2 #
3 # All the tests in this file are ones that run exceptionally slowly
4 # (each test taking seconds or even minutes) in the absence of particular
5 # optimisations. Thus it is a sort of canary for optimisations being
6 # broken.
7 #
8 # Although it includes a watchdog timeout, this is set to a generous limit
9 # to allow for running on slow systems; therefore a broken optimisation
10 # might be indicated merely by this test file taking unusually long to
11 # run, rather than actually timing out.
12 #
13 # This is similar to t/perf/speed.t but tests performance regressions specific
14 # to taint.
15 #
16
17 BEGIN {
18     chdir 't' if -d 't';
19     @INC = ('../lib');
20     require Config; import Config;
21     require './test.pl';
22     skip_all_if_miniperl("No Scalar::Util under miniperl");
23 }
24
25 use strict;
26 use warnings;
27 use Scalar::Util qw(tainted);
28
29 $| = 1;
30
31 plan tests => 2;
32
33 watchdog(60);
34
35 {
36     my $in = substr($ENV{PATH}, 0, 0) . ( "ab" x 200_000 );
37     utf8::upgrade($in);
38     ok(tainted($in), "performance issue only when tainted");
39     while ($in =~ /\Ga+b/g) { }
40     pass("\\G on tainted string");
41 }
42
43 1;