From edb3e522657971caa7efe0050bb58d6fe2969109 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 15 Apr 2022 15:46:34 -0700 Subject: zdtm: return 1 from pr_err, pr_perror, fail This allows to make test code more compact: if (ret == -1) { pr_perror("XXX"); return 1; } vs if (ret == -1) return pr_perror("XXX"); Signed-off-by: Andrei Vagin --- test/zdtm/lib/zdtmtst.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h index ed7c23ee2..d91886d25 100644 --- a/test/zdtm/lib/zdtmtst.h +++ b/test/zdtm/lib/zdtmtst.h @@ -126,11 +126,25 @@ extern int write_pidfile(int pid); /* message helpers */ extern int test_log_init(const char *outfile, const char *suffix); extern int zdtm_seccomp; -#define pr_err(format, arg...) test_msg("ERR: %s:%d: " format, __FILE__, __LINE__, ##arg) -#define pr_perror(format, arg...) \ - test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", __FILE__, __LINE__, ##arg, errno, strerror(errno)) -#define fail(format, arg...) \ - test_msg("FAIL: %s:%d: " format " (errno = %d (%s))\n", __FILE__, __LINE__, ##arg, errno, strerror(errno)) +#define pr_err(format, arg...) \ + ({ \ + test_msg("ERR: %s:%d: " format, __FILE__, __LINE__, ##arg); \ + 1; \ + }) + +#define pr_perror(format, arg...) \ + ({ \ + test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", __FILE__, __LINE__, ##arg, errno, \ + strerror(errno)); \ + 1; \ + }) + +#define fail(format, arg...) \ + ({ \ + test_msg("FAIL: %s:%d: " format " (errno = %d (%s))\n", __FILE__, __LINE__, ##arg, errno, \ + strerror(errno)); \ + 1; \ + }) #define skip(format, arg...) test_msg("SKIP: %s:%d: " format "\n", __FILE__, __LINE__, ##arg) #define pass() test_msg("PASS\n") -- cgit v1.2.3