From 5c55fe7192db4b8dae470f4ac3eb03bdfa1ad4e3 Mon Sep 17 00:00:00 2001 From: "donley%tekka.wwa.com" Date: Sun, 20 Sep 1998 03:21:58 +0000 Subject: [PATCH] Fixed a few problems with API.xs and made a few additional tests in api.pl. API.xs: Resolved problem with out of memory/dump core when passing numbers as the actual modification. API.xs: Fixed a non-reported bug that I stumbled on. When freeing ber's in Perl, if ($ber) will return true even when $ber is NULL. I therefore had to make the check for this stuff in Perl. Also changed this for ldap_msgfree. There's probably a few other functions I'll want to do this with. api.pl: Made the telephoneNumber attribute numeric just for fun. Added a bit of text explaining that later tests are dependent on earlier ones. I had people running it without ROOT and expecting the search tests to fail. This should make it absolutely clear that this is a self- contained test. The basic search test is in 'make test'. git-svn-id: svn://10.0.0.236/branches/devel-branch-1_1@10529 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/directory/perldap/API.xs | 29 +++++++++++++++++++---- mozilla/directory/perldap/test_api/api.pl | 13 ++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/mozilla/directory/perldap/API.xs b/mozilla/directory/perldap/API.xs index 03d7a8416e6..799a3748af4 100644 --- a/mozilla/directory/perldap/API.xs +++ b/mozilla/directory/perldap/API.xs @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: API.xs,v 1.15 1998-08-13 22:40:53 leif Exp $ + * $Id: API.xs,v 1.15.2.1 1998-09-20 03:21:55 donley%tekka.wwa.com Exp $ * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in @@ -118,7 +118,7 @@ struct berval ** avref2berptrptr(SV *avref) I32 avref_arraylen; int ix_av,val_len; SV **current_val; - char *tmp_char; + char *tmp_char,*tmp2; struct berval **tmp_ber; if (SvTYPE(SvRV(avref)) != SVt_PVAV || @@ -132,11 +132,14 @@ struct berval ** avref2berptrptr(SV *avref) { New(1,tmp_ber[ix_av],1,struct berval); current_val = av_fetch((AV *)SvRV(avref),ix_av,0); + + tmp_char = SvPV(*current_val,na); val_len = SvCUR(*current_val); - Newz(1,tmp_char,val_len+1,char); - Copy(SvPV(*current_val,na),tmp_char,val_len,char); - tmp_ber[ix_av]->bv_val = tmp_char; + Newz(1,tmp2,val_len+1,char); + Copy(tmp_char,tmp2,val_len,char); + + tmp_ber[ix_av]->bv_val = tmp2; tmp_ber[ix_av]->bv_len = val_len; } tmp_ber[ix_av] = NULL; @@ -479,6 +482,13 @@ void ldap_ber_free(ber,freebuf) BerElement * ber int freebuf + CODE: + { + if (ber) + { + ldap_ber_free(ber,freebuf); + } + } int ldap_bind(ld,dn,passwd,authmethod) @@ -1052,6 +1062,15 @@ ldap_mods_free(mods,freemods) int ldap_msgfree(lm) LDAPMessage * lm + CODE: + { + if (lm) + { + RETVAL = ldap_msgfree(lm); + } + } + OUTPUT: + RETVAL int ldap_msgid(lm) diff --git a/mozilla/directory/perldap/test_api/api.pl b/mozilla/directory/perldap/test_api/api.pl index 8911e730240..f60c3147f11 100755 --- a/mozilla/directory/perldap/test_api/api.pl +++ b/mozilla/directory/perldap/test_api/api.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w ############################################################################# -# $Id: api.pl,v 1.6 1998-08-13 04:40:00 clayton Exp $ +# $Id: api.pl,v 1.6.2.1 1998-09-20 03:21:58 donley%tekka.wwa.com Exp $ # # The contents of this file are subject to the Mozilla Public License # Version 1.0 (the "License"); you may not use this file except in @@ -12,7 +12,7 @@ # License for the specific language governing rights and limitations # under the License. # -# The Original Code is PerlDAP. The Initial Developer of the Original +# The Original Code is PerLDAP. The Initial Developer of the Original # Code is Netscape Communications Corp. and Clayton Donley. Portions # created by Netscape are Copyright (C) Netscape Communications # Corp., portions created by Clayton Donley are Copyright (C) Clayton @@ -44,6 +44,10 @@ if (!$HOST) exit -1; } +print "\nPerLDAP API TestSuite\n"; +print "\nNote: Failures in earlier tests will cause later tests to fail.\n"; +print "\n"; + my $howmany = 10; # Initialize the Connection @@ -132,8 +136,9 @@ foreach my $number (1..$howmany) foreach my $number (1..$howmany) { $entry = { - "sn" => {"a",["Test"]}, - "telephoneNumber" => "800-555-111$number", + "sn" => {"ab",["Test"]}, + "telephoneNumber" => {"ab",[123.456]}, +# "telephoneNumber" => "800-555-111$number", }; if (ldap_modify_s($ld,"cn=Mozilla $number,$BASE",$entry) != LDAP_SUCCESS)