mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-29 14:50:08 +01:00
test: make the TEST_COLLECTION() macro re-usable in the same file
Concat the line number to the generated variable names, this way we can have more than one TEST_COLLECTION() in the same file. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1065>
This commit is contained in:
parent
0135b0b41c
commit
3390f2e647
2 changed files with 14 additions and 5 deletions
|
|
@ -62,4 +62,13 @@
|
|||
|
||||
#define CASE_RETURN_STRING(a) case a: return #a
|
||||
|
||||
/**
|
||||
* Concatenate two macro args into one, e.g.:
|
||||
* int CONCAT(foo_, __LINE__);
|
||||
* will produce:
|
||||
* int foo_123;
|
||||
*/
|
||||
#define CONCAT2(X,Y) X##Y
|
||||
#define CONCAT(X,Y) CONCAT2(X,Y)
|
||||
|
||||
#define _fallthrough_ __attribute__((fallthrough))
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ struct test_collection {
|
|||
void (*setup)(void);
|
||||
} __attribute__((aligned(16)));
|
||||
|
||||
#define TEST_COLLECTION(name) \
|
||||
static void (name##_setup)(void); \
|
||||
static const struct test_collection _test_collection \
|
||||
#define TEST_COLLECTION(name_) \
|
||||
static void (CONCAT(name_ , __LINE__))(void); \
|
||||
static const struct test_collection CONCAT(_test_collection_, __LINE__) \
|
||||
__attribute__ ((used)) \
|
||||
__attribute__ ((section ("test_collection_section"))) = { \
|
||||
#name, name##_setup \
|
||||
#name_, CONCAT(name_, __LINE__) \
|
||||
}; \
|
||||
static void (name##_setup)(void)
|
||||
static void (CONCAT(name_, __LINE__))(void)
|
||||
|
||||
__attribute__ ((format (printf, 3, 0)))
|
||||
void _litest_checkpoint(const char *func,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue