xref: /openbmc/linux/tools/testing/selftests/timens/log.h (revision 8dd06ef34b6e2f41b29fbf5fc1663780f2524285)
1*61c57676SDmitry Safonov /* SPDX-License-Identifier: GPL-2.0 */
2*61c57676SDmitry Safonov 
3*61c57676SDmitry Safonov #ifndef __SELFTEST_TIMENS_LOG_H__
4*61c57676SDmitry Safonov #define __SELFTEST_TIMENS_LOG_H__
5*61c57676SDmitry Safonov 
6*61c57676SDmitry Safonov #define pr_msg(fmt, lvl, ...)						\
7*61c57676SDmitry Safonov 	ksft_print_msg("[%s] (%s:%d)\t" fmt "\n",			\
8*61c57676SDmitry Safonov 			lvl, __FILE__, __LINE__, ##__VA_ARGS__)
9*61c57676SDmitry Safonov 
10*61c57676SDmitry Safonov #define pr_p(func, fmt, ...)	func(fmt ": %m", ##__VA_ARGS__)
11*61c57676SDmitry Safonov 
12*61c57676SDmitry Safonov #define pr_err(fmt, ...)						\
13*61c57676SDmitry Safonov 	({								\
14*61c57676SDmitry Safonov 		ksft_test_result_error(fmt "\n", ##__VA_ARGS__);		\
15*61c57676SDmitry Safonov 		-1;							\
16*61c57676SDmitry Safonov 	})
17*61c57676SDmitry Safonov 
18*61c57676SDmitry Safonov #define pr_fail(fmt, ...)					\
19*61c57676SDmitry Safonov 	({							\
20*61c57676SDmitry Safonov 		ksft_test_result_fail(fmt, ##__VA_ARGS__);	\
21*61c57676SDmitry Safonov 		-1;						\
22*61c57676SDmitry Safonov 	})
23*61c57676SDmitry Safonov 
24*61c57676SDmitry Safonov #define pr_perror(fmt, ...)	pr_p(pr_err, fmt, ##__VA_ARGS__)
25*61c57676SDmitry Safonov 
26*61c57676SDmitry Safonov #endif
27