Debian Codegraph @

tests/t/lib/ProFTPD/Tests/Modules/mod_redis.pm

raw
1 package ProFTPD::Tests::Modules::mod_redis;
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 IO::Socket::INET6;
11
12 use ProFTPD::TestSuite::FTP;
13 use ProFTPD::TestSuite::Utils qw(:auth :config :features :running :test :testsuite);
14
15 $| = 1;
16
17 my $order = 0;
18
19 my $TESTS = {
20 redis_log_on_command => {
21 order => ++$order,
22 test_class => [qw(forking)],
23 },
24
25 redis_log_on_command_custom_key => {
26 order => ++$order,
27 test_class => [qw(forking)],
28 },
29
30 redis_log_on_command_per_dir => {
31 order => ++$order,
32 test_class => [qw(forking)],
33 },
34
35 redis_log_on_command_per_dir_none => {
36 order => ++$order,
37 test_class => [qw(forking)],
38 },
39
40 redis_log_on_command_per_dir_none2 => {
41 order => ++$order,
42 test_class => [qw(forking)],
43 },
44
45 redis_log_on_event => {
46 order => ++$order,
47 test_class => [qw(forking)],
48 },
49
50 redis_log_on_event_custom_key => {
51 order => ++$order,
52 test_class => [qw(forking)],
53 },
54
55 redis_log_on_event_per_dir => {
56 order => ++$order,
57 test_class => [qw(forking)],
58 },
59
60 redis_log_on_event_per_dir_none => {
61 order => ++$order,
62 test_class => [qw(forking)],
63 },
64
65 redis_log_on_event_per_dir_none2 => {
66 order => ++$order,
67 test_class => [qw(forking)],
68 },
69
70 redis_log_fmt_extra_with_log_on_command => {
71 order => ++$order,
72 test_class => [qw(forking)],
73 },
74
75 redis_log_fmt_extra_with_log_on_event => {
76 order => ++$order,
77 test_class => [qw(forking)],
78 },
79
80 };
81
82 sub new {
83 return shift()->SUPER::new(@_);
84 }
85
86 sub list_tests {
87 # Check for the required Perl modules:
88 #
89 # Redis
90
91 my $required = [qw(
92 JSON
93 Redis
94 )];
95
96 foreach my $req (@$required) {
97 eval "use $req";
98 if ($@) {
99 print STDERR "\nWARNING:\n + Module '$req' not found, skipping all tests\n";
100
101 if ($ENV{TEST_VERBOSE}) {
102 print STDERR "Unable to load $req: $@\n";
103 }
104
105 return qw(testsuite_empty_test);
106 }
107 }
108
109 return testsuite_get_runnable_tests($TESTS);
110 }
111
112 sub redis_list_delete {
113 my $key = shift;
114
115 require Redis;
116 my $redis = Redis->new(
117 reconnect => 5,
118 every => 250_000
119 );
120
121 $redis->del($key);
122 $redis->quit();
123 return 1;
124 }
125
126 sub redis_list_getall {
127 my $key = shift;
128
129 require Redis;
130 my $redis = Redis->new(
131 reconnect => 5,
132 every => 250_000
133 );
134
135 my $data = $redis->lrange($key, 0, -1);
136 $redis->quit();
137
138 return $data;
139 }
140
141 sub redis_log_on_command {
142 my $self = shift;
143 my $tmpdir = $self->{tmpdir};
144 my $setup = test_setup($tmpdir, 'redis');
145
146 my $fmt_name = 'custom';
147 redis_list_delete($fmt_name);
148
149 my $config = {
150 PidFile => $setup->{pid_file},
151 ScoreboardFile => $setup->{scoreboard_file},
152 SystemLog => $setup->{log_file},
153 TraceLog => $setup->{log_file},
154 Trace => 'jot:20 redis:20',
155
156 AuthUserFile => $setup->{auth_user_file},
157 AuthGroupFile => $setup->{auth_group_file},
158 AuthOrder => 'mod_auth_file.c',
159
160 IfModules => {
161 'mod_delay.c' => {
162 DelayEngine => 'off',
163 },
164
165 # Note: we need to use arrays here, since order of directives matters.
166 'mod_redis.c' => [
167 'RedisEngine on',
168 'RedisServer 127.0.0.1:6379',
169 "RedisLog $setup->{log_file}",
170 "LogFormat $fmt_name \"%a %u\"",
171 "RedisLogOnCommand PASS $fmt_name",
172 ],
173 },
174 };
175
176 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
177 $config);
178
179 # Open pipes, for use between the parent and child processes. Specifically,
180 # the child will indicate when it's done with its test by writing a message
181 # to the parent.
182 my ($rfh, $wfh);
183 unless (pipe($rfh, $wfh)) {
184 die("Can't open pipe: $!");
185 }
186
187 my $ex;
188
189 # Fork child
190 $self->handle_sigchld();
191 defined(my $pid = fork()) or die("Can't fork: $!");
192 if ($pid) {
193 eval {
194 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
195 $client->login($setup->{user}, $setup->{passwd});
196
197 my $resp_code = $client->response_code();
198 my $resp_msg = $client->response_msg(0);
199 $client->quit();
200
201 my $expected = 230;
202 $self->assert($expected == $resp_code,
203 "Expected response code $expected, got $resp_code");
204
205 $expected = "User $setup->{user} logged in";
206 $self->assert($expected eq $resp_msg,
207 "Expected response message '$expected', got '$resp_msg'");
208 };
209 if ($@) {
210 $ex = $@;
211 }
212
213 $wfh->print("done\n");
214 $wfh->flush();
215
216 } else {
217 eval { server_wait($setup->{config_file}, $rfh) };
218 if ($@) {
219 warn($@);
220 exit 1;
221 }
222
223 exit 0;
224 }
225
226 # Stop server
227 server_stop($setup->{pid_file});
228 $self->assert_child_ok($pid);
229
230 eval {
231 my $data = redis_list_getall($fmt_name);
232
233 my $nrecords = scalar(@$data);
234 $self->assert($nrecords == 1, "Expected 1 record, got $nrecords");
235
236 require JSON;
237 my $record = decode_json($data->[0]);
238
239 my $expected = $setup->{user};
240 $self->assert($record->{user} eq $expected,
241 "Expected user '$expected', got '$record->{user}'");
242
243 $expected = '127.0.0.1';
244 $self->assert($record->{remote_ip} eq $expected,
245 "Expected remote IP '$expected', got '$record->{remote_ip}'");
246 };
247 if ($@) {
248 $ex = $@;
249 }
250
251 test_cleanup($setup->{log_file}, $ex);
252 }
253
254 sub redis_log_on_command_custom_key {
255 my $self = shift;
256 my $tmpdir = $self->{tmpdir};
257 my $setup = test_setup($tmpdir, 'redis');
258
259 my $fmt_name = 'custom';
260 my $key_name = "ftp.$setup->{user}.PASS";
261 redis_list_delete($key_name);
262
263 my $config = {
264 PidFile => $setup->{pid_file},
265 ScoreboardFile => $setup->{scoreboard_file},
266 SystemLog => $setup->{log_file},
267 TraceLog => $setup->{log_file},
268 Trace => 'jot:20 redis:20',
269
270 AuthUserFile => $setup->{auth_user_file},
271 AuthGroupFile => $setup->{auth_group_file},
272 AuthOrder => 'mod_auth_file.c',
273
274 IfModules => {
275 'mod_delay.c' => {
276 DelayEngine => 'off',
277 },
278
279 # Note: we need to use arrays here, since order of directives matters.
280 'mod_redis.c' => [
281 'RedisEngine on',
282 'RedisServer 127.0.0.1:6379',
283 "RedisLog $setup->{log_file}",
284 "LogFormat $fmt_name \"%a %u\"",
285 "RedisLogOnCommand PASS $fmt_name ftp.%u.%m",
286 ],
287 },
288 };
289
290 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
291 $config);
292
293 # Open pipes, for use between the parent and child processes. Specifically,
294 # the child will indicate when it's done with its test by writing a message
295 # to the parent.
296 my ($rfh, $wfh);
297 unless (pipe($rfh, $wfh)) {
298 die("Can't open pipe: $!");
299 }
300
301 my $ex;
302
303 # Fork child
304 $self->handle_sigchld();
305 defined(my $pid = fork()) or die("Can't fork: $!");
306 if ($pid) {
307 eval {
308 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
309 $client->login($setup->{user}, $setup->{passwd});
310
311 my $resp_code = $client->response_code();
312 my $resp_msg = $client->response_msg(0);
313 $client->quit();
314
315 my $expected = 230;
316 $self->assert($expected == $resp_code,
317 "Expected response code $expected, got $resp_code");
318
319 $expected = "User $setup->{user} logged in";
320 $self->assert($expected eq $resp_msg,
321 "Expected response message '$expected', got '$resp_msg'");
322 };
323 if ($@) {
324 $ex = $@;
325 }
326
327 $wfh->print("done\n");
328 $wfh->flush();
329
330 } else {
331 eval { server_wait($setup->{config_file}, $rfh) };
332 if ($@) {
333 warn($@);
334 exit 1;
335 }
336
337 exit 0;
338 }
339
340 # Stop server
341 server_stop($setup->{pid_file});
342 $self->assert_child_ok($pid);
343
344 eval {
345 my $data = redis_list_getall($key_name);
346
347 if ($ENV{TEST_VERBOSE}) {
348 use Data::Dumper;
349 print STDERR "# Redis data:\n", Dumper($data), "\n";
350 }
351
352 my $nrecords = scalar(@$data);
353 $self->assert($nrecords == 1, "Expected 1 record, got $nrecords");
354
355 require JSON;
356 my $record = decode_json($data->[0]);
357
358 my $expected = $setup->{user};
359 $self->assert($record->{user} eq $expected,
360 "Expected user '$expected', got '$record->{user}'");
361
362 $expected = '127.0.0.1';
363 $self->assert($record->{remote_ip} eq $expected,
364 "Expected remote IP '$expected', got '$record->{remote_ip}'");
365 };
366 if ($@) {
367 $ex = $@;
368 }
369
370 test_cleanup($setup->{log_file}, $ex);
371 }
372
373 sub redis_log_on_command_per_dir {
374 my $self = shift;
375 my $tmpdir = $self->{tmpdir};
376 my $setup = test_setup($tmpdir, 'redis');
377
378 my $sub_dir = File::Spec->rel2abs("$tmpdir/test.d");
379 mkpath($sub_dir);
380
381 my $fmt_name = 'custom';
382 redis_list_delete($fmt_name);
383
384 my $config = {
385 PidFile => $setup->{pid_file},
386 ScoreboardFile => $setup->{scoreboard_file},
387 SystemLog => $setup->{log_file},
388 TraceLog => $setup->{log_file},
389 Trace => 'jot:20 redis:20',
390
391 AuthUserFile => $setup->{auth_user_file},
392 AuthGroupFile => $setup->{auth_group_file},
393 AuthOrder => 'mod_auth_file.c',
394
395 IfModules => {
396 'mod_delay.c' => {
397 DelayEngine => 'off',
398 },
399 },
400 };
401
402 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
403 $config);
404
405 if (open(my $fh, ">> $setup->{config_file}")) {
406 if ($^O eq 'darwin') {
407 # Mac OSX hack
408 $sub_dir = '/private' . $sub_dir;
409 }
410
411 print $fh <<EOC;
412 <IfModule mod_redis.c>
413 RedisEngine on
414 RedisServer 127.0.0.1:6379
415 RedisLog $setup->{log_file}
416 LogFormat $fmt_name "%a %u"
417
418 <Directory $sub_dir>
419 RedisLogOnCommand PWD $fmt_name
420 </Directory>
421 </IfModule>
422 EOC
423 unless (close($fh)) {
424 die("Can't write $setup->{config_file}: $!");
425 }
426
427 } else {
428 die("Can't open $setup->{config_file}: $!");
429 }
430
431 # Open pipes, for use between the parent and child processes. Specifically,
432 # the child will indicate when it's done with its test by writing a message
433 # to the parent.
434 my ($rfh, $wfh);
435 unless (pipe($rfh, $wfh)) {
436 die("Can't open pipe: $!");
437 }
438
439 my $ex;
440
441 # Fork child
442 $self->handle_sigchld();
443 defined(my $pid = fork()) or die("Can't fork: $!");
444 if ($pid) {
445 eval {
446 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
447 $client->login($setup->{user}, $setup->{passwd});
448 $client->pwd();
449 $client->cwd('test.d');
450 $client->pwd();
451 $client->quit();
452 };
453 if ($@) {
454 $ex = $@;
455 }
456
457 $wfh->print("done\n");
458 $wfh->flush();
459
460 } else {
461 eval { server_wait($setup->{config_file}, $rfh) };
462 if ($@) {
463 warn($@);
464 exit 1;
465 }
466
467 exit 0;
468 }
469
470 # Stop server
471 server_stop($setup->{pid_file});
472 $self->assert_child_ok($pid);
473
474 eval {
475 my $data = redis_list_getall($fmt_name);
476
477 if ($ENV{TEST_VERBOSE}) {
478 use Data::Dumper;
479 print STDERR "# Redis data:\n", Dumper($data), "\n";
480 }
481
482 my $nrecords = scalar(@$data);
483 $self->assert($nrecords == 1, "Expected 1 record, got $nrecords");
484
485 require JSON;
486 my $record = decode_json($data->[0]);
487
488 my $expected = $setup->{user};
489 $self->assert($record->{user} eq $expected,
490 "Expected user '$expected', got '$record->{user}'");
491
492 $expected = '127.0.0.1';
493 $self->assert($record->{remote_ip} eq $expected,
494 "Expected remote IP '$expected', got '$record->{remote_ip}'");
495 };
496 if ($@) {
497 $ex = $@;
498 }
499
500 test_cleanup($setup->{log_file}, $ex);
501 }
502
503 sub redis_log_on_command_per_dir_none {
504 my $self = shift;
505 my $tmpdir = $self->{tmpdir};
506 my $setup = test_setup($tmpdir, 'redis');
507
508 my $sub_dir = File::Spec->rel2abs("$tmpdir/test.d");
509 mkpath($sub_dir);
510
511 my $fmt_name = 'custom';
512 redis_list_delete($fmt_name);
513
514 my $config = {
515 PidFile => $setup->{pid_file},
516 ScoreboardFile => $setup->{scoreboard_file},
517 SystemLog => $setup->{log_file},
518 TraceLog => $setup->{log_file},
519 Trace => 'jot:20 redis:20',
520
521 AuthUserFile => $setup->{auth_user_file},
522 AuthGroupFile => $setup->{auth_group_file},
523 AuthOrder => 'mod_auth_file.c',
524
525 IfModules => {
526 'mod_delay.c' => {
527 DelayEngine => 'off',
528 },
529 },
530 };
531
532 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
533 $config);
534
535 if (open(my $fh, ">> $setup->{config_file}")) {
536 if ($^O eq 'darwin') {
537 # Mac OSX hack
538 $sub_dir = '/private' . $sub_dir;
539 }
540
541 print $fh <<EOC;
542 <IfModule mod_redis.c>
543 RedisEngine on
544 RedisServer 127.0.0.1:6379
545 RedisLog $setup->{log_file}
546 LogFormat $fmt_name "%a %u"
547
548 <Directory $setup->{home_dir}>
549 RedisLogOnCommand PWD $fmt_name
550 </Directory>
551
552 <Directory $sub_dir>
553 RedisLogOnCommand none
554 </Directory>
555 </IfModule>
556 EOC
557 unless (close($fh)) {
558 die("Can't write $setup->{config_file}: $!");
559 }
560
561 } else {
562 die("Can't open $setup->{config_file}: $!");
563 }
564
565 # Open pipes, for use between the parent and child processes. Specifically,
566 # the child will indicate when it's done with its test by writing a message
567 # to the parent.
568 my ($rfh, $wfh);
569 unless (pipe($rfh, $wfh)) {
570 die("Can't open pipe: $!");
571 }
572
573 my $ex;
574
575 # Fork child
576 $self->handle_sigchld();
577 defined(my $pid = fork()) or die("Can't fork: $!");
578 if ($pid) {
579 eval {
580 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
581 $client->login($setup->{user}, $setup->{passwd});
582 $client->pwd();
583 $client->cwd('test.d');
584 $client->pwd();
585 $client->quit();
586 };
587 if ($@) {
588 $ex = $@;
589 }
590
591 $wfh->print("done\n");
592 $wfh->flush();
593
594 } else {
595 eval { server_wait($setup->{config_file}, $rfh) };
596 if ($@) {
597 warn($@);
598 exit 1;
599 }
600
601 exit 0;
602 }
603
604 # Stop server
605 server_stop($setup->{pid_file});
606 $self->assert_child_ok($pid);
607
608 eval {
609 my $data = redis_list_getall($fmt_name);
610
611 if ($ENV{TEST_VERBOSE}) {
612 use Data::Dumper;
613 print STDERR "# Redis data:\n", Dumper($data), "\n";
614 }
615
616 my $nrecords = scalar(@$data);
617 $self->assert($nrecords == 0, "Expected 0 records, got $nrecords");
618 };
619 if ($@) {
620 $ex = $@;
621 }
622
623 test_cleanup($setup->{log_file}, $ex);
624 }
625
626 sub redis_log_on_command_per_dir_none2 {
627 my $self = shift;
628 my $tmpdir = $self->{tmpdir};
629 my $setup = test_setup($tmpdir, 'redis');
630
631 my $sub_dir = File::Spec->rel2abs("$tmpdir/test.d");
632 mkpath($sub_dir);
633
634 my $fmt_name = 'custom';
635 redis_list_delete($fmt_name);
636
637 my $config = {
638 PidFile => $setup->{pid_file},
639 ScoreboardFile => $setup->{scoreboard_file},
640 SystemLog => $setup->{log_file},
641 TraceLog => $setup->{log_file},
642 Trace => 'jot:20 redis:20',
643
644 AuthUserFile => $setup->{auth_user_file},
645 AuthGroupFile => $setup->{auth_group_file},
646 AuthOrder => 'mod_auth_file.c',
647
648 IfModules => {
649 'mod_delay.c' => {
650 DelayEngine => 'off',
651 },
652 },
653 };
654
655 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
656 $config);
657
658 if (open(my $fh, ">> $setup->{config_file}")) {
659 if ($^O eq 'darwin') {
660 # Mac OSX hack
661 $sub_dir = '/private' . $sub_dir;
662 }
663
664 print $fh <<EOC;
665 <IfModule mod_redis.c>
666 RedisEngine on
667 RedisServer 127.0.0.1:6379
668 RedisLog $setup->{log_file}
669 LogFormat $fmt_name "%a %u"
670
671 <Directory />
672 RedisLogOnCommand PWD $fmt_name
673 </Directory>
674
675 <Directory $sub_dir>
676 RedisLogOnCommand none
677 </Directory>
678 </IfModule>
679 EOC
680 unless (close($fh)) {
681 die("Can't write $setup->{config_file}: $!");
682 }
683
684 } else {
685 die("Can't open $setup->{config_file}: $!");
686 }
687
688 # Open pipes, for use between the parent and child processes. Specifically,
689 # the child will indicate when it's done with its test by writing a message
690 # to the parent.
691 my ($rfh, $wfh);
692 unless (pipe($rfh, $wfh)) {
693 die("Can't open pipe: $!");
694 }
695
696 my $ex;
697
698 # Fork child
699 $self->handle_sigchld();
700 defined(my $pid = fork()) or die("Can't fork: $!");
701 if ($pid) {
702 eval {
703 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
704 $client->login($setup->{user}, $setup->{passwd});
705 $client->pwd();
706 $client->cwd('test.d');
707 $client->pwd();
708 $client->quit();
709 };
710 if ($@) {
711 $ex = $@;
712 }
713
714 $wfh->print("done\n");
715 $wfh->flush();
716
717 } else {
718 eval { server_wait($setup->{config_file}, $rfh) };
719 if ($@) {
720 warn($@);
721 exit 1;
722 }
723
724 exit 0;
725 }
726
727 # Stop server
728 server_stop($setup->{pid_file});
729 $self->assert_child_ok($pid);
730
731 eval {
732 my $data = redis_list_getall($fmt_name);
733
734 if ($ENV{TEST_VERBOSE}) {
735 use Data::Dumper;
736 print STDERR "# Redis data:\n", Dumper($data), "\n";
737 }
738
739 my $nrecords = scalar(@$data);
740 $self->assert($nrecords == 1, "Expected 1 record, got $nrecords");
741 };
742 if ($@) {
743 $ex = $@;
744 }
745
746 test_cleanup($setup->{log_file}, $ex);
747 }
748
749 sub redis_log_on_event {
750 my $self = shift;
751 my $tmpdir = $self->{tmpdir};
752 my $setup = test_setup($tmpdir, 'redis');
753
754 my $fmt_name = 'custom';
755 redis_list_delete($fmt_name);
756
757 my $config = {
758 PidFile => $setup->{pid_file},
759 ScoreboardFile => $setup->{scoreboard_file},
760 SystemLog => $setup->{log_file},
761 TraceLog => $setup->{log_file},
762 Trace => 'event:20 netio:10 jot:20 redis:20 response:20',
763
764 AuthUserFile => $setup->{auth_user_file},
765 AuthGroupFile => $setup->{auth_group_file},
766 AuthOrder => 'mod_auth_file.c',
767
768 IfModules => {
769 'mod_delay.c' => {
770 DelayEngine => 'off',
771 },
772
773 # Note: we need to use arrays here, since order of directives matters.
774 'mod_redis.c' => [
775 'RedisEngine on',
776 'RedisServer 127.0.0.1:6379',
777 "RedisLog $setup->{log_file}",
778 "LogFormat $fmt_name \"%A %a %b %c %D %d %E %{epoch} %F %f %{gid} %g %H %h %I %{iso8601} %J %L %l %m %O %P %p %{protocol} %R %r %{remote-port} %S %s %T %t %U %u %{uid} %V %v %{version}\"",
779 "RedisLogOnEvent ALL $fmt_name",
780 ],
781 },
782 };
783
784 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
785 $config);
786
787 # Open pipes, for use between the parent and child processes. Specifically,
788 # the child will indicate when it's done with its test by writing a message
789 # to the parent.
790 my ($rfh, $wfh);
791 unless (pipe($rfh, $wfh)) {
792 die("Can't open pipe: $!");
793 }
794
795 my $ex;
796
797 # Fork child
798 $self->handle_sigchld();
799 defined(my $pid = fork()) or die("Can't fork: $!");
800 if ($pid) {
801 eval {
802 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
803 $client->login($setup->{user}, $setup->{passwd});
804
805 my $resp_code = $client->response_code();
806 my $resp_msg = $client->response_msg(0);
807
808 my $expected = 230;
809 $self->assert($expected == $resp_code,
810 "Expected response code $expected, got $resp_code");
811
812 $expected = "User $setup->{user} logged in";
813 $self->assert($expected eq $resp_msg,
814 "Expected response message '$expected', got '$resp_msg'");
815
816 $client->quit();
817 };
818 if ($@) {
819 $ex = $@;
820 }
821
822 $wfh->print("done\n");
823 $wfh->flush();
824
825 } else {
826 eval { server_wait($setup->{config_file}, $rfh) };
827 if ($@) {
828 warn($@);
829 exit 1;
830 }
831
832 exit 0;
833 }
834
835 # Stop server
836 server_stop($setup->{pid_file});
837 $self->assert_child_ok($pid);
838
839 eval {
840 my $data = redis_list_getall($fmt_name);
841
842 if ($ENV{TEST_VERBOSE}) {
843 use Data::Dumper;
844 print STDERR "# Redis data:\n", Dumper($data), "\n";
845 }
846
847 my $nrecords = scalar(@$data);
848 $self->assert($nrecords == 4 || $nrecords == 5,
849 "Expected 4-5 records, got $nrecords");
850
851 require JSON;
852 my $record = decode_json($data->[3]);
853
854 my $expected = $setup->{user};
855 $self->assert($record->{user} eq $expected,
856 "Expected user '$expected', got '$record->{user}'");
857
858 $expected = '127.0.0.1';
859 $self->assert($record->{remote_ip} eq $expected,
860 "Expected remote IP '$expected', got '$record->{remote_ip}'");
861 };
862 if ($@) {
863 $ex = $@;
864 }
865
866 test_cleanup($setup->{log_file}, $ex);
867 }
868
869 sub redis_log_on_event_custom_key {
870 my $self = shift;
871 my $tmpdir = $self->{tmpdir};
872 my $setup = test_setup($tmpdir, 'redis');
873
874 my $fmt_name = 'custom';
875 my $key_name = 'ftp.127.0.0.1';
876 redis_list_delete($key_name);
877
878 my $config = {
879 PidFile => $setup->{pid_file},
880 ScoreboardFile => $setup->{scoreboard_file},
881 SystemLog => $setup->{log_file},
882 TraceLog => $setup->{log_file},
883 Trace => 'event:20 netio:10 jot:20 redis:20 response:20',
884
885 AuthUserFile => $setup->{auth_user_file},
886 AuthGroupFile => $setup->{auth_group_file},
887 AuthOrder => 'mod_auth_file.c',
888
889 IfModules => {
890 'mod_delay.c' => {
891 DelayEngine => 'off',
892 },
893
894 # Note: we need to use arrays here, since order of directives matters.
895 'mod_redis.c' => [
896 'RedisEngine on',
897 'RedisServer 127.0.0.1:6379',
898 "RedisLog $setup->{log_file}",
899 "LogFormat $fmt_name \"%A %a %b %c %D %d %E %{epoch} %F %f %{gid} %g %H %h %I %{iso8601} %J %L %l %m %O %P %p %{protocol} %R %r %{remote-port} %S %s %T %t %U %u %{uid} %V %v %{version}\"",
900 "RedisLogOnEvent ALL $fmt_name ftp.%a",
901 ],
902 },
903 };
904
905 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
906 $config);
907
908 # Open pipes, for use between the parent and child processes. Specifically,
909 # the child will indicate when it's done with its test by writing a message
910 # to the parent.
911 my ($rfh, $wfh);
912 unless (pipe($rfh, $wfh)) {
913 die("Can't open pipe: $!");
914 }
915
916 my $ex;
917
918 # Fork child
919 $self->handle_sigchld();
920 defined(my $pid = fork()) or die("Can't fork: $!");
921 if ($pid) {
922 eval {
923 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
924 $client->login($setup->{user}, $setup->{passwd});
925
926 my $resp_code = $client->response_code();
927 my $resp_msg = $client->response_msg(0);
928
929 my $expected = 230;
930 $self->assert($expected == $resp_code,
931 "Expected response code $expected, got $resp_code");
932
933 $expected = "User $setup->{user} logged in";
934 $self->assert($expected eq $resp_msg,
935 "Expected response message '$expected', got '$resp_msg'");
936
937 $client->quit();
938 };
939 if ($@) {
940 $ex = $@;
941 }
942
943 $wfh->print("done\n");
944 $wfh->flush();
945
946 } else {
947 eval { server_wait($setup->{config_file}, $rfh) };
948 if ($@) {
949 warn($@);
950 exit 1;
951 }
952
953 exit 0;
954 }
955
956 # Stop server
957 server_stop($setup->{pid_file});
958 $self->assert_child_ok($pid);
959
960 eval {
961 my $data = redis_list_getall($key_name);
962
963 if ($ENV{TEST_VERBOSE}) {
964 use Data::Dumper;
965 print STDERR "# Redis data:\n", Dumper($data), "\n";
966 }
967
968 my $nrecords = scalar(@$data);
969 $self->assert($nrecords == 4 || $nrecords == 5,
970 "Expected 4-5 records, got $nrecords");
971
972 require JSON;
973 my $record = decode_json($data->[3]);
974
975 my $expected = $setup->{user};
976 $self->assert($record->{user} eq $expected,
977 "Expected user '$expected', got '$record->{user}'");
978
979 $expected = '127.0.0.1';
980 $self->assert($record->{remote_ip} eq $expected,
981 "Expected remote IP '$expected', got '$record->{remote_ip}'");
982 };
983 if ($@) {
984 $ex = $@;
985 }
986
987 test_cleanup($setup->{log_file}, $ex);
988 }
989
990 sub redis_log_on_event_per_dir {
991 my $self = shift;
992 my $tmpdir = $self->{tmpdir};
993 my $setup = test_setup($tmpdir, 'redis');
994
995 my $sub_dir = File::Spec->rel2abs("$tmpdir/test.d");
996 mkpath($sub_dir);
997
998 my $fmt_name = 'custom';
999 redis_list_delete($fmt_name);
1000
1001 my $config = {
1002 PidFile => $setup->{pid_file},
1003 ScoreboardFile => $setup->{scoreboard_file},
1004 SystemLog => $setup->{log_file},
1005 TraceLog => $setup->{log_file},
1006 Trace => 'jot:20 redis:20',
1007
1008 AuthUserFile => $setup->{auth_user_file},
1009 AuthGroupFile => $setup->{auth_group_file},
1010 AuthOrder => 'mod_auth_file.c',
1011
1012 IfModules => {
1013 'mod_delay.c' => {
1014 DelayEngine => 'off',
1015 },
1016 },
1017 };
1018
1019 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
1020 $config);
1021
1022 if (open(my $fh, ">> $setup->{config_file}")) {
1023 if ($^O eq 'darwin') {
1024 # Mac OSX hack
1025 $sub_dir = '/private' . $sub_dir;
1026 }
1027
1028 print $fh <<EOC;
1029 <IfModule mod_redis.c>
1030 RedisEngine on
1031 RedisServer 127.0.0.1:6379
1032 RedisLog $setup->{log_file}
1033 LogFormat $fmt_name "%a %u"
1034
1035 <Directory $sub_dir>
1036 RedisLogOnEvent PWD $fmt_name
1037 </Directory>
1038 </IfModule>
1039 EOC
1040 unless (close($fh)) {
1041 die("Can't write $setup->{config_file}: $!");
1042 }
1043
1044 } else {
1045 die("Can't open $setup->{config_file}: $!");
1046 }
1047
1048 # Open pipes, for use between the parent and child processes. Specifically,
1049 # the child will indicate when it's done with its test by writing a message
1050 # to the parent.
1051 my ($rfh, $wfh);
1052 unless (pipe($rfh, $wfh)) {
1053 die("Can't open pipe: $!");
1054 }
1055
1056 my $ex;
1057
1058 # Fork child
1059 $self->handle_sigchld();
1060 defined(my $pid = fork()) or die("Can't fork: $!");
1061 if ($pid) {
1062 eval {
1063 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
1064 $client->login($setup->{user}, $setup->{passwd});
1065 $client->pwd();
1066 $client->cwd('test.d');
1067 $client->pwd();
1068 $client->quit();
1069 };
1070 if ($@) {
1071 $ex = $@;
1072 }
1073
1074 $wfh->print("done\n");
1075 $wfh->flush();
1076
1077 } else {
1078 eval { server_wait($setup->{config_file}, $rfh) };
1079 if ($@) {
1080 warn($@);
1081 exit 1;
1082 }
1083
1084 exit 0;
1085 }
1086
1087 # Stop server
1088 server_stop($setup->{pid_file});
1089 $self->assert_child_ok($pid);
1090
1091 eval {
1092 my $data = redis_list_getall($fmt_name);
1093
1094 if ($ENV{TEST_VERBOSE}) {
1095 use Data::Dumper;
1096 print STDERR "# Redis data:\n", Dumper($data), "\n";
1097 }
1098
1099 my $nrecords = scalar(@$data);
1100 $self->assert($nrecords == 1, "Expected 1 record, got $nrecords");
1101
1102 require JSON;
1103 my $record = decode_json($data->[0]);
1104
1105 my $expected = $setup->{user};
1106 $self->assert($record->{user} eq $expected,
1107 "Expected user '$expected', got '$record->{user}'");
1108
1109 $expected = '127.0.0.1';
1110 $self->assert($record->{remote_ip} eq $expected,
1111 "Expected remote IP '$expected', got '$record->{remote_ip}'");
1112 };
1113 if ($@) {
1114 $ex = $@;
1115 }
1116
1117 test_cleanup($setup->{log_file}, $ex);
1118 }
1119
1120 sub redis_log_on_event_per_dir_none {
1121 my $self = shift;
1122 my $tmpdir = $self->{tmpdir};
1123 my $setup = test_setup($tmpdir, 'redis');
1124
1125 my $sub_dir = File::Spec->rel2abs("$tmpdir/test.d");
1126 mkpath($sub_dir);
1127
1128 my $fmt_name = 'custom';
1129 redis_list_delete($fmt_name);
1130
1131 my $config = {
1132 PidFile => $setup->{pid_file},
1133 ScoreboardFile => $setup->{scoreboard_file},
1134 SystemLog => $setup->{log_file},
1135 TraceLog => $setup->{log_file},
1136 Trace => 'jot:20 redis:20',
1137
1138 AuthUserFile => $setup->{auth_user_file},
1139 AuthGroupFile => $setup->{auth_group_file},
1140 AuthOrder => 'mod_auth_file.c',
1141
1142 IfModules => {
1143 'mod_delay.c' => {
1144 DelayEngine => 'off',
1145 },
1146 },
1147 };
1148
1149 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
1150 $config);
1151
1152 if (open(my $fh, ">> $setup->{config_file}")) {
1153 if ($^O eq 'darwin') {
1154 # Mac OSX hack
1155 $sub_dir = '/private' . $sub_dir;
1156 }
1157
1158 print $fh <<EOC;
1159 <IfModule mod_redis.c>
1160 RedisEngine on
1161 RedisServer 127.0.0.1:6379
1162 RedisLog $setup->{log_file}
1163 LogFormat $fmt_name "%a %u"
1164
1165 <Directory $setup->{home_dir}>
1166 RedisLogOnEvent PWD $fmt_name
1167 </Directory>
1168
1169 <Directory $sub_dir>
1170 RedisLogOnEvent none
1171 </Directory>
1172 </IfModule>
1173 EOC
1174 unless (close($fh)) {
1175 die("Can't write $setup->{config_file}: $!");
1176 }
1177
1178 } else {
1179 die("Can't open $setup->{config_file}: $!");
1180 }
1181
1182 # Open pipes, for use between the parent and child processes. Specifically,
1183 # the child will indicate when it's done with its test by writing a message
1184 # to the parent.
1185 my ($rfh, $wfh);
1186 unless (pipe($rfh, $wfh)) {
1187 die("Can't open pipe: $!");
1188 }
1189
1190 my $ex;
1191
1192 # Fork child
1193 $self->handle_sigchld();
1194 defined(my $pid = fork()) or die("Can't fork: $!");
1195 if ($pid) {
1196 eval {
1197 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
1198 $client->login($setup->{user}, $setup->{passwd});
1199 $client->pwd();
1200 $client->cwd('test.d');
1201 $client->pwd();
1202 $client->quit();
1203 };
1204 if ($@) {
1205 $ex = $@;
1206 }
1207
1208 $wfh->print("done\n");
1209 $wfh->flush();
1210
1211 } else {
1212 eval { server_wait($setup->{config_file}, $rfh) };
1213 if ($@) {
1214 warn($@);
1215 exit 1;
1216 }
1217
1218 exit 0;
1219 }
1220
1221 # Stop server
1222 server_stop($setup->{pid_file});
1223 $self->assert_child_ok($pid);
1224
1225 eval {
1226 my $data = redis_list_getall($fmt_name);
1227
1228 if ($ENV{TEST_VERBOSE}) {
1229 use Data::Dumper;
1230 print STDERR "# Redis data:\n", Dumper($data), "\n";
1231 }
1232
1233 my $nrecords = scalar(@$data);
1234 $self->assert($nrecords == 0, "Expected 0 records, got $nrecords");
1235 };
1236 if ($@) {
1237 $ex = $@;
1238 }
1239
1240 test_cleanup($setup->{log_file}, $ex);
1241 }
1242
1243 sub redis_log_on_event_per_dir_none2 {
1244 my $self = shift;
1245 my $tmpdir = $self->{tmpdir};
1246 my $setup = test_setup($tmpdir, 'redis');
1247
1248 my $sub_dir = File::Spec->rel2abs("$tmpdir/test.d");
1249 mkpath($sub_dir);
1250
1251 my $fmt_name = 'custom';
1252 redis_list_delete($fmt_name);
1253
1254 my $config = {
1255 PidFile => $setup->{pid_file},
1256 ScoreboardFile => $setup->{scoreboard_file},
1257 SystemLog => $setup->{log_file},
1258 TraceLog => $setup->{log_file},
1259 Trace => 'jot:20 redis:20',
1260
1261 AuthUserFile => $setup->{auth_user_file},
1262 AuthGroupFile => $setup->{auth_group_file},
1263 AuthOrder => 'mod_auth_file.c',
1264
1265 IfModules => {
1266 'mod_delay.c' => {
1267 DelayEngine => 'off',
1268 },
1269 },
1270 };
1271
1272 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
1273 $config);
1274
1275 if (open(my $fh, ">> $setup->{config_file}")) {
1276 if ($^O eq 'darwin') {
1277 # Mac OSX hack
1278 $sub_dir = '/private' . $sub_dir;
1279 }
1280
1281 print $fh <<EOC;
1282 <IfModule mod_redis.c>
1283 RedisEngine on
1284 RedisServer 127.0.0.1:6379
1285 RedisLog $setup->{log_file}
1286 LogFormat $fmt_name "%a %u"
1287
1288 <Directory />
1289 RedisLogOnEvent PWD $fmt_name
1290 </Directory>
1291
1292 <Directory $sub_dir>
1293 RedisLogOnEvent none
1294 </Directory>
1295 </IfModule>
1296 EOC
1297 unless (close($fh)) {
1298 die("Can't write $setup->{config_file}: $!");
1299 }
1300
1301 } else {
1302 die("Can't open $setup->{config_file}: $!");
1303 }
1304
1305 # Open pipes, for use between the parent and child processes. Specifically,
1306 # the child will indicate when it's done with its test by writing a message
1307 # to the parent.
1308 my ($rfh, $wfh);
1309 unless (pipe($rfh, $wfh)) {
1310 die("Can't open pipe: $!");
1311 }
1312
1313 my $ex;
1314
1315 # Fork child
1316 $self->handle_sigchld();
1317 defined(my $pid = fork()) or die("Can't fork: $!");
1318 if ($pid) {
1319 eval {
1320 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
1321 $client->login($setup->{user}, $setup->{passwd});
1322 $client->pwd();
1323 $client->cwd('test.d');
1324 $client->pwd();
1325 $client->quit();
1326 };
1327 if ($@) {
1328 $ex = $@;
1329 }
1330
1331 $wfh->print("done\n");
1332 $wfh->flush();
1333
1334 } else {
1335 eval { server_wait($setup->{config_file}, $rfh) };
1336 if ($@) {
1337 warn($@);
1338 exit 1;
1339 }
1340
1341 exit 0;
1342 }
1343
1344 # Stop server
1345 server_stop($setup->{pid_file});
1346 $self->assert_child_ok($pid);
1347
1348 eval {
1349 my $data = redis_list_getall($fmt_name);
1350
1351 if ($ENV{TEST_VERBOSE}) {
1352 use Data::Dumper;
1353 print STDERR "# Redis data:\n", Dumper($data), "\n";
1354 }
1355
1356 my $nrecords = scalar(@$data);
1357 $self->assert($nrecords == 1, "Expected 1 record, got $nrecords");
1358 };
1359 if ($@) {
1360 $ex = $@;
1361 }
1362
1363 test_cleanup($setup->{log_file}, $ex);
1364 }
1365
1366 sub redis_log_fmt_extra_with_log_on_commmand {
1367 my $self = shift;
1368 my $tmpdir = $self->{tmpdir};
1369 my $setup = test_setup($tmpdir, 'redis');
1370
1371 my $fmt_name = 'custom';
1372 redis_list_delete($fmt_name);
1373
1374 my $config = {
1375 PidFile => $setup->{pid_file},
1376 ScoreboardFile => $setup->{scoreboard_file},
1377 SystemLog => $setup->{log_file},
1378 TraceLog => $setup->{log_file},
1379 Trace => 'jot:20 redis:20',
1380
1381 AuthUserFile => $setup->{auth_user_file},
1382 AuthGroupFile => $setup->{auth_group_file},
1383 AuthOrder => 'mod_auth_file.c',
1384
1385 IfModules => {
1386 'mod_delay.c' => {
1387 DelayEngine => 'off',
1388 },
1389
1390 # Note: we need to use arrays here, since order of directives matters.
1391 'mod_redis.c' => [
1392 'RedisEngine on',
1393 'RedisServer 127.0.0.1:6379',
1394 "RedisLog $setup->{log_file}",
1395 "LogFormat $fmt_name \"%a %u\"",
1396 "RedisLogOnCommand PASS $fmt_name",
1397 "RedisLogFormatExtra $fmt_name {\"foo\":\"%u\",\"bar\":\"BAZ\",\"baz\":{},\"quxx\":[1,3,5],\"quzz\":null}",
1398 ],
1399 },
1400 };
1401
1402 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
1403 $config);
1404
1405 # Open pipes, for use between the parent and child processes. Specifically,
1406 # the child will indicate when it's done with its test by writing a message
1407 # to the parent.
1408 my ($rfh, $wfh);
1409 unless (pipe($rfh, $wfh)) {
1410 die("Can't open pipe: $!");
1411 }
1412
1413 my $ex;
1414
1415 # Fork child
1416 $self->handle_sigchld();
1417 defined(my $pid = fork()) or die("Can't fork: $!");
1418 if ($pid) {
1419 eval {
1420 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
1421 $client->login($setup->{user}, $setup->{passwd});
1422
1423 my $resp_code = $client->response_code();
1424 my $resp_msg = $client->response_msg(0);
1425 $client->quit();
1426
1427 my $expected = 230;
1428 $self->assert($expected == $resp_code,
1429 "Expected response code $expected, got $resp_code");
1430
1431 $expected = "User $setup->{user} logged in";
1432 $self->assert($expected eq $resp_msg,
1433 "Expected response message '$expected', got '$resp_msg'");
1434 };
1435 if ($@) {
1436 $ex = $@;
1437 }
1438
1439 $wfh->print("done\n");
1440 $wfh->flush();
1441
1442 } else {
1443 eval { server_wait($setup->{config_file}, $rfh) };
1444 if ($@) {
1445 warn($@);
1446 exit 1;
1447 }
1448
1449 exit 0;
1450 }
1451
1452 # Stop server
1453 server_stop($setup->{pid_file});
1454 $self->assert_child_ok($pid);
1455
1456 eval {
1457 my $data = redis_list_getall($fmt_name);
1458
1459 my $nrecords = scalar(@$data);
1460 $self->assert($nrecords == 1, "Expected 1 record, got $nrecords");
1461
1462 require JSON;
1463 my $record = decode_json($data->[0]);
1464
1465 my $expected = $setup->{user};
1466 $self->assert($record->{user} eq $expected,
1467 "Expected user '$expected', got '$record->{user}'");
1468
1469 $expected = '127.0.0.1';
1470 $self->assert($record->{remote_ip} eq $expected,
1471 "Expected remote IP '$expected', got '$record->{remote_ip}'");
1472
1473 # Note that we do not expect the "quzz" key, because it is null.
1474 foreach my $key (qw(foo bar baz quxx)) {
1475 $self->assert(defined($record->{$key}),
1476 "Key $key does not exist in record as expected");
1477 }
1478 };
1479 if ($@) {
1480 $ex = $@;
1481 }
1482
1483 test_cleanup($setup->{log_file}, $ex);
1484 }
1485
1486 sub redis_log_fmt_extra_with_log_on_event {
1487 my $self = shift;
1488 my $tmpdir = $self->{tmpdir};
1489 my $setup = test_setup($tmpdir, 'redis');
1490
1491 my $fmt_name = 'custom';
1492 redis_list_delete($fmt_name);
1493
1494 my $config = {
1495 PidFile => $setup->{pid_file},
1496 ScoreboardFile => $setup->{scoreboard_file},
1497 SystemLog => $setup->{log_file},
1498 TraceLog => $setup->{log_file},
1499 Trace => 'jot:20 redis:20',
1500
1501 AuthUserFile => $setup->{auth_user_file},
1502 AuthGroupFile => $setup->{auth_group_file},
1503 AuthOrder => 'mod_auth_file.c',
1504
1505 IfModules => {
1506 'mod_delay.c' => {
1507 DelayEngine => 'off',
1508 },
1509
1510 # Note: we need to use arrays here, since order of directives matters.
1511
1512 # Note: we need to use arrays here, since order of directives matters.
1513 'mod_redis.c' => [
1514 'RedisEngine on',
1515 'RedisServer 127.0.0.1:6379',
1516 "RedisLog $setup->{log_file}",
1517 "LogFormat $fmt_name \"%A %a %b %c %D %d %E %{epoch} %F %f %{gid} %g %H %h %I %{iso8601} %J %L %l %m %O %P %p %{protocol} %R %r %{remote-port} %S %s %T %t %U %u %{uid} %V %v %{version}\"",
1518 "RedisLogOnEvent ALL $fmt_name",
1519 "RedisLogFormatExtra $fmt_name {\"foo\":\"%u\",\"bar\":\"BAZ\",\"baz\":{},\"quxx\":[1,3,5],\"quzz\":null}",
1520 ],
1521 },
1522 };
1523
1524 my ($port, $config_user, $config_group) = config_write($setup->{config_file},
1525 $config);
1526
1527 # Open pipes, for use between the parent and child processes. Specifically,
1528 # the child will indicate when it's done with its test by writing a message
1529 # to the parent.
1530 my ($rfh, $wfh);
1531 unless (pipe($rfh, $wfh)) {
1532 die("Can't open pipe: $!");
1533 }
1534
1535 my $ex;
1536
1537 # Fork child
1538 $self->handle_sigchld();
1539 defined(my $pid = fork()) or die("Can't fork: $!");
1540 if ($pid) {
1541 eval {
1542 my $client = ProFTPD::TestSuite::FTP->new('127.0.0.1', $port);
1543 $client->login($setup->{user}, $setup->{passwd});
1544
1545 my $resp_code = $client->response_code();
1546 my $resp_msg = $client->response_msg(0);
1547 $client->quit();
1548
1549 my $expected = 230;
1550 $self->assert($expected == $resp_code,
1551 "Expected response code $expected, got $resp_code");
1552
1553 $expected = "User $setup->{user} logged in";
1554 $self->assert($expected eq $resp_msg,
1555 "Expected response message '$expected', got '$resp_msg'");
1556 };
1557 if ($@) {
1558 $ex = $@;
1559 }
1560
1561 $wfh->print("done\n");
1562 $wfh->flush();
1563
1564 } else {
1565 eval { server_wait($setup->{config_file}, $rfh) };
1566 if ($@) {
1567 warn($@);
1568 exit 1;
1569 }
1570
1571 exit 0;
1572 }
1573
1574 # Stop server
1575 server_stop($setup->{pid_file});
1576 $self->assert_child_ok($pid);
1577
1578 eval {
1579 my $data = redis_list_getall($fmt_name);
1580
1581 my $nrecords = scalar(@$data);
1582 $self->assert($nrecords == 4 || $nrecords == 5,
1583 "Expected 4-5 records, got $nrecords");
1584
1585 require JSON;
1586 my $record = decode_json($data->[3]);
1587
1588 my $expected = $setup->{user};
1589 $self->assert($record->{user} eq $expected,
1590 "Expected user '$expected', got '$record->{user}'");
1591
1592 $expected = '127.0.0.1';
1593 $self->assert($record->{remote_ip} eq $expected,
1594 "Expected remote IP '$expected', got '$record->{remote_ip}'");
1595
1596 # Note that we do not expect the "quzz" key, because it is null.
1597 foreach my $key (qw(foo bar baz quxx)) {
1598 $self->assert(defined($record->{$key}),
1599 "Key $key does not exist in record as expected");
1600 }
1601 };
1602 if ($@) {
1603 $ex = $@;
1604 }
1605
1606 test_cleanup($setup->{log_file}, $ex);
1607 }
1608
1609 1;