b4f41f61c4b43357af2bf86cd5a44a596335a33b
[kivitendo-erp.git] / t / 003safesys.t
1 # -*- Mode: perl; indent-tabs-mode: nil -*-
2
3 # The contents of this file are subject to the Mozilla Public
4 # License Version 1.1 (the "License"); you may not use this file
5 # except in compliance with the License. You may obtain a copy of
6 # the License at http://www.mozilla.org/MPL/
7
8 # Software distributed under the License is distributed on an "AS
9 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 # implied. See the License for the specific language governing
11 # rights and limitations under the License.
12
13 # The Original Code are the Bugzilla Tests.
14
15 # The Initial Developer of the Original Code is Zach Lipton
16 # Portions created by Zach Lipton are 
17 # Copyright (C) 2001 Zach Lipton.  All
18 # Rights Reserved.
19
20 # Contributor(s): Zach Lipton <zach@zachlipton.com>
21
22
23 #################
24 #Bugzilla Test 3#
25 ###Safesystem####
26
27 use strict;
28
29 use lib 't';
30
31 use Support::Files;
32
33 use Test::More tests => scalar(@Support::Files::testitems);
34
35 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
36 # This will handle verbosity for us automatically.
37 my $fh;
38 {
39     local $^W = 0;  # Don't complain about non-existent filehandles
40     if (-e \*Test::More::TESTOUT) {
41         $fh = \*Test::More::TESTOUT;
42     } elsif (-e \*Test::Builder::TESTOUT) {
43         $fh = \*Test::Builder::TESTOUT;
44     } else {
45         $fh = \*STDOUT;
46     }
47 }
48
49 my @testitems = @Support::Files::testitems; 
50 my $perlapp = "\"$^X\"";
51
52 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     }
63 }
64
65 exit 0;