/Compress/ modules are at version 2.021. Remove vestigal MAPs and comments.
[p5sagit/p5-mst-13.2.git] / ext / POSIX / t / taint.t
index 2fc171b..3ca0174 100644 (file)
@@ -1,8 +1,6 @@
 #!./perl -Tw
 
 BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
     require Config; import Config;
     if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
        print "1..0\n";
@@ -10,9 +8,8 @@ BEGIN {
     }
 }
 
-require "./test.pl";
+use Test::More tests => 7;
 use Scalar::Util qw/tainted/;
-plan(tests => 5);
 
 
 use POSIX qw(fcntl_h open read mkfifo);
@@ -29,19 +26,26 @@ my $testfd;
 
 my $TAINT = substr($^X, 0, 0);
 
-eval { mkfifo($TAINT. "TEST", 0) };
-ok($@ =~ /^Insecure dependency/,              'mkfifo with tainted data');
+my $file = 'POSIX.xs';
 
-eval { $testfd = open($TAINT. "TEST", O_WRONLY, 0) };
-ok($@ =~ /^Insecure dependency/,              'open with tainted data');
+eval { mkfifo($TAINT. $file, 0) };
+like($@, qr/^Insecure dependency/,              'mkfifo with tainted data');
 
-eval { $testfd = open("TEST", O_RDONLY, 0) };
-ok($@ eq "",                                  'open with untainted data');
+eval { $testfd = open($TAINT. $file, O_WRONLY, 0) };
+like($@, qr/^Insecure dependency/,              'open with tainted data');
+
+eval { $testfd = open($file, O_RDONLY, 0) };
+is($@, "",                                  'open with untainted data');
 
 read($testfd, $buffer, 2) if $testfd > 2;
-is( $buffer, "#!",                               '    read' );
+is( $buffer, "#d",                               '    read' );
 ok(tainted($buffer),                          '    scalar tainted');
-read($testfd, $buffer[1], 2) if $testfd > 2;
 
-#is( $buffer[1], "./",                       '    read' );
-#ok(tainted($buffer[1]),                       '    array element tainted');
+TODO: {
+    local $TODO = "POSIX::read won't taint an array element";
+
+    read($testfd, $buffer[1], 2) if $testfd > 2;
+
+    is( $buffer[1], "./",                            '    read' );
+    ok(tainted($buffer[1]),                       '    array element tainted');
+}