9 our @EXPORT_OK = qw(mailgroup dynamic_socket);
14 use List::Util qw'shuffle';
18 Exim::Runtest - helper functions for the runtest script
23 my $foo = Exim::Runtest::foo('foo');
27 The B<Exim::Runtest> module provides some simple functions
28 for the F<runtest> script. No functions are exported yet.
33 my $group = shift // croak "Need a default group name.";
35 croak "Need a group *name*, not a numeric group id."
38 return $group if getgrnam $group;
41 setgrent or die "setgrent: $!\n";
42 push @groups, $_ while defined($_ = getgrent);
44 return (shuffle @groups)[0];
49 for (my $port = 1024; $port < 65000; $port++) {
50 $socket = IO::Socket::INET->new(
51 LocalHost => '127.0.0.1',
57 croak 'Can not allocate a free port.';
68 =item B<mailgroup>(I<$default>)
70 Check if the mailgroup I<$default> exists. Return the checked
71 group name or some other random but existing group.
73 =item B<dynamic_socket>()
75 Return a dynamically allocated listener socket in the range
76 between 1024 and 65534;