Debian Codegraph @

t/08_rand.t

raw symbols SCIP
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use sigtrap qw(die normal-signals error-signals);
6
7 use Errno ':POSIX';
8 use Test::More tests => 14;
9
10 use POSIX::2008;
11
12 SKIP: {
13 if (! defined &POSIX::2008::getentropy) {
14 skip 'getentropy() UNAVAILABLE', 14;
15 }
16
17 if (! defined POSIX::2008::getentropy(1) && $! == ENOSYS) {
18 skip 'getentropy() UNAVAILABLE', 14;
19 }
20
21 foreach my $l (~0, -273, 16361) {
22 my $rv = POSIX::2008::getentropy($l);
23 is($rv, undef, "getentropy($l) is undef");
24 cmp_ok($!, '==', EINVAL, "getentropy($l) fails with EINVAL");
25 }
26
27 foreach my $l (0, 12, 93, 164) {
28 my $rv = POSIX::2008::getentropy($l);
29 isnt($rv, undef, "getentropy($l) is defined");
30 cmp_ok(length("$rv"), '==', $l, "getentropy($l) has length $l");
31 }
32 }