[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: test suite data



Howard Chu wrote:
Hallvard B Furuseth wrote:
Quanah Gibson-Mount writes:
Hm, for #2, some sort of intelligent sort, since LDAP doesn't support the
concept of ordered results, any test relying on order is fundamentally
flawed. ;)  That'd deal with all backends correctly, I would think.
ldapsearch -S "" sorts by DN.  But such a change cascades into large
changes to the testdata files, and IIRC there are a few tests where
a specific order is expected.  Don't quite remember.

Right, the glue tests expect a particular order. Don't recall if any others do.

So when testing back-ldif I modify scripts/acfilter.sh to sort some LDIF
output files before comparing them.  If Perl is present I sort by DN (I
think), and it could sort the lines in each entry too.  Probably loses
some possible errors, but not many.  E.g. where an LDIF to be compared
consists of the concatenated output of several commands.
Without Perl it just sorts line by line.  Better than nothing.
If anyone cares we could write an LDIF-sort program in C.

I think awk would be a better choice, since we already use it. I'll look into that.

This works with gawk:
#! /bin/sh
# $OpenLDAP: pkg/ldap/tests/scripts/acfilter.sh,v 1.13 2008/01/07 23:20:16 kurt Exp $
grep -v '^#' | awk 'BEGIN{FS="\n";RS=""}
{j=0;
for (i=1; i<=NF; i++){
if ($i ~ /^ /){
x[j] = x[j] "\n" $i;
} else {
j++; x[j] = $i
}
}
print x[1];
delete x[1];
j=asort(x);
for (i=1; i<=j; i++){
print x[i];
}
delete x;
print ""
}'


(all as a single line of text)

Unfortunately the asort() function is a GNU extension, so I think we have to pipe to the sort command instead:

grep -v '^#' | awk 'BEGIN{FS="\n";RS=""}{j=0; for (i=1; i<=NF; i++){ if ($i ~ /^ /) { x[j] = x[j] "\n" $i; } else { j++; x[j] = $i }} print x[1]; for (i=2; i<=j; i++){print x[i] | "sort +0";} delete x; close("sort +0"); print ""}'

--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/