xref: /openbsd-src/gnu/usr.bin/perl/t/perf/taint.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
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
17BEGIN {
18    chdir 't' if -d 't';
19    @INC = ('../lib');
20    require Config; import Config;
21    require './test.pl';
22}
23
24use strict;
25use warnings;
26use Scalar::Util qw(tainted);
27
28$| = 1;
29
30plan tests => 2;
31
32watchdog(60);
33
34{
35    my $in = substr($ENV{PATH}, 0, 0) . ( "ab" x 200_000 );
36    utf8::upgrade($in);
37    ok(tainted($in), "performance issue only when tainted");
38    while ($in =~ /\Ga+b/g) { }
39    pass("\\G on tainted string");
40}
41
421;
43