Change sample command-line.
[irspy-moved-to-github.git] / bin / find-different-access-point.pl
1 #!/usr/bin/perl
2
3 #
4 # Run like this:
5 #       find-different-access-point.pl fish bagel:210/gils bagel:210/marc
6 # This is not an IRSpy program: it's a ZOOM-Perl program, which is
7 # used to find a BIB-1 attribute that is supported differently by two
8 # or more targets.  Using the output of this, it's possible to create
9 # an IRSpy test plugin that passes one server and fails another.
10
11 use strict;
12 use warnings;
13 use ZOOM;
14
15 if (@ARGV < 3) {
16     print STDERR "Usage $0 <PQF> <target1> <target2> [<target3> ...]";
17     exit 1;
18 }
19
20 my $query = shift(@ARGV);
21 my @conns = map { new ZOOM::Connection($_) } @ARGV;
22
23 print "$query\n";
24 print "@ARGV\n";
25 for (my $i = 1; $i < 9999; $i++) {
26     print "$i";
27     my $different = 0;
28     my $sofar = undef;
29     foreach my $conn (@conns) {
30         my $rs;
31         eval { $rs = $conn->search_pqf("\@attr 1=$i $query") };
32         my $ok = !$@;
33         print "\t", $ok ? "ok(" . $rs->size(). ")" : "FAIL($@)";
34         if (!defined $sofar) {
35             $sofar = $ok;
36         } elsif ($ok != $sofar) {
37             $different = 1;
38         }
39     }
40     print "\n";
41     last if $different;
42 }