X-Git-Url: http://git.indexdata.com/?p=simpleserver-moved-to-github.git;a=blobdiff_plain;f=test.pl;h=022dcaf3a0ff33ba5b728a6901343d8dce497ed1;hp=b0a03de6731298deac96075f61ac31476eed32fa;hb=0bd288ae9f8333f0bb558792c31aff49900605cb;hpb=8aaa9b6ef2b98a5ac710343e826d469d926371d0 diff --git a/test.pl b/test.pl index b0a03de..022dcaf 100644 --- a/test.pl +++ b/test.pl @@ -6,7 +6,7 @@ # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) -BEGIN { $| = 1; print "1..1\n"; } +BEGIN { $| = 1; print "1..4\n"; } END {print "not ok 1\n" unless $loaded;} use Net::Z3950::SimpleServer; $loaded = 1; @@ -14,6 +14,12 @@ print "ok 1\n"; ######################### End of black magic. +print "not " if Net::Z3950::SimpleServer::yaz_diag_srw_to_bib1(11) != 3; +print "ok 2\n"; + +print "not " if Net::Z3950::SimpleServer::yaz_diag_bib1_to_srw(3) != 11; +print "ok 3\n"; + # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): @@ -76,27 +82,32 @@ sub my_close_handler { print "\nEverything is ok!\n"; } print "-----------------------------------------------\n"; + print "not " if $error; + print "ok 4\n"; } +my $socketFile = "/tmp/SimpleServer-test-$$"; +my $socket = "unix:$socketFile"; + if (!defined($pid = fork() )) { die "Cannot fork: $!\n"; } elsif ($pid) { ## Parent launches server - my $handler = Net::Z3950::SimpleServer->new({ + my $handler = Net::Z3950::SimpleServer->new( INIT => \&my_init_handler, CLOSE => \&my_close_handler, SEARCH => \&my_search_handler, - FETCH => \&my_fetch_handler }); + FETCH => \&my_fetch_handler); - $handler->launch_server("test.pl", "-1", @ARGV); + $handler->launch_server("test.pl", "-1", $socket); } else { ## Child starts the client sleep(1); - open(CLIENT, "| yaz-client tcp:localhost:9999 > /dev/null") + open(CLIENT, "| yaz-client $socket > /dev/null") or die "Couldn't fork client: $!\n"; print CLIENT "f test\n"; print CLIENT "s\n"; print CLIENT "close\n"; print CLIENT "quit\n"; close(CLIENT) or die "Couldn't close: $!\n"; + unlink($socketFile); } -