Add ARM files
[dh-make-perl] / dev / arm / libio-socket-ssl-perl / libio-socket-ssl-perl-1.16 / .pc / disable_timebomb_tests.patch / t / compatibility.t
1 #!perl -w
2 # Before `make install' is performed this script should be runnable with
3 # `make test'. After `make install' it should work as `perl t/compatibility.t'
4
5 use IO::Socket::SSL;
6 use Socket;
7 eval {require "t/ssl_settings.req";} ||
8 eval {require "ssl_settings.req";};
9
10 $|=1;
11
12 foreach ($^O) {
13     if (/MacOS/ or /VOS/ or /vmesa/ or /riscos/ or /amigaos/) {
14         print "1..0 # Skipped: fork not implemented on this platform\n";
15         exit;
16     }
17 }
18
19 $SIG{'CHLD'} = "IGNORE";
20
21 print "1..9\n";
22 IO::Socket::SSL::context_init(SSL_verify_mode => 0x01, SSL_version => 'TLSv1' );
23
24
25 my $server = IO::Socket::INET->new(
26     LocalAddr => $SSL_SERVER_ADDR,
27     Listen => 1,
28     Proto => 'tcp', ReuseAddr => 1, Timeout => 15
29 );
30
31 if (!$server) {
32     print "Bail out! ";
33     print("Setup of test IO::Socket::INET client and server failed.  All the rest of ",
34           "the tests in this suite will fail also unless you change the values in ",
35           "ssl_settings.req in the t/ directory.");
36     exit;
37 }
38
39 my ($SSL_SERVER_PORT) = unpack_sockaddr_in( $server->sockname );
40
41 print "ok\n";
42
43 unless (fork) {
44     close $server;
45     $MyClass::client = new IO::Socket::INET("$SSL_SERVER_ADDR:$SSL_SERVER_PORT");
46     package MyClass;
47     use IO::Socket::SSL;
48     @ISA = "IO::Socket::SSL";
49     MyClass->start_SSL($client) || print "not ";
50     print "ok\n";
51     (ref($client) eq "MyClass") || print "not ";
52     print "ok\n";
53     $client->issuer_name || print "not ";
54     print "ok\n";
55     $client->subject_name || print "not ";
56     print "ok\n";
57     $client->opened || print "not ";
58     print "ok\n";
59     print $client "Ok to close\n";
60     close $client;
61     exit(0);
62 }
63
64 my $contact = $server->accept;
65
66 IO::Socket::SSL::socketToSSL($contact,
67                              {SSL_server => 1,
68                               SSL_verify_mode => 0}) || print "not ";
69 print "ok\n";
70 <$contact>;
71 close $contact;
72 close $server;
73
74 bless $contact, "MyClass";
75 print "not " if IO::Socket::SSL::socket_to_SSL($contact, SSL_server => 1);
76 print "ok\n";
77
78 print "not " unless (ref($contact) eq "MyClass");
79 print "ok\n";
80
81 sub bail {
82         print "Bail Out! $IO::Socket::SSL::ERROR";
83 }