2 * Copyright © 2012 Intel Corporation
3 * Copyright © 2013 Sam Spilsbury <smspillaz@gmail.com>
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of the copyright holders not be used in
10 * advertising or publicity pertaining to distribution of the software
11 * without specific, written prior permission. The copyright holders make
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #ifndef _WESTON_TEST_RUNNER_H_
25 #define _WESTON_TEST_RUNNER_H_
30 #error "Tests must not be built with NDEBUG defined, they rely on assert()."
36 const void *table_data;
40 } __attribute__ ((aligned (32)));
42 #define TEST_BEGIN(name, arg) \
45 #define TEST_COMMON(func, name, ret, data, size, n_elem) \
46 static void func(void *); \
48 const struct weston_test test##name \
49 __attribute__ ((section ("test_section"))) = \
51 #name, func, data, size, n_elem, ret \
54 #define NO_ARG_TEST(name, ret) \
55 TEST_COMMON(wrap##name, name, ret, NULL, 0, 1) \
56 static void name(void); \
57 static void wrap##name(void *data) \
63 TEST_BEGIN(name, void)
65 #define ARG_TEST(name, ret, test_data) \
66 TEST_COMMON(name, name, ret, test_data, \
67 sizeof(test_data[0]), \
68 sizeof(test_data) / sizeof (test_data[0])) \
69 TEST_BEGIN(name, void *data) \
71 #define TEST(name) NO_ARG_TEST(name, 0)
72 #define FAIL_TEST(name) NO_ARG_TEST(name, 1)
73 #define TEST_P(name, data) ARG_TEST(name, 0, data)
74 #define FAIL_TEST_P(name, data) ARG_TEST(name, 1, data)