diff options
Diffstat (limited to 'src/kernel/tests/include/tst_assert.h')
-rw-r--r-- | src/kernel/tests/include/tst_assert.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/kernel/tests/include/tst_assert.h b/src/kernel/tests/include/tst_assert.h new file mode 100644 index 0000000..dcb62df --- /dev/null +++ b/src/kernel/tests/include/tst_assert.h @@ -0,0 +1,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__ */ |