]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/lxctest.h
tests: include config.h
[mirror_lxc.git] / src / tests / lxctest.h
CommitLineData
bed0d08f
CB
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
e49c56d6
CB
27#include "config.h"
28
bed0d08f
CB
29#include <stdbool.h>
30#include <stdio.h>
31#include <stdlib.h>
32
83319023
CB
33#define lxc_debug_stream(stream, format, ...) \
34 do { \
90658f16 35 fprintf(stream, "%s: %d: %s: " format "\n", __FILE__, __LINE__, \
83319023
CB
36 __func__, __VA_ARGS__); \
37 } while (false)
38
39#define lxc_error(format, ...) lxc_debug_stream(stderr, format, __VA_ARGS__)
40#define lxc_debug(format, ...) lxc_debug_stream(stdout, format, __VA_ARGS__)
41
bed0d08f
CB
42#define lxc_test_assert_stringify(expression, stringify_expression) \
43 do { \
44 if (!(expression)) { \
45 fprintf(stderr, "%s: %s: %d: %s\n", __FILE__, \
46 __func__, __LINE__, stringify_expression); \
47 abort(); \
48 } \
49 } while (false)
50
51#define lxc_test_assert_abort(expression) lxc_test_assert_stringify(expression, #expression)
52
90658f16
CB
53#define test_error_ret(__ret__, format, ...) \
54 ({ \
55 typeof(__ret__) __internal_ret__ = (__ret__); \
56 fprintf(stderr, format, ##__VA_ARGS__); \
57 __internal_ret__; \
58 })
59
bed0d08f 60#endif /* __LXC_TEST_H */