source: rtems-central/rtemsqual/tests/test_applconfig.py @ a4e08c5

Last change on this file since a4e08c5 was a4e08c5, checked in by Sebastian Huber <sebastian.huber@…>, on 04/18/20 at 12:51:08

Enable branch coverage

  • Property mode set to 100644
File size: 10.3 KB
Line 
1# SPDX-License-Identifier: BSD-2-Clause
2""" Unit tests for the rtemsqual.applconfig module. """
3
4# Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26
27import os
28import shutil
29
30from rtemsqual.applconfig import generate
31from rtemsqual.items import ItemCache
32
33
34def test_applconfig(tmpdir):
35    item_cache_config = {}
36    item_cache_config["cache-directory"] = "cache"
37    spec_src = os.path.join(os.path.dirname(__file__), "spec-applconfig")
38    spec_dst = os.path.join(tmpdir, "spec")
39    shutil.copytree(spec_src, spec_dst)
40    item_cache_config["paths"] = [os.path.normpath(spec_dst)]
41    ic = ItemCache(item_cache_config)
42
43    applconfig_config = {}
44    g_rst = os.path.join(tmpdir, "g.rst")
45    applconfig_config["groups"] = [{"uid": "g", "target": g_rst}]
46    generate(applconfig_config, ic)
47
48    with open(g_rst, "r") as src:
49        content = (
50            ".. SPDX-License-Identifier: CC-BY-SA-4.0\n"
51            "\n"
52            ".. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)\n"
53            "\n"
54            "group name\n"
55            "==========\n"
56            "\n"
57            "description\n"
58            "\n"
59            ".. index:: a\n"
60            ".. index:: index a\n"
61            "\n"
62            ".. _a:\n"
63            "\n"
64            "a\n"
65            "-\n"
66            "\n"
67            "CONSTANT:\n"
68            "    ``a``\n"
69            "\n"
70            "OPTION TYPE:\n"
71            "    This configuration option is a boolean feature define.\n"
72            "\n"
73            "DEFAULT CONFIGURATION:\n"
74            "    default a\n"
75            "\n"
76            "DESCRIPTION:\n"
77            "    description a\n"
78            "\n"
79            "NOTES:\n"
80            "    notes a\n"
81            "\n"
82            ".. index:: b\n"
83            "\n"
84            ".. _b:\n"
85            "\n"
86            "b\n"
87            "-\n"
88            "\n"
89            "CONSTANT:\n"
90            "    ``b``\n"
91            "\n"
92            "OPTION TYPE:\n"
93            "    This configuration option is a boolean feature define.\n"
94            "\n"
95            "DEFAULT CONFIGURATION:\n"
96            "    If this configuration option is undefined, then the described feature is not\n"
97            "    enabled.\n"
98            "\n"
99            "DESCRIPTION:\n"
100            "    description b\n"
101            "\n"
102            "NOTES:\n"
103            "    None.\n"
104            "\n"
105            ".. index:: c\n"
106            "\n"
107            ".. _c:\n"
108            "\n"
109            "c\n"
110            "-\n"
111            "\n"
112            "CONSTANT:\n"
113            "    ``c``\n"
114            "\n"
115            "OPTION TYPE:\n"
116            "    This configuration option is an integer define.\n"
117            "\n"
118            "DEFAULT VALUE:\n"
119            "    The default value is 13.\n"
120            "\n"
121            "VALUE CONSTRAINTS:\n"
122            "    The value of this configuration option shall satisfy all of the following\n"
123            "    constraints:\n"
124            "\n"
125            "    * It shall be greater than or equal to -1.\n"
126            "\n"
127            "    * It shall be less than or equal to 99.\n"
128            "\n"
129            "    * custom c 1\n"
130            "\n"
131            "    * custom c 2\n"
132            "\n"
133            "    * constraint d\n"
134            "\n"
135            "DESCRIPTION:\n"
136            "    description c\n"
137            "\n"
138            "NOTES:\n"
139            "    notes c\n"
140            "\n"
141            ".. index:: e\n"
142            "\n"
143            ".. _e:\n"
144            "\n"
145            "e\n"
146            "-\n"
147            "\n"
148            "CONSTANT:\n"
149            "    ``e``\n"
150            "\n"
151            "OPTION TYPE:\n"
152            "    This configuration option is an integer define.\n"
153            "\n"
154            "DEFAULT VALUE:\n"
155            "    The default value is 7.\n"
156            "\n"
157            "VALUE CONSTRAINTS:\n"
158            "    The value of this configuration option shall be greater than or equal to -2.\n"
159            "\n"
160            "DESCRIPTION:\n"
161            "    description e\n"
162            "\n"
163            "NOTES:\n"
164            "    None.\n"
165            "\n"
166            ".. index:: f\n"
167            "\n"
168            ".. _f:\n"
169            "\n"
170            "f\n"
171            "-\n"
172            "\n"
173            "CONSTANT:\n"
174            "    ``f``\n"
175            "\n"
176            "OPTION TYPE:\n"
177            "    This configuration option is an integer define.\n"
178            "\n"
179            "DEFAULT VALUE:\n"
180            "    The default value is 1.\n"
181            "\n"
182            "VALUE CONSTRAINTS:\n"
183            "    The value of this configuration option shall be less than or equal to 2.\n"
184            "\n"
185            "DESCRIPTION:\n"
186            "    description f\n"
187            "\n"
188            "NOTES:\n"
189            "    None.\n"
190            "\n"
191            ".. index:: h\n"
192            "\n"
193            ".. _h:\n"
194            "\n"
195            "h\n"
196            "-\n"
197            "\n"
198            "CONSTANT:\n"
199            "    ``h``\n"
200            "\n"
201            "OPTION TYPE:\n"
202            "    This configuration option is an integer define.\n"
203            "\n"
204            "DEFAULT VALUE:\n"
205            "    The default value is 1.\n"
206            "\n"
207            "VALUE CONSTRAINTS:\n"
208            "    custom h\n"
209            "\n"
210            "DESCRIPTION:\n"
211            "    description h\n"
212            "\n"
213            "NOTES:\n"
214            "    None.\n"
215            "\n"
216            ".. index:: i\n"
217            "\n"
218            ".. _i:\n"
219            "\n"
220            "i\n"
221            "-\n"
222            "\n"
223            "CONSTANT:\n"
224            "    ``i``\n"
225            "\n"
226            "OPTION TYPE:\n"
227            "    This configuration option is an integer define.\n"
228            "\n"
229            "DEFAULT VALUE:\n"
230            "    The default value is 1.\n"
231            "\n"
232            "VALUE CONSTRAINTS:\n"
233            "    The value of this configuration option shall be\n"
234            "    an element of {1, 2, 3}.\n"
235            "\n"
236            "DESCRIPTION:\n"
237            "    description i\n"
238            "\n"
239            "NOTES:\n"
240            "    None.\n"
241            "\n"
242            ".. index:: j\n"
243            "\n"
244            ".. _j:\n"
245            "\n"
246            "j\n"
247            "-\n"
248            "\n"
249            "CONSTANT:\n"
250            "    ``j``\n"
251            "\n"
252            "OPTION TYPE:\n"
253            "    This configuration option is an integer define.\n"
254            "\n"
255            "DEFAULT VALUE:\n"
256            "    Foo bar.\n"
257            "\n"
258            "VALUE CONSTRAINTS:\n"
259            "    The value of this configuration option shall satisfy all of the following\n"
260            "    constraints:\n"
261            "\n"
262            "    * It shall be an element of [1, 2].\n"
263            "\n"
264            "    * constraint d\n"
265            "\n"
266            "DESCRIPTION:\n"
267            "    description j\n"
268            "\n"
269            "NOTES:\n"
270            "    None.\n"
271            "\n"
272            ".. index:: k\n"
273            "\n"
274            ".. _k:\n"
275            "\n"
276            "k\n"
277            "-\n"
278            "\n"
279            "CONSTANT:\n"
280            "    ``k``\n"
281            "\n"
282            "OPTION TYPE:\n"
283            "    This configuration option is an integer define.\n"
284            "\n"
285            "DEFAULT VALUE:\n"
286            "    The default value is 1.\n"
287            "\n"
288            "VALUE CONSTRAINTS:\n"
289            "    The value of this configuration option shall satisfy all of the following\n"
290            "    constraints:\n"
291            "\n"
292            "    * custom k 1\n"
293            "\n"
294            "    * custom k 2\n"
295            "\n"
296            "DESCRIPTION:\n"
297            "    description k\n"
298            "\n"
299            "NOTES:\n"
300            "    None.\n"
301            "\n"
302            ".. index:: l\n"
303            "\n"
304            ".. _l:\n"
305            "\n"
306            "l\n"
307            "-\n"
308            "\n"
309            "CONSTANT:\n"
310            "    ``l``\n"
311            "\n"
312            "OPTION TYPE:\n"
313            "    This configuration option is an initializer define.\n"
314            "\n"
315            "DEFAULT VALUE:\n"
316            "    The default value is 1.\n"
317            "\n"
318            "VALUE CONSTRAINTS:\n"
319            "    The value of this configuration option shall be greater than or equal to 0\n"
320            "    and less than or equal to 2.\n"
321            "\n"
322            "DESCRIPTION:\n"
323            "    description l\n"
324            "\n"
325            "NOTES:\n"
326            "    None.\n"
327            "\n"
328            ".. index:: m\n"
329            "\n"
330            ".. _m:\n"
331            "\n"
332            "m\n"
333            "-\n"
334            "\n"
335            "CONSTANT:\n"
336            "    ``m``\n"
337            "\n"
338            "OPTION TYPE:\n"
339            "    This configuration option is an initializer define.\n"
340            "\n"
341            "DEFAULT VALUE:\n"
342            "    The default value is 1.\n"
343            "\n"
344            "DESCRIPTION:\n"
345            "    description m\n"
346            "\n"
347            "NOTES:\n"
348            "    None.\n")
349        assert content == src.read()
Note: See TracBrowser for help on using the repository browser.