2 # Copyright (C) 2019 EfficiOS Inc.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; only version 2
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 class UserComponentTestCase(unittest
.TestCase
):
27 def _create_comp(comp_cls
, name
=None, log_level
=bt2
.LoggingLevel
.NONE
):
33 return graph
.add_component(comp_cls
, name
, logging_level
=log_level
)
36 class MySink(bt2
._UserSinkComponent
):
37 def __init__(comp_self
, params
):
38 self
.assertEqual(comp_self
.name
, 'yaes')
43 def _graph_is_configured(self
):
46 comp
= self
._create
_comp
(MySink
, 'yaes')
48 def test_logging_level(self
):
49 class MySink(bt2
._UserSinkComponent
):
50 def __init__(comp_self
, params
):
51 self
.assertEqual(comp_self
.logging_level
, bt2
.LoggingLevel
.INFO
)
56 def _graph_is_configured(self
):
59 comp
= self
._create
_comp
(MySink
, 'yaes', bt2
.LoggingLevel
.INFO
)
62 class MySink(bt2
._UserSinkComponent
):
63 def __init__(comp_self
, params
):
64 self
.assertEqual(comp_self
.cls
, MySink
)
69 def _graph_is_configured(self
):
72 self
._create
_comp
(MySink
)
75 class MySink(bt2
._UserSinkComponent
):
76 def __init__(comp_self
, params
):
77 self
.assertIsInstance(comp_self
.addr
, int)
78 self
.assertNotEqual(comp_self
.addr
, 0)
83 def _graph_is_configured(self
):
86 self
._create
_comp
(MySink
)
88 def test_finalize(self
):
91 class MySink(bt2
._UserSinkComponent
):
95 def _graph_is_configured(self
):
98 def _finalize(comp_self
):
103 comp
= graph
.add_component(MySink
, 'lel')
107 self
.assertTrue(finalized
)
110 class GenericComponentTestCase(unittest
.TestCase
):
112 def _create_comp(comp_cls
, name
=None, log_level
=bt2
.LoggingLevel
.NONE
):
118 return graph
.add_component(comp_cls
, name
, logging_level
=log_level
)
121 class MySink(bt2
._UserSinkComponent
):
125 def _graph_is_configured(self
):
128 comp
= self
._create
_comp
(MySink
, 'yaes')
129 self
.assertEqual(comp
.name
, 'yaes')
131 def test_logging_level(self
):
132 class MySink(bt2
._UserSinkComponent
):
136 def _graph_is_configured(self
):
139 comp
= self
._create
_comp
(MySink
, 'yaes', bt2
.LoggingLevel
.WARNING
)
140 self
.assertEqual(comp
.logging_level
, bt2
.LoggingLevel
.WARNING
)
142 def test_class(self
):
143 class MySink(bt2
._UserSinkComponent
):
147 def _graph_is_configured(self
):
150 comp
= self
._create
_comp
(MySink
)
151 self
.assertEqual(comp
.cls
, MySink
)
154 class MySink(bt2
._UserSinkComponent
):
158 def _graph_is_configured(self
):
161 comp
= self
._create
_comp
(MySink
)
162 self
.assertIsInstance(comp
.addr
, int)
163 self
.assertNotEqual(comp
.addr
, 0)
This page took 0.031534 seconds and 4 git commands to generate.