Introduce EXIM_BUILD_SUFFIX for src/Makefile and testsuite
[exim.git] / test / t / 00-basic.t
1 use Test::More;
2 use Test::Pod::Coverage;
3 use Test::Exception;
4
5 use lib 'lib';
6 use_ok 'Exim::Runtest', qw(:all) or BAIL_OUT 'Can not load the module';
7
8 can_ok 'Exim::Runtest', qw(mailgroup dynamic_socket exim_binary);
9 pod_coverage_ok 'Exim::Runtest' => 'docs complete';
10
11 subtest 'mailgroup' => sub {
12 my $group = getgrgid $(;
13 ok $group => 'got a group name';
14 note "use group $group";
15
16 is mailgroup($group), $group => 'group names match';
17 ok $group = mailgroup('non existing group') => 'cope with unknown group';
18 note "got random group: $group";
19
20 ok getgrnam($group) => 'got an existing group';
21
22 dies_ok { mailgroup(22) } 'dies on numeric group';
23 dies_ok { mailgroup() } 'dies on missing default group';
24 };
25
26 subtest 'dynamic_socket' => sub {
27 ok my $socket = dynamic_socket() => 'got a socket';
28 note "got socket on port @{[$socket->sockport]}";
29 isa_ok $socket => 'IO::Socket::INET';
30 cmp_ok $socket->sockport(), '>=', 1024 => 'port is >= 1024';
31 $socket->close;
32 };
33
34 subtest 'exim_binary' => sub {
35 my @argv1 = qw(/bin/sh a b);
36 my @argv2 = qw(t/samples/foo a b);
37 chomp(my $cwd = `pwd`); # don't use Cwd, as we use Cwd in the tested module already
38 is_deeply [exim_binary(@argv1)], \@argv1 => 'got the binary as abs path from argv';
39 is_deeply [exim_binary(@argv2)], ["$cwd/t/samples/foo", @argv2[1,$#argv2]] => 'got the binary as rel path from argv';
40 };
41
42 done_testing;