stas 2003/07/19 02:57:05
Modified: t/conf modperl_extra.pl Added: t/response/TestModperl ithreads.pm Log: first basic tests of interoperation of ithreads and mod_perl 2 Revision Changes Path 1.1 modperl-2.0/t/response/TestModperl/ithreads.pm Index: ithreads.pm =================================================================== package TestModperl::ithreads; use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestUtil; use Apache::TestTrace; use Apache::Const -compile => 'OK'; # XXX: at this moment ithreads can be used only with 5.8.1. However # once ithreads will be available on CPAN, we will need to change the # check for perl 5.8.0 and this certain version of ithreads (here and # in t/conf/modperl_extra.pl sub handler { my $r = shift; plan $r, tests => 2, have have_threads, {"perl >= 5.8.1 is required (this is $])" => ($] >= 5.008001)}; # threads must have been preloaded at the server startup for this # test (this is done at t/conf/modperl_extra.pl) require threads; threads->import(); { my $tid = threads->self->tid; debug "1st TID is $tid" if defined $tid; ok defined $tid; } { my $thr = threads->new(sub { my $tid = threads->self->tid; debug "2nd TID is $tid" if defined $tid; return 2; }); ok $thr->join == 2; } Apache::OK; } 1; __END__ SetHandler modperl 1.31 +13 -0 modperl-2.0/t/conf/modperl_extra.pl Index: modperl_extra.pl =================================================================== RCS file: /home/cvs/modperl-2.0/t/conf/modperl_extra.pl,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- modperl_extra.pl 2 Jun 2003 03:03:39 -0000 1.30 +++ modperl_extra.pl 19 Jul 2003 09:57:05 -0000 1.31 @@ -79,6 +79,19 @@ # attempt to use perl's mip early Apache->server->add_config(['<Perl >', '1;', '</Perl>']); + +# this is needed for TestModperl::ithreads +# one should be able to boot ithreads at the server startup and then +# access the ithreads setup at run-time when a perl interpreter is +# running on a different native threads (testing that perl +# interpreters and ithreads aren't related to the native threads they +# are running on). This should work starting from perl-5.8.1 and higher. +use Config; +if ($] >= 5.008001 && $Config{useithreads}) { + eval { require threads; threads->import() }; +} + + use constant IOBUFSIZE => 8192; use Apache::Const -compile => qw(MODE_READBYTES);