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 | |
---|
27 | import os |
---|
28 | import shutil |
---|
29 | |
---|
30 | from rtemsqual.applconfig import generate |
---|
31 | from rtemsqual.items import ItemCache |
---|
32 | |
---|
33 | |
---|
34 | def 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 = """.. SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
50 | |
---|
51 | .. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) |
---|
52 | |
---|
53 | group name |
---|
54 | ========== |
---|
55 | |
---|
56 | description |
---|
57 | |
---|
58 | .. index:: a |
---|
59 | .. index:: index a |
---|
60 | |
---|
61 | .. _a: |
---|
62 | |
---|
63 | a |
---|
64 | - |
---|
65 | |
---|
66 | CONSTANT: |
---|
67 | ``a`` |
---|
68 | |
---|
69 | OPTION TYPE: |
---|
70 | This configuration option is a boolean feature define. |
---|
71 | |
---|
72 | DEFAULT CONFIGURATION: |
---|
73 | default a |
---|
74 | |
---|
75 | DESCRIPTION: |
---|
76 | description a |
---|
77 | |
---|
78 | NOTES: |
---|
79 | notes a |
---|
80 | |
---|
81 | .. index:: b |
---|
82 | |
---|
83 | .. _b: |
---|
84 | |
---|
85 | b |
---|
86 | - |
---|
87 | |
---|
88 | CONSTANT: |
---|
89 | ``b`` |
---|
90 | |
---|
91 | OPTION TYPE: |
---|
92 | This configuration option is a boolean feature define. |
---|
93 | |
---|
94 | DEFAULT CONFIGURATION: |
---|
95 | If this configuration option is undefined, then the described feature is \ |
---|
96 | not |
---|
97 | enabled. |
---|
98 | |
---|
99 | DESCRIPTION: |
---|
100 | description b |
---|
101 | |
---|
102 | NOTES: |
---|
103 | None. |
---|
104 | |
---|
105 | .. index:: c |
---|
106 | |
---|
107 | .. _c: |
---|
108 | |
---|
109 | c |
---|
110 | - |
---|
111 | |
---|
112 | CONSTANT: |
---|
113 | ``c`` |
---|
114 | |
---|
115 | OPTION TYPE: |
---|
116 | This configuration option is an integer define. |
---|
117 | |
---|
118 | DEFAULT VALUE: |
---|
119 | The default value is 13. |
---|
120 | |
---|
121 | VALUE CONSTRAINTS: |
---|
122 | The value of this configuration option shall satisfy all of the following |
---|
123 | constraints: |
---|
124 | |
---|
125 | * It shall be greater than or equal to -1. |
---|
126 | |
---|
127 | * It shall be less than or equal to 99. |
---|
128 | |
---|
129 | * custom c 1 |
---|
130 | |
---|
131 | * custom c 2 |
---|
132 | |
---|
133 | * constraint d |
---|
134 | |
---|
135 | DESCRIPTION: |
---|
136 | description c |
---|
137 | |
---|
138 | NOTES: |
---|
139 | notes c |
---|
140 | |
---|
141 | .. index:: e |
---|
142 | |
---|
143 | .. _e: |
---|
144 | |
---|
145 | e |
---|
146 | - |
---|
147 | |
---|
148 | CONSTANT: |
---|
149 | ``e`` |
---|
150 | |
---|
151 | OPTION TYPE: |
---|
152 | This configuration option is an integer define. |
---|
153 | |
---|
154 | DEFAULT VALUE: |
---|
155 | The default value is 7. |
---|
156 | |
---|
157 | VALUE CONSTRAINTS: |
---|
158 | The value of this configuration option shall be greater than or equal to \ |
---|
159 | -2. |
---|
160 | |
---|
161 | DESCRIPTION: |
---|
162 | description e |
---|
163 | |
---|
164 | NOTES: |
---|
165 | None. |
---|
166 | |
---|
167 | .. index:: f |
---|
168 | |
---|
169 | .. _f: |
---|
170 | |
---|
171 | f |
---|
172 | - |
---|
173 | |
---|
174 | CONSTANT: |
---|
175 | ``f`` |
---|
176 | |
---|
177 | OPTION TYPE: |
---|
178 | This configuration option is an integer define. |
---|
179 | |
---|
180 | DEFAULT VALUE: |
---|
181 | The default value is 1. |
---|
182 | |
---|
183 | VALUE CONSTRAINTS: |
---|
184 | The value of this configuration option shall be less than or equal to 2. |
---|
185 | |
---|
186 | DESCRIPTION: |
---|
187 | description f |
---|
188 | |
---|
189 | NOTES: |
---|
190 | None. |
---|
191 | |
---|
192 | .. index:: h |
---|
193 | |
---|
194 | .. _h: |
---|
195 | |
---|
196 | h |
---|
197 | - |
---|
198 | |
---|
199 | CONSTANT: |
---|
200 | ``h`` |
---|
201 | |
---|
202 | OPTION TYPE: |
---|
203 | This configuration option is an integer define. |
---|
204 | |
---|
205 | DEFAULT VALUE: |
---|
206 | The default value is 1. |
---|
207 | |
---|
208 | VALUE CONSTRAINTS: |
---|
209 | custom h |
---|
210 | |
---|
211 | DESCRIPTION: |
---|
212 | description h |
---|
213 | |
---|
214 | NOTES: |
---|
215 | None. |
---|
216 | |
---|
217 | .. index:: i |
---|
218 | |
---|
219 | .. _i: |
---|
220 | |
---|
221 | i |
---|
222 | - |
---|
223 | |
---|
224 | CONSTANT: |
---|
225 | ``i`` |
---|
226 | |
---|
227 | OPTION TYPE: |
---|
228 | This configuration option is an integer define. |
---|
229 | |
---|
230 | DEFAULT VALUE: |
---|
231 | The default value is 1. |
---|
232 | |
---|
233 | VALUE CONSTRAINTS: |
---|
234 | The value of this configuration option shall be |
---|
235 | an element of {1, 2, 3}. |
---|
236 | |
---|
237 | DESCRIPTION: |
---|
238 | description i |
---|
239 | |
---|
240 | NOTES: |
---|
241 | None. |
---|
242 | |
---|
243 | .. index:: j |
---|
244 | |
---|
245 | .. _j: |
---|
246 | |
---|
247 | j |
---|
248 | - |
---|
249 | |
---|
250 | CONSTANT: |
---|
251 | ``j`` |
---|
252 | |
---|
253 | OPTION TYPE: |
---|
254 | This configuration option is an integer define. |
---|
255 | |
---|
256 | DEFAULT VALUE: |
---|
257 | Foo bar. |
---|
258 | |
---|
259 | VALUE CONSTRAINTS: |
---|
260 | The value of this configuration option shall satisfy all of the following |
---|
261 | constraints: |
---|
262 | |
---|
263 | * It shall be an element of [1, 2]. |
---|
264 | |
---|
265 | * constraint d |
---|
266 | |
---|
267 | DESCRIPTION: |
---|
268 | description j |
---|
269 | |
---|
270 | NOTES: |
---|
271 | None. |
---|
272 | |
---|
273 | .. index:: k |
---|
274 | |
---|
275 | .. _k: |
---|
276 | |
---|
277 | k |
---|
278 | - |
---|
279 | |
---|
280 | CONSTANT: |
---|
281 | ``k`` |
---|
282 | |
---|
283 | OPTION TYPE: |
---|
284 | This configuration option is an integer define. |
---|
285 | |
---|
286 | DEFAULT VALUE: |
---|
287 | The default value is 1. |
---|
288 | |
---|
289 | VALUE CONSTRAINTS: |
---|
290 | The value of this configuration option shall satisfy all of the following |
---|
291 | constraints: |
---|
292 | |
---|
293 | * custom k 1 |
---|
294 | |
---|
295 | * custom k 2 |
---|
296 | |
---|
297 | DESCRIPTION: |
---|
298 | description k |
---|
299 | |
---|
300 | NOTES: |
---|
301 | None. |
---|
302 | |
---|
303 | .. index:: l |
---|
304 | |
---|
305 | .. _l: |
---|
306 | |
---|
307 | l |
---|
308 | - |
---|
309 | |
---|
310 | CONSTANT: |
---|
311 | ``l`` |
---|
312 | |
---|
313 | OPTION TYPE: |
---|
314 | This configuration option is an initializer define. |
---|
315 | |
---|
316 | DEFAULT VALUE: |
---|
317 | The default value is 1. |
---|
318 | |
---|
319 | VALUE CONSTRAINTS: |
---|
320 | The value of this configuration option shall be greater than or equal to 0 |
---|
321 | and less than or equal to 2. |
---|
322 | |
---|
323 | DESCRIPTION: |
---|
324 | description l |
---|
325 | |
---|
326 | NOTES: |
---|
327 | None. |
---|
328 | |
---|
329 | .. index:: m |
---|
330 | |
---|
331 | .. _m: |
---|
332 | |
---|
333 | m |
---|
334 | - |
---|
335 | |
---|
336 | CONSTANT: |
---|
337 | ``m`` |
---|
338 | |
---|
339 | OPTION TYPE: |
---|
340 | This configuration option is an initializer define. |
---|
341 | |
---|
342 | DEFAULT VALUE: |
---|
343 | The default value is 1. |
---|
344 | |
---|
345 | DESCRIPTION: |
---|
346 | description m |
---|
347 | |
---|
348 | NOTES: |
---|
349 | None. |
---|
350 | """ |
---|
351 | assert content == src.read() |
---|