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 comp
= self
._create
_comp
(MySink
, 'yaes')
45 def test_logging_level(self
):
46 class MySink(bt2
._UserSinkComponent
):
47 def __init__(comp_self
, params
):
48 self
.assertEqual(comp_self
.logging_level
, bt2
.LoggingLevel
.INFO
)
53 comp
= self
._create
_comp
(MySink
, 'yaes', bt2
.LoggingLevel
.INFO
)
56 class MySink(bt2
._UserSinkComponent
):
57 def __init__(comp_self
, params
):
58 self
.assertEqual(comp_self
.cls
, MySink
)
63 self
._create
_comp
(MySink
)
66 class MySink(bt2
._UserSinkComponent
):
67 def __init__(comp_self
, params
):
68 self
.assertIsInstance(comp_self
.addr
, int)
69 self
.assertNotEqual(comp_self
.addr
, 0)
74 self
._create
_comp
(MySink
)
76 def test_finalize(self
):
79 class MySink(bt2
._UserSinkComponent
):
83 def _finalize(comp_self
):
88 comp
= graph
.add_component(MySink
, 'lel')
92 self
.assertTrue(finalized
)
95 class GenericComponentTestCase(unittest
.TestCase
):
97 def _create_comp(comp_cls
, name
=None, log_level
=bt2
.LoggingLevel
.NONE
):
103 return graph
.add_component(comp_cls
, name
, logging_level
=log_level
)
106 class MySink(bt2
._UserSinkComponent
):
110 comp
= self
._create
_comp
(MySink
, 'yaes')
111 self
.assertEqual(comp
.name
, 'yaes')
113 def test_logging_level(self
):
114 class MySink(bt2
._UserSinkComponent
):
118 comp
= self
._create
_comp
(MySink
, 'yaes', bt2
.LoggingLevel
.WARNING
)
119 self
.assertEqual(comp
.logging_level
, bt2
.LoggingLevel
.WARNING
)
121 def test_class(self
):
122 class MySink(bt2
._UserSinkComponent
):
126 comp
= self
._create
_comp
(MySink
)
127 self
.assertEqual(comp
.cls
, MySink
)
130 class MySink(bt2
._UserSinkComponent
):
134 comp
= self
._create
_comp
(MySink
)
135 self
.assertIsInstance(comp
.addr
, int)
136 self
.assertNotEqual(comp
.addr
, 0)
This page took 0.034456 seconds and 5 git commands to generate.