2 # Copyright (C) 2001-2008, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 7;
14 t/pmc/timer.t - Timer PMCs
26 $ENV{TEST_PROG_ARGS} ||= '';
28 pasm_output_is( <<'CODE', <<'OUT', "Timer setup" );
31 set P0[.PARROT_TIMER_SEC], 7
32 set I0, P0[.PARROT_TIMER_SEC]
37 set I0, P0[.PARROT_TIMER_USEC]
43 set I0, P0[.PARROT_TIMER_RUNNING]
55 pasm_output_is( <<'CODE', <<'OUT', "Timer setup - initializer" );
57 new P1, ['FixedPMCArray']
59 set P1[0], .PARROT_TIMER_SEC
61 set P1[2], .PARROT_TIMER_USEC
65 set I0, P0[.PARROT_TIMER_SEC]
70 set I0, P0[.PARROT_TIMER_USEC]
78 set I0, P0[.PARROT_TIMER_RUNNING]
91 skip( "No thread enabled", 3 ) unless ( $PConfig{HAS_THREADS} );
93 pasm_output_like( <<'CODE', <<'OUT', "Timer setup - initializer/start" );
95 new P1, ['FixedPMCArray']
97 set P1[0], .PARROT_TIMER_NSEC
99 set P1[2], .PARROT_TIMER_HANDLER
100 get_global P2, "_timer_sub"
102 set P1[4], .PARROT_TIMER_RUNNING
105 new P0, ['Timer'], P1
117 pasm_output_is( <<'CODE', <<'OUT', "Timer setup - initializer/start/stop" );
118 .include "timer.pasm"
119 new P1, ['FixedPMCArray']
121 set P1[0], .PARROT_TIMER_NSEC
123 set P1[2], .PARROT_TIMER_HANDLER
124 get_global P2, "_timer_sub"
126 set P1[4], .PARROT_TIMER_RUNNING
129 new P0, ['Timer'], P1
132 set P0[.PARROT_TIMER_RUNNING], 0
144 my @todo = $ENV{TEST_PROG_ARGS} =~ /--runcore=jit/ ?
145 ( todo => 'TT #1316, add scheduler features to JIT' ) : ();
146 pasm_output_is( <<'CODE', <<'OUT', "Timer setup - initializer/start/repeat" , @todo );
147 .include "timer.pasm"
148 new P1, ['FixedPMCArray']
150 set P1[0], .PARROT_TIMER_NSEC
152 set P1[2], .PARROT_TIMER_HANDLER
153 get_global P2, "_timer_sub"
155 set P1[4], .PARROT_TIMER_REPEAT
157 set P1[6], .PARROT_TIMER_RUNNING
160 new P0, ['Timer'], P1
180 pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
186 does bool1, pmc1, "scalar"
189 does bool1, pmc1, "event"
192 does bool1, pmc1, "no_interface"
203 pir_output_is( << 'CODE', << 'OUTPUT', "Timer - many repetitions" );
205 .include 'timer.pasm'
208 $P0 = get_global "expired_count"
214 set_global "expired_count", $P2
217 $P1 = get_global "expired"
219 $P0[.PARROT_TIMER_HANDLER] = $P1
220 $P0[.PARROT_TIMER_SEC] = 0
221 $P0[.PARROT_TIMER_REPEAT] = 9999
222 $P0[.PARROT_TIMER_RUNNING] = 1
226 if $P2 < 10000 goto loop
237 # cperl-indent-level: 4
240 # vim: expandtab shiftwidth=4: