kivitendo/t/003safesys.t @ 59626ee2
1d91e75c | Sven Schöling | # -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
d9e8ef2c | Moritz Bunkus | #
|
||
1d91e75c | Sven Schöling | # The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
d9e8ef2c | Moritz Bunkus | #
|
||
1d91e75c | Sven Schöling | # Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
d9e8ef2c | Moritz Bunkus | #
|
||
1d91e75c | Sven Schöling | # The Original Code are the Bugzilla Tests.
|
||
d9e8ef2c | Moritz Bunkus | #
|
||
1d91e75c | Sven Schöling | # The Initial Developer of the Original Code is Zach Lipton
|
||
d9e8ef2c | Moritz Bunkus | # Portions created by Zach Lipton are
|
||
1d91e75c | Sven Schöling | # Copyright (C) 2001 Zach Lipton. All
|
||
# Rights Reserved.
|
||||
d9e8ef2c | Moritz Bunkus | #
|
||
1d91e75c | Sven Schöling | # Contributor(s): Zach Lipton <zach@zachlipton.com>
|
||
#################
|
||||
#Bugzilla Test 3#
|
||||
###Safesystem####
|
||||
use strict;
|
||||
d9e8ef2c | Moritz Bunkus | use threads;
|
||
1d91e75c | Sven Schöling | |||
use lib 't';
|
||||
use Support::Files;
|
||||
d9e8ef2c | Moritz Bunkus | use Sys::CPU;
|
||
use Thread::Pool::Simple;
|
||||
1d91e75c | Sven Schöling | |||
use Test::More tests => scalar(@Support::Files::testitems);
|
||||
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
|
||||
# This will handle verbosity for us automatically.
|
||||
my $fh;
|
||||
{
|
||||
local $^W = 0; # Don't complain about non-existent filehandles
|
||||
if (-e \*Test::More::TESTOUT) {
|
||||
$fh = \*Test::More::TESTOUT;
|
||||
} elsif (-e \*Test::Builder::TESTOUT) {
|
||||
$fh = \*Test::Builder::TESTOUT;
|
||||
} else {
|
||||
$fh = \*STDOUT;
|
||||
}
|
||||
}
|
||||
d9e8ef2c | Moritz Bunkus | my @testitems = @Support::Files::testitems;
|
||
1d91e75c | Sven Schöling | my $perlapp = "\"$^X\"";
|
||
d9e8ef2c | Moritz Bunkus | sub test_file {
|
||
my ($file) = @_;
|
||||
my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1";
|
||||
my $loginfo =`$command`;
|
||||
if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) {
|
||||
ok(0,"$file DOES NOT use proper system or exec calls");
|
||||
print $fh $loginfo;
|
||||
} else {
|
||||
ok(1,"$file uses proper system and exec calls");
|
||||
}
|
||||
}
|
||||
my $pool = Thread::Pool::Simple->new(
|
||||
min => 2,
|
||||
max => Sys::CPU::cpu_count() + 1,
|
||||
do => [ \&test_file ],
|
||||
passid => 0,
|
||||
);
|
||||
1d91e75c | Sven Schöling | foreach my $file (@testitems) {
|
||
d9e8ef2c | Moritz Bunkus | $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
$pool->add($file) if $file; # skip null entries
|
||||
1d91e75c | Sven Schöling | }
|
||
d9e8ef2c | Moritz Bunkus | $pool->join;
|
||
1d91e75c | Sven Schöling | exit 0;
|