"Fossies" - the Fresh Open Source Software Archive

Member "Time-HiRes-1.9764/t/sleep.t" (10 Aug 2020, 856 Bytes) of package /linux/privat/Time-HiRes-1.9764.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

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