source: rtems-central/rtemsspec/tests/test_interface.py @ 6fc23e6

Last change on this file since 6fc23e6 was 6fc23e6, checked in by Sebastian Huber <sebastian.huber@…>, on 08/19/20 at 09:07:54

interface: Add automatically generated warning

  • Property mode set to 100644
File size: 8.7 KB
Line 
1# SPDX-License-Identifier: BSD-2-Clause
2""" Unit tests for the rtemsspec.interface 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 pytest
29
30from rtemsspec.interface import generate
31from rtemsspec.items import EmptyItemCache, ItemCache
32from rtemsspec.tests.util import create_item_cache_config_and_copy_spec
33
34
35def test_interface(tmpdir):
36    interface_config = {}
37    interface_config["item-level-interfaces"] = []
38    base_directory = os.path.join(tmpdir, "base")
39    interface_domains = {"/domain-abc": base_directory}
40    interface_config["domains"] = interface_domains
41
42    generate(interface_config, EmptyItemCache())
43
44    interface_config["item-level-interfaces"] = ["/command-line"]
45
46    item_cache_config = create_item_cache_config_and_copy_spec(
47        tmpdir, "spec-interface", with_spec_types=True)
48    generate(interface_config, ItemCache(item_cache_config))
49
50    with open(os.path.join(base_directory, "include", "h.h"), "r") as src:
51        content = """/* SPDX-License-Identifier: BSD-2-Clause */
52
53/**
54 * @file
55 *
56 * @ingroup GroupA
57 * @ingroup GroupB
58 * @ingroup GroupC
59 *
60 * @brief This header file defines X.
61 */
62
63/*
64 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
65 *
66 * Redistribution and use in source and binary forms, with or without
67 * modification, are permitted provided that the following conditions
68 * are met:
69 * 1. Redistributions of source code must retain the above copyright
70 *    notice, this list of conditions and the following disclaimer.
71 * 2. Redistributions in binary form must reproduce the above copyright
72 *    notice, this list of conditions and the following disclaimer in the
73 *    documentation and/or other materials provided with the distribution.
74 *
75 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
76 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
77 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
78 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
79 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
80 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
81 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
82 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
83 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
84 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
85 * POSSIBILITY OF SUCH DAMAGE.
86 */
87
88/*
89 * This file was automatically generated.  Do not edit it manually.
90 * Please have a look at
91 *
92 * https://docs.rtems.org/branches/master/eng/req/howto.html
93 *
94 * for information how to maintain and re-generate this file.
95 */
96
97#ifndef _H_H
98#define _H_H
99
100#include <h3.h>
101#include <math.h>
102#include <stdint.h>
103
104#if !defined(ASM) && defined(RTEMS_SMP)
105  #include <h2.h>
106#endif
107
108#if defined(ASM) && defined(RTEMS_SMP)
109  #include <h4.h>
110#endif
111
112#ifdef __cplusplus
113extern "C" {
114#endif
115
116/**
117 * @defgroup GroupA Group A
118 *
119 * @brief Group A brief description.
120 *
121 * Group A description.
122 */
123
124/**
125 * @defgroup GroupB Group B
126 *
127 * @ingroup GroupA
128 */
129
130/* Forward declaration */
131struct Struct;
132
133/**
134 * @ingroup GroupB
135 *
136 * @brief Enum brief description.
137 *
138 * Enum description.
139 */
140typedef enum {
141  /**
142   * @brief Enumerator 0 brief description.
143   */
144  ENUMERATOR_0,
145
146  /**
147   * @brief Enumerator 1 brief description.
148   */
149  ENUMERATOR_1,
150
151  /**
152   * @brief Enumerator 2 brief description.
153   */
154  ENUMERATOR_2
155} Enum;
156
157/**
158 * @ingroup GroupA
159 */
160#if defined(A) || (B > C)
161  #define DEFINE ((float_t) 456)
162#elif defined(C) && defined(D)
163  #define DEFINE ((float_t) 789)
164#else
165  #define DEFINE \\
166    ((float_t) 123)
167#endif
168
169/**
170 * @ingroup GroupB
171 *
172 * @brief Enum B brief description.
173 */
174typedef enum EnumB {
175  /**
176   * @brief Enumerator B brief description.
177   */
178  ENUMERATOR_B = ENUMERATOR_A
179} EnumB;
180
181/**
182 * @ingroup GroupA
183 *
184 * @brief Function brief description.
185 *
186 * Function description.  References to VeryLongFunction(), ::Integer, #Enum,
187 * #DEFINE, #VERY_LONG_MACRO, #Variable, ::ENUMERATOR_0, Struct, a, and
188 * interface.
189 *
190 * @param Param0 is parameter 0.
191 *
192 * @param[in] Param1 is parameter 1.
193 *
194 * @param[out] Param2 is parameter 2.
195 *
196 * @param[in,out] Param3 is parameter 3.
197 */
198void Function( int Param0, const int *Param1, int *Param2, int *Param3 );
199
200/**
201 * @ingroup GroupB
202 *
203 * @brief Very long function brief description.
204 *
205 * VeryLongFunction description.
206 *
207 * VeryLongFunction notes.
208 *
209 * @param VeryLongParam0 is very long parameter 0 with some super important and
210 *   extra very long description which makes a lot of sense.
211 *
212 * @param[in] VeryLongParam1 is very long parameter 1.
213 *
214 * @param[out] VeryLongParam2 is very long parameter 2.
215 *
216 * @param[in,out] VeryLongParam3 is very long parameter 3.
217 *
218 * @retval 1 is returned, in case A.
219 *
220 * @retval 2 is returned, in case B.
221 *
222 * @return Sometimes some value.  See Function().
223 */
224static inline int VeryLongFunction(
225  int                  VeryLongParam0,
226  const struct Struct *VeryLongParam1,
227  struct Struct    *( *VeryLongParam2 )( void ),
228  struct Struct       *VeryLongParam3
229)
230{
231  (void) VeryLongParam1;
232  (void) VeryLongParam2;
233  (void) VeryLongParam3;
234  return VeryLongParam0 + 1;
235}
236
237/**
238 * @ingroup GroupB
239 *
240 * @brief Very long macro brief description.
241 *
242 * @param VeryLongParam0 is very long parameter 0 with some super important and
243 *   extra very long description which makes a lot of sense.
244 *
245 * @param[in] VeryLongParam1 is very long parameter 1.
246 *
247 * @param[out] VeryLongParam2 is very long parameter 2.
248 *
249 * @param[in,out] VeryLongParam3 is very long parameter 3.
250 *
251 * @retval 1 is returned, in case A.
252 *
253 * @retval 2 is returned, in case B.
254 *
255 * @return Sometimes some value.
256 */
257#define VERY_LONG_MACRO( \\
258  VeryLongParam0, \\
259  VeryLongParam1, \\
260  VeryLongParam2, \\
261  VeryLongParam3 \\
262) \\
263  do { \\
264    (void) VeryLongParam1; \\
265    (void) VeryLongParam2; \\
266    (void) VeryLongParam3; \\
267  } while ( 0 ); \\
268  VeryLongParam0 + 1;
269
270/**
271 * @ingroup GroupB
272 *
273 * @brief Short macro brief description.
274 *
275 * @param Param0 is parameter 0.
276 *
277 * @return Sometimes some value.
278 */
279#if 0
280  #define MACRO( Param0 )
281#else
282  #define MACRO( Param0 ) ( ( Param0 ) + 1 )
283#endif
284
285/**
286 * @ingroup GroupC
287 */
288struct Struct {
289  /**
290   * @brief Brief union description.
291   *
292   * Union description.
293   */
294  union {
295    /**
296     * @brief Brief member description.
297     *
298     * Member description.
299     */
300    uint32_t some_member;
301
302    /**
303     * @brief Brief struct description.
304     *
305     * struct description.
306     */
307    struct {
308      /**
309       * @brief Brief member 2 description.
310       *
311       * Member 2 description.
312       */
313      uint32_t some_member_2;
314
315      /**
316       * @brief Brief member 3 description.
317       *
318       * Member 3 description.
319       */
320      Enum some_member_3;
321    } some_struct;
322  } some_union;
323
324  /**
325   * @brief Brief member 4 description.
326   *
327   * Member 4 description.
328   */
329  Enum some_member_4;
330};
331
332/**
333 * @ingroup GroupB
334 *
335 * @brief Typedef Integer brief description.
336 *
337 * Typedef Integer description.
338 */
339typedef uint32_t Integer /* Some comment. */;
340
341/**
342 * @ingroup GroupB
343 */
344#if defined(RTEMS_SMP)
345  typedef uint32_t Integer3;
346#endif
347
348#if !defined(ASM)
349  /**
350   * @ingroup GroupC
351   *
352   * @brief Variable brief description.
353   *
354   * Variable description.
355   */
356  extern struct Struct *Variable;
357#endif
358
359#ifdef __cplusplus
360}
361#endif
362
363#endif /* _H_H */
364"""
365        assert content == src.read()
Note: See TracBrowser for help on using the repository browser.