Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d9e8ef2c

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID d9e8ef2cc93042fbf9d2b4850381149d84a98033
  • Vorgänger a4684ad1
  • Nachfolger 388e410d

Tests: t/003safesys.t parallelisiert

Unterschiede anzeigen:

t/003safesys.t
1 1
# -*- Mode: perl; indent-tabs-mode: nil -*-
2
# 
2
#
3 3
# The contents of this file are subject to the Mozilla Public
4 4
# License Version 1.1 (the "License"); you may not use this file
5 5
# except in compliance with the License. You may obtain a copy of
6 6
# the License at http://www.mozilla.org/MPL/
7
# 
7
#
8 8
# Software distributed under the License is distributed on an "AS
9 9
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 10
# implied. See the License for the specific language governing
11 11
# rights and limitations under the License.
12
# 
12
#
13 13
# The Original Code are the Bugzilla Tests.
14
# 
14
#
15 15
# The Initial Developer of the Original Code is Zach Lipton
16
# Portions created by Zach Lipton are 
16
# Portions created by Zach Lipton are
17 17
# Copyright (C) 2001 Zach Lipton.  All
18 18
# Rights Reserved.
19
# 
19
#
20 20
# Contributor(s): Zach Lipton <zach@zachlipton.com>
21 21

  
22 22

  
......
25 25
###Safesystem####
26 26

  
27 27
use strict;
28
use threads;
28 29

  
29 30
use lib 't';
30 31

  
31 32
use Support::Files;
33
use Sys::CPU;
34
use Thread::Pool::Simple;
32 35

  
33 36
use Test::More tests => scalar(@Support::Files::testitems);
34 37

  
......
46 49
    }
47 50
}
48 51

  
49
my @testitems = @Support::Files::testitems; 
52
my @testitems = @Support::Files::testitems;
50 53
my $perlapp = "\"$^X\"";
51 54

  
55
sub test_file {
56
  my ($file)  = @_;
57
  my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1";
58
  my $loginfo =`$command`;
59

  
60
  if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) {
61
    ok(0,"$file DOES NOT use proper system or exec calls");
62
    print $fh $loginfo;
63
  } else {
64
    ok(1,"$file uses proper system and exec calls");
65
  }
66
}
67

  
68
my $pool = Thread::Pool::Simple->new(
69
  min    => 2,
70
  max    => Sys::CPU::cpu_count() + 1,
71
  do     => [ \&test_file ],
72
  passid => 0,
73
);
74

  
52 75
foreach my $file (@testitems) {
53
    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
54
    next if (!$file); # skip null entries
55
    my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1";
56
    my $loginfo=`$command`;
57
    if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) {
58
        ok(0,"$file DOES NOT use proper system or exec calls");
59
        print $fh $loginfo;
60
    } else {
61
        ok(1,"$file uses proper system and exec calls");
62
    }
76
  $file =~ s/\s.*$//;           # nuke everything after the first space (#comment)
77
  $pool->add($file) if $file;   # skip null entries
63 78
}
64 79

  
80
$pool->join;
81

  
65 82
exit 0;

Auch abrufbar als: Unified diff