]> git.proxmox.com Git - mirror_lxc.git/blob - src/tests/lxctest.h
spelling: timeout
[mirror_lxc.git] / src / tests / lxctest.h
1 /*
2 * lxc: linux Container library
3 *
4 * Copyright © 2016 Canonical Ltd.
5 *
6 * Authors:
7 * Christian Brauner <christian.brauner@mailbox.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef __LXC_TEST_H_
25 #define __LXC_TEST_H_
26
27 #include <stdbool.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30
31 #define lxc_debug_stream(stream, format, ...) \
32 do { \
33 fprintf(stream, "%s: %d: %s: " format, __FILE__, __LINE__, \
34 __func__, __VA_ARGS__); \
35 } while (false)
36
37 #define lxc_error(format, ...) lxc_debug_stream(stderr, format, __VA_ARGS__)
38 #define lxc_debug(format, ...) lxc_debug_stream(stdout, format, __VA_ARGS__)
39
40 #define lxc_test_assert_stringify(expression, stringify_expression) \
41 do { \
42 if (!(expression)) { \
43 fprintf(stderr, "%s: %s: %d: %s\n", __FILE__, \
44 __func__, __LINE__, stringify_expression); \
45 abort(); \
46 } \
47 } while (false)
48
49 #define lxc_test_assert_abort(expression) lxc_test_assert_stringify(expression, #expression)
50
51 #endif /* __LXC_TEST_H */