]> www.infradead.org Git - mtd-utils.git/commitdiff
fs-tests: integck: implement own version of CHECK
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Wed, 13 Apr 2011 14:09:36 +0000 (17:09 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 18 Apr 2011 14:44:46 +0000 (17:44 +0300)
Remove the final dependency on the common code - the CHECK() macro.
Now we are finally independent. The reason we needed this is that
we are going to improve integck to handle errors more gracefully,
in order to support failure testing better. And this requires changes
in the common code, but it is ancient and shared by many tests, and
we do not want to touch it. So we better make integck independent
and concentrate on integck only.

This patch also removes Makefile dependencies. And while on it, remove
the broken 'tests' target.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/fs-tests/integrity/Makefile
tests/fs-tests/integrity/integck.c

index 364a732bd1ad3a14523a53256cd19d25d53c9acb..03652a23a0f12f3f6bed98e9af4c608bea2c869e 100644 (file)
@@ -13,12 +13,5 @@ TARGETS = integck
 
 all: $(TARGETS)
 
-$(TARGETS): ../lib/tests.o
-
-../lib/tests.o: ../lib/tests.h
-
 clean:
        rm -f *.o $(TARGETS)
-
-tests: all
-       ./integck
index 2dbe9dea4959534c712f58b066ebfbeddaaba104..387874c154150c03983cfb133794e14803e90323 100644 (file)
@@ -36,7 +36,6 @@
 #include <sys/vfs.h>
 #include <sys/mount.h>
 #include <sys/statvfs.h>
-#include "tests.h"
 
 #define PROGRAM_VERSION "1.1"
 #define PROGRAM_NAME "integck"
 /* The pattern for the top directory where we run the test */
 #define TEST_DIR_PATTERN "integck_test_dir_%u"
 
+/*
+ * Check if a condition is true and die if not.
+ */
+#define stringify1(x) #x
+#define stringify(x) stringify1(x)
+#define CHECK(cond) do {                                         \
+       if (!(cond)) {                                           \
+               int _err = errno;                                \
+               fflush(stdout);                                  \
+               errmsg("condition '%s' failed at %s:%d\n",       \
+                      stringify(cond), __FILE__, __LINE__);     \
+               errmsg("error %d (%s)\n", _err, strerror(_err)); \
+               exit(EXIT_FAILURE);                              \
+       }                                                        \
+} while(0)
+
 /* The variables below are set by command line arguments */
 static struct {
        long repeat_cnt;