2 # Before `make install' is performed this script should be runnable with
3 # `make test'. After `make install' it should work as `perl t/readline.t'
5 # This tests the behavior of readline with the variety of
8 # $/ '' - read up to next nonempty line: .*?\n\n+
9 # $/ s - read up to string s
10 # $/ \$num - read $num bytes
11 # scalar context - get first match
12 # array context - get all matches
19 if ( grep { $^O =~m{$_} } qw( MacOS VOS vmesa riscos amigaos ) ) {
20 print "1..0 # Skipped: fork not implemented on this platform\n";
26 "multi\nple\n\n1234567890line\n\n\n\nbla\n\nblubb\n\nblip",
31 ($b=<$c>) eq "multi\nple\n\n" || die "LFLF failed ($b)";
33 ($b=<$c>) eq "1234567890" || die "\\size failed ($b)";
35 ($b=<$c>) eq "line\n\n\n\n" || die "'' failed ($b)";
37 die "'' @ failed: @c" unless $c[0] eq "bla\n\n" &&
38 $c[1] eq "blubb\n\n" &&
39 $c[2] eq "blip" && @c == 3;
44 "some\nstring\nwith\nsome\nlines\nwhatever",
49 ($b=<$c>) eq "some\n" || die "LF failed ($b)";
51 ($b=<$c>) eq "string\nwith\nsome\nlines\nwhatever" || die "undef failed ($b)";
56 "some\nstring\nwith\nsome\nlines\nwhatever",
61 die "LF @ failed: @c" unless $c[0] eq "some\n" &&
62 $c[1] eq "string\n" && $c[2] eq "with\n" && $c[3] eq "some\n" &&
63 $c[4] eq "lines\n" && $c[5] eq "whatever" && @c == 6;
69 "some\nstring\nwith\nsome\nlines\nwhatever",
74 die "undef @ failed: @c" unless
75 $c[0] eq "some\nstring\nwith\nsome\nlines\nwhatever"
87 die "\\2 @ failed: @c" unless
88 $c[0] eq '12' && $c[1] eq '34' && $c[2] eq '56' &&
89 $c[3] eq '78' && $c[4] eq '90' && @c == 5;
95 print "1..".(1+3*@tests)."\n";
98 # first create simple ssl-server
100 my $addr = '127.0.0.1';
101 my $server = IO::Socket::SSL->new(
105 SSL_cert_file => "certs/server-cert.pem",
106 SSL_key_file => "certs/server-key.pem",
111 ok("Server Initialization");
113 # add server port to addr
114 $addr.= ':'.(sockaddr_in( getsockname( $server )))[0];
117 if ( !defined $pid ) {
118 die $!; # fork failed
120 } elsif ( $pid ) { ###### Server
122 foreach my $test (@tests) {
123 my $to_client = $server->accept || do {
124 notok( "accept failed: ".$server->errstr() );
128 ok( "Server accepted" );
129 $to_client->print($test->[0]);
137 my $testid = "Test00";
138 foreach my $test (@tests) {
139 my $to_server = IO::Socket::SSL->new( $addr ) || do {
140 notok( "connect failed: ".IO::Socket::SSL->errstr() );
143 ok( "client connected" );
144 eval { $test->[1]( $to_server ) };
145 $@ ? notok( "$testid $@" ) : ok( $testid );
151 sub ok { print "ok # [$ID] @_\n"; }
152 sub notok { print "not ok # [$ID] @_\n"; }