[03/11] fs-tests: integck: check errno in pvc macro

Submitted by Artem Bityutskiy on May 17, 2011, 7:38 a.m.

Details

Message ID 1305617896-23711-4-git-send-email-dedekind1@gmail.com
State Accepted
Commit 6baa47e6b91363fa6b760d2a5592dc3fd3991b26
Headers show

Commit Message

Artem Bityutskiy May 17, 2011, 7:38 a.m.
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

All errors but write errors have corresponding CHECK(), so if something
gets wrong we fail. But in case of I/O errors we do not fail if an
unexpected error happens, which makes it difficult to trace issues.
Inject the errno checking to the pvc macro to make sure we fail if
errno is not EROFS.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 tests/fs-tests/integrity/integck.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 1b08acc..b411a68 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -69,12 +69,18 @@ 
 		check_failed(stringify(cond), __func__, __FILE__, __LINE__); \
 } while(0)
 
+#define CHECK_ERRNO() do {                                                   \
+	if (args.power_cut_mode)                                             \
+		CHECK(errno == EROFS);                                       \
+	else                                                                 \
+		CHECK(0);                                                    \
+} while(0)
+
 #define pcv(fmt, ...) do {                                                   \
 	if (!args.power_cut_mode || (args.power_cut_mode && args.verbose))   \
 		normsg(fmt " (line %d, error %d (%s))",                      \
 		       ##__VA_ARGS__, __LINE__, errno, strerror(errno));     \
-	if (!args.power_cut_mode)                                            \
-		CHECK(0);                                                    \
+	CHECK_ERRNO();                                                       \
 } while(0)
 
 /* The variables below are set by command line arguments */