From: Arvin Schnell Date: Thu, 17 Feb 2011 16:10:20 +0000 (+0100) Subject: - allow to check rollback statistics X-Git-Tag: v0.1.3~478 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5dbc828cb5e0b14cc50a390b6ed7643180f74de;p=thirdparty%2Fsnapper.git - allow to check rollback statistics --- diff --git a/testsuite-real/common.cc b/testsuite-real/common.cc index 96dbd6d6..d217d21a 100644 --- a/testsuite-real/common.cc +++ b/testsuite-real/common.cc @@ -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() { diff --git a/testsuite-real/common.h b/testsuite-real/common.h index 4e3489ac..064a76a6 100644 --- a/testsuite-real/common.h +++ b/testsuite-real/common.h @@ -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(); diff --git a/testsuite-real/owner1.cc b/testsuite-real/owner1.cc index 7e626331..cd967827 100644 --- a/testsuite-real/owner1.cc +++ b/testsuite-real/owner1.cc @@ -29,6 +29,8 @@ main() second_snapshot(); + check_rollback_statistics(3, 0, 0); + rollback(); check_first(); diff --git a/testsuite-real/permissions1.cc b/testsuite-real/permissions1.cc index e25a2540..a88cbd85 100644 --- a/testsuite-real/permissions1.cc +++ b/testsuite-real/permissions1.cc @@ -30,6 +30,8 @@ main() second_snapshot(); + check_rollback_statistics(4, 0, 0); + rollback(); check_first(); diff --git a/testsuite-real/simple1.cc b/testsuite-real/simple1.cc index 578e59ff..e9087bc0 100644 --- a/testsuite-real/simple1.cc +++ b/testsuite-real/simple1.cc @@ -28,6 +28,8 @@ main() second_snapshot(); + check_rollback_statistics(3, 0, 3); + rollback(); check_first();