comparison mail_imap_ssl.t @ 976:a8b8dd6e8ae1

Tests: changed startup order in mail tests for consistency. Notably, run_daemon() is postponed until after write_file_expand(). Also added waitforsocket() to avoid startup race.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 12 Jul 2016 20:51:06 +0300
parents c227348453db
children 1b11a12be179
comparison
equal deleted inserted replaced
975:e17ffab3febc 976:a8b8dd6e8ae1
31 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; 31 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
32 plan(skip_all => 'IO::Socket::SSL too old') if $@; 32 plan(skip_all => 'IO::Socket::SSL too old') if $@;
33 33
34 local $SIG{PIPE} = 'IGNORE'; 34 local $SIG{PIPE} = 'IGNORE';
35 35
36 my $t = Test::Nginx->new() 36 my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap http rewrite/)
37 ->has(qw/mail mail_ssl imap http rewrite/)->has_daemon('openssl') 37 ->has_daemon('openssl')->plan(12)
38 ->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon, port(8144)) 38 ->write_file_expand('nginx.conf', <<'EOF');
39 ->plan(12);
40
41 $t->write_file_expand('nginx.conf', <<'EOF');
42 39
43 %%TEST_GLOBALS%% 40 %%TEST_GLOBALS%%
44 41
45 daemon off; 42 daemon off;
46 43
136 . "-out '$d/$name.crt' -keyout '$d/$name.key' " 133 . "-out '$d/$name.crt' -keyout '$d/$name.key' "
137 . ">>$d/openssl.out 2>&1") == 0 134 . ">>$d/openssl.out 2>&1") == 0
138 or die "Can't create certificate for $name: $!\n"; 135 or die "Can't create certificate for $name: $!\n";
139 } 136 }
140 137
141 $t->run(); 138 $t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon);
139 $t->run()->waitforsocket('127.0.0.1:' . port(8144));
142 140
143 ############################################################################### 141 ###############################################################################
144 142
145 my $cred = sub { encode_base64("\0test\@example.com\0$_[0]", '') }; 143 my $cred = sub { encode_base64("\0test\@example.com\0$_[0]", '') };
146 my %ssl = ( 144 my %ssl = (