Testsuite: Add flavour detection
[exim.git] / test / t / 00-basic.t
CommitLineData
acda7677 1use Test::More;
b1227303
HSHR
2use Test::Pod::Coverage;
3use Test::Exception;
4
acda7677 5use lib 'lib';
87e93574 6use_ok 'Exim::Runtest', qw(:all) or BAIL_OUT 'Can not load the module';
acda7677 7
6336058c 8can_ok 'Exim::Runtest', qw(mailgroup dynamic_socket exim_binary flavour flavours);
b1227303 9pod_coverage_ok 'Exim::Runtest' => 'docs complete';
acda7677 10
b16852e2
HSHR
11subtest 'mailgroup' => sub {
12 my $group = getgrgid $(;
13 ok $group => 'got a group name';
b1227303 14 note "use group $group";
acda7677 15
87e93574
HSHR
16 is mailgroup($group), $group => 'group names match';
17 ok $group = mailgroup('non existing group') => 'cope with unknown group';
b1227303 18 note "got random group: $group";
acda7677 19
b16852e2 20 ok getgrnam($group) => 'got an existing group';
b1227303 21
87e93574
HSHR
22 dies_ok { mailgroup(22) } 'dies on numeric group';
23 dies_ok { mailgroup() } 'dies on missing default group';
b16852e2 24};
acda7677 25
b369d470 26subtest 'dynamic_socket' => sub {
87e93574 27 ok my $socket = dynamic_socket() => 'got a socket';
b1227303 28 note "got socket on port @{[$socket->sockport]}";
b369d470 29 isa_ok $socket => 'IO::Socket::INET';
58ae4e3e 30 cmp_ok $socket->sockport(), '>=', 1024 => 'port is >= 1024';
b369d470
HSHR
31 $socket->close;
32};
acda7677 33
fefe59d9
HSHR
34subtest '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};
acda7677 41
6336058c
HSHR
42subtest 'flavour' => sub {
43 is flavour('t/samples/etc.debian8-os-release'), 'debian8' => 'got flavour debian8 from os-release';
44 is flavour('t/samples/etc.debian8-debian-version'), 'debian8' => 'got flavour debian8 from debian_version';
45 is flavour('t/samples/etc.fedora24'), 'fedora24' => 'got flavour fedora24 from os-release';
46 is_deeply [flavours()], ['debian8'] => 'got available flavours';
47};
48
acda7677 49done_testing;