After building the server, it's a good idea to test it throughly by calling:
panic% make test
Fortunately, mod_perl comes with a big collection of tests, which attempt to exercise all the features you asked for at the configuration stage. If any of the tests fails, the make test step will fail.
Running make test will start the freshly built httpd on port 8529 (an unprivileged port), running under the UID (user ID) and GID (group ID) of the perl Makefile.PL process. The httpd will be terminated when the tests are finished.
To change the default port (8529) used for the tests, do this:
panic% perl Makefile.PL PORT=xxxx
Each file in the testing suite generally includes more than one test, but when you do the testing, the program will report only how many tests were passed and the total number of tests defined in the test file. To learn which ones failed, run the tests in verbose mode by using the TEST_VERBOSE parameter:
panic% make test TEST_VERBOSE=1
As of mod_perl v1.23, you can use the environment variables APACHE_USER and APACHE_GROUP to override the default User and Group settings in the httpd.conf file used for make test. These two variables should be set before the Makefile is created to take effect during the testing stage. For example, if you want to set them to httpd, you can do the following in the Bourne-style shell:
panic% export APACHE_USER=httpd panic% export APACHE_GROUP=httpd panic% perl Makefile.PL ...
Tests are invoked by running the ./TEST script located in the ./t directory. Use the -v option for verbose tests. You might run an individual test like this:
panic% perl t/TEST -v modules/file.t
or all tests in a test subdirectory:
panic% perl t/TEST modules
The TEST script starts the server before the test is executed. If for some reason it fails to start, use make start_httpd to start it manually:
panic% make start_httpd
To shut down Apache when the testing is complete, use make kill_httpd:
panic% make kill_httpd
The following sections cover problems that you may encounter during the testing stage.
make test requires Apache to be running already, so if you specified NO_HTTPD=1 during the perl Makefile.PL stage, you'll have to build httpd independently before running make test. Go to the Apache source tree and run make, then return to the mod_perl source tree and continue with the server testing.
If you get an error like this:
still waiting for server to warm up...............not ok
you may want to examine the t/logs/error_log file, where all the make test-stage errors are logged. If you still cannot find the problem or this file is completely empty, you may want to run the test with strace (or truss) in the following way (assumming that you are located in the root directory of the mod_perl source tree):
panic% make start_httpd panic% strace -f -s1024 -o strace.out -p `cat t/logs/httpd.pid` & panic% make run_tests panic% make kill_httpd
where the strace -f option tells strace to trace child processes as they are created, -s1024 allows trace strings of a maximum of 1024 characters to be printed (it's 32 by default), -o gives the name of the file to which the output should be written, -p supplies the PID of the parent process, and & puts the job in the background.
When the tests are complete, you can examine the generated strace.out file and hopefully find the problem. We talk about creating and analyzing trace outputs in Chapter 21.
If you had a stale Apache header layout in one of the include paths during the build process, you will see the message "mod_perl.c is incompatible with this version of Apache" when you try to execute httpd. Find the file ap_mmn.h using find, locate, or another utility. Delete this file and rebuild Apache. The Red Hat Linux distribution usually installs it in /usr/local/include.
Before installing mod_perl-enabled Apache from scratch, it's a good idea to remove all the pre-installed Apache modules, and thus save the trouble of looking for files that mess up the build process. For example, to remove the precompiled Apache installed as a Red Hat Package Manager (RPM) package, as root you should do:
panic# rpm -e apache
There may be other RPM packages that depend on the Apache RPM package. You will be notified about any other dependent packages, and you can decide whether to delete them, too. You can always supply the ?nodeps option to tell the RPM manager to ignore the dependencies.
apt users would do this instead:
panic# apt-get remove apache
make test may report some tests as skipped. They are skipped because you are missing the modules that are needed for these tests to pass. You might want to peek at the contents of each test; you will find them all in the ./t directory. It's possible that you don't need any of the missing modules to get your work done, in which case you shouldn't worry that the tests are skipped.
If you want to make sure that all tests pass, you will need to figure out what modules are missing from your installation. For example, if you see:
modules/cookie......skipping test on this platform
you may want to install the Apache::Cookie module. If you see:
modules/request.....skipping test on this platform
Apache::Request is missing. If you see:
 Apache::Cookie and Apache::Request are both part of the libapreq distribution.
modules/psections...skipping test on this platform
Devel::Symdump and Data::Dumper are needed.
Chances are that all of these will be installed if you use CPAN.pm to install Bundle::Apache. We talk about CPAN installations later in this chapter.
The make test suite uses localhost to run the tests that require a network. Make sure you have this entry in /etc/hosts:
127.0.0.1 localhost.localdomain localhost
Also make sure you have the loopback device lo configured. If you aren't sure, run:
panic% /sbin/ifconfig lo
This will tell you whether the loopback device is configured.