Commit | Line | Data |
---|---|---|
90e44bf6 Z |
1 | use strict; |
2 | ||
3 | use Test::More 0.82 tests => 4; | |
4 | use t::Watchdog; | |
5 | ||
6 | BEGIN { require_ok "Time::HiRes"; } | |
7 | ||
8 | use Config; | |
9 | ||
10 | my $xdefine = ''; | |
11 | if (open(XDEFINE, "xdefine")) { | |
12 | chomp($xdefine = <XDEFINE> || ""); | |
13 | close(XDEFINE); | |
14 | } | |
15 | ||
16 | my $can_subsecond_alarm = | |
17 | defined &Time::HiRes::gettimeofday && | |
18 | defined &Time::HiRes::ualarm && | |
19 | defined &Time::HiRes::usleep && | |
20 | ($Config{d_ualarm} || $xdefine =~ /-DHAS_UALARM/); | |
21 | ||
22 | eval { Time::HiRes::sleep(-1) }; | |
23 | like $@, qr/::sleep\(-1\): negative time not invented yet/, | |
24 | "negative time error"; | |
25 | ||
26 | SKIP: { | |
27 | skip "no subsecond alarm", 2 unless $can_subsecond_alarm; | |
28 | my $f = Time::HiRes::time; | |
29 | note "time...$f"; | |
30 | ok 1; | |
31 | ||
32 | my $r = [Time::HiRes::gettimeofday()]; | |
33 | Time::HiRes::sleep (0.5); | |
34 | note "sleep...", Time::HiRes::tv_interval($r); | |
35 | ok 1; | |
36 | } | |
37 | ||
38 | 1; |