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