]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: print error message on error
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 26 May 2011 11:58:26 +0000 (14:58 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 27 May 2011 12:55:08 +0000 (15:55 +0300)
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 <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/integck.c

index 8b1fb406677becfd486f06156c1dccbd31973b79..e2a878f734bc9e03ad797671c4d56c469ab5c681 100644 (file)
                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)