3 no warnings qw(redefine once);
8 use Test::More tests => 6;
12 require './l7directord';
15 our @system_wrapper_args = ();
16 our @system_wrapper_returns = ();
17 #...............................................
22 local @system_wrapper_args = ();
23 local @system_wrapper_returns = ();
25 is_deeply \@system_wrapper_args, [], 'ld_cmd_children - no execute';
29 local @system_wrapper_args = ();
30 local @system_wrapper_returns = ();
31 $main::CONFIG{execute} = { subconf1 => 1, subconf2 => 1 };
33 is_deeply \@system_wrapper_args, [], 'ld_cmd_children - exists execute, but no command';
37 local @system_wrapper_args = ();
38 local @system_wrapper_returns = ();
39 $main::CONFIG{execute} = { subconf1 => 1, subconf2 => 1 };
40 ld_cmd_children('start');
41 is_deeply \@system_wrapper_args, ['l7directord subconf1 start', 'l7directord subconf2 start'],
42 'ld_cmd_children - exists execute and command';
46 local @system_wrapper_args = ();
47 local @system_wrapper_returns = ();
48 $main::CONFIG{execute} = { subconf1 => 1, subconf2 => 1 };
49 ld_cmd_children('start', {});
50 is_deeply \@system_wrapper_args, [], 'ld_cmd_children - specified empty config';
54 local @system_wrapper_args = ();
55 local @system_wrapper_returns = ();
56 my $execute = { subconf1 => 1, subconf2 => 1 };
57 ld_cmd_children(undef, $execute);
58 is_deeply \@system_wrapper_args, [], 'ld_cmd_children - specified config but not exist command';
62 local @system_wrapper_args = ();
63 local @system_wrapper_returns = ();
64 my $execute = { subconf1 => 1, subconf2 => 1 };
65 ld_cmd_children('start', $execute);
66 is_deeply \@system_wrapper_args, ['l7directord subconf1 start', 'l7directord subconf2 start'],
67 'ld_cmd_children - specified config and exists command';
70 #...............................................
75 %main::CONFIG = %main::GLOBAL;
76 $main::PROC_ENV{l7directord} = 'l7directord';
79 *system_wrapper = \&__system_wrapper;
82 sub __system_wrapper {
83 push @system_wrapper_args, @_;
84 return shift @system_wrapper_returns;