Commit | Line | Data |
---|---|---|
4bd7f2db | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2013, 2014 Ericsson |
4bd7f2db AM |
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) { | |
3de23137 AM |
339 | File dir = new File(tempTraceDir); |
340 | if (dir.exists()) { | |
341 | deltree(dir); | |
342 | } | |
343 | dir.mkdirs(); | |
791072b0 | 344 | |
3de23137 AM |
345 | File metadataFile = new File(tempTraceDir + "/metadata"); |
346 | try (FileWriter fw = new FileWriter(metadataFile);) { | |
791072b0 | 347 | fw.write(metadata); |
3de23137 AM |
348 | } catch (IOException e) { |
349 | e.printStackTrace(); | |
350 | } | |
791072b0 | 351 | |
3de23137 AM |
352 | byte magicLE[] = { (byte) 0xC1, (byte) 0x1F, (byte) 0xFC, |
353 | (byte) 0xC1 }; | |
354 | byte uuid[] = { (byte) 0xb0, 0x4d, 0x39, 0x1b, (byte) 0xe7, | |
355 | 0x36, 0x44, (byte) 0xc1, (byte) 0x8d, (byte) 0x89, 0x4b, | |
356 | (byte) 0xb4, 0x38, (byte) 0x85, 0x7f, (byte) 0x8d }; | |
f2847103 | 357 | |
3de23137 | 358 | Event ev = new Event(2, 2); |
f2847103 | 359 | |
3de23137 AM |
360 | final int nbEvents = (DATA_SIZE / ev.getSize()) - 1; |
361 | final int contentSize = (nbEvents * ev.getSize() + | |
362 | HEADER_SIZE) * 8; | |
f2847103 | 363 | |
3de23137 AM |
364 | ByteBuffer data = ByteBuffer.allocate(PACKET_SIZE); |
365 | data.order(ByteOrder.LITTLE_ENDIAN); | |
366 | data.clear(); | |
f2847103 | 367 | |
3de23137 AM |
368 | // packet header |
369 | // magic number 4 | |
370 | data.put(magicLE); | |
371 | // uuid 16 | |
372 | data.put(uuid); | |
373 | // stream ID 4 | |
374 | data.putInt(0); | |
f2847103 | 375 | |
3de23137 AM |
376 | // packet context |
377 | // timestamp_begin 8 | |
378 | data.putLong(0xa500); | |
f2847103 | 379 | |
3de23137 AM |
380 | // timestamp_end 8 |
381 | data.putLong(nbEvents * 0x10000 + 0xa5a6); | |
f2847103 | 382 | |
3de23137 AM |
383 | // content_size 8 |
384 | data.putLong(contentSize); | |
f2847103 | 385 | |
3de23137 AM |
386 | // packet_size 8 |
387 | data.putLong(PACKET_SIZE * 8); | |
f2847103 | 388 | |
3de23137 AM |
389 | // events_discarded 8 |
390 | data.putLong(0); | |
f2847103 | 391 | |
3de23137 AM |
392 | // cpu_id 4 |
393 | data.putInt(0); | |
f2847103 | 394 | |
3de23137 AM |
395 | // fill me |
396 | for (int i = 0; i < nbEvents; i++) { | |
397 | ev.setEventTimestamp(i * 0x10000 + 0xa5a5); | |
398 | ev.setEventContent(i); | |
399 | ev.writeEvent(data); | |
400 | } | |
401 | ||
402 | // The byteBuffer needs to be flipped in file writing mode | |
403 | data.flip(); | |
f2847103 | 404 | |
3de23137 AM |
405 | File dummyFile = new File(tempTraceDir + "/dummyChan"); |
406 | try (FileOutputStream fos = new FileOutputStream(dummyFile);) { | |
f2847103 | 407 | fos.getChannel().write(data); |
791072b0 MK |
408 | } catch (IOException e) { |
409 | e.printStackTrace(); | |
791072b0 MK |
410 | } |
411 | ||
412 | } | |
413 | ||
f2847103 SD |
414 | /** |
415 | * Close trace | |
416 | */ | |
417 | @After | |
418 | public void tearDown(){ | |
dd9752d5 | 419 | trace.close(); |
f2847103 SD |
420 | } |
421 | ||
791072b0 MK |
422 | /** |
423 | * Simple test (only the minimum) | |
b146ad80 SD |
424 | * |
425 | * @throws CTFReaderException | |
426 | * something wrong happened | |
791072b0 MK |
427 | */ |
428 | @Test | |
429 | public void TSDLSimpleTest() throws CTFReaderException { | |
430 | createDummyTrace(simpleTSDL); | |
f2847103 | 431 | trace = new CTFTrace(tempTraceDir); |
791072b0 | 432 | assertNotNull(trace); |
791072b0 MK |
433 | } |
434 | ||
435 | /** | |
436 | * Test with environment variables | |
b146ad80 SD |
437 | * |
438 | * @throws CTFReaderException | |
439 | * something wrong happened | |
791072b0 MK |
440 | */ |
441 | @Test | |
442 | public void TSDLEnvironmentTest() throws CTFReaderException { | |
443 | createDummyTrace(envTSDL); | |
f2847103 | 444 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
445 | assertNotNull(trace); |
446 | } | |
447 | ||
448 | /** | |
449 | * Test with Clocks | |
b146ad80 SD |
450 | * |
451 | * @throws CTFReaderException | |
452 | * something wrong happened | |
791072b0 MK |
453 | */ |
454 | @Test | |
455 | public void TSDLEnumTest() throws CTFReaderException { | |
456 | createDummyTrace(enumTSDL); | |
f2847103 | 457 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
458 | assertNotNull(trace); |
459 | } | |
460 | ||
461 | /** | |
462 | * Test with Clocks | |
b146ad80 SD |
463 | * |
464 | * @throws CTFReaderException | |
465 | * something wrong happened | |
791072b0 MK |
466 | */ |
467 | @Test | |
468 | public void TSDLClockTest() throws CTFReaderException { | |
469 | createDummyTrace(clockTSDL); | |
f2847103 | 470 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
471 | assertNotNull(trace); |
472 | } | |
473 | ||
474 | /** | |
475 | * Test with Contexts | |
b146ad80 SD |
476 | * |
477 | * @throws CTFReaderException | |
478 | * something wrong happened | |
791072b0 MK |
479 | */ |
480 | @Test | |
481 | public void TSDLContextTest() throws CTFReaderException { | |
482 | createDummyTrace(contextTSDL); | |
f2847103 | 483 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
484 | assertNotNull(trace); |
485 | } | |
486 | ||
487 | /** | |
488 | * Test with Callsites | |
b146ad80 SD |
489 | * |
490 | * @throws CTFReaderException | |
491 | * something wrong happened | |
791072b0 MK |
492 | */ |
493 | @Test | |
494 | public void TSDLCallsiteTest() throws CTFReaderException { | |
495 | createDummyTrace(callsiteTSDL); | |
f2847103 | 496 | trace = new CTFTrace(tempTraceDir); |
791072b0 MK |
497 | assertNotNull(trace); |
498 | } | |
499 | ||
500 | /** | |
501 | * Test everything | |
b146ad80 SD |
502 | * |
503 | * @throws CTFReaderException | |
504 | * something wrong happened | |
791072b0 MK |
505 | */ |
506 | @Test | |
507 | public void TSDLAllTest() throws CTFReaderException { | |
508 | createDummyTrace(allDressedTSDL); | |
f2847103 | 509 | trace = new CTFTrace(tempTraceDir); |
791072b0 | 510 | assertNotNull(trace); |
8e964be1 | 511 | |
0594c61c | 512 | Map<Long, IEventDeclaration> events = trace.getEvents(0L); |
8e964be1 MK |
513 | final EventDeclaration eventDeclaration = (EventDeclaration) events.get(2L); |
514 | assertEquals("http://example.com/path_to_model?q=ust_tests_demo:done", | |
515 | eventDeclaration.getCustomAttribute("model.emf.uri")); | |
791072b0 MK |
516 | } |
517 | ||
518 | } |