tests/bindings/python: Mark all tests as skipped
[babeltrace.git] / tests / bindings / python / babeltrace / test_reader_event_declaration.py
CommitLineData
d6ca48e5
JG
1# The MIT License (MIT)
2#
3# Copyright (c) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4# Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
5#
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to deal
8# in the Software without restriction, including without limitation the rights
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10# copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12#
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23
24import collections
25import unittest
26import bt2
27import babeltrace
90cfc012 28#import babeltrace.reader_event_declaration as event_declaration
d6ca48e5 29
90cfc012 30@unittest.skip("this is broken")
d6ca48e5
JG
31class EventDeclarationTestCase(unittest.TestCase):
32 def setUp(self):
33 self._values = {
34 'ph_field_1' : 42,
35 'ph_field_2' : 'bla bla',
36 'spc_field' : 'some string',
37 'seh_field' : 'another string',
38 'sec_field' : 68752,
39 'ec_field' : 89,
40 'ef_field' : 8476,
41 }
42
43 self._int_ft = bt2.IntegerFieldType(32)
44 self._str_ft = bt2.StringFieldType()
45
46 self._trace = bt2.Trace()
47 self._trace.packet_header_field_type = bt2.StructureFieldType()
48 self._trace.packet_header_field_type += collections.OrderedDict([
49 ('ph_field_1', self._int_ft),
50 ('ph_field_2', self._str_ft),
51 ])
52
53 self._sc = bt2.StreamClass()
54 self._sc.packet_context_field_type = bt2.StructureFieldType()
55 self._sc.packet_context_field_type += collections.OrderedDict([
56 ('spc_field', self._str_ft),
57 ])
58
59 self._sc.event_header_field_type = bt2.StructureFieldType()
60 self._sc.event_header_field_type += collections.OrderedDict([
61 ('seh_field', self._str_ft),
62 ])
63
64 self._sc.event_context_field_type = bt2.StructureFieldType()
65 self._sc.event_context_field_type += collections.OrderedDict([
66 ('sec_field', self._int_ft),
67 ])
68
69 self._clock_class = bt2.ClockClass('allo', 1000)
70 self._trace.add_clock_class(self._clock_class)
71
72 self._ec = bt2.EventClass('event_class_name')
73 self._ec.id = 42
74 self._ec.context_field_type = bt2.StructureFieldType()
75 self._ec.context_field_type += collections.OrderedDict([
76 ('ec_field', self._int_ft),
77 ])
78 self._ec.payload_field_type = bt2.StructureFieldType()
79 self._ec.payload_field_type += collections.OrderedDict([
80 ('ef_field', self._int_ft),
81 ])
82
83 self._sc.add_event_class(self._ec)
84
85 self._trace.add_stream_class(self._sc)
86 self._cc_prio_map = bt2.ClockClassPriorityMap()
87 self._cc_prio_map[self._clock_class] = 231
88 self._stream = self._sc()
89 self._packet = self._stream.create_packet()
90 self._packet.header_field['ph_field_1'] = self._values['ph_field_1']
91 self._packet.header_field['ph_field_2'] = self._values['ph_field_2']
92 self._packet.context_field['spc_field'] = self._values['spc_field']
93
94 def tearDown(self):
95 del self._trace
96 del self._sc
97 del self._ec
98 del self._int_ft
99 del self._str_ft
100 del self._clock_class
101 del self._cc_prio_map
102 del self._stream
103 del self._packet
104
105 def _get_event_declaration(self):
106 return event_declaration._create_event_declaration(self._ec)
107
108 def test_name(self):
109 declaration = self._get_event_declaration()
110 self.assertEqual(declaration.name, 'event_class_name')
111
112 def test_id(self):
113 declaration = self._get_event_declaration()
114 self.assertEqual(declaration.id, 42)
115
116 def test_fields(self):
117 declaration = self._get_event_declaration()
118 fields = declaration.fields
119 self.assertEqual(len(list(fields)), len(self._values))
120
121 def test_fields_scope(self):
122 declaration = self._get_event_declaration()
123 event_fields = list(
124 declaration.fields_scope(babeltrace.CTFScope.EVENT_FIELDS))
125 self.assertEqual(len(event_fields), 1)
126 self.assertEqual(event_fields[0].name, 'ef_field')
127 self.assertEqual(event_fields[0].scope,
128 babeltrace.CTFScope.EVENT_FIELDS)
129
130 event_ctx_fields = list(
131 declaration.fields_scope(babeltrace.CTFScope.EVENT_CONTEXT))
132 self.assertEqual(len(event_ctx_fields), 1)
133 self.assertEqual(event_ctx_fields[0].name, 'ec_field')
134 self.assertEqual(event_ctx_fields[0].scope,
135 babeltrace.CTFScope.EVENT_CONTEXT)
136
137 stream_ectx_fields = list(
138 declaration.fields_scope(babeltrace.CTFScope.STREAM_EVENT_CONTEXT))
139 self.assertEqual(len(stream_ectx_fields), 1)
140 self.assertEqual(stream_ectx_fields[0].name, 'sec_field')
141 self.assertEqual(stream_ectx_fields[0].scope,
142 babeltrace.CTFScope.STREAM_EVENT_CONTEXT)
143
144 stream_eh_fields = list(
145 declaration.fields_scope(babeltrace.CTFScope.STREAM_EVENT_HEADER))
146 self.assertEqual(len(stream_eh_fields), 1)
147 self.assertEqual(stream_eh_fields[0].name, 'seh_field')
148 self.assertEqual(stream_eh_fields[0].scope,
149 babeltrace.CTFScope.STREAM_EVENT_HEADER)
150
151 stream_pctx_fields = list(
152 declaration.fields_scope(babeltrace.CTFScope.STREAM_PACKET_CONTEXT))
153 self.assertEqual(len(stream_pctx_fields), 1)
154 self.assertEqual(stream_pctx_fields[0].name, 'spc_field')
155 self.assertEqual(stream_pctx_fields[0].scope,
156 babeltrace.CTFScope.STREAM_PACKET_CONTEXT)
157
158 stream_ph_fields = list(
159 declaration.fields_scope(babeltrace.CTFScope.TRACE_PACKET_HEADER))
160 self.assertEqual(len(stream_ph_fields), 2)
161 self.assertEqual(stream_ph_fields[0].name, 'ph_field_1')
162 self.assertEqual(stream_ph_fields[0].scope,
163 babeltrace.CTFScope.TRACE_PACKET_HEADER)
164 self.assertEqual(stream_ph_fields[1].name, 'ph_field_2')
165 self.assertEqual(stream_ph_fields[1].scope,
166 babeltrace.CTFScope.TRACE_PACKET_HEADER)
This page took 0.032566 seconds and 4 git commands to generate.