Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/CoverageTrackerTest.java @ 22220:20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
- deprecate Node.isInstrumentable() and Node.createWrapperNode(), now Instrumenter methods
- Instrumenter uses new Accessor methods to delegate implementation to TruffleLanguage implementations
- rework many instrumentation-related tests
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Thu, 17 Sep 2015 21:23:57 -0700 |
parents | 1c0f490984d5 |
children | 964e789e17f7 |
rev | line source |
---|---|
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
1 /* |
21568
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18988
diff
changeset
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
4 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
21568
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18988
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18988
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18988
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
10 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
15 * accompanied this code). |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
16 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
20 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
23 * questions. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
24 */ |
21568
3b8bbf51d320
Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18988
diff
changeset
|
25 package com.oracle.truffle.tools.test; |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
26 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
27 import static com.oracle.truffle.tools.test.TestNodes.createExpr13TestRootNode; |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
28 import static com.oracle.truffle.tools.test.ToolTestingLanguage.VALUE_TAG; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
29 import static org.junit.Assert.assertEquals; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
30 import static org.junit.Assert.assertNotNull; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
31 import static org.junit.Assert.assertNull; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
32 import static org.junit.Assert.assertTrue; |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
33 |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
34 import java.io.IOException; |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
35 import java.lang.reflect.Field; |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
36 |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
37 import org.junit.Ignore; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
38 import org.junit.Test; |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
39 |
22219
1c0f490984d5
Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
diff
changeset
|
40 import com.oracle.truffle.api.instrument.Instrumenter; |
1c0f490984d5
Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
diff
changeset
|
41 import com.oracle.truffle.api.instrument.Probe; |
1c0f490984d5
Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
diff
changeset
|
42 import com.oracle.truffle.api.instrument.StandardSyntaxTag; |
1c0f490984d5
Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
diff
changeset
|
43 import com.oracle.truffle.api.nodes.Node; |
1c0f490984d5
Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
diff
changeset
|
44 import com.oracle.truffle.api.nodes.RootNode; |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
45 import com.oracle.truffle.api.source.Source; |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
46 import com.oracle.truffle.api.vm.TruffleVM; |
22219
1c0f490984d5
Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
diff
changeset
|
47 import com.oracle.truffle.tools.CoverageTracker; |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
48 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
49 public class CoverageTrackerTest { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
50 |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
51 @SuppressWarnings("unused") private static com.oracle.truffle.tools.test.ToolTestingLanguage DUMMY = null; |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
52 @SuppressWarnings("unused") private static ToolTestingLanguage INSTANCE = ToolTestingLanguage.INSTANCE; |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
53 |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
54 @Test |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
55 public void testNoExecution() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
56 final TruffleVM vm = TruffleVM.newVM().build(); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
57 final Field field = TruffleVM.class.getDeclaredField("instrumenter"); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
58 field.setAccessible(true); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
59 final Instrumenter instrumenter = (Instrumenter) field.get(vm); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
60 final CoverageTracker tool = new CoverageTracker(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
61 assertEquals(tool.getCounts().entrySet().size(), 0); |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
62 tool.install(instrumenter); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
63 assertEquals(tool.getCounts().entrySet().size(), 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
64 tool.setEnabled(false); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
65 assertEquals(tool.getCounts().entrySet().size(), 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
66 tool.setEnabled(true); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
67 assertEquals(tool.getCounts().entrySet().size(), 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
68 tool.reset(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
69 assertEquals(tool.getCounts().entrySet().size(), 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
70 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
71 assertEquals(tool.getCounts().entrySet().size(), 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
72 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
73 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
74 @Test |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
75 public void testToolCreatedTooLate() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, IOException { |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
76 final TruffleVM vm = TruffleVM.newVM().build(); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
77 final Field field = TruffleVM.class.getDeclaredField("instrumenter"); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
78 field.setAccessible(true); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
79 final Instrumenter instrumenter = (Instrumenter) field.get(vm); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
80 final CoverageTracker tool = new CoverageTracker(VALUE_TAG); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
81 tool.install(instrumenter); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
82 final Source source = Source.fromText("testToolCreatedTooLate text", "testToolCreatedTooLate").withMimeType("text/x-toolTest"); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
83 assertEquals(vm.eval(source).get(), 13); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
84 assertTrue(tool.getCounts().isEmpty()); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
85 tool.dispose(); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
86 } |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
87 |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
88 @Ignore |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
89 @Test |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
90 public void testToolInstalledcTooLate() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
91 final Instrumenter instrumenter = TestNodes.createInstrumenter(); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
92 final CoverageTracker tool = new CoverageTracker(); |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
93 final RootNode expr13rootNode = createExpr13TestRootNode(instrumenter); |
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
94 |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
95 tool.install(instrumenter); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
96 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
97 assertTrue(tool.getCounts().isEmpty()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
98 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
99 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
100 |
22220
20380d1d41f2
Truffle/Instrumentation: second merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22219
diff
changeset
|
101 @Ignore |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
102 @Test |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
103 public void testCountingCoverage() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
104 final Instrumenter instrumenter = TestNodes.createInstrumenter(); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
105 final CoverageTracker tool = new CoverageTracker(); |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
106 tool.install(instrumenter); |
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
107 final RootNode expr13rootNode = createExpr13TestRootNode(instrumenter); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
108 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
109 // Not probed yet. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
110 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
111 assertTrue(tool.getCounts().isEmpty()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
112 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
113 final Node addNode = expr13rootNode.getChildren().iterator().next(); |
22214
3aad794eec0e
Truffle/Instrumentation: first large merge of instrumentation code into the TruffleVM framework
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
21951
diff
changeset
|
114 final Probe probe = instrumenter.probe(addNode); |
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
115 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
116 // Probed but not tagged yet. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
117 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
118 assertTrue(tool.getCounts().isEmpty()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
119 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
120 probe.tagAs(StandardSyntaxTag.STATEMENT, "fake statement for testing"); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
121 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
122 // Counting now; execute once |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
123 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
124 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
125 final Long[] longs1 = tool.getCounts().get(addNode.getSourceSection().getSource()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
126 assertNotNull(longs1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
127 assertEquals(longs1.length, 2); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
128 assertNull(longs1[0]); // Line 1 is empty (text lines are 1-based) |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
129 assertEquals(1L, longs1[1].longValue()); // Expression is on line 2 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
130 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
131 // Execute 99 more times |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
132 for (int i = 0; i < 99; i++) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
133 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
134 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
135 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
136 final Long[] longs100 = tool.getCounts().get(addNode.getSourceSection().getSource()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
137 assertNotNull(longs100); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
138 assertEquals(longs100.length, 2); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
139 assertNull(longs100[0]); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
140 assertEquals(100L, longs100[1].longValue()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
141 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
142 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
143 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
144 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
145 } |