Commit 63d3d9db authored by Xavier Guimard's avatar Xavier Guimard

Move extra-tests to lemonldap-ng-portal/xt


git-svn-id: svn://svn.forge.objectweb.org/svnroot/lemonldap/trunk@3040 1dbb9719-a921-0410-b57f-c3a383c2c641
parent d1a5baa4
......@@ -201,6 +201,7 @@ manager_test: manager handler_test common_test
@$(MAKE) -C ${SRCMANAGERDIR} test FULLPERL="$(PERL) -I../${SRCCOMMONDIR}/blib/lib/ -I../${SRCHANDLERDIR}/blib/lib/"
extra_test: all
cd ${SRCPORTALDIR} && prove xt
PERL_DL_NONLAZY=1 $(PERL) "-MExtUtils::Command::MM" "-e" "test_harness(0, 'lemonldap-ng-common/blib/lib', 'lemonldap-ng-handler/blib/lib', 'lemonldap-ng-manager/blib/lib', 'lemonldap-ng-portal/blib/lib')" extra-tests/*.t
#
......
use strict;
use Test::More tests => 6;
use_ok( 'Lemonldap::NG::Portal::Simple' );
ok(open(F, 'lemonldap-ng-portal/blib/lib/Lemonldap/NG/Portal/Simple.pm'));
my (%h1,%h2,@missingInStatus,@differentValues);
# Load constants
while(<F>){
$h1{$1} = $2 if(/^\s*PE_(\w+)\s*=>\s*(-?\d+),$/);
last if(/^sub/);
}
close F;
ok(open(F, 'lemonldap-ng-handler/blib/lib/Lemonldap/NG/Handler/Status.pm'));
while(<F>){
$h2{$2} = $1 if(/^\s*(-?\d+)\s*=>\s*'PORTAL_(\w+)',$/);
}
foreach my $k(sort keys %h1) {
if(defined($h2{$k})){
unless($h1{$k} == $h2{$k}){
push @differentValues,$k;
}
delete $h2{$k};
}
else {
push @missingInStatus,$k;
}
delete $h1{$k};
}
ok(!@differentValues,'Search different constant values between Status.pm and portal');
ok(!@missingInStatus,join(', ','Search missing constants in Status.pm',@missingInStatus));
ok(!(keys %h2), 'Constants set in Status.pm and not in portal');
#!/usr/bin/perl
use Test::More;
use Test::Weaken qw(leaks);
use Lemonldap::NG::Portal;
my $p;
my $tester = Test::Weaken::leaks(
{ constructor => sub {Lemonldap::NG::Portal::SharedConf->new()},
destructor => sub {my $p = shift;undef $p;undef $Lemonldap::NG::Portal::SharedConf::confCached},
}
);
if ($tester) {
my $unfreed_proberefs = $tester->unfreed_proberefs();
my $unfreed_count = @{$unfreed_proberefs};
printf "Test 2: %d of %d original references were not freed\n",
$tester->unfreed_count(), $tester->probe_count()
or Carp::croak("Cannot print to STDOUT: $ERRNO");
print "These are the probe references to the unfreed objects:\n"
or Carp::croak("Cannot print to STDOUT: $ERRNO");
for my $ix ( 0 .. $#{$unfreed_proberefs} ) {
print Data::Dumper->Dump( [ $unfreed_proberefs->[$ix] ],
["unfreed_$ix"] )
or Carp::croak("Cannot print to STDOUT: $ERRNO");
}
}
ok(!$tester);
use strict;
use Test::More tests => 7;
use_ok('Lemonldap::NG::Portal::Simple');
use_ok('Lemonldap::NG::Handler::Status');
ok( open( F, $INC{'Lemonldap/NG/Portal/Simple.pm'} ) );
my ( %h1, %h2, @missingInStatus, @differentValues );
# Load constants
while (<F>) {
$h1{$1} = $2 if (/^\s*PE_(\w+)\s*=>\s*(-?\d+),$/);
last if (/^sub/);
}
close F;
ok( open( F, $INC{'Lemonldap/NG/Handler/Status.pm'} ) );
while (<F>) {
$h2{$2} = $1 if (/^\s*(-?\d+)\s*=>\s*'PORTAL_(\w+)',$/);
}
foreach my $k ( sort keys %h1 ) {
if ( defined( $h2{$k} ) ) {
unless ( $h1{$k} == $h2{$k} ) {
push @differentValues, $k;
}
delete $h2{$k};
}
else {
push @missingInStatus, $k;
}
delete $h1{$k};
}
ok( !@differentValues,
'Search different constant values between Status.pm and portal' );
ok( !@missingInStatus,
join( ', ', 'Search missing constants in Status.pm', @missingInStatus ) );
ok( !( keys %h2 ), 'Constants set in Status.pm and not in portal' );
#!/usr/bin/perl
use Test::More tests => 1;
use Lemonldap::NG::Portal;
SKIP: {
my $p;
eval 'use Test::Weaken qw(leaks)';
if ($@) {
skip 'Test::Weaken is not available', 1;
}
else {
my $tester = Test::Weaken::leaks(
{
constructor => sub {
Lemonldap::NG::Portal::Simple->new(
{
globalStorage => 'Apache::Session::File',
domain => 'example.com',
authentication => 'LDAP test=1',
user => '',
password => '',
}
);
},
destructor => sub {
my $p = shift;
undef $p;
undef $Lemonldap::NG::Portal::SharedConf::confCached;
},
}
);
if ($tester) {
my $unfreed_proberefs = $tester->unfreed_proberefs();
my $unfreed_count = @{$unfreed_proberefs};
printf STDERR
"Test 2: %d of %d original references were not freed\n",
$tester->unfreed_count(), $tester->probe_count();
print STDERR
"These are the probe references to the unfreed objects:\n";
require Data::Dumper;
for my $ix ( 0 .. $#{$unfreed_proberefs} ) {
print STDERR Data::Dumper->Dump( [ $unfreed_proberefs->[$ix] ],
["unfreed_$ix"] );
}
}
ok( !$tester );
}
}
done_testing;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment