xref: /openbsd-src/gnu/usr.bin/perl/cpan/File-Path/t/taint.t (revision b39c515898423c8d899e35282f4b395f7cad3298)
1*b39c5158Smillert#! perl -T
2*b39c5158Smillert
3*b39c5158Smillert# Taint tests for module File::Path
4*b39c5158Smillert
5*b39c5158Smillertuse strict;
6*b39c5158Smillert
7*b39c5158Smillertuse Test::More tests => 6;
8*b39c5158Smillert
9*b39c5158SmillertBEGIN {
10*b39c5158Smillert    use_ok('File::Path', qw(rmtree mkpath make_path remove_tree));
11*b39c5158Smillert    use_ok('File::Spec::Functions');
12*b39c5158Smillert}
13*b39c5158Smillert
14*b39c5158Smillert# find a place to work
15*b39c5158Smillertmy $tmp_base = catdir(
16*b39c5158Smillert    curdir(),
17*b39c5158Smillert    sprintf( 'taint-%x-%x-%x', time, $$, rand(99999) ),
18*b39c5158Smillert);
19*b39c5158Smillert
20*b39c5158Smillert# invent some names
21*b39c5158Smillertmy @dir = (
22*b39c5158Smillert    catdir($tmp_base, qw(a b)),
23*b39c5158Smillert    catdir($tmp_base, qw(a c)),
24*b39c5158Smillert    catdir($tmp_base, qw(z b)),
25*b39c5158Smillert    catdir($tmp_base, qw(z c)),
26*b39c5158Smillert);
27*b39c5158Smillert
28*b39c5158Smillert# create them
29*b39c5158Smillertmy @created = make_path(@dir);
30*b39c5158Smillertis(scalar(@created), 7, "created list of directories");
31*b39c5158Smillert
32*b39c5158Smillertmy $count = rmtree($tmp_base, {error => \(my $err), result => \my $res});
33*b39c5158Smillertis( $count, 7, 'rmtree under taint' );
34*b39c5158Smillertis( scalar(@$err), 0, 'no errors' );
35*b39c5158Smillertis( scalar(@$res), 7, 'seven items' );
36