summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/ext/File-Glob/t
diff options
context:
space:
mode:
authorafresh1 <afresh1@openbsd.org>2014-03-24 14:58:42 +0000
committerafresh1 <afresh1@openbsd.org>2014-03-24 14:58:42 +0000
commit91f110e064cd7c194e59e019b83bb7496c1c84d4 (patch)
tree3e8e577405dba7e94b43cbf21c22f21aaa5ab949 /gnu/usr.bin/perl/ext/File-Glob/t
parentdo not call purge_task every 10 secs, it is only needed once at startup and (diff)
downloadwireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.tar.xz
wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.zip
Import perl-5.18.2
OK espie@ sthen@ deraadt@
Diffstat (limited to 'gnu/usr.bin/perl/ext/File-Glob/t')
-rwxr-xr-xgnu/usr.bin/perl/ext/File-Glob/t/basic.t7
-rw-r--r--gnu/usr.bin/perl/ext/File-Glob/t/rt114984.t31
-rwxr-xr-xgnu/usr.bin/perl/ext/File-Glob/t/taint.t9
-rw-r--r--gnu/usr.bin/perl/ext/File-Glob/t/threads.t71
4 files changed, 114 insertions, 4 deletions
diff --git a/gnu/usr.bin/perl/ext/File-Glob/t/basic.t b/gnu/usr.bin/perl/ext/File-Glob/t/basic.t
index bcd99996215..78710753f9c 100755
--- a/gnu/usr.bin/perl/ext/File-Glob/t/basic.t
+++ b/gnu/usr.bin/perl/ext/File-Glob/t/basic.t
@@ -52,7 +52,7 @@ if (GLOB_ERROR) {
SKIP: {
my ($name, $home);
skip $^O, 1 if $^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS'
- || $^O eq 'os2' || $^O eq 'beos';
+ || $^O eq 'os2';
skip "Can't find user for $>: $@", 1 unless eval {
($name, $home) = (getpwuid($>))[0,7];
1;
@@ -130,7 +130,7 @@ SKIP: {
# check bad protections
# should return an empty list, and set ERROR
SKIP: {
- skip $^O, 2 if $^O eq 'mpeix' or $^O eq 'MSWin32' or $^O eq 'NetWare'
+ skip $^O, 2 if $^O eq 'MSWin32' or $^O eq 'NetWare'
or $^O eq 'os2' or $^O eq 'VMS' or $^O eq 'cygwin';
skip "AFS", 2 if Cwd::cwd() =~ m#^$Config{'afsroot'}#s;
skip "running as root", 2 if not $>;
@@ -159,9 +159,10 @@ is_deeply(\@a, ['a', 'b']);
@a = grep !/(,v$|~$|\.(pm|ori?g|rej)$)/, @a;
@a = (grep !/test.pl/, @a) if $^O eq 'VMS';
+map { $_ =~ s/test\.?/TEST/i } @a if $^O eq 'VMS';
print "# @a\n";
-is_deeply(\@a, [($vms_mode ? 'test.' : 'TEST'), 'a', 'b']);
+is_deeply(\@a, ['TEST', 'a', 'b']);
# "~" should expand to $ENV{HOME}
{
diff --git a/gnu/usr.bin/perl/ext/File-Glob/t/rt114984.t b/gnu/usr.bin/perl/ext/File-Glob/t/rt114984.t
new file mode 100644
index 00000000000..285bb70e957
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/File-Glob/t/rt114984.t
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+use v5.16.0;
+use File::Temp 'tempdir';
+use File::Spec::Functions;
+use Test::More;
+
+BEGIN {
+ plan skip_all => "Home-grown glob does not do character classes on $^O" if $^O eq 'VMS';
+}
+
+plan tests => 1;
+
+my @md = (1..305);
+my @mp = (1000..1205);
+
+my $path = tempdir uc cleanup => 1;
+
+foreach (@md) {
+ open(my $f, ">", catfile $path, "md_$_.dat");
+ close $f;
+}
+
+foreach (@mp) {
+ open(my $f, ">", catfile $path, "mp_$_.dat");
+ close $f;
+}
+my @b = glob(qq{$path/mp_[0123456789]*.dat
+ $path/md_[0123456789]*.dat});
+is scalar(@b), @md+@mp,
+ 'File::Glob extends the stack when returning a long list';
diff --git a/gnu/usr.bin/perl/ext/File-Glob/t/taint.t b/gnu/usr.bin/perl/ext/File-Glob/t/taint.t
index 3f49836bce8..4751303fe0e 100755
--- a/gnu/usr.bin/perl/ext/File-Glob/t/taint.t
+++ b/gnu/usr.bin/perl/ext/File-Glob/t/taint.t
@@ -10,7 +10,14 @@ BEGIN {
}
}
-use Test::More tests => 2;
+use Test::More;
+BEGIN {
+ plan(
+ ${^TAINT}
+ ? (tests => 2)
+ : (skip_all => "Appear to running a perl without taint support")
+ );
+}
BEGIN {
use_ok('File::Glob');
diff --git a/gnu/usr.bin/perl/ext/File-Glob/t/threads.t b/gnu/usr.bin/perl/ext/File-Glob/t/threads.t
new file mode 100644
index 00000000000..03f00ceb63f
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/File-Glob/t/threads.t
@@ -0,0 +1,71 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require Config; import Config;
+ if ($Config{'extensions'} !~ /\bFile\/Glob\b/i) {
+ print "1..0\n";
+ exit 0;
+ }
+}
+use strict;
+use warnings;
+# Test::More needs threads pre-loaded
+use if $Config{useithreads}, 'threads';
+use Test::More;
+
+BEGIN {
+ if (! $Config{'useithreads'}) {
+ plan skip_all => "Perl not compiled with 'useithreads'";
+ }
+}
+
+use File::Temp qw(tempdir);
+use File::Spec qw();
+use File::Glob qw(csh_glob);
+
+my($dir) = tempdir(CLEANUP => 1)
+ or die "Could not create temporary directory";
+
+my @temp_files = qw(1_file.tmp 2_file.tmp 3_file.tmp);
+for my $file (@temp_files) {
+ open my $fh, ">", File::Spec->catfile($dir, $file)
+ or die "Could not create file $dir/$file: $!";
+ close $fh;
+}
+my $cwd = Cwd::cwd();
+chdir $dir
+ or die "Could not chdir to $dir: $!";
+
+sub do_glob { scalar csh_glob("*") }
+# Stablish some glob state
+my $first_file = do_glob();
+is($first_file, $temp_files[0]);
+
+my @files;
+push @files, threads->create(\&do_glob)->join() for 1..5;
+is_deeply(
+ \@files,
+ [($temp_files[1]) x 5],
+ "glob() state is cloned for new threads"
+);
+
+@files = threads->create({'context' => 'list'},
+ sub {
+ return do_glob(), threads->create(\&do_glob)->join()
+ })->join();
+
+is_deeply(
+ \@files,
+ [@temp_files[1,2]],
+ "..and for new threads inside threads"
+);
+
+my $second_file = do_glob();
+is($second_file, $temp_files[1], "state doesn't leak from threads");
+
+chdir $cwd
+ or die "Could not chdir back to $cwd: $!";
+
+done_testing;