summaryrefslogtreecommitdiffstats
path: root/kernel/tests/include/tst_assert.h
blob: dcb62dfeae9fa7fda405ed7b3d948c3b04a57553 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved.
 * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
 * Copyright (c) 2020 Cyril Hrubis <chrubis@suse.cz>
 */
#ifndef TST_ASSERT_H__
#define TST_ASSERT_H__

#define TST_ASSERT_INT(path, val) \
	tst_assert_int(__FILE__, __LINE__, path, val)

/*
 * Asserts that integer value stored in file pointed by path equals to the
 * value passed to this function. This is mostly useful for asserting correct
 * values in sysfs, procfs, etc.
 */
void tst_assert_int(const char *file, const int lineno,
		    const char *path, int val);

#define TST_ASSERT_FILE_INT(path, prefix, val) \
	tst_assert_file_int(__FILE__, __LINE__, path, prefix, val)

/*
 * Same as tst_assert_int() but for unsigned long.
 */
void tst_assert_ulong(const char *file, const int lineno,
                      const char *path, unsigned long val);

#define TST_ASSERT_ULONG(path, val) \
	tst_assert_ulong(__FILE__, __LINE__, path, val)

/*
 * Asserts that integer value stored in the prefix field of file pointed by path
 * equals to the value passed to this function. This is mostly useful for
 * asserting correct field values in sysfs, procfs, etc.
 */

void tst_assert_file_int(const char *file, const int lineno,
			 const char *path, const char *prefix, int val);


#define TST_ASSERT_STR(path, val) \
	tst_assert_str(__FILE__, __LINE__, path, val)

/*
 * Asserts that a string value stored in file pointed by path equals to the
 * value passed to this function. This is mostly useful for asserting correct
 * values in sysfs, procfs, etc.
 */
void tst_assert_str(const char *file, const int lineno,
		    const char *path, const char *val);

#define TST_ASSERT_FILE_STR(path, prefix, val) \
	tst_assert_file_str(__FILE__, __LINE__, path, prefix, val)

/*
 * Asserts that a string value stored in the prefix field of file pointed by path
 * equals to the value passed to this function. This is mostly useful for
 * asserting correct field values in sysfs, procfs, etc.
 */
void tst_assert_file_str(const char *file, const int lineno,
			 const char *path, const char *prefix, const char *val);

#endif /* TST_ASSERT_H__ */