Commit | Line | Data |
---|---|---|
4bd7f2db AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 Ericsson | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * Matthew Khouzam - Initial API and implementation | |
f2847103 | 10 | * Simon Delisle - Generate dummy trace |
4bd7f2db AM |
11 | *******************************************************************************/ |
12 | ||
791072b0 MK |
13 | package org.eclipse.linuxtools.ctf.core.tests.trace; |
14 | ||
0594c61c AM |
15 | import static org.junit.Assert.assertEquals; |
16 | import static org.junit.Assert.assertNotNull; | |
791072b0 MK |
17 | |
18 | import java.io.File; | |
19 | import java.io.FileOutputStream; | |
20 | import java.io.FileWriter; | |
21 | import java.io.IOException; | |
f2847103 SD |
22 | import java.nio.ByteBuffer; |
23 | import java.nio.ByteOrder; | |
0594c61c | 24 | import java.util.Map; |
791072b0 | 25 | |
8e964be1 | 26 | import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; |
791072b0 MK |
27 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
28 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; | |
8e964be1 | 29 | import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration; |
791072b0 | 30 | import org.eclipse.linuxtools.internal.ctf.core.event.metadata.IOStructGen; |
f2847103 | 31 | import org.junit.After; |
791072b0 MK |
32 | import org.junit.Test; |
33 | ||
34 | /** | |
35 | * Unit tests for {@link IOStructGen} | |
791072b0 | 36 | * |
4bd7f2db | 37 | * @author Matthew Khouzam |
791072b0 | 38 | */ |
791072b0 MK |
39 | public class IOstructgenTest { |
40 | ||
791072b0 MK |
41 | private static final String metadataDecs = "typealias integer { size = 8; align = 8; signed = false; } := uint8_t;\n" |
42 | + "typealias integer { size = 16; align = 8; signed = false; } := uint16_t;\n" | |
43 | + "typealias integer { size = 32; align = 8; signed = false; } := uint32_t;\n" | |
44 | + "typealias integer { size = 64; align = 8; signed = false; } := uint64_t;\n" | |
45 | + "typealias integer { size = 64; align = 8; signed = false; } := unsigned long;\n" | |
46 | + "typealias integer { size = 5; align = 1; signed = false; } := uint5_t;\n" | |
47 | + "typealias integer { size = 27; align = 1; signed = false; } := uint27_t;\n" | |
48 | + "typealias integer { size = 32; align = 1; signed = true; base = decimal; } := int32_t;\n" | |
49 | + "typealias integer { size = 31; align = 1; signed = true; base = dec; } := int31_t;\n" | |
50 | + "typealias integer { size = 30; align = 1; signed = true; base = d; } := int30_t;\n" | |
51 | + "typealias integer { size = 29; align = 1; signed = true; base = i; } := int29_t;\n" | |
52 | + "typealias integer { size = 28; align = 1; signed = true; base = u; } := int28_t;\n" | |
53 | + "typealias integer { size = 27; align = 1; signed = true; base = hexadecimal; } := int27_t;\n" | |
54 | + "typealias integer { size = 26; align = 1; signed = true; base = hex; } := int26_t;\n" | |
55 | + "typealias integer { size = 25; align = 1; signed = true; base = x; } := int25_t;\n" | |
56 | + "typealias integer { size = 24; align = 1; signed = true; base = X; } := int24_t;\n" | |
57 | + "typealias integer { size = 23; align = 1; signed = true; base = p; } := int23_t;\n" | |
58 | + "typealias integer { size = 22; align = 1; signed = true; base = 16; } := int22_t;\n" | |
59 | + "typealias integer { size = 21; align = 1; signed = true; base = oct; } := int21_t;\n" | |
60 | + "typealias integer { size = 20; align = 1; signed = true; base = b; } := int20_t;\n" | |
61 | + "typealias integer { size = 19; align = 1; signed = true; base = octal; } := int19_t;\n" | |
62 | + "typealias integer { size = 18; align = 1; signed = true; base = o; } := int18_t;\n" | |
63 | + "typealias integer { size = 17; align = 1; signed = true; base = binary; } := int17_t;\n" | |
64 | + "\n" | |
65 | + "trace {\n" | |
66 | + " major = 1;\n" | |
67 | + " minor = 8;\n" | |
68 | + " uuid = \"b04d391b-e736-44c1-8d89-4bb438857f8d\";\n" | |
69 | + " byte_order = le;\n" | |
70 | + " packet.header := struct {\n" | |
71 | + " uint32_t magic;\n" | |
72 | + " uint8_t uuid[16];\n" | |
73 | + " uint32_t stream_id;\n" + " };\n" + "};\n" + "\n"; | |
74 | private static final String environmentMD = "env {\n" | |
75 | + " hostname = \"DemoSystem\";\n" | |
76 | + " vpid = 1337;\n" | |
77 | + " procname = \"demo\";\n" | |
78 | + " domain = \"autogenerated\";\n" | |
79 | + " tracer_name = \"tmf\";\n" | |
80 | + " tracer_major = 2;\n" | |
81 | + " tracer_minor = 0x01;\n" | |
82 | + " tracer_patchlevel = 0;\n" | |
83 | + "};\n" + "\n"; | |
84 | private static final String clockMD = "clock {\n" + " name = monotonic;\n" | |
85 | + " uuid = \"cbf9f42e-9be7-4798-a96f-11db556e2ebb\";\n" | |
86 | + " description = \"Monotonic Clock\";\n" | |
87 | + " freq = 1000000000; /* Frequency, in Hz */\n" | |
88 | + " /* clock value offset from Epoch is: offset * (1/freq) */\n" | |
89 | + " offset = 1350310657466295832;\n" + "};\n" | |
90 | + "\n"; | |
91 | ||
92 | private static final String ctfStart = | |
b146ad80 SD |
93 | "typealias integer {\n" |
94 | + " size = 27; align = 1; signed = false;\n" | |
95 | + " map = clock.monotonic.value;\n" | |
96 | + "} := uint27_clock_monotonic_t;\n" | |
97 | + "\n" | |
98 | + "typealias integer {\n" | |
99 | + " size = 32; align = 8; signed = false;\n" | |
100 | + " map = clock.monotonic.value;\n" | |
101 | + "} := uint32_clock_monotonic_t;\n" | |
102 | + "\n" | |
103 | + "typealias integer {\n" | |
104 | + " size = 64; align = 8; signed = false;\n" | |
105 | + " map = clock.monotonic.value;\n" | |
106 | + "} := uint64_clock_monotonic_t;\n" | |
107 | + "\n"; | |
791072b0 MK |
108 | |
109 | private static final String ctfHeaders = | |
b146ad80 SD |
110 | "struct packet_context {\n" |
111 | + " uint64_clock_monotonic_t timestamp_begin;\n" | |
112 | + " uint64_clock_monotonic_t timestamp_end;\n" | |
113 | + " uint64_t content_size;\n" | |
114 | + " uint64_t packet_size;\n" | |
115 | + " unsigned long events_discarded;\n" | |
116 | + " uint32_t cpu_id;\n" | |
117 | + "};\n" | |
118 | + "\n" | |
119 | + "struct event_header_compact {\n" | |
120 | + " enum : uint5_t { compact = 0 ... 30, extended = 31 } id;\n" | |
121 | + " variant <id> {\n" | |
122 | + " struct {\n" | |
123 | + " uint27_clock_monotonic_t timestamp;\n" | |
124 | + " } compact;\n" | |
125 | + " struct {\n" | |
126 | + " uint32_t id;\n" | |
127 | + " uint64_clock_monotonic_t timestamp;\n" | |
128 | + " } extended;\n" | |
129 | + " } v;\n" | |
130 | + "} align(8);\n" | |
131 | + "\n" | |
132 | + "struct event_header_large {\n" | |
133 | + " enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;\n" | |
134 | + " variant <id> {\n" + " struct {\n" | |
135 | + " uint32_clock_monotonic_t timestamp;\n" | |
136 | + " } compact;\n" + " struct {\n" | |
137 | + " uint32_t id;\n" | |
138 | + " uint64_clock_monotonic_t timestamp;\n" | |
139 | + " } extended;\n" + " } v;\n" + "} align(8);\n" + "\n"; | |
791072b0 MK |
140 | |
141 | private static final String ctfBody = "stream {\n" | |
142 | + " id = 0;\n" | |
143 | + " event.header := struct event_header_compact;\n" | |
144 | + " packet.context := struct packet_context;\n" | |
145 | + " event.context := struct {\n" | |
146 | + " integer { size = 64; align = 8; signed = 0; encoding = none; base = 16; } _ip;\n" | |
147 | + " };\n" | |
148 | + "};\n" | |
149 | + "\n" | |
150 | + "event {\n" | |
151 | + " name = \"ust_tests_demo3:done\";\n" | |
152 | + " id = 0;\n" | |
153 | + " stream_id = 0;\n" | |
154 | + " loglevel = 4;\n" | |
155 | + " fields := struct {\n" | |
156 | + " integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _value;\n" | |
157 | + " };\n" | |
158 | + "};\n" | |
159 | + "\n" | |
160 | + "event {\n" | |
161 | + " name = \"ust_tests_demo:starting\";\n" | |
162 | + " id = 1;\n" | |
163 | + " stream_id = 0;\n" | |
164 | + " loglevel = 2;\n" | |
165 | + " model.emf.uri = \"http://example.com/path_to_model?q=ust_tests_demo:starting\";\n" | |
166 | + " fields := struct {\n" | |
167 | + " integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _value;\n" | |
168 | + " };\n" | |
169 | + "};\n" | |
170 | + "\n" | |
171 | + "event {\n" | |
172 | + " name = \"ust_tests_demo:done\";\n" | |
173 | + " id = 2;\n" | |
174 | + " stream_id = 0;\n" | |
175 | + " loglevel = 2;\n" | |
176 | + " model.emf.uri = \"http://example.com/path_to_model?q=ust_tests_demo:done\";\n" | |
177 | + " fields := struct {\n" | |
178 | + " integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _value;\n" | |
179 | + " };\n" | |
180 | + "};\n" | |
181 | + "\n" | |
182 | + "event {\n" | |
183 | + " name = \"ust_tests_demo2:loop\";\n" | |
184 | + " id = 3;\n" | |
185 | + " stream_id = 0;\n" | |
186 | + " loglevel = 4;\n" | |
187 | + " fields := struct {\n" | |
188 | + " integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _intfield;\n" | |
189 | + " integer { size = 32; align = 8; signed = 1; encoding = none; base = 16; } _intfield2;\n" | |
190 | + " integer { size = 64; align = 8; signed = 1; encoding = none; base = 10; } _longfield;\n" | |
191 | + " integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; byte_order = be; } _netintfield;\n" | |
192 | + " integer { size = 32; align = 8; signed = 1; encoding = none; base = 16; byte_order = be; } _netintfieldhex;\n" | |
193 | + " integer { size = 64; align = 8; signed = 1; encoding = none; base = 10; } _arrfield1[3];\n" | |
194 | + " integer { size = 8; align = 8; signed = 1; encoding = UTF8; base = 10; } _arrfield2[10];\n" | |
195 | + " integer { size = 64; align = 8; signed = 0; encoding = none; base = 10; } __seqfield1_length;\n" | |
196 | + " integer { size = 8; align = 8; signed = 1; encoding = none; base = 10; } _seqfield1[ __seqfield1_length ];\n" | |
197 | + " integer { size = 64; align = 8; signed = 0; encoding = none; base = 10; } __seqfield2_length;\n" | |
198 | + " integer { size = 8; align = 8; signed = 1; encoding = UTF8; base = 10; } _seqfield2[ __seqfield2_length ];\n" | |
199 | + " string _stringfield;\n" | |
200 | + " floating_point { exp_dig = 8; mant_dig = 24; align = 8; } _floatfield;\n" | |
201 | + " floating_point { exp_dig = 11; mant_dig = 53; align = 8; } _doublefield;\n" | |
202 | + " };\n" | |
203 | + "};\n" | |
204 | + "\n"; | |
205 | ||
206 | private static final String enumMd = | |
b146ad80 SD |
207 | "typealias integer { size = 32; align = 8; signed = false; } := int;\n" |
208 | + "typealias enum { ONE = 0, a,b,c=10, d} := useless_enum;\n" | |
209 | + "struct useless{ \n" | |
210 | + " enum : uint8_t { A=0, \"B\",} enum3;\n" | |
211 | + " useless_enum enum2;" | |
212 | + " enum { C, D, E } enum4;\n" | |
213 | + " uint16_t val;\n" | |
214 | + "} ;\n" | |
215 | + "\n" | |
216 | + "event {\n" | |
217 | + " name = \"enumEvent\";\n" | |
218 | + " id = 6;\n" | |
219 | + " stream_id = 0;\n" | |
220 | + " loglevel = 5;\n" | |
221 | + " fields := struct{\n" | |
222 | + " uint16_t _some_field;\n" | |
223 | // + " useless junk;\n" | |
224 | // + " bad_enum a;\n" | |
225 | + " enum {A, B, C = 3 , } _other_enum;\n" | |
226 | + " };\n" | |
227 | + "};\n" | |
228 | + "\n"; | |
791072b0 MK |
229 | |
230 | private final static String contextMD = | |
231 | "event {\n" + | |
b146ad80 SD |
232 | " name = \"someOtherEvent\";\n" + |
233 | " id = 5;\n" + | |
234 | " stream_id = 0;\n" + | |
235 | " loglevel = 5;\n" + | |
236 | " context := struct{\n" + | |
237 | " uint16_t _someContext;\n" + | |
238 | " };\n" + | |
239 | " fields := struct{\n" + | |
240 | " uint16_t _somefield;\n" + | |
241 | " };\n" + | |
242 | "};\n " + | |
243 | "\n"; | |
791072b0 MK |
244 | |
245 | private static final String callsiteMD = | |
b146ad80 SD |
246 | "callsite {\n" |
247 | + " name = \"ust_tests_demo2:loop\";\n" | |
248 | + " func = \"main\";\n" + " ip = 0x400a29;\n" | |
249 | + " file = \"demo.c\";\n" + " line = 59;\n" + "};\n" + "\n" | |
250 | + "callsite {\n" + " name = \"ust_tests_demo3:done\";\n" | |
251 | + " func = \"main\";\n" + " ip = 0x400a6c;\n" | |
252 | + " file = \"demo.c\";\n" + " line = 62;\n" + "};\n" + "\n" | |
253 | + "callsite {\n" + " name = \"ust_tests_demo:done\";\n" | |
254 | + " func = \"main\";\n" + " ip = 0x400aaf;\n" | |
255 | + " file = \"demo.c\";\n" + " line = 61;\n" + "};\n" + "\n" | |
256 | + "callsite {\n" + " name = \"ust_tests_demo:starting\";\n" | |
257 | + " func = \"main\";\n" + " ip = 0x400af2;\n" | |
258 | + " file = \"demo.c\";\n" + " line = 55;\n" + "};\n"; | |
791072b0 MK |
259 | |
260 | private static final String simpleTSDL = metadataDecs + ctfStart + ctfHeaders | |
261 | + ctfBody; | |
262 | private static final String enumTSDL = metadataDecs + ctfStart + ctfHeaders | |
263 | + ctfBody + enumMd; | |
264 | private static final String clockTSDL = metadataDecs + clockMD + ctfStart | |
265 | + ctfHeaders + ctfBody; | |
266 | private static final String envTSDL = metadataDecs + environmentMD + ctfStart | |
267 | + ctfHeaders + ctfBody; | |
268 | private static final String contextTSDL = metadataDecs + environmentMD + ctfStart | |
b146ad80 | 269 | + ctfHeaders + ctfBody + contextMD; |
791072b0 MK |
270 | private static final String callsiteTSDL = metadataDecs + ctfStart + ctfHeaders |
271 | + ctfBody + callsiteMD; | |
272 | private static final String allDressedTSDL = metadataDecs + environmentMD + clockMD | |
b146ad80 | 273 | + ctfStart + ctfHeaders + ctfBody + enumMd + callsiteMD; |
791072b0 MK |
274 | |
275 | static final String tempTraceDir = System.getProperty("java.io.tmpdir") | |
f2847103 SD |
276 | + File.separator + "tempTrace"; |
277 | ||
278 | private static final int DATA_SIZE = 4096; | |
279 | ||
280 | private static final int HEADER_SIZE = 68; | |
281 | ||
282 | private static final int PACKET_SIZE = DATA_SIZE + HEADER_SIZE + 512; | |
283 | ||
284 | private CTFTrace trace; | |
285 | ||
286 | private static class Event { | |
287 | private static final int EVENT_SIZE = 16; | |
288 | private int eventId; | |
289 | private int eventTimestamp; | |
290 | private int eventContent; | |
291 | ||
292 | public Event(int id, int content) { | |
293 | eventId = id; | |
294 | eventTimestamp = 0; | |
295 | eventContent = content; | |
296 | } | |
297 | ||
298 | public void setEventTimestamp(int eventTimestamp) { | |
299 | this.eventTimestamp = eventTimestamp; | |
300 | } | |
301 | ||
302 | public void setEventContent(int eventContent) { | |
303 | this.eventContent = eventContent; | |
304 | } | |
305 | ||
306 | public void writeEvent(ByteBuffer data) { | |
307 | // Id and Timestamp | |
308 | int timeId = eventTimestamp << 5; | |
309 | timeId |= eventId & 0x1f; | |
310 | data.putInt(timeId); | |
311 | ||
312 | // Context | |
313 | long ip = 0x0000facedecafe00L + ((data.position() / | |
314 | getSize()) & 0x0F); | |
315 | data.putLong(ip); | |
316 | ||
317 | // Content | |
318 | data.putInt(eventContent); | |
319 | ||
320 | } | |
321 | ||
322 | public int getSize() { | |
323 | return EVENT_SIZE; | |
324 | } | |
325 | ||
326 | } | |
791072b0 MK |
327 | |
328 | private static void deltree(File f) { | |
329 | for (File elem : f.listFiles()) { | |
330 | if (elem.isDirectory()) { | |
331 | deltree(elem); | |
332 | } | |
333 | elem.delete(); | |
334 | } | |
335 | f.delete(); | |
336 | } | |
337 | ||
338 | private static void createDummyTrace(String metadata) { | |
339 | ||
791072b0 | 340 | try { |
f2847103 SD |
341 | File dir; |
342 | dir = new File(tempTraceDir); | |
343 | if (dir.exists()) { | |
344 | deltree(dir); | |
791072b0 | 345 | } |
f2847103 SD |
346 | dir.mkdirs(); |
347 | File metadataFile; | |
348 | metadataFile = new File(tempTraceDir + "/metadata"); | |
349 | FileWriter fw = new FileWriter(metadataFile); | |
791072b0 MK |
350 | fw.write(metadata); |
351 | fw.close(); | |
791072b0 | 352 | |
f2847103 SD |
353 | byte magicLE[] = { (byte) 0xC1, (byte) 0x1F, (byte) 0xFC, |
354 | (byte) 0xC1 }; | |
355 | byte uuid[] = { (byte) 0xb0, 0x4d, 0x39, 0x1b, (byte) 0xe7, | |
356 | 0x36, 0x44, (byte) 0xc1, (byte) 0x8d, (byte) 0x89, 0x4b, | |
791072b0 | 357 | (byte) 0xb4, 0x38, (byte) 0x85, 0x7f, (byte) 0x8d }; |
f2847103 SD |
358 | |
359 | Event ev = new Event(2, 2); | |
360 | ||
361 | final int nbEvents = (DATA_SIZE / ev.getSize()) - 1; | |
362 | final int contentSize = (nbEvents * ev.getSize() + | |
363 | HEADER_SIZE) * 8; | |
364 | ||
365 | ByteBuffer data = ByteBuffer.allocate(PACKET_SIZE); | |
366 | data.order(ByteOrder.LITTLE_ENDIAN); | |
367 | data.clear(); | |
368 | ||
369 | // packet header | |
370 | // magic number 4 | |
371 | data.put(magicLE); | |
372 | // uuid 16 | |
373 | data.put(uuid); | |
374 | // stream ID 4 | |
375 | data.putInt(0); | |
376 | ||
377 | // packet context | |
378 | // timestamp_begin 8 | |
379 | data.putLong(0xa500); | |
380 | ||
381 | // timestamp_end 8 | |
382 | data.putLong(nbEvents * 0x10000 + 0xa5a6); | |
383 | ||
384 | // content_size 8 | |
385 | data.putLong(contentSize); | |
386 | ||
387 | // packet_size 8 | |
388 | data.putLong(PACKET_SIZE * 8); | |
389 | ||
390 | // events_discarded 8 | |
391 | data.putLong(0); | |
392 | ||
393 | // cpu_id 4 | |
394 | data.putInt(0); | |
395 | ||
396 | // fill me | |
397 | for (int i = 0; i < nbEvents; i++) { | |
398 | ev.setEventTimestamp(i * 0x10000 + 0xa5a5); | |
399 | ev.setEventContent(i); | |
400 | ev.writeEvent(data); | |
791072b0 | 401 | } |
f2847103 SD |
402 | |
403 | File dummyFile; | |
404 | dummyFile = new File(tempTraceDir + "/dummyChan"); | |
405 | FileOutputStream fos = new FileOutputStream(dummyFile); | |
406 | // The byteBuffer needs to be flipped in file writing mode | |
407 | data.flip(); | |
408 | fos.getChannel().write(data); | |
791072b0 | 409 | fos.close(); |
791072b0 MK |
410 | } catch (IOException e) { |
411 | e.printStackTrace(); | |
412 | } finally { | |
791072b0 MK |
413 | } |
414 | ||
415 | } | |
416 | ||
f2847103 SD |
417 | /** |
418 | * Close trace | |
419 | */ | |
420 | @After | |
421 | public void tearDown(){ | |
422 | trace.dispose(); | |
423 | } | |
424 | ||
791072b0 MK |
425 | /** |
426 | * Simple test (only the minimum) | |
b146ad80 SD |
427 | * |
428 | * @throws CTFReaderException | |
429 | * something wrong happened | |
791072b0 MK |
430 | */ |
431 | @Test | |
432 | public void TSDLSimpleTest() throws CTFReaderException { | |
433 | createDummyTrace(simpleTSDL); | |
f2847103 | 434 | trace = new CTFTrace(tempTraceDir); |
791072b0 | 435 | assertNotNull(trace); |
791072b0 MK |
436 | } |
437 | ||
438 | /** | |
439 | * Test with environment variables | |
b146ad80 SD |
440 | * |
441 | * @throws CTFReaderException | |
442 | * something wrong happened | |
791072b0 MK |
443 | */ |
444 | @Test | |
445 | public void TSDLEnvironmentTest() throws CTFReaderException { | |
446 | createDummyTrace(envTSDL); | |
f2847103 | 447 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
448 | assertNotNull(trace); |
449 | } | |
450 | ||
451 | /** | |
452 | * Test with Clocks | |
b146ad80 SD |
453 | * |
454 | * @throws CTFReaderException | |
455 | * something wrong happened | |
791072b0 MK |
456 | */ |
457 | @Test | |
458 | public void TSDLEnumTest() throws CTFReaderException { | |
459 | createDummyTrace(enumTSDL); | |
f2847103 | 460 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
461 | assertNotNull(trace); |
462 | } | |
463 | ||
464 | /** | |
465 | * Test with Clocks | |
b146ad80 SD |
466 | * |
467 | * @throws CTFReaderException | |
468 | * something wrong happened | |
791072b0 MK |
469 | */ |
470 | @Test | |
471 | public void TSDLClockTest() throws CTFReaderException { | |
472 | createDummyTrace(clockTSDL); | |
f2847103 | 473 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
474 | assertNotNull(trace); |
475 | } | |
476 | ||
477 | /** | |
478 | * Test with Contexts | |
b146ad80 SD |
479 | * |
480 | * @throws CTFReaderException | |
481 | * something wrong happened | |
791072b0 MK |
482 | */ |
483 | @Test | |
484 | public void TSDLContextTest() throws CTFReaderException { | |
485 | createDummyTrace(contextTSDL); | |
f2847103 | 486 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
487 | assertNotNull(trace); |
488 | } | |
489 | ||
490 | /** | |
491 | * Test with Callsites | |
b146ad80 SD |
492 | * |
493 | * @throws CTFReaderException | |
494 | * something wrong happened | |
791072b0 MK |
495 | */ |
496 | @Test | |
497 | public void TSDLCallsiteTest() throws CTFReaderException { | |
498 | createDummyTrace(callsiteTSDL); | |
f2847103 | 499 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
500 | assertNotNull(trace); |
501 | } | |
502 | ||
503 | /** | |
504 | * Test everything | |
b146ad80 SD |
505 | * |
506 | * @throws CTFReaderException | |
507 | * something wrong happened | |
791072b0 MK |
508 | */ |
509 | @Test | |
510 | public void TSDLAllTest() throws CTFReaderException { | |
511 | createDummyTrace(allDressedTSDL); | |
f2847103 | 512 | trace = new CTFTrace(tempTraceDir); |
791072b0 | 513 | assertNotNull(trace); |
8e964be1 | 514 | |
0594c61c | 515 | Map<Long, IEventDeclaration> events = trace.getEvents(0L); |
8e964be1 MK |
516 | final EventDeclaration eventDeclaration = (EventDeclaration) events.get(2L); |
517 | assertEquals("http://example.com/path_to_model?q=ust_tests_demo:done", | |
518 | eventDeclaration.getCustomAttribute("model.emf.uri")); | |
791072b0 MK |
519 | } |
520 | ||
521 | } |