summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2016-11-18 14:13:22 +0000
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2016-11-18 14:17:28 +0000
commit51d89e3583b4182c42c21b343376f2286f67fc3b (patch)
treeb80b6dadf7cb27ab8041252f353b8d171e1b3acd
parent5107ee87c4e62c09d0b66489e92b3d2b0d67c266 (diff)
downloadperl-51d89e3583b4182c42c21b343376f2286f67fc3b.tar.gz
Use test.pl functions in t/op/groups.t
The test file was already loading test.pl, but not using any functions other than skip_all(_if_miniperl). This ports the rest of the test to using note(), skip() and ok(). Diff is best read with -w and --color-words or --word-diff.
-rw-r--r--t/op/groups.t79
1 files changed, 35 insertions, 44 deletions
diff --git a/t/op/groups.t b/t/op/groups.t
index 06cd3f5f15..e50c50a8c1 100644
--- a/t/op/groups.t
+++ b/t/op/groups.t
@@ -44,50 +44,49 @@ sub Test {
my $pwgid = $( + 0;
my ($pwgnam) = getgrgid($pwgid);
$pwgnam //= '';
- print "# pwgid=$pwgid pwgnam=$pwgnam \$(=$(\n";
+ note "pwgid=$pwgid pwgnam=$pwgnam \$(=$(";
# Get perl's supplementary groups by looking at $(
my ( $gid_count, $all_perl_groups ) = perl_groups();
my %basegroup = basegroups( $pwgid, $pwgnam );
my @extracted_supplementary_groups = remove_basegroup( \ %basegroup, \ @extracted_groups );
- print "1..2\n";
+ plan 2;
# Test: The supplementary groups in $( should match the
# getgroups(2) kernal API call.
#
- my $ngroups_max = posix_ngroups_max();
- if ( defined $ngroups_max && $ngroups_max < @extracted_groups ) {
- # Some OSes (like darwin)but conceivably others might return
- # more groups from `id -a' than can be handled by the
- # kernel. On darwin, NGROUPS_MAX is 16 and 12 are taken up for
- # the system already.
- #
- # There is more fall-out from this than just Perl's unit
- # tests. You may be a member of a group according to Active
- # Directory (or whatever) but the OS won't respect it because
- # it's the 17th (or higher) group and there's no space to
- # store your membership.
- print "ok 1 # SKIP Your platform's `$groups_command' is broken\n";
- }
-
- elsif ( darwin() ) {
- # darwin uses getgrouplist(3) or an Open Directory API within
- # /usr/bin/id and /usr/bin/groups which while "nice" isn't
- # accurate for this test. The hard, real, list of groups we're
- # running in derives from getgroups(2) and is not dynamic but
- # the Libc API getgrouplist(3) is.
- #
- # In practical terms, this meant that while `id -a' can be
- # relied on in other OSes to purely use getgroups(2) and show
- # us what's real, darwin will use getgrouplist(3) to show us
- # what might be real if only we'd open a new console.
- #
- print "ok 1 # SKIP darwin's `${groups_command}' can't be trusted\n";
- }
+ SKIP: {
+ my $ngroups_max = posix_ngroups_max();
+ if ( defined $ngroups_max && $ngroups_max < @extracted_groups ) {
+ # Some OSes (like darwin)but conceivably others might return
+ # more groups from `id -a' than can be handled by the
+ # kernel. On darwin, NGROUPS_MAX is 16 and 12 are taken up for
+ # the system already.
+ #
+ # There is more fall-out from this than just Perl's unit
+ # tests. You may be a member of a group according to Active
+ # Directory (or whatever) but the OS won't respect it because
+ # it's the 17th (or higher) group and there's no space to
+ # store your membership.
+ skip "Your platform's `$groups_command' is broken";
+ }
- else {
+ if ( darwin() ) {
+ # darwin uses getgrouplist(3) or an Open Directory API within
+ # /usr/bin/id and /usr/bin/groups which while "nice" isn't
+ # accurate for this test. The hard, real, list of groups we're
+ # running in derives from getgroups(2) and is not dynamic but
+ # the Libc API getgrouplist(3) is.
+ #
+ # In practical terms, this meant that while `id -a' can be
+ # relied on in other OSes to purely use getgroups(2) and show
+ # us what's real, darwin will use getgrouplist(3) to show us
+ # what might be real if only we'd open a new console.
+ #
+ skip "darwin's `${groups_command}' can't be trusted";
+ }
# Read $( but ignore any groups in $( that we failed to parse
# successfully out of the `id -a` mess.
@@ -101,7 +100,6 @@ sub Test {
if ( match_groups( \ @supplementary_groups,
\ @extracted_supplementary_groups,
$pwgid ) ) {
- print "ok 1\n";
$ok1 = 1;
}
elsif ( cygwin_nt() ) {
@@ -111,24 +109,17 @@ sub Test {
if ( match_groups( \ @supplementary_groups,
\ @extracted_supplementary_groups,
$pwgid ) ) {
- print "ok 1 # This Cygwin behaves like Unix (Win2k?)\n";
+ note "This Cygwin behaves like Unix (Win2k?)";
$ok1 = 1;
}
}
- unless ( $ok1 ) {
- print "nok 1 (perl's `\$(' disagrees with `${groups_command}'\n";
- }
+ ok $ok1, "perl's `\$(' agrees with `${groups_command}'";
}
# multiple 0's indicate GROUPSTYPE is currently long but should be short
$gid_count->{0} //= 0;
- if ( 0 == $pwgid || $gid_count->{0} < 2 ) {
- print "ok 2\n";
- }
- else {
- print "not ok 2 (groupstype should be type short, not long)\n";
- }
+ ok 0 == $pwgid || $gid_count->{0} < 2, "groupstype should be type short, not long";
return;
}
@@ -258,7 +249,7 @@ sub extract_system_groups {
push @extracted, $+{gr_name} || $+{gid};
}
else {
- print "# ignoring group entry [$_]\n";
+ note "ignoring group entry [$_]";
}
}