source: mainline/uspace/lib/pcut/include/pcut/datadef.h

Last change on this file was 9b20126, checked in by Vojtech Horky <vojtechhorky@…>, 11 years ago

Update PCUT to newest version

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * Copyright (c) 2012-2013 Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - 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 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @file
30 * Data types internally used by PCUT.
31 */
32#ifndef PCUT_DATADEF_H_GUARD
33#define PCUT_DATADEF_H_GUARD
34
35#include <pcut/prevs.h>
36#include <stdlib.h>
37#include <stddef.h>
38
39/** @cond devel */
40
41#if defined(__GNUC__) || defined(__clang__)
42#define PCUT_CC_UNUSED_VARIABLE(name, initializer) \
43 name __attribute__((unused)) = initializer
44#else
45#define PCUT_CC_UNUSED_VARIABLE(name, initializer) \
46 name = initializer
47#endif
48
49
50enum {
51 PCUT_KIND_SKIP,
52 PCUT_KIND_NESTED,
53 PCUT_KIND_SETUP,
54 PCUT_KIND_TEARDOWN,
55 PCUT_KIND_TESTSUITE,
56 PCUT_KIND_TEST
57};
58
59enum {
60 PCUT_EXTRA_TIMEOUT,
61 PCUT_EXTRA_SKIP,
62 PCUT_EXTRA_LAST
63};
64
65enum {
66 PCUT_MAIN_EXTRA_PREINIT_HOOK,
67 PCUT_MAIN_EXTRA_INIT_HOOK,
68 PCUT_MAIN_EXTRA_REPORT_XML,
69 PCUT_MAIN_EXTRA_LAST
70};
71
72/** Generic wrapper for test cases, test suites etc. */
73typedef struct pcut_item pcut_item_t;
74
75/** Extra information about a test. */
76typedef struct pcut_extra pcut_extra_t;
77
78/** Extra information for the main() function. */
79typedef struct pcut_main_extra pcut_main_extra_t;
80
81/** Test method type. */
82typedef void (*pcut_test_func_t)(void);
83
84/** Set-up or tear-down method type. */
85typedef void (*pcut_setup_func_t)(void);
86
87/** @copydoc pcut_extra_t */
88struct pcut_extra {
89 /** Discriminator for the union.
90 *
91 * Use PCUT_EXTRA_* to determine which field of the union is used.
92 */
93 int type;
94 /** Test-specific time-out in seconds. */
95 int timeout;
96};
97
98/** @copydoc pcut_main_extra_t */
99struct pcut_main_extra {
100 /** Discriminator for the union.
101 *
102 * Use PCUT_MAIN_EXTRA_* to determine which field of the union is used.
103 */
104 int type;
105 /** Callback once PCUT initializes itself. */
106 void (*init_hook)(void);
107 /** Callback even before command-line arguments are processed. */
108 void (*preinit_hook)(int *, char ***);
109};
110
111/** @copydoc pcut_item_t */
112struct pcut_item {
113 /** Link to previous item. */
114 pcut_item_t *previous;
115 /** Link to next item. */
116 pcut_item_t *next;
117
118 /** Unique id of this item. */
119 int id;
120
121 /** Discriminator for this item. */
122 int kind;
123
124 /** Name of this item. */
125 const char *name;
126
127 /** Test-case function. */
128 pcut_test_func_t test_func;
129
130 /** Set-up function of a suite. */
131 pcut_setup_func_t setup_func;
132 /** Tear-down function of a suite. */
133 pcut_setup_func_t teardown_func;
134
135 /** Extra attributes. */
136 pcut_extra_t *extras;
137
138 /** Extra attributes for main() function. */
139 pcut_main_extra_t *main_extras;
140
141 /** Nested lists. */
142 pcut_item_t *nested;
143};
144
145/** @endcond */
146
147#endif
Note: See TracBrowser for help on using the repository browser.