| 1 |
package ProFTPD::Tests::Modules::mod_delay; |
| 2 |
|
| 3 |
use lib qw(t/lib); |
| 4 |
use base qw(ProFTPD::TestSuite::Child); |
| 5 |
use strict; |
| 6 |
|
| 7 |
use File::Path qw(mkpath); |
| 8 |
use File::Spec; |
| 9 |
use IO::Handle; |
| 10 |
use Time::HiRes qw(gettimeofday tv_interval); |
| 11 |
|
| 12 |
use ProFTPD::TestSuite::FTP; |
| 13 |
use ProFTPD::TestSuite::Utils qw(:auth :config :running :test :testsuite); |
| 14 |
|
| 15 |
$| = 1; |
| 16 |
|
| 17 |
my $order = 0; |
| 18 |
|
| 19 |
my $TESTS = { |
| 20 |
delay_cold_table => { |
| 21 |
order => ++$order, |
| 22 |
test_class => [qw(forking)], |
| 23 |
}, |
| 24 |
|
| 25 |
delay_warm_table => { |
| 26 |
order => ++$order, |
| 27 |
test_class => [qw(forking slow)], |
| 28 |
}, |
| 29 |
|
| 30 |
delay_extra_user_cmd_bug3622 => { |
| 31 |
order => ++$order, |
| 32 |
test_class => [qw(bug forking)], |
| 33 |
}, |
| 34 |
|
| 35 |
delay_extra_pass_cmd_bug3622 => { |
| 36 |
order => ++$order, |
| 37 |
test_class => [qw(bug forking)], |
| 38 |
}, |
| 39 |
|
| 40 |
delay_table_none_bug4020 => { |
| 41 |
order => ++$order, |
| 42 |
test_class => [qw(bug forking)], |
| 43 |
}, |
| 44 |
|
| 45 |
delay_delayonevent_user_bug4020 => { |
| 46 |
order => ++$order, |
| 47 |
test_class => [qw(bug forking)], |
| 48 |
}, |
| 49 |
|
| 50 |
delay_delayonevent_pass_bug4020 => { |
| 51 |
order => ++$order, |
| 52 |
test_class => [qw(bug forking)], |
| 53 |
}, |
| 54 |
|
| 55 |
delay_delayonevent_failedlogin_bug4020 => { |
| 56 |
order => ++$order, |
| 57 |
test_class => [qw(bug forking)], |
| 58 |
}, |
| 59 |
|
| 60 |
delay_delayonevent_user_pass_bug4020 => { |
| 61 |
order => ++$order, |
| 62 |
test_class => [qw(bug forking)], |
| 63 |
}, |
| 64 |
|
| 65 |
delay_table_default_issue1440 => { |
| 66 |
order => ++$order, |
| 67 |
test_class => [qw(bug forking)], |
| 68 |
}, |
| 69 |
|
| 70 |
delay_delayonevent_connect_issue1701 => { |
| 71 |
order => ++$order, |
| 72 |
test_class => [qw(bug forking)], |
| 73 |
}, |
| 74 |
|
| 75 |
}; |
| 76 |
|
| 77 |
sub new { |
| 78 |
return shift()->SUPER::new(@_); |
| 79 |
} |
| 80 |
|
| 81 |
sub list_tests { |
| 82 |
return testsuite_get_runnable_tests($TESTS); |
| 83 |
} |
| 84 |
|
| 85 |
sub delay_cold_table { |
| 86 |
my $self = shift; |
| 87 |
my $tmpdir = $self->{tmpdir}; |
| 88 |
my $setup = test_setup($tmpdir, 'delay'); |
| 89 |
|
| 90 |
my $delay_tab = File::Spec->rel2abs("$setup->{home_dir}/delay.tab"); |
| 91 |
|
| 92 |
my $config = { |
| 93 |
PidFile => $setup->{pid_file}, |
| 94 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 95 |
SystemLog => $setup->{log_file}, |
| 96 |
TraceLog => $setup->{log_file}, |
| 97 |
Trace => 'delay:20', |
| 98 |
|
| 99 |
AuthUserFile => $setup->{auth_user_file}, |
| 100 |
AuthGroupFile => $setup->{auth_group_file}, |
| 101 |
AuthOrder => 'mod_auth_file.c', |
| 102 |
|
| 103 |
IfModules => { |
| 104 |
'mod_delay.c' => { |
| 105 |
DelayTable => $delay_tab, |
| 106 |
}, |
| 107 |
}, |
| 108 |
}; |
| 109 |
|
| 110 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 111 |
$config); |
| 112 |
|
| 113 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 114 |
# the child will indicate when it's done with its test by writing a message |
| 115 |
# to the parent. |
| 116 |
my ($rfh, $wfh); |
| 117 |
unless (pipe($rfh, $wfh)) { |
| 118 |
die("Can't open pipe: $!"); |
| 119 |
} |
| 120 |
|
| 121 |
my $ex; |
| 122 |
|
| 123 |
# Fork child |
| 124 |
$self->handle_sigchld(); |
| 125 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 126 |
if ($pid) { |
| 127 |
eval { |
| 128 |
# Allow for server startup |
| 129 |
sleep(2); |
| 130 |
|
| 131 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port); |
| 132 |
$client->login($setup->{user}, $setup->{passwd}); |
| 133 |
$client->quit(); |
| 134 |
}; |
| 135 |
if ($@) { |
| 136 |
$ex = $@; |
| 137 |
} |
| 138 |
|
| 139 |
$wfh->print("done\n"); |
| 140 |
$wfh->flush(); |
| 141 |
|
| 142 |
} else { |
| 143 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 144 |
if ($@) { |
| 145 |
warn($@); |
| 146 |
exit 1; |
| 147 |
} |
| 148 |
|
| 149 |
exit 0; |
| 150 |
} |
| 151 |
|
| 152 |
# Stop server |
| 153 |
server_stop($setup->{pid_file}); |
| 154 |
$self->assert_child_ok($pid); |
| 155 |
|
| 156 |
test_cleanup($setup->{log_file}, $ex); |
| 157 |
} |
| 158 |
|
| 159 |
sub delay_warm_table { |
| 160 |
my $self = shift; |
| 161 |
my $tmpdir = $self->{tmpdir}; |
| 162 |
my $setup = test_setup($tmpdir, 'delay'); |
| 163 |
|
| 164 |
my $delay_tab = File::Spec->rel2abs("$setup->{home_dir}/delay.tab"); |
| 165 |
|
| 166 |
# In order to warm up the DelayTable, we need to fill its columns, |
| 167 |
# which means more than 256 logins before the table is "warm". |
| 168 |
my $nlogins = 300; |
| 169 |
|
| 170 |
my $timeout = ($nlogins * 2); |
| 171 |
|
| 172 |
my $config = { |
| 173 |
PidFile => $setup->{pid_file}, |
| 174 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 175 |
SystemLog => $setup->{log_file}, |
| 176 |
TraceLog => $setup->{log_file}, |
| 177 |
Trace => 'delay:20', |
| 178 |
|
| 179 |
AuthUserFile => $setup->{auth_user_file}, |
| 180 |
AuthGroupFile => $setup->{auth_group_file}, |
| 181 |
AuthOrder => 'mod_auth_file.c', |
| 182 |
|
| 183 |
IfModules => { |
| 184 |
'mod_delay.c' => { |
| 185 |
DelayTable => $delay_tab, |
| 186 |
}, |
| 187 |
}, |
| 188 |
}; |
| 189 |
|
| 190 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 191 |
$config); |
| 192 |
|
| 193 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 194 |
# the child will indicate when it's done with its test by writing a message |
| 195 |
# to the parent. |
| 196 |
my ($rfh, $wfh); |
| 197 |
unless (pipe($rfh, $wfh)) { |
| 198 |
die("Can't open pipe: $!"); |
| 199 |
} |
| 200 |
|
| 201 |
my $ex; |
| 202 |
|
| 203 |
# Fork child |
| 204 |
$self->handle_sigchld(); |
| 205 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 206 |
if ($pid) { |
| 207 |
eval { |
| 208 |
# Allow for server startup |
| 209 |
sleep(2); |
| 210 |
|
| 211 |
my $max_elapsed = -1; |
| 212 |
|
| 213 |
for (my $i = 0; $i < $nlogins; $i++) { |
| 214 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port); |
| 215 |
|
| 216 |
my $start = [gettimeofday()]; |
| 217 |
$client->login($setup->{user}, $setup->{passwd}); |
| 218 |
my $elapsed = tv_interval($start); |
| 219 |
|
| 220 |
$client->quit(); |
| 221 |
|
| 222 |
if ($elapsed > $max_elapsed) { |
| 223 |
$max_elapsed = $elapsed; |
| 224 |
} |
| 225 |
|
| 226 |
if ($ENV{TEST_VERBOSE}) { |
| 227 |
if ($i % 50 == 0) { |
| 228 |
print STDERR " + login #", $i + 1, " (max elapsed = $max_elapsed)\n"; |
| 229 |
} |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
if ($ENV{TEST_VERBOSE}) { |
| 234 |
print STDERR " + max elapsed = $max_elapsed\n"; |
| 235 |
} |
| 236 |
}; |
| 237 |
if ($@) { |
| 238 |
$ex = $@; |
| 239 |
} |
| 240 |
|
| 241 |
$wfh->print("done\n"); |
| 242 |
$wfh->flush(); |
| 243 |
|
| 244 |
} else { |
| 245 |
eval { server_wait($setup->{config_file}, $rfh, $timeout) }; |
| 246 |
if ($@) { |
| 247 |
warn($@); |
| 248 |
exit 1; |
| 249 |
} |
| 250 |
|
| 251 |
exit 0; |
| 252 |
} |
| 253 |
|
| 254 |
# Stop server |
| 255 |
server_stop($setup->{pid_file}); |
| 256 |
$self->assert_child_ok($pid); |
| 257 |
|
| 258 |
test_cleanup($setup->{log_file}, $ex); |
| 259 |
} |
| 260 |
|
| 261 |
sub delay_extra_user_cmd_bug3622 { |
| 262 |
my $self = shift; |
| 263 |
my $tmpdir = $self->{tmpdir}; |
| 264 |
my $setup = test_setup($tmpdir, 'delay'); |
| 265 |
|
| 266 |
my $delay_tab = File::Spec->rel2abs("$tmpdir/delay.tab"); |
| 267 |
|
| 268 |
my $config = { |
| 269 |
PidFile => $setup->{pid_file}, |
| 270 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 271 |
SystemLog => $setup->{log_file}, |
| 272 |
TraceLog => $setup->{log_file}, |
| 273 |
Trace => 'delay:20', |
| 274 |
|
| 275 |
AuthUserFile => $setup->{auth_user_file}, |
| 276 |
AuthGroupFile => $setup->{auth_group_file}, |
| 277 |
AuthOrder => 'mod_auth_file.c', |
| 278 |
|
| 279 |
IfModules => { |
| 280 |
'mod_delay.c' => { |
| 281 |
DelayTable => $delay_tab, |
| 282 |
}, |
| 283 |
}, |
| 284 |
}; |
| 285 |
|
| 286 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 287 |
$config); |
| 288 |
|
| 289 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 290 |
# the child will indicate when it's done with its test by writing a message |
| 291 |
# to the parent. |
| 292 |
my ($rfh, $wfh); |
| 293 |
unless (pipe($rfh, $wfh)) { |
| 294 |
die("Can't open pipe: $!"); |
| 295 |
} |
| 296 |
|
| 297 |
my $ex; |
| 298 |
|
| 299 |
# Fork child |
| 300 |
$self->handle_sigchld(); |
| 301 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 302 |
if ($pid) { |
| 303 |
eval { |
| 304 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port); |
| 305 |
$client->login($setup->{user}, $setup->{passwd}); |
| 306 |
|
| 307 |
# Note that, with Bug#4217, a second USER command will succeed. |
| 308 |
eval { $client->user($setup->{user}) }; |
| 309 |
if ($@) { |
| 310 |
die("USER failed: " . $client->response_code() . ' ' . |
| 311 |
$client->response_msg()); |
| 312 |
} |
| 313 |
|
| 314 |
my $resp_code = $client->response_code(); |
| 315 |
my $resp_msg = $client->response_msg(); |
| 316 |
|
| 317 |
my $expected = 230; |
| 318 |
$self->assert($expected == $resp_code, |
| 319 |
test_msg("Expected response code $expected, got $resp_code")); |
| 320 |
|
| 321 |
$expected = "User $setup->{user} logged in"; |
| 322 |
$self->assert($expected eq $resp_msg, |
| 323 |
test_msg("Expected response message '$expected', got '$resp_msg'")); |
| 324 |
|
| 325 |
$client->quit(); |
| 326 |
}; |
| 327 |
if ($@) { |
| 328 |
$ex = $@; |
| 329 |
} |
| 330 |
|
| 331 |
$wfh->print("done\n"); |
| 332 |
$wfh->flush(); |
| 333 |
|
| 334 |
} else { |
| 335 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 336 |
if ($@) { |
| 337 |
warn($@); |
| 338 |
exit 1; |
| 339 |
} |
| 340 |
|
| 341 |
exit 0; |
| 342 |
} |
| 343 |
|
| 344 |
# Stop server |
| 345 |
server_stop($setup->{pid_file}); |
| 346 |
$self->assert_child_ok($pid); |
| 347 |
|
| 348 |
test_cleanup($setup->{log_file}, $ex) if $ex; |
| 349 |
|
| 350 |
# Examine the TraceLog, looking for "unable to load DelayTable" messages. |
| 351 |
# There shouldn't be any. |
| 352 |
|
| 353 |
eval { |
| 354 |
if (open(my $fh, "< $setup->{log_file}")) { |
| 355 |
my $ok = 1; |
| 356 |
my $expected = '\[\d+\]\s+<(\S+):(\d+)>: (.*?)$'; |
| 357 |
|
| 358 |
while (my $line = <$fh>) { |
| 359 |
chomp($line); |
| 360 |
|
| 361 |
if ($ENV{TEST_VERBOSE}) { |
| 362 |
print STDERR "# $line\n"; |
| 363 |
} |
| 364 |
|
| 365 |
if ($line =~ /$expected/) { |
| 366 |
my $trace_channel = $1; |
| 367 |
my $trace_level = $2; |
| 368 |
my $trace_msg = $3; |
| 369 |
|
| 370 |
next unless $trace_channel eq 'delay'; |
| 371 |
|
| 372 |
if ($trace_msg =~ /unable to load DelayTable/) { |
| 373 |
$ok = 0; |
| 374 |
last; |
| 375 |
} |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
close($fh); |
| 380 |
$self->assert($ok, test_msg("Trace messages appeared unexpectedly")); |
| 381 |
|
| 382 |
} else { |
| 383 |
die("Can't open $setup->{log_file}: $!"); |
| 384 |
} |
| 385 |
}; |
| 386 |
if ($@) { |
| 387 |
$ex = $@; |
| 388 |
} |
| 389 |
|
| 390 |
test_cleanup($setup->{log_file}, $ex); |
| 391 |
} |
| 392 |
|
| 393 |
sub delay_extra_pass_cmd_bug3622 { |
| 394 |
my $self = shift; |
| 395 |
my $tmpdir = $self->{tmpdir}; |
| 396 |
my $setup = test_setup($tmpdir, 'delay'); |
| 397 |
|
| 398 |
my $delay_tab = File::Spec->rel2abs("$setup->{home_dir}/delay.tab"); |
| 399 |
|
| 400 |
my $config = { |
| 401 |
PidFile => $setup->{pid_file}, |
| 402 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 403 |
SystemLog => $setup->{log_file}, |
| 404 |
TraceLog => $setup->{log_file}, |
| 405 |
Trace => 'delay:20', |
| 406 |
|
| 407 |
AuthUserFile => $setup->{auth_user_file}, |
| 408 |
AuthGroupFile => $setup->{auth_group_file}, |
| 409 |
AuthOrder => 'mod_auth_file.c', |
| 410 |
|
| 411 |
IfModules => { |
| 412 |
'mod_delay.c' => { |
| 413 |
DelayTable => $delay_tab, |
| 414 |
}, |
| 415 |
}, |
| 416 |
}; |
| 417 |
|
| 418 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 419 |
$config); |
| 420 |
|
| 421 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 422 |
# the child will indicate when it's done with its test by writing a message |
| 423 |
# to the parent. |
| 424 |
my ($rfh, $wfh); |
| 425 |
unless (pipe($rfh, $wfh)) { |
| 426 |
die("Can't open pipe: $!"); |
| 427 |
} |
| 428 |
|
| 429 |
my $ex; |
| 430 |
|
| 431 |
# Fork child |
| 432 |
$self->handle_sigchld(); |
| 433 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 434 |
if ($pid) { |
| 435 |
eval { |
| 436 |
# Allow for server startup |
| 437 |
sleep(2); |
| 438 |
|
| 439 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port); |
| 440 |
$client->login($setup->{user}, $setup->{passwd}); |
| 441 |
|
| 442 |
eval { $client->pass($setup->{passwd}) }; |
| 443 |
unless ($@) { |
| 444 |
die("Second PASS command succeeded unexpectedly"); |
| 445 |
} |
| 446 |
|
| 447 |
my $resp_code = $client->response_code(); |
| 448 |
my $resp_msg = $client->response_msg(); |
| 449 |
|
| 450 |
my $expected = 503; |
| 451 |
$self->assert($expected == $resp_code, |
| 452 |
test_msg("Expected response code $expected, got $resp_code")); |
| 453 |
|
| 454 |
$expected = 'You are already logged in'; |
| 455 |
$self->assert($expected eq $resp_msg, |
| 456 |
test_msg("Expected response message '$expected', got '$resp_msg'")); |
| 457 |
|
| 458 |
$client->quit(); |
| 459 |
}; |
| 460 |
if ($@) { |
| 461 |
$ex = $@; |
| 462 |
} |
| 463 |
|
| 464 |
$wfh->print("done\n"); |
| 465 |
$wfh->flush(); |
| 466 |
|
| 467 |
} else { |
| 468 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 469 |
if ($@) { |
| 470 |
warn($@); |
| 471 |
exit 1; |
| 472 |
} |
| 473 |
|
| 474 |
exit 0; |
| 475 |
} |
| 476 |
|
| 477 |
# Stop server |
| 478 |
server_stop($setup->{pid_file}); |
| 479 |
$self->assert_child_ok($pid); |
| 480 |
|
| 481 |
test_cleanup($setup->{log_file}, $ex) if $ex; |
| 482 |
|
| 483 |
# Examine the TraceLog, looking for "unable to load DelayTable" messages. |
| 484 |
# There shouldn't be any. |
| 485 |
|
| 486 |
eval { |
| 487 |
if (open(my $fh, "< $setup->{log_file}")) { |
| 488 |
my $ok = 1; |
| 489 |
|
| 490 |
while (my $line = <$fh>) { |
| 491 |
chomp($line); |
| 492 |
|
| 493 |
my $expected = '\[\d+\]\s+<(\S+):(\d+)>: (.*?)$'; |
| 494 |
|
| 495 |
if ($line =~ /$expected/) { |
| 496 |
my $trace_channel = $1; |
| 497 |
my $trace_level = $2; |
| 498 |
my $trace_msg = $3; |
| 499 |
|
| 500 |
next unless $trace_channel eq 'delay'; |
| 501 |
|
| 502 |
if ($trace_msg =~ /unable to load DelayTable/) { |
| 503 |
$ok = 0; |
| 504 |
last; |
| 505 |
} |
| 506 |
} |
| 507 |
} |
| 508 |
|
| 509 |
close($fh); |
| 510 |
|
| 511 |
$self->assert($ok, test_msg("Trace messages appeared unexpectedly")); |
| 512 |
|
| 513 |
} else { |
| 514 |
die("Can't open $setup->{log_file}: $!"); |
| 515 |
} |
| 516 |
}; |
| 517 |
if ($@) { |
| 518 |
$ex = $@; |
| 519 |
} |
| 520 |
|
| 521 |
test_cleanup($setup->{log_file}, $ex); |
| 522 |
} |
| 523 |
|
| 524 |
sub delay_table_none_bug4020 { |
| 525 |
my $self = shift; |
| 526 |
my $tmpdir = $self->{tmpdir}; |
| 527 |
my $setup = test_setup($tmpdir, 'delay'); |
| 528 |
|
| 529 |
my $config = { |
| 530 |
PidFile => $setup->{pid_file}, |
| 531 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 532 |
SystemLog => $setup->{log_file}, |
| 533 |
TraceLog => $setup->{log_file}, |
| 534 |
Trace => 'delay:20', |
| 535 |
|
| 536 |
AuthUserFile => $setup->{auth_user_file}, |
| 537 |
AuthGroupFile => $setup->{auth_group_file}, |
| 538 |
AuthOrder => 'mod_auth_file.c', |
| 539 |
|
| 540 |
IfModules => { |
| 541 |
'mod_delay.c' => { |
| 542 |
DelayTable => 'none', |
| 543 |
}, |
| 544 |
}, |
| 545 |
}; |
| 546 |
|
| 547 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 548 |
$config); |
| 549 |
|
| 550 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 551 |
# the child will indicate when it's done with its test by writing a message |
| 552 |
# to the parent. |
| 553 |
my ($rfh, $wfh); |
| 554 |
unless (pipe($rfh, $wfh)) { |
| 555 |
die("Can't open pipe: $!"); |
| 556 |
} |
| 557 |
|
| 558 |
my $ex; |
| 559 |
|
| 560 |
# Fork child |
| 561 |
$self->handle_sigchld(); |
| 562 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 563 |
if ($pid) { |
| 564 |
eval { |
| 565 |
# Allow for server startup |
| 566 |
sleep(2); |
| 567 |
|
| 568 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port); |
| 569 |
$client->login($setup->{user}, $setup->{passwd}); |
| 570 |
$client->quit(); |
| 571 |
}; |
| 572 |
if ($@) { |
| 573 |
$ex = $@; |
| 574 |
} |
| 575 |
|
| 576 |
$wfh->print("done\n"); |
| 577 |
$wfh->flush(); |
| 578 |
|
| 579 |
} else { |
| 580 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 581 |
if ($@) { |
| 582 |
warn($@); |
| 583 |
exit 1; |
| 584 |
} |
| 585 |
|
| 586 |
exit 0; |
| 587 |
} |
| 588 |
|
| 589 |
# Stop server |
| 590 |
server_stop($setup->{pid_file}); |
| 591 |
$self->assert_child_ok($pid); |
| 592 |
|
| 593 |
test_cleanup($setup->{log_file}, $ex) if $ex; |
| 594 |
|
| 595 |
# Examine the TraceLog, looking for "unable to load DelayTable" messages. |
| 596 |
# There shouldn't be any. |
| 597 |
|
| 598 |
eval { |
| 599 |
if (open(my $fh, "< $setup->{log_file}")) { |
| 600 |
my $ok = 1; |
| 601 |
|
| 602 |
while (my $line = <$fh>) { |
| 603 |
chomp($line); |
| 604 |
|
| 605 |
my $expected = '\[\d+\]\s+<(\S+):(\d+)>: (.*?)$'; |
| 606 |
|
| 607 |
if ($line =~ /$expected/) { |
| 608 |
my $trace_channel = $1; |
| 609 |
my $trace_level = $2; |
| 610 |
my $trace_msg = $3; |
| 611 |
|
| 612 |
next unless $trace_channel eq 'delay'; |
| 613 |
|
| 614 |
if ($trace_msg =~ /(unable to load|error opening) DelayTable/) { |
| 615 |
$ok = 0; |
| 616 |
|
| 617 |
if ($ENV{TEST_VERBOSE}) { |
| 618 |
print STDERR " + unexpected TraceLog line: $line\n"; |
| 619 |
} |
| 620 |
|
| 621 |
last; |
| 622 |
} |
| 623 |
} |
| 624 |
} |
| 625 |
|
| 626 |
close($fh); |
| 627 |
|
| 628 |
$self->assert($ok, test_msg("Trace messages appeared unexpectedly")); |
| 629 |
|
| 630 |
} else { |
| 631 |
die("Can't open $setup->{log_file}: $!"); |
| 632 |
} |
| 633 |
}; |
| 634 |
if ($@) { |
| 635 |
$ex = $@; |
| 636 |
} |
| 637 |
|
| 638 |
test_cleanup($setup->{log_file}, $ex); |
| 639 |
} |
| 640 |
|
| 641 |
sub delay_delayonevent_user_bug4020 { |
| 642 |
my $self = shift; |
| 643 |
my $tmpdir = $self->{tmpdir}; |
| 644 |
my $setup = test_setup($tmpdir, 'delay'); |
| 645 |
|
| 646 |
my $user_delay_secs = 2; |
| 647 |
|
| 648 |
my $config = { |
| 649 |
PidFile => $setup->{pid_file}, |
| 650 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 651 |
SystemLog => $setup->{log_file}, |
| 652 |
TraceLog => $setup->{log_file}, |
| 653 |
Trace => 'delay:20', |
| 654 |
|
| 655 |
AuthUserFile => $setup->{auth_user_file}, |
| 656 |
AuthGroupFile => $setup->{auth_group_file}, |
| 657 |
AuthOrder => 'mod_auth_file.c', |
| 658 |
|
| 659 |
IfModules => { |
| 660 |
'mod_delay.c' => { |
| 661 |
DelayTable => 'none', |
| 662 |
DelayOnEvent => 'USER 2000ms', |
| 663 |
}, |
| 664 |
}, |
| 665 |
}; |
| 666 |
|
| 667 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 668 |
$config); |
| 669 |
|
| 670 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 671 |
# the child will indicate when it's done with its test by writing a message |
| 672 |
# to the parent. |
| 673 |
my ($rfh, $wfh); |
| 674 |
unless (pipe($rfh, $wfh)) { |
| 675 |
die("Can't open pipe: $!"); |
| 676 |
} |
| 677 |
|
| 678 |
my $ex; |
| 679 |
|
| 680 |
# Fork child |
| 681 |
$self->handle_sigchld(); |
| 682 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 683 |
if ($pid) { |
| 684 |
eval { |
| 685 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port, 0, |
| 686 |
$user_delay_secs + 2); |
| 687 |
|
| 688 |
my $start = [gettimeofday()]; |
| 689 |
$client->login($setup->{user}, $setup->{passwd}); |
| 690 |
my $elapsed = tv_interval($start); |
| 691 |
|
| 692 |
$client->quit(); |
| 693 |
|
| 694 |
if ($ENV{TEST_VERBOSE}) { |
| 695 |
print STDERR "Elapsed login time: $elapsed secs\n"; |
| 696 |
} |
| 697 |
|
| 698 |
if ($elapsed < $user_delay_secs) { |
| 699 |
die("Expected at least $user_delay_secs sec delay, got $elapsed"); |
| 700 |
} |
| 701 |
}; |
| 702 |
if ($@) { |
| 703 |
$ex = $@; |
| 704 |
} |
| 705 |
|
| 706 |
$wfh->print("done\n"); |
| 707 |
$wfh->flush(); |
| 708 |
|
| 709 |
} else { |
| 710 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 711 |
if ($@) { |
| 712 |
warn($@); |
| 713 |
exit 1; |
| 714 |
} |
| 715 |
|
| 716 |
exit 0; |
| 717 |
} |
| 718 |
|
| 719 |
# Stop server |
| 720 |
server_stop($setup->{pid_file}); |
| 721 |
$self->assert_child_ok($pid); |
| 722 |
|
| 723 |
test_cleanup($setup->{log_file}, $ex); |
| 724 |
} |
| 725 |
|
| 726 |
sub delay_delayonevent_pass_bug4020 { |
| 727 |
my $self = shift; |
| 728 |
my $tmpdir = $self->{tmpdir}; |
| 729 |
my $setup = test_setup($tmpdir, 'delay'); |
| 730 |
|
| 731 |
my $pass_delay_secs = 2; |
| 732 |
|
| 733 |
my $config = { |
| 734 |
PidFile => $setup->{pid_file}, |
| 735 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 736 |
SystemLog => $setup->{log_file}, |
| 737 |
TraceLog => $setup->{log_file}, |
| 738 |
Trace => 'delay:20', |
| 739 |
|
| 740 |
AuthUserFile => $setup->{auth_user_file}, |
| 741 |
AuthGroupFile => $setup->{auth_group_file}, |
| 742 |
AuthOrder => 'mod_auth_file.c', |
| 743 |
|
| 744 |
IfModules => { |
| 745 |
'mod_delay.c' => { |
| 746 |
DelayTable => 'none', |
| 747 |
DelayOnEvent => 'PASS 2000', |
| 748 |
}, |
| 749 |
}, |
| 750 |
}; |
| 751 |
|
| 752 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 753 |
$config); |
| 754 |
|
| 755 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 756 |
# the child will indicate when it's done with its test by writing a message |
| 757 |
# to the parent. |
| 758 |
my ($rfh, $wfh); |
| 759 |
unless (pipe($rfh, $wfh)) { |
| 760 |
die("Can't open pipe: $!"); |
| 761 |
} |
| 762 |
|
| 763 |
my $ex; |
| 764 |
|
| 765 |
# Fork child |
| 766 |
$self->handle_sigchld(); |
| 767 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 768 |
if ($pid) { |
| 769 |
eval { |
| 770 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port, 0, |
| 771 |
$pass_delay_secs + 2); |
| 772 |
|
| 773 |
my $start = [gettimeofday()]; |
| 774 |
eval { $client->login($setup->{user}, 'foobar') }; |
| 775 |
unless ($@) { |
| 776 |
die("Login succeeded unexpectedly"); |
| 777 |
} |
| 778 |
my $elapsed = tv_interval($start); |
| 779 |
|
| 780 |
if ($ENV{TEST_VERBOSE}) { |
| 781 |
print STDERR "Elapsed login time: $elapsed secs\n"; |
| 782 |
} |
| 783 |
|
| 784 |
if ($elapsed < $pass_delay_secs) { |
| 785 |
die("Expected at least $pass_delay_secs sec delay, got $elapsed"); |
| 786 |
} |
| 787 |
|
| 788 |
$start = [gettimeofday()]; |
| 789 |
$client->login($setup->{user}, $setup->{passwd}); |
| 790 |
$elapsed = tv_interval($start); |
| 791 |
|
| 792 |
$client->quit(); |
| 793 |
|
| 794 |
if ($ENV{TEST_VERBOSE}) { |
| 795 |
print STDERR "Elapsed login time: $elapsed secs\n"; |
| 796 |
} |
| 797 |
|
| 798 |
if ($elapsed < $pass_delay_secs) { |
| 799 |
die("Expected at least $pass_delay_secs sec delay, got $elapsed"); |
| 800 |
} |
| 801 |
}; |
| 802 |
if ($@) { |
| 803 |
$ex = $@; |
| 804 |
} |
| 805 |
|
| 806 |
$wfh->print("done\n"); |
| 807 |
$wfh->flush(); |
| 808 |
|
| 809 |
} else { |
| 810 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 811 |
if ($@) { |
| 812 |
warn($@); |
| 813 |
exit 1; |
| 814 |
} |
| 815 |
|
| 816 |
exit 0; |
| 817 |
} |
| 818 |
|
| 819 |
# Stop server |
| 820 |
server_stop($setup->{pid_file}); |
| 821 |
$self->assert_child_ok($pid); |
| 822 |
|
| 823 |
test_cleanup($setup->{log_file}, $ex); |
| 824 |
} |
| 825 |
|
| 826 |
sub delay_delayonevent_failedlogin_bug4020 { |
| 827 |
my $self = shift; |
| 828 |
my $tmpdir = $self->{tmpdir}; |
| 829 |
my $setup = test_setup($tmpdir, 'delay'); |
| 830 |
|
| 831 |
my $failed_delay_secs = 2; |
| 832 |
|
| 833 |
my $config = { |
| 834 |
PidFile => $setup->{pid_file}, |
| 835 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 836 |
SystemLog => $setup->{log_file}, |
| 837 |
TraceLog => $setup->{log_file}, |
| 838 |
Trace => 'delay:20', |
| 839 |
|
| 840 |
AuthUserFile => $setup->{auth_user_file}, |
| 841 |
AuthGroupFile => $setup->{auth_group_file}, |
| 842 |
AuthOrder => 'mod_auth_file.c', |
| 843 |
|
| 844 |
IfModules => { |
| 845 |
'mod_delay.c' => { |
| 846 |
DelayTable => 'none', |
| 847 |
DelayOnEvent => 'FailedLogin 2000', |
| 848 |
}, |
| 849 |
}, |
| 850 |
}; |
| 851 |
|
| 852 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 853 |
$config); |
| 854 |
|
| 855 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 856 |
# the child will indicate when it's done with its test by writing a message |
| 857 |
# to the parent. |
| 858 |
my ($rfh, $wfh); |
| 859 |
unless (pipe($rfh, $wfh)) { |
| 860 |
die("Can't open pipe: $!"); |
| 861 |
} |
| 862 |
|
| 863 |
my $ex; |
| 864 |
|
| 865 |
# Fork child |
| 866 |
$self->handle_sigchld(); |
| 867 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 868 |
if ($pid) { |
| 869 |
eval { |
| 870 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port, 0, |
| 871 |
$failed_delay_secs + 2); |
| 872 |
|
| 873 |
my $start = [gettimeofday()]; |
| 874 |
eval { $client->login($setup->{user}, 'foobar') }; |
| 875 |
unless ($@) { |
| 876 |
die("Login succeeded unexpectedly"); |
| 877 |
} |
| 878 |
my $elapsed = tv_interval($start); |
| 879 |
|
| 880 |
if ($ENV{TEST_VERBOSE}) { |
| 881 |
print STDERR "Elapsed login time: $elapsed secs\n"; |
| 882 |
} |
| 883 |
|
| 884 |
if ($elapsed < $failed_delay_secs) { |
| 885 |
die("Expected at least $failed_delay_secs sec delay, got $elapsed"); |
| 886 |
} |
| 887 |
|
| 888 |
$start = [gettimeofday()]; |
| 889 |
$client->login($setup->{user}, $setup->{passwd}); |
| 890 |
$elapsed = tv_interval($start); |
| 891 |
|
| 892 |
if ($ENV{TEST_VERBOSE}) { |
| 893 |
print STDERR "Elapsed login time: $elapsed secs\n"; |
| 894 |
} |
| 895 |
|
| 896 |
$client->quit(); |
| 897 |
}; |
| 898 |
if ($@) { |
| 899 |
$ex = $@; |
| 900 |
} |
| 901 |
|
| 902 |
$wfh->print("done\n"); |
| 903 |
$wfh->flush(); |
| 904 |
|
| 905 |
} else { |
| 906 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 907 |
if ($@) { |
| 908 |
warn($@); |
| 909 |
exit 1; |
| 910 |
} |
| 911 |
|
| 912 |
exit 0; |
| 913 |
} |
| 914 |
|
| 915 |
# Stop server |
| 916 |
server_stop($setup->{pid_file}); |
| 917 |
$self->assert_child_ok($pid); |
| 918 |
|
| 919 |
test_cleanup($setup->{log_file}, $ex); |
| 920 |
} |
| 921 |
|
| 922 |
sub delay_delayonevent_user_pass_bug4020 { |
| 923 |
my $self = shift; |
| 924 |
my $tmpdir = $self->{tmpdir}; |
| 925 |
my $setup = test_setup($tmpdir, 'delay'); |
| 926 |
|
| 927 |
my $login_delay_secs = 4; |
| 928 |
|
| 929 |
my $config = { |
| 930 |
PidFile => $setup->{pid_file}, |
| 931 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 932 |
SystemLog => $setup->{log_file}, |
| 933 |
TraceLog => $setup->{log_file}, |
| 934 |
Trace => 'delay:20', |
| 935 |
|
| 936 |
AuthUserFile => $setup->{auth_user_file}, |
| 937 |
AuthGroupFile => $setup->{auth_group_file}, |
| 938 |
AuthOrder => 'mod_auth_file.c', |
| 939 |
|
| 940 |
IfModules => { |
| 941 |
'mod_delay.c' => [ |
| 942 |
'DelayTable none', |
| 943 |
'DelayOnEvent USER 2sec', |
| 944 |
'DelayOnEvent PASS 2sec', |
| 945 |
], |
| 946 |
}, |
| 947 |
}; |
| 948 |
|
| 949 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 950 |
$config); |
| 951 |
|
| 952 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 953 |
# the child will indicate when it's done with its test by writing a message |
| 954 |
# to the parent. |
| 955 |
my ($rfh, $wfh); |
| 956 |
unless (pipe($rfh, $wfh)) { |
| 957 |
die("Can't open pipe: $!"); |
| 958 |
} |
| 959 |
|
| 960 |
my $ex; |
| 961 |
|
| 962 |
# Fork child |
| 963 |
$self->handle_sigchld(); |
| 964 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 965 |
if ($pid) { |
| 966 |
eval { |
| 967 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port, 0, |
| 968 |
$login_delay_secs + 2); |
| 969 |
|
| 970 |
my $start = [gettimeofday()]; |
| 971 |
$client->login($setup->{user}, $setup->{passwd}); |
| 972 |
my $elapsed = tv_interval($start); |
| 973 |
|
| 974 |
$client->quit(); |
| 975 |
|
| 976 |
if ($ENV{TEST_VERBOSE}) { |
| 977 |
print STDERR "Elapsed login time: $elapsed secs\n"; |
| 978 |
} |
| 979 |
|
| 980 |
if ($elapsed < $login_delay_secs) { |
| 981 |
die("Expected at least $login_delay_secs sec delay, got $elapsed"); |
| 982 |
} |
| 983 |
}; |
| 984 |
if ($@) { |
| 985 |
$ex = $@; |
| 986 |
} |
| 987 |
|
| 988 |
$wfh->print("done\n"); |
| 989 |
$wfh->flush(); |
| 990 |
|
| 991 |
} else { |
| 992 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 993 |
if ($@) { |
| 994 |
warn($@); |
| 995 |
exit 1; |
| 996 |
} |
| 997 |
|
| 998 |
exit 0; |
| 999 |
} |
| 1000 |
|
| 1001 |
# Stop server |
| 1002 |
server_stop($setup->{pid_file}); |
| 1003 |
$self->assert_child_ok($pid); |
| 1004 |
|
| 1005 |
test_cleanup($setup->{log_file}, $ex); |
| 1006 |
} |
| 1007 |
|
| 1008 |
sub delay_table_default_issue1440 { |
| 1009 |
my $self = shift; |
| 1010 |
my $tmpdir = $self->{tmpdir}; |
| 1011 |
my $setup = test_setup($tmpdir, 'delay'); |
| 1012 |
|
| 1013 |
my $config = { |
| 1014 |
PidFile => $setup->{pid_file}, |
| 1015 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 1016 |
SystemLog => $setup->{log_file}, |
| 1017 |
TraceLog => $setup->{log_file}, |
| 1018 |
Trace => 'delay:20', |
| 1019 |
|
| 1020 |
AuthUserFile => $setup->{auth_user_file}, |
| 1021 |
AuthGroupFile => $setup->{auth_group_file}, |
| 1022 |
AuthOrder => 'mod_auth_file.c', |
| 1023 |
|
| 1024 |
IfModules => { |
| 1025 |
'mod_delay.c' => { |
| 1026 |
'DelayEngine on', |
| 1027 |
}, |
| 1028 |
}, |
| 1029 |
}; |
| 1030 |
|
| 1031 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 1032 |
$config); |
| 1033 |
|
| 1034 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 1035 |
# the child will indicate when it's done with its test by writing a message |
| 1036 |
# to the parent. |
| 1037 |
my ($rfh, $wfh); |
| 1038 |
unless (pipe($rfh, $wfh)) { |
| 1039 |
die("Can't open pipe: $!"); |
| 1040 |
} |
| 1041 |
|
| 1042 |
my $ex; |
| 1043 |
|
| 1044 |
# Fork child |
| 1045 |
$self->handle_sigchld(); |
| 1046 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 1047 |
if ($pid) { |
| 1048 |
eval { |
| 1049 |
# Allow for server startup |
| 1050 |
sleep(1); |
| 1051 |
|
| 1052 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port, 0, 2); |
| 1053 |
|
| 1054 |
my $start = [gettimeofday()]; |
| 1055 |
$client->login($setup->{user}, $setup->{passwd}); |
| 1056 |
my $elapsed = tv_interval($start); |
| 1057 |
|
| 1058 |
$client->quit(); |
| 1059 |
|
| 1060 |
if ($ENV{TEST_VERBOSE}) { |
| 1061 |
print STDERR "Elapsed login time: $elapsed secs\n"; |
| 1062 |
} |
| 1063 |
}; |
| 1064 |
if ($@) { |
| 1065 |
$ex = $@; |
| 1066 |
} |
| 1067 |
|
| 1068 |
$wfh->print("done\n"); |
| 1069 |
$wfh->flush(); |
| 1070 |
|
| 1071 |
} else { |
| 1072 |
eval { server_wait($setup->{config_file}, $rfh) }; |
| 1073 |
if ($@) { |
| 1074 |
warn($@); |
| 1075 |
exit 1; |
| 1076 |
} |
| 1077 |
|
| 1078 |
exit 0; |
| 1079 |
} |
| 1080 |
|
| 1081 |
# Stop server |
| 1082 |
server_stop($setup->{pid_file}); |
| 1083 |
$self->assert_child_ok($pid); |
| 1084 |
|
| 1085 |
# mod_delay/0.7: no DelayOnEvent rules configured with "DelayTable none" in effect, disabling module |
| 1086 |
|
| 1087 |
eval { |
| 1088 |
if (open(my $fh, "< $setup->{log_file}")) { |
| 1089 |
my $saw_delaytable_none = 0; |
| 1090 |
|
| 1091 |
while (my $line = <$fh>) { |
| 1092 |
chomp($line); |
| 1093 |
|
| 1094 |
if ($ENV{TEST_VERBOSE}) { |
| 1095 |
print STDERR "# $line\n"; |
| 1096 |
} |
| 1097 |
|
| 1098 |
if ($line =~ /.*?DelayTable none.*?in effect, disabling module/) { |
| 1099 |
$saw_delaytable_none = 1; |
| 1100 |
last; |
| 1101 |
} |
| 1102 |
} |
| 1103 |
|
| 1104 |
close($fh); |
| 1105 |
|
| 1106 |
$self->assert($saw_delaytable_none == 0, |
| 1107 |
test_msg("Saw 'DelayTable none' in effect unexpectedly")); |
| 1108 |
|
| 1109 |
} else { |
| 1110 |
die("Can't read $setup->{log_file}: $!"); |
| 1111 |
} |
| 1112 |
}; |
| 1113 |
if ($@) { |
| 1114 |
$ex = $@; |
| 1115 |
} |
| 1116 |
|
| 1117 |
test_cleanup($setup->{log_file}, $ex); |
| 1118 |
} |
| 1119 |
|
| 1120 |
sub delay_delayonevent_connect_issue1701 { |
| 1121 |
my $self = shift; |
| 1122 |
my $tmpdir = $self->{tmpdir}; |
| 1123 |
my $setup = test_setup($tmpdir, 'delay'); |
| 1124 |
|
| 1125 |
my $pass_delay_secs = 2; |
| 1126 |
|
| 1127 |
my $config = { |
| 1128 |
PidFile => $setup->{pid_file}, |
| 1129 |
ScoreboardFile => $setup->{scoreboard_file}, |
| 1130 |
SystemLog => $setup->{log_file}, |
| 1131 |
TraceLog => $setup->{log_file}, |
| 1132 |
Trace => 'delay:20 event:20', |
| 1133 |
|
| 1134 |
AuthUserFile => $setup->{auth_user_file}, |
| 1135 |
AuthGroupFile => $setup->{auth_group_file}, |
| 1136 |
AuthOrder => 'mod_auth_file.c', |
| 1137 |
|
| 1138 |
IfModules => { |
| 1139 |
'mod_delay.c' => { |
| 1140 |
DelayTable => 'none', |
| 1141 |
DelayOnEvent => 'Connect 100-5000ms', |
| 1142 |
}, |
| 1143 |
}, |
| 1144 |
}; |
| 1145 |
|
| 1146 |
my ($port, $config_user, $config_group) = config_write($setup->{config_file}, |
| 1147 |
$config); |
| 1148 |
|
| 1149 |
# Open pipes, for use between the parent and child processes. Specifically, |
| 1150 |
# the child will indicate when it's done with its test by writing a message |
| 1151 |
# to the parent. |
| 1152 |
my ($rfh, $wfh); |
| 1153 |
unless (pipe($rfh, $wfh)) { |
| 1154 |
die("Can't open pipe: $!"); |
| 1155 |
} |
| 1156 |
|
| 1157 |
my $ex; |
| 1158 |
|
| 1159 |
# Fork child |
| 1160 |
$self->handle_sigchld(); |
| 1161 |
defined(my $pid = fork()) or die("Can't fork: $!"); |
| 1162 |
if ($pid) { |
| 1163 |
eval { |
| 1164 |
# Allow for server startup |
| 1165 |
sleep(2); |
| 1166 |
|
| 1167 |
for (my $i = 0; $i < 10; $i++) { |
| 1168 |
my $start = [gettimeofday()]; |
| 1169 |
my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port, 0, 10); |
| 1170 |
my $elapsed = tv_interval($start); |
| 1171 |
|
| 1172 |
$client->login($setup->{user}, $setup->{passwd}); |
| 1173 |
|
| 1174 |
if ($ENV{TEST_VERBOSE}) { |
| 1175 |
print STDERR "Elapsed connect time: $elapsed secs\n"; |
| 1176 |
} |
| 1177 |
|
| 1178 |
$client->quit(); |
| 1179 |
} |
| 1180 |
}; |
| 1181 |
if ($@) { |
| 1182 |
$ex = $@; |
| 1183 |
} |
| 1184 |
|
| 1185 |
$wfh->print("done\n"); |
| 1186 |
$wfh->flush(); |
| 1187 |
|
| 1188 |
} else { |
| 1189 |
eval { server_wait($setup->{config_file}, $rfh, 300) }; |
| 1190 |
if ($@) { |
| 1191 |
warn($@); |
| 1192 |
exit 1; |
| 1193 |
} |
| 1194 |
|
| 1195 |
exit 0; |
| 1196 |
} |
| 1197 |
|
| 1198 |
# Stop server |
| 1199 |
server_stop($setup->{pid_file}); |
| 1200 |
$self->assert_child_ok($pid); |
| 1201 |
|
| 1202 |
test_cleanup($setup->{log_file}, $ex); |
| 1203 |
} |
| 1204 |
|
| 1205 |
1; |