]> git.vpit.fr Git - perl/modules/Linux-SysInfo.git/blob - t/30-threads.t
Skip threads tests unless perl version is 5.13.4 or greater
[perl/modules/Linux-SysInfo.git] / t / 30-threads.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use Linux::SysInfo::TestThreads;
8
9 use Test::More 'no_plan';
10
11 use Linux::SysInfo qw<sysinfo>;
12
13 sub try {
14  my $tid = threads->tid();
15  SKIP: {
16   my $si = sysinfo;
17   skip 'system error (sysinfo returned undef)' => 4 unless defined $si;
18   is ref($si), 'HASH', "sysinfo returns a hash reference in thread $tid";
19
20   for (1 .. 3) {
21    if (defined $si->{uptime}) {
22     like $si->{uptime}, qr/^\d+(?:\.\d+)?$/,
23                                     "key $_ looks like a number in thread $tid";
24    } else {
25     fail "key $_ isn't defined in thread $tid";
26    }
27   }
28  }
29 }
30
31 my @threads = map spawn(\&try, $_), 1 .. 10;
32
33 $_->join for @threads;
34
35 pass 'done';