]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- allow to check rollback statistics
authorArvin Schnell <aschnell@suse.de>
Thu, 17 Feb 2011 16:10:20 +0000 (17:10 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 17 Feb 2011 16:10:20 +0000 (17:10 +0100)
testsuite-real/common.cc
testsuite-real/common.h
testsuite-real/owner1.cc
testsuite-real/permissions1.cc
testsuite-real/simple1.cc

index 96dbd6d6b2605b54dd7a355452c47fe68dda9f31..d217d21ad61f695b1565ea6559a45cb8814fa733 100644 (file)
@@ -53,6 +53,23 @@ second_snapshot()
 }
 
 
+void
+check_rollback_statistics(unsigned int numCreate, unsigned int numModify, unsigned int numDelete)
+{
+    sh->setComparison(first, second);
+
+    Files& files = sh->getFiles();
+    for (Files::iterator it = files.begin(); it != files.end(); ++it)
+       it->setRollback(true);
+
+    RollbackStatistic rs = sh->getRollbackStatistic();
+
+    check_int_equal(rs.numCreate, numCreate);
+    check_int_equal(rs.numModify, numModify);
+    check_int_equal(rs.numDelete, numDelete);
+}
+
+
 void
 rollback()
 {
index 4e3489ac539a819f3fd68ff3ebfac67ccdec6d7e..064a76a6cee6acfdaeb820314236ee9c458e8c84 100644 (file)
@@ -16,27 +16,38 @@ check_failure(const char* str, Type actual, Type expected, const char* file,
 }
 
 
-#define check_true(expr)                                                \
-    do {                                                                \
-        bool actual = (expr);                                           \
-        if (!actual)                                                    \
-            check_failure(#expr, actual, true, __FILE__, __LINE__,      \
-                          __PRETTY_FUNCTION__);                         \
+#define check_true(expr)                                               \
+    do {                                                               \
+       bool actual = (expr);                                           \
+       if (!actual)                                                    \
+           check_failure(#expr, actual, true, __FILE__, __LINE__,      \
+                         __PRETTY_FUNCTION__);                         \
     } while (0)
 
 
-#define check_zero(expr)                                                \
-    do {                                                                \
-        int actual = (expr);                                            \
-        if (actual != 0)                                                \
-            check_failure(#expr, actual, 0, __FILE__, __LINE__,         \
-                          __PRETTY_FUNCTION__);                         \
+#define check_zero(expr)                                               \
+    do {                                                               \
+       int actual = (expr);                                            \
+       if (actual != 0)                                                \
+           check_failure(#expr, actual, 0, __FILE__, __LINE__,         \
+                         __PRETTY_FUNCTION__);                         \
+    } while (0)
+
+
+#define check_int_equal(expr, expected)                                        \
+    do {                                                               \
+       unsigned int actual = (expr);                                   \
+       if (actual != expected)                                         \
+           check_failure(#expr, actual, expected, __FILE__, __LINE__,  \
+                         __PRETTY_FUNCTION__);                         \
     } while (0)
 
 
 void setup();
 void first_snapshot();
 void second_snapshot();
+void check_rollback_statistics(unsigned int numCreate, unsigned int numModify,
+                              unsigned int numDelete);
 void rollback();
 void check_first();
 
index 7e626331deb8b27fc7f61825c06e02a9cdb35bb5..cd9678271c3c1c7b10c743c99e7d3ed079ff0922 100644 (file)
@@ -29,6 +29,8 @@ main()
 
     second_snapshot();
 
+    check_rollback_statistics(3, 0, 0);
+
     rollback();
 
     check_first();
index e25a2540e2e437e7cca34cbe3554c0bf54722199..a88cbd853da9688f1ba0d93d801e09f9b75f745a 100644 (file)
@@ -30,6 +30,8 @@ main()
 
     second_snapshot();
 
+    check_rollback_statistics(4, 0, 0);
+
     rollback();
 
     check_first();
index 578e59ff7a5c361f8c1bd52481a5df98fd1a16e6..e9087bc0a81ba970304410530bd977f9bac41a00 100644 (file)
@@ -28,6 +28,8 @@ main()
 
     second_snapshot();
 
+    check_rollback_statistics(3, 0, 3);
+
     rollback();
 
     check_first();