| 1 |
#!/usr/local/bin/perl -w |
| 2 |
|
| 3 |
# test.pl |
| 4 |
# Copyright (C) 1997 by USC/ISI |
| 5 |
# $Id: test_parsing.pl,v 1.1 2007-05-15 12:06:30 Daddy Exp $ |
| 6 |
# |
| 7 |
# Copyright (c) 1997 University of Southern California. |
| 8 |
# All rights reserved. |
| 9 |
# |
| 10 |
# Redistribution and use in source and binary forms are permitted |
| 11 |
# provided that the above copyright notice and this paragraph are |
| 12 |
# duplicated in all such forms and that any documentation, advertising |
| 13 |
# materials, and other materials related to such distribution and use |
| 14 |
# acknowledge that the software was developed by the University of |
| 15 |
# Southern California, Information Sciences Institute. The name of the |
| 16 |
# University may not be used to endorse or promote products derived from |
| 17 |
# this software without specific prior written permission. |
| 18 |
# |
| 19 |
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
| 20 |
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 21 |
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 22 |
|
| 23 |
sub usage |
| 24 |
{ |
| 25 |
print STDERR <<END; |
| 26 |
usage: $0 [-dIXuv] [-e SearchEngine] |
| 27 |
|
| 28 |
Runs WWW::Search tests. The default action (no arguments) is to run |
| 29 |
internal tests on all engines, then run external tests on all engines. |
| 30 |
|
| 31 |
Options: |
| 32 |
-e Yahoo,HotBot limit actions to certain Search Engine(s) |
| 33 |
-i run interal tests only |
| 34 |
-u update saved test files |
| 35 |
-v verbose (show commands) |
| 36 |
-x run external tests only |
| 37 |
END |
| 38 |
my $unused = <<'UNUSED'; |
| 39 |
To save a result to a file, use the search_to_file option of WebSearch. |
| 40 |
Something like: |
| 41 |
|
| 42 |
bin/WebSearch -e AltaVista::Web -o search_to_file=Test-Pages/AltaVista/Web/zero_result -- '+LSAM +No_SuchWord' |
| 43 |
UNUSED |
| 44 |
exit 1; |
| 45 |
} # usage |
| 46 |
|
| 47 |
use strict; |
| 48 |
|
| 49 |
# use Config; |
| 50 |
use Getopt::Long; |
| 51 |
use WWW::Search; |
| 52 |
use WWW::Search::Test; |
| 53 |
|
| 54 |
use vars qw( $verbose $debug $desired_search_engines $update_saved_files ); |
| 55 |
use vars qw( $do_internal $do_external ); |
| 56 |
$do_internal = $do_external = 0; |
| 57 |
undef $debug; |
| 58 |
$desired_search_engines = ''; |
| 59 |
&usage unless &GetOptions( |
| 60 |
'd:i' => \$debug, |
| 61 |
'e=s' => \$desired_search_engines, |
| 62 |
'u' => \$update_saved_files, |
| 63 |
'v' => \$verbose, |
| 64 |
'i' => \$do_internal, |
| 65 |
'x' => \$do_external, |
| 66 |
); |
| 67 |
($do_internal, $do_external) = (1,1) unless ($do_internal || $do_external); |
| 68 |
$debug = 1 if (defined($debug) and ($debug < 1)); |
| 69 |
|
| 70 |
my $oTest = new WWW::Search::Test($desired_search_engines); |
| 71 |
$oTest->{debug} = $debug; |
| 72 |
$oTest->{verbose} = $verbose; |
| 73 |
|
| 74 |
&main(); |
| 75 |
|
| 76 |
exit 0; |
| 77 |
|
| 78 |
sub test_cases |
| 79 |
{ |
| 80 |
my ($o, $query, $sSE, $sM, $file); |
| 81 |
my $bogus_query = $WWW::Search::Test::bogus_query; |
| 82 |
|
| 83 |
$sSE = 'AltaVista'; |
| 84 |
$sM = 'John Heidemann <[email protected]>'; |
| 85 |
|
| 86 |
$file = 'zero_result_no_plus'; |
| 87 |
$oTest->test($sSE, $sM, $file, $bogus_query, $TEST_EXACTLY); |
| 88 |
|
| 89 |
$file = 'zero_result'; |
| 90 |
$query = '+LSAM +' . $bogus_query; |
| 91 |
$oTest->test($sSE, $sM, $file, $query, $TEST_EXACTLY); |
| 92 |
|
| 93 |
$file = 'one_page_result'; |
| 94 |
$query = '+LS'.'AM +Aut'.'oSearch'; |
| 95 |
$oTest->test($sSE, $sM, $file, $query, $TEST_RANGE, 2, 10); |
| 96 |
|
| 97 |
$file = 'two_page_result'; |
| 98 |
$query = '+LS'.'AM +IS'.'I +Heide'.'mann'; |
| 99 |
$oTest->test($sSE, $sM, $file, $query, $TEST_GREATER_THAN, 10); |
| 100 |
|
| 101 |
###################################################################### |
| 102 |
|
| 103 |
$sSE = 'AltaVista::Web'; |
| 104 |
$sM = 'John Heidemann <[email protected]>'; |
| 105 |
|
| 106 |
$file = 'zero_result'; |
| 107 |
$query = '+LSA'.'M +' . $bogus_query; |
| 108 |
$oTest->test($sSE, $sM, $file, $query, $TEST_EXACTLY); |
| 109 |
|
| 110 |
$file = 'one_page_result'; |
| 111 |
$query = '+LSA'.'M +AutoSea'.'rch'; |
| 112 |
$oTest->test($sSE, $sM, $file, $query, $TEST_RANGE, 2, 10); |
| 113 |
|
| 114 |
$file = 'two_page_result'; |
| 115 |
$query = '+LSA'.'M +IS'.'I +I'.'B'; |
| 116 |
$oTest->test($sSE, $sM, $file, $query, $TEST_GREATER_THAN, 10); |
| 117 |
|
| 118 |
###################################################################### |
| 119 |
|
| 120 |
$sSE = 'AltaVista::AdvancedWeb'; |
| 121 |
$sM = 'John Heidemann <[email protected]>'; |
| 122 |
$oTest->not_working($sSE, $sM); |
| 123 |
# $query = 'LS'.'AM and ' . $bogus_query; |
| 124 |
# $oTest->test($sSE, $sM, 'zero', $query, $TEST_EXACTLY); |
| 125 |
# $query = 'LSA'.'M and AutoSea'.'rch'; |
| 126 |
# $oTest->test($sSE, $sM, 'one', $query, $TEST_RANGE, 2, 11); |
| 127 |
# $query = 'LSA'.'M and IS'.'I and I'.'B'; |
| 128 |
# $oTest->test($sSE, $sM, 'two', $query, $TEST_GREATER_THAN, 10); |
| 129 |
|
| 130 |
###################################################################### |
| 131 |
|
| 132 |
$sSE = 'AltaVista::News'; |
| 133 |
$sM = 'John Heidemann <[email protected]>'; |
| 134 |
$oTest->not_working($sSE, $sM); |
| 135 |
# $query = '+pe'.'rl +' . $bogus_query; |
| 136 |
# $oTest->test($sSE, $sM, 'zero', $query, $TEST_EXACTLY); |
| 137 |
# $query = '+Pe'.'rl +CP'.'AN'; |
| 138 |
# $oTest->test($sSE, $sM, 'multi', $query, $TEST_GREATER_THAN, 30); # 30 hits/page |
| 139 |
|
| 140 |
###################################################################### |
| 141 |
|
| 142 |
$sSE = 'AltaVista::AdvancedNews'; |
| 143 |
$sM = 'John Heidemann <[email protected]>'; |
| 144 |
$oTest->not_working($sSE, $sM); |
| 145 |
# $query = 'per'.'l and ' . $bogus_query; |
| 146 |
# $oTest->test($sSE, $sM, 'zero', $query, $TEST_EXACTLY); |
| 147 |
# $query = 'Per'.'l and CP'.'AN'; |
| 148 |
# $oTest->test($sSE, $sM, 'multi', $query, $TEST_GREATER_THAN, 70); # 30 hits/page |
| 149 |
|
| 150 |
###################################################################### |
| 151 |
|
| 152 |
$oTest->eval_test('AltaVista::Intranet'); |
| 153 |
|
| 154 |
###################################################################### |
| 155 |
|
| 156 |
$oTest->no_test('Crawler', 'unsupported'); |
| 157 |
# $oTest->test($sSE, $sM, 'zero', $bogus_query, $TEST_EXACTLY); |
| 158 |
# $query = 'Bay'.'reuth Bindl'.'acher Be'.'rg Flu'.'gplatz P'.'ilot'; |
| 159 |
# $oTest->test($sSE, $sM, 'one', $query, $TEST_RANGE, 2, 10); |
| 160 |
# # 10 hits/page |
| 161 |
# $query = 'Fra'.'nkfurter Al'.'lgemeine Sonnt'.'agszeitung Rech'.'erche'; |
| 162 |
# $oTest->test($sSE, $sM, 'two', $query, $TEST_GREATER_THAN, 10); |
| 163 |
|
| 164 |
###################################################################### |
| 165 |
|
| 166 |
$oTest->eval_test('Excite::News'); |
| 167 |
|
| 168 |
###################################################################### |
| 169 |
|
| 170 |
$sSE = 'ExciteForWebServers'; |
| 171 |
$sM = 'Paul Lindner <[email protected]>'; |
| 172 |
$oTest->not_working($sSE, $sM); |
| 173 |
# &test($sSE, $sM, 'zero', $bogus_query, $TEST_EXACTLY); |
| 174 |
# $query = 'bur'.'undi'; |
| 175 |
# &test($sSE, $sM, 'one', $query, $TEST_RANGE, 2, 99); |
| 176 |
|
| 177 |
###################################################################### |
| 178 |
|
| 179 |
$oTest->eval_test('Fireball'); |
| 180 |
|
| 181 |
###################################################################### |
| 182 |
|
| 183 |
$sSE = 'FolioViews'; |
| 184 |
$sM = 'Paul Lindner <[email protected]>'; |
| 185 |
$oTest->test($sSE, $sM, 'zero', $bogus_query, $TEST_EXACTLY); |
| 186 |
$query = 'bur'.'undi'; |
| 187 |
$oTest->test($sSE, $sM, 'one', $query, $TEST_RANGE, 2, 400); |
| 188 |
|
| 189 |
###################################################################### |
| 190 |
|
| 191 |
$oTest->eval_test('Google'); |
| 192 |
|
| 193 |
$oTest->no_test('Gopher', 'Paul Lindner <[email protected]>'); |
| 194 |
|
| 195 |
$oTest->eval_test('GoTo'); |
| 196 |
|
| 197 |
$oTest->eval_test('HotFiles'); |
| 198 |
|
| 199 |
$oTest->eval_test('Infoseek::Companies'); |
| 200 |
$oTest->eval_test('Infoseek::Email'); |
| 201 |
$oTest->eval_test('Infoseek::News'); |
| 202 |
$oTest->eval_test('Infoseek::Web'); |
| 203 |
|
| 204 |
$oTest->no_test('Livelink', 'Paul Lindner <[email protected]>'); |
| 205 |
|
| 206 |
$oTest->eval_test('LookSmart'); |
| 207 |
# use WWW::Search::LookSmart; |
| 208 |
# $oTest->no_test('LookSmart', $WWW::Search::LookSmart::MAINTAINER); |
| 209 |
|
| 210 |
$oTest->eval_test('Lycos'); |
| 211 |
|
| 212 |
$oTest->eval_test('Magellan'); |
| 213 |
|
| 214 |
$oTest->eval_test('MetaCrawler', 'Jim Smyser <[email protected]>'); |
| 215 |
|
| 216 |
###################################################################### |
| 217 |
|
| 218 |
$sSE = 'Metapedia'; |
| 219 |
$sM = 'Jim Smyser <[email protected]>'; |
| 220 |
|
| 221 |
$file = 'zero'; |
| 222 |
$oTest->test($sSE, $sM, $file, $bogus_query, $TEST_EXACTLY); |
| 223 |
|
| 224 |
###################################################################### |
| 225 |
|
| 226 |
$sSE = 'MSIndexServer'; |
| 227 |
$sM = 'Paul Lindner <[email protected]>'; |
| 228 |
$oTest->not_working($sSE, $sM); |
| 229 |
# $oTest->test($sSE, $sM, 'zero', $bogus_query, $TEST_EXACTLY); |
| 230 |
# $query = 'bur'.'undi'; |
| 231 |
# $oTest->test($sSE, $sM, 'one', $query, $TEST_RANGE, 2, 99); |
| 232 |
|
| 233 |
###################################################################### |
| 234 |
|
| 235 |
$oTest->eval_test('NetFind'); |
| 236 |
|
| 237 |
$oTest->eval_test('NorthernLight'); |
| 238 |
|
| 239 |
###################################################################### |
| 240 |
|
| 241 |
$sSE = 'Null'; |
| 242 |
$sM = 'Paul Lindner <[email protected]>'; |
| 243 |
$oTest->test($sSE, $sM, 'zero', $bogus_query, $TEST_EXACTLY); |
| 244 |
|
| 245 |
###################################################################### |
| 246 |
|
| 247 |
$oTest->eval_test('OpenDirectory'); |
| 248 |
|
| 249 |
###################################################################### |
| 250 |
|
| 251 |
$sSE = 'PLweb'; |
| 252 |
$sM = 'Paul Lindner <[email protected]>'; |
| 253 |
$oTest->not_working($sSE, $sM); |
| 254 |
# $oTest->test($sSE, $sM, 'zero', $bogus_query, $TEST_EXACTLY); |
| 255 |
# $query = 'bur'.'undi'; |
| 256 |
# $oTest->test($sSE, $sM, 'one', $query, $TEST_RANGE, 2, 99); |
| 257 |
|
| 258 |
###################################################################### |
| 259 |
|
| 260 |
$sSE = 'Search97'; |
| 261 |
$sM = 'Paul Lindner <[email protected]>'; |
| 262 |
$oTest->not_working($sSE, $sM); |
| 263 |
# $file = 'zero'; |
| 264 |
# $oTest->test($sSE, $sM, $file, $bogus_query, $TEST_EXACTLY); |
| 265 |
# $file = 'one'; |
| 266 |
# $query = 'bur'.'undi'; |
| 267 |
# $oTest->test($sSE, $sM, $file, $query, $TEST_RANGE, 2, 99); |
| 268 |
|
| 269 |
###################################################################### |
| 270 |
|
| 271 |
$sSE = 'SFgate'; |
| 272 |
$sM = 'Paul Lindner <[email protected]>'; |
| 273 |
$oTest->test($sSE, $sM, 'zero', $bogus_query, $TEST_EXACTLY); |
| 274 |
$query = 'bur'.'undi'; |
| 275 |
$oTest->test($sSE, $sM, 'one', $query, $TEST_RANGE, 2, 99); |
| 276 |
|
| 277 |
###################################################################### |
| 278 |
|
| 279 |
$oTest->no_test('Simple', 'Paul Lindner <[email protected]>'); |
| 280 |
|
| 281 |
$oTest->eval_test('Snap'); |
| 282 |
|
| 283 |
$oTest->no_test('Verity', 'Paul Lindner <[email protected]>'); |
| 284 |
|
| 285 |
$oTest->eval_test('WebCrawler'); |
| 286 |
|
| 287 |
$oTest->eval_test('ZDNet'); |
| 288 |
|
| 289 |
} # test_cases |
| 290 |
|
| 291 |
|
| 292 |
sub main |
| 293 |
{ |
| 294 |
# print "\nVERSION INFO:\n "; |
| 295 |
# my ($cmd) = &web_search_bin . " --VERSION"; |
| 296 |
# print `$cmd`; |
| 297 |
|
| 298 |
if ($update_saved_files) |
| 299 |
{ |
| 300 |
print "\nUPDATING.\n\n"; |
| 301 |
$oTest->mode($MODE_UPDATE); |
| 302 |
&test_cases(); |
| 303 |
# Can not do update AND test: |
| 304 |
return; |
| 305 |
} # if |
| 306 |
|
| 307 |
if ($do_internal) |
| 308 |
{ |
| 309 |
print "\nTESTING INTERNAL PARSING.\n (Errors here should be reported to the WWW::Search maintainer.)\n\n"; |
| 310 |
$oTest->reset_error_count; |
| 311 |
$oTest->mode($MODE_INTERNAL); |
| 312 |
&test_cases(); |
| 313 |
print "\n"; |
| 314 |
if ($oTest->{error_count} <= 0) |
| 315 |
{ |
| 316 |
print "All ", $oTest->mode, " tests have passed.\n\n"; |
| 317 |
} |
| 318 |
else |
| 319 |
{ |
| 320 |
print "Some ", $oTest->mode, " tests failed. Please check the README file before reporting errors (sometimes back-ends have known failures).\n"; |
| 321 |
} |
| 322 |
} # if $do_internal |
| 323 |
|
| 324 |
if ($do_external) |
| 325 |
{ |
| 326 |
print "\n\nTESTING EXTERNAL QUERIES.\n (Errors here suggest search-engine reformatting and should be\n reported to the maintainer of the back-end for the search engine.)\n\n"; |
| 327 |
$oTest->reset_error_count; |
| 328 |
$oTest->mode($MODE_EXTERNAL); |
| 329 |
&test_cases(); |
| 330 |
print "\n"; |
| 331 |
if ($oTest->{error_count} <= 0) |
| 332 |
{ |
| 333 |
print "All ", $oTest->mode, " tests have passed.\n\n"; |
| 334 |
} |
| 335 |
else |
| 336 |
{ |
| 337 |
print "Some ", $oTest->mode, " tests failed. Please check the README file before reporting errors (sometimes back-ends have known failures).\n"; |
| 338 |
} |
| 339 |
} # if $do_external |
| 340 |
} # main |
| 341 |
|
| 342 |
=head2 TO DO |
| 343 |
|
| 344 |
=over |
| 345 |
|
| 346 |
=item No identified needs at the moment... |
| 347 |
|
| 348 |
=back |
| 349 |
|
| 350 |
=head2 HOW IT WORKS |
| 351 |
|
| 352 |
At present there is only one function available, namely &test(). It |
| 353 |
takes at least 5 arguments. These are: 1) the name of the search |
| 354 |
engine (string); 2) the maintainer's name (and email address) |
| 355 |
(string); 3) a filename (unique among tests for this backend) |
| 356 |
(string); 4) the raw query string; 5) the test method (one of the |
| 357 |
constants $TEST_EXACTLY, $TEST_RANGE, $TEST_GREATER_THAN, |
| 358 |
$TEST_BY_COUNTING); optional arguments 6 and 7 are integers to be used |
| 359 |
when counting the results. |
| 360 |
|
| 361 |
The query is sent to the engine, and the results are compared to |
| 362 |
previously stored results as follows: If the method is $TEST_EXACTLY, |
| 363 |
the two lists of URLs must match exactly. If the method is |
| 364 |
$TEST_RANGE, the number of URLs must be between arg6 and arg7. If the |
| 365 |
method is $TEST_GREATER_THAN, the number of URLs must be greater than |
| 366 |
arg6. If the method is $TEST_BY_COUNTING, the number of URLs must be |
| 367 |
exactly arg6 (but we don't care what the URLs are). |
| 368 |
|
| 369 |
=cut |
| 370 |
|