Testsuite: structure the testsuite test
[exim.git] / test / lib / Exim / Runtest.pm
CommitLineData
1f187290
HSHR
1package Exim::Runtest;
2use strict;
3use warnings;
4use Carp;
5
6use List::Util qw'shuffle';
7
8
9# find a group name, preferrable 'mail', but
10# use some other random name if 'mail' isn't a valid group
11# name
12sub mailgroup {
13 my $group = shift;
14
15 croak "Need a group *name*, not a numeric group id."
16 if $group =~ /^\d+$/;
17
18 return $group if getgrnam $group;
19
20 my @groups;
21 setgrent or die "setgrent: $!\n";
22 push @groups, $_ while defined($_ = getgrent);
23 endgrent;
24 return (shuffle @groups)[0];
25};
26
27
281;