[svn:parrot] r48268 - in branches/gsoc_instrument/t: dynpmc library
khairul at svn.parrot.org
khairul at svn.parrot.org
Tue Aug 3 03:23:31 UTC 2010
Author: khairul
Date: Tue Aug 3 03:23:30 2010
New Revision: 48268
URL: https://trac.parrot.org/parrot/changeset/48268
Log:
Updated test cases
Modified:
branches/gsoc_instrument/t/dynpmc/instrument.t
branches/gsoc_instrument/t/dynpmc/instrumentclass.t
branches/gsoc_instrument/t/dynpmc/instrumentgc.t
branches/gsoc_instrument/t/dynpmc/instrumentobject.t
branches/gsoc_instrument/t/dynpmc/instrumentop.t
branches/gsoc_instrument/t/library/instrument_eventlibrary.t
branches/gsoc_instrument/t/library/instrument_probe.t
Modified: branches/gsoc_instrument/t/dynpmc/instrument.t
==============================================================================
--- branches/gsoc_instrument/t/dynpmc/instrument.t Tue Aug 3 03:20:16 2010 (r48267)
+++ branches/gsoc_instrument/t/dynpmc/instrument.t Tue Aug 3 03:23:30 2010 (r48268)
@@ -64,12 +64,13 @@
.sub 'test_insert_and_remove_op_hook'
# Plan: Test insertion and removal of hooks.
- .local pmc instr
+ .local pmc instr, instrument
.local pmc probe1, probe2
- probe1 = new ['MockProbe']
- probe2 = new ['MockProbe']
- instr = new ['Instrument']
+ probe1 = new ['MockProbe']
+ probe2 = new ['MockProbe']
+ instrument = new ['Instrument']
+ instr = instrument['runcore']
# Test insert and remove 1 hook on existing op (op 0 = noop).
instr.'insert_op_hook'(probe1, 0)
@@ -135,12 +136,13 @@
.sub 'test_insert_and_remove_op_catchall'
# Plan: Test insertion and removal of catchall probes.
- .local pmc instr
+ .local pmc instr, instrument
.local pmc probe1, probe2
probe1 = new ['MockProbe']
probe2 = new ['MockProbe']
- instr = new ['Instrument']
+ instrument = new ['Instrument']
+ instr = instrument['runcore']
# Test insert and remove 1 catchall.
instr.'insert_op_catchall'(probe1)
Modified: branches/gsoc_instrument/t/dynpmc/instrumentclass.t
==============================================================================
--- branches/gsoc_instrument/t/dynpmc/instrumentclass.t Tue Aug 3 03:20:16 2010 (r48267)
+++ branches/gsoc_instrument/t/dynpmc/instrumentclass.t Tue Aug 3 03:23:30 2010 (r48268)
@@ -232,6 +232,8 @@
.sub test_notification_cb
.param pmc data
+ .param pmc instr
+ .param pmc probe
$P0 = get_global '%notification'
Modified: branches/gsoc_instrument/t/dynpmc/instrumentgc.t
==============================================================================
--- branches/gsoc_instrument/t/dynpmc/instrumentgc.t Tue Aug 3 03:20:16 2010 (r48267)
+++ branches/gsoc_instrument/t/dynpmc/instrumentgc.t Tue Aug 3 03:23:30 2010 (r48268)
@@ -360,12 +360,15 @@
is($S0, 'main', 'Event: Sub ok.')
# Test type.
- $S0 = data['type']
- is($S0, 'do_gc_mark', 'Event: Type ok.')
+ $P10 = data['event']
+ $S0 = join '::', $P10
+ is($S0, 'GC::administration::do_gc_mark', 'Event: Type ok.')
.end
.sub sample_notification_callback
.param pmc data
+ .param pmc instr
+ .param pmc probe
.local pmc results
results = get_global '%!notifications'
@@ -378,8 +381,8 @@
results['file'] = $S0
$S0 = data['sub']
results['sub'] = $S0
- $S0 = data['type']
- results['type'] = $S0
+ $P0 = data['event']
+ results['event'] = $P0
.end
Modified: branches/gsoc_instrument/t/dynpmc/instrumentobject.t
==============================================================================
--- branches/gsoc_instrument/t/dynpmc/instrumentobject.t Tue Aug 3 03:20:16 2010 (r48267)
+++ branches/gsoc_instrument/t/dynpmc/instrumentobject.t Tue Aug 3 03:23:30 2010 (r48268)
@@ -27,7 +27,7 @@
# Load the Instrument library.
load_bytecode 'Instrument/InstrumentLib.pbc'
- plan(0)
+ plan(6)
setup()
test_notification()
@@ -79,30 +79,32 @@
# Test if notifications is raised only for the object that is instrumented.
# Check:
# 1. Event is raised.
- # 2. The event is of type Class::Class_Name::method::Method_Name
+ # 2. The event is of type Object::address::method::Method_Name
+ # 3. The class event still fires.
$P0 = new ['Instrument']
-
- $P1 = get_hll_global ['Instrument'], 'Probe'
- $P2 = $P1.'new'()
+ $P2 = $P0.'instrument_op'()
$P2.'catchall'(1)
$P2.'callback'('test_notification_probe_cb')
-
$P0.'attach'($P2)
+ $P4 = get_hll_global ['Instrument';'Event'], 'Class'
+ $P5 = $P4.'new'()
+
+ $P5.'inspect_class'('TestClass')
+ $P5.'inspect_method'('test')
+ $P5.'callback'('test_notification_class_cb')
+ $P0.'attach'($P5)
+
$P3 = new ['ResizableStringArray']
push $P3, 't/dynpmc/instrumentobject-test1.pir'
$S0 = $P3[0]
# Prepare the globals.
- $P4 = new ['Hash']
- set_global '%notification', $P4
-
- # TODO: Added this to see what events were raised. Remove when done.
- $P8 = $P0['eventdispatcher']
- $P9 = get_global 'event_dumper'
- $P8.'register'('Class', $P9)
- $P8.'register'('Object', $P9)
+ $P6 = new ['Hash']
+ set_global '%notification', $P6
+ $P7 = box 0
+ set_global '$class_event', $P7
$P0.'run'($S0, $P3)
@@ -138,15 +140,15 @@
$S1 = $P12
is($S0, $S1, 'Event: Event ok')
+ # Check that the class event still fires.
+ $P12 = get_global '$class_event'
+ $I0 = $P12
+ is($I0, 1, 'Event: Class event still fires.')
.end
-.sub event_dumper
- .param pmc data
-
- $S0 = data['event']
-
- print 'Event: '
- say $S0
+.sub test_notification_class_cb
+ $P0 = get_global '$class_event'
+ $P0 = 1
.end
.sub test_notification_probe_cb
@@ -160,10 +162,10 @@
# and instrument the object.
$S0 = op.'family'()
if $S0 == 'new' goto INSTRUMENT
-
.return()
INSTRUMENT:
+
$P0 = get_global 'test_notification_probe_instrument_obj'
.return($P0)
.end
@@ -180,10 +182,12 @@
# Get the object.
$P0 = op.'get_arg'(0)
- $P1 = instr.'instrument_object'($P0)
- # Instrument the method.
- $P1.'insert_method_hook'('test')
+ # Instrument the object.
+ $P1 = instr.'instrument_object'($P0)
+ $P1.'inspect_method'('test')
+ $P1.'callback'('test_notification_cb')
+ instr.'attach'($P1)
# Build up the event string.
$P2 = new ['ResizableStringArray']
@@ -196,15 +200,13 @@
$P9 = box $S0
set_global '$notification_object', $P9
-
- # Register the event.
- $P3 = instr['eventdispatcher']
- $P4 = get_global 'test_notification_cb'
- $P3.'register'($S1, $P4)
.end
.sub test_notification_cb
.param pmc data
+ .param pmc instr
+ .param pmc probe
+
$P0 = get_global '%notification'
$P0['called'] = 1
Modified: branches/gsoc_instrument/t/dynpmc/instrumentop.t
==============================================================================
--- branches/gsoc_instrument/t/dynpmc/instrumentop.t Tue Aug 3 03:20:16 2010 (r48267)
+++ branches/gsoc_instrument/t/dynpmc/instrumentop.t Tue Aug 3 03:23:30 2010 (r48268)
@@ -64,19 +64,19 @@
# Test a single opcode.
.local pmc instr, probe, probe_class, args
+ instr = new ['Instrument']
+
# Set up the program args.
args = new ['ResizableStringArray']
args.'push'('t/dynpmc/instrumentop-test1.pir')
# Create a catchall probe.
- probe_class = get_hll_global ['Instrument'], 'Probe'
- probe = probe_class.'new'()
+ probe = instr.'instrument_op'()
probe.'inspect'('say_sc')
probe.'callback'('test_one_op_callback')
# Create the Instrument instance and run it
# against t/dynpmc/instrumentop-test1.pir.
- instr = new ['Instrument']
instr.'attach'(probe)
instr.'run'('t/dynpmc/instrumentop-test1.pir', args)
.end
Modified: branches/gsoc_instrument/t/library/instrument_eventlibrary.t
==============================================================================
--- branches/gsoc_instrument/t/library/instrument_eventlibrary.t Tue Aug 3 03:20:16 2010 (r48267)
+++ branches/gsoc_instrument/t/library/instrument_eventlibrary.t Tue Aug 3 03:23:30 2010 (r48268)
@@ -112,6 +112,8 @@
.sub test_loadlib_callback
.param pmc data
+ .param pmc instr
+ .param pmc probe
# data['library'] is the library name.
$P0 = get_global '%test_loadlib_res'
@@ -151,7 +153,6 @@
fh.'puts'(program)
fh.'close'()
-
# Setup the test.
$P0 = new ['Hash']
$P0['Sc 2: Function Ok?'] = 1
@@ -209,6 +210,8 @@
.sub test_gc_scenario_1
.param pmc data
+ .param pmc instr
+ .param pmc probe
# Test that a singular function was instrumented.
# Record the function name.
@@ -220,6 +223,8 @@
.sub test_gc_scenario_2
.param pmc data
+ .param pmc instr
+ .param pmc probe
# Test that a group function was instrumented.
# Ensure that the function is of type allocate.
@@ -237,6 +242,8 @@
.sub test_gc_scenario_3
.param pmc data
+ .param pmc instr
+ .param pmc probe
# Since the probe was disabled, this should not be called.
$P0 = get_global '%test_gc_res'
Modified: branches/gsoc_instrument/t/library/instrument_probe.t
==============================================================================
--- branches/gsoc_instrument/t/library/instrument_probe.t Tue Aug 3 03:20:16 2010 (r48267)
+++ branches/gsoc_instrument/t/library/instrument_probe.t Tue Aug 3 03:23:30 2010 (r48268)
@@ -122,8 +122,8 @@
args = new ['ResizableStringArray']
push args, 't/library/instrument_probe-dynop.pir'
- probe_class = get_hll_global ['Instrument'], 'Probe'
- probe = probe_class.'new'()
+ instr = new ['Instrument']
+ probe = instr.'instrument_op'()
probe.'inspect'('read_s_p_ic')
# At this point, the dynop does not exist.
@@ -140,7 +140,6 @@
# Attach it to the instrument, run the dynop test file.
# Then recheck the counts.
- instr = new ['Instrument']
instr.'attach'(probe)
instr.'run'('t/library/instrument_probe-dynop.pir', args)
@@ -191,14 +190,15 @@
args = new ['ResizableStringArray']
push args, 't/library/instrument_probe-2-op.pir'
+ instr = new ['Instrument']
+
# Exception handler to catch exit.
eh = new ['ExceptionHandler']
eh.'handle_types'(.CONTROL_ERROR, .CONTROL_EXIT)
eh.'min_severity'(.EXCEPT_NORMAL)
eh.'max_severity'(.EXCEPT_EXIT)
- probe_class = get_hll_global ['Instrument'], 'Probe'
- probe = probe_class.'new'()
+ probe = instr.'instrument_op'()
# Test pass by name.
probe.'callback'('generic_callback')
@@ -245,7 +245,6 @@
probe.'callback'('test_callback_callback')
probe.'inspect'('say_sc')
- instr = new ['Instrument']
instr.'attach'(probe)
instr.'run'('t/library/instrument_probe-2-op.pir', args)
.end
@@ -280,15 +279,14 @@
args = new ['ResizableStringArray']
push args, 't/library/instrument_probe-2-op.pir'
- probe_class = get_hll_global ['Instrument'], 'Probe'
- probe = probe_class.'new'()
+ instr = new ['Instrument']
+ probe = instr.'instrument_op'()
# We only want the callback to be called once.
# So set it to inspect end.
probe.'inspect'('end')
probe.'callback'('test_enable_callback')
- instr = new ['Instrument']
instr.'attach'(probe)
# On attach, the probe is enabled.
@@ -312,15 +310,14 @@
$P0 = box 0
set_global "$test_disable_fail", $P0
- probe_class = get_hll_global ['Instrument'], 'Probe'
- probe = probe_class.'new'()
+ instr = new ['Instrument']
+ probe = instr.'instrument_op'()
# We only want the callback to be called once.
# So set it to inspect end.
probe.'inspect'('end')
probe.'callback'('test_disable_callback')
- instr = new ['Instrument']
instr.'attach'(probe)
# On attach, the probe is enabled.
More information about the parrot-commits
mailing list