From c0f504fec29666a1b7e4e26fb22bdd72ca561185 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 26 May 2011 14:58:26 +0300 Subject: fs-tests: integck: print error message on error Currently pcv macro print the error message only if we are not doing power cut testing or if we have -v flag. But if we run without -v and an error happen and the error code is not EROFS/EIO, pcv() does not print anything. This patch makes it print the error message in that case as well. Signed-off-by: Artem Bityutskiy --- tests/fs-tests/integrity/integck.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 8b1fb40..e2a878f 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -70,27 +70,22 @@ check_failed(stringify(cond), __func__, __FILE__, __LINE__); \ } while(0) -#define CHECK_ERRNO() do { \ - if (args.power_cut_mode) \ - /* \ - * In case of emulated power cut failures the FS has to \ - * return EROFS. But unfortunately, the Linux kernel \ - * sometimes returns EIO to user-space anyway (when write- \ - * back fails the return code is awayse EIO). \ - */ \ - CHECK(errno == EROFS || errno == EIO); \ - else \ - CHECK(0); \ -} while(0) - +/* + * In case of emulated power cut failures the FS has to return EROFS. But + * unfortunately, the Linux kernel sometimes returns EIO to user-space anyway + * (when write-back fails the return code is awayse EIO). + */ #define pcv(fmt, ...) do { \ - if (!args.power_cut_mode || args.verbose) \ + int __err = 1; \ + if (args.power_cut_mode && (errno == EROFS || errno == EIO)) \ + __err = 0; \ + if (!args.power_cut_mode || args.verbose || __err) \ normsg(fmt " (line %d, error %d (%s))", \ ##__VA_ARGS__, __LINE__, errno, strerror(errno)); \ - CHECK_ERRNO(); \ + CHECK(!__err); \ } while(0) -#define v(fmt, ...) do { \ +#define v(fmt, ...) do { \ if (args.verbose) \ normsg(fmt " (line %d)", ##__VA_ARGS__, __LINE__); \ } while(0) -- cgit v1.2.3