Testsuite: structure the testsuite test
[exim.git] / test / lib / Exim / Runtest.pm
1 package Exim::Runtest;
2 use strict;
3 use warnings;
4 use Carp;
5
6 use 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
12 sub 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
28 1;