#!/usr/bin/perl -w # # TWiki Collaboration Platform, http://TWiki.org/ # # Copyright (C) 2000-2004 Peter Thoeny, peter@thoeny.com # # For licensing info read license.txt file in the TWiki root. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details, published at # http://www.gnu.org/copyleft/gpl.html # # DESCRIPTION: Test utility to see if CGI is running and enabled # for the bin directory, and check a variety of TWiki, Perl and RCS # setup. # NOTE: Testenv should always run on older TWiki versions, as far as # possible - so any dependency on TWiki modules should be carefully # handled and error checked. If a newer feature or subroutine is not # there, it's OK to fail silently and not do the associated tests. # This is more painful to code, but it means that testenv can be downloaded # from CVS and used on older TWiki versions to diagnose problems. package TWiki; use vars qw( $useLocale $setlibAvail ); my $brokenTWikiCfg; BEGIN { # Set default current working directory if( $ENV{"SCRIPT_FILENAME"} && $ENV{"SCRIPT_FILENAME"} =~ /^(.+)\/[^\/]+$/ ) { chdir $1; } # Set library paths in @INC, read TWiki.cfg and set locale, at compile time # Try to use setlib.cfg, use default path if missing if ( -r './setlib.cfg' ) { require './setlib.cfg'; $setlibAvail = 1; } else { unshift @INC, '../lib'; $setlibAvail = 0; } # Read the configuration file now in order to set locale; # includes checking for broken syntax etc. Need 'require' # to get the $!/$@ to work. $brokenTWikiCfg = 0; unless( eval 'require "TWiki.cfg" ' ){ # Includes OS detection # Capture the Perl error(s) $brokenTWikiCfg = 1; $brokenTWikiCfgError = ( $! ? "$!\n" : '') . # $! if not readable, ( $@ ? "$@\n" : ''); # $@ if not compileable } # Do a dynamic 'use locale' for this script if( $useLocale ) { require locale; import locale (); } } # use strict; # Recommended for mod_perl, enable for Perl 5.6.1 only # Doesn't work well here, due to 'do "TWiki.cfg"' # use diagnostics; # Debug only &main(); sub checkBasicModules { # Check whether basic CGI modules exist (some broken installations of # Perl don't have this, even though they are standard modules), and warn user my @basicMods = @_; my $modMissing = 0; my $mod; foreach $mod (@basicMods) { eval "use $mod"; if ($@) { unless ($modMissing) { print "Content-type: text/html\n\n"; print "
Warning: "; print "Essential module $mod not installed - please check your Perl\n"; print "installation, including the setting of \@INC, and re-install Perl if necessary.
\n"; } } # If any critical modules missing, display @INC and give up if ($modMissing) { print "\@INC setting:
";
print join "
\n", @INC;
print "