From: Arvin Schnell Date: Wed, 30 Jan 2013 17:32:00 +0000 (+0100) Subject: - fix compile with older gcc versions X-Git-Tag: v0.1.3~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45bde563da55e84b336fa1e8475682412f516e11;p=thirdparty%2Fsnapper.git - fix compile with older gcc versions --- diff --git a/configure.in b/configure.in index 18ffbc99..84e13667 100644 --- a/configure.in +++ b/configure.in @@ -29,7 +29,7 @@ dnl Disable it by "configure --disable-silent-rules" or "make V=1" m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) CFLAGS="${CFLAGS} -Wall -Wformat=2 -Wmissing-prototypes" -CXXFLAGS="${CXXFLAGS} -std=c++0x -DHAVE_CXX0X -Wall -Wextra -Wformat=2 -Wnon-virtual-dtor -Wno-unused-parameter" +CXXFLAGS="${CXXFLAGS} -std=c++0x -Wall -Wextra -Wformat=2 -Wnon-virtual-dtor -Wno-unused-parameter" fillupdir=/var/adm/fillup-templates diff --git a/testsuite-cmp/cmp.cc b/testsuite-cmp/cmp.cc index 98c0a9d9..106532f7 100644 --- a/testsuite-cmp/cmp.cc +++ b/testsuite-cmp/cmp.cc @@ -14,6 +14,16 @@ using namespace std; using namespace snapper; +struct helper +{ + helper(vector& result) + : result(result) {} + void operator()(const string& name, unsigned int status) + { result.push_back(name + " " + statusToString(status)); } + vector result; +}; + + bool cmp(const string& fstype, const string& subvolume, unsigned int num1, unsigned int num2) { @@ -28,9 +38,13 @@ cmp(const string& fstype, const string& subvolume, unsigned int num1, unsigned i { StopWatch sw1; +#if 1 + cmpdirs_cb_t cb1 = helper(result1); +#else cmpdirs_cb_t cb1 = [&result1](const string& name, unsigned int status) { result1.push_back(name + " " + statusToString(status)); }; +#endif filesystem->cmpDirs(dir1, dir2, cb1); @@ -46,9 +60,13 @@ cmp(const string& fstype, const string& subvolume, unsigned int num1, unsigned i { StopWatch sw2; +#if 1 + cmpdirs_cb_t cb2 = helper(result2); +#else cmpdirs_cb_t cb2 = [&result2](const string& name, unsigned int status) { result2.push_back(name + " " + statusToString(status)); }; +#endif snapper::cmpDirs(dir1, dir2, cb2); @@ -58,28 +76,22 @@ cmp(const string& fstype, const string& subvolume, unsigned int num1, unsigned i sort(result2.begin(), result2.end()); } - y2mil("speedup " << fixed << 100.0 * t2 / t1 << "%"); + y2mil("speedup " << fixed << 100.0 * (t2 - t1) / t1 << "% (" << t1 << "s vs. " << t2 << "s)"); - if (result1 == result2) - { - cout << fstype << " " << subvolume << " " << num1 << " " << num2 << " results match" << endl; + std::ofstream fout1("/tmp/result1-" + decString(num1) + "-" + decString(num2)); + for (vector::const_iterator it = result1.begin(); it != result1.end(); ++it) + fout1 << *it << endl; - return true; - } - else - { - cout << fstype << " " << subvolume << " " << num1 << " " << num2 << " results don't match" << endl; + std::ofstream fout2("/tmp/result2-" + decString(num1) + "-" + decString(num2)); + for (vector::const_iterator it = result2.begin(); it != result2.end(); ++it) + fout2 << *it << endl; - std::ofstream fout1("/tmp/result1-" + decString(num1) + "-" + decString(num2)); - for (vector::const_iterator it = result1.begin(); it != result1.end(); ++it) - fout1 << *it << endl; + bool ok = result1 == result2; - std::ofstream fout2("/tmp/result2-" + decString(num1) + "-" + decString(num2)); - for (vector::const_iterator it = result2.begin(); it != result2.end(); ++it) - fout2 << *it << endl; + cout << fstype << " " << subvolume << " " << num1 << " " << num2 + << (ok ? " success" : " failure") << endl; - return false; - } + return ok; } @@ -97,5 +109,5 @@ main(int argc, char** argv) unsigned int num1 = atoi(argv[3]); unsigned int num2 = atoi(argv[4]); - exit(cmp(fstype, subvolume, num1, num2) ? EXIT_SUCCESS : EXIT_FAILURE); + return cmp(fstype, subvolume, num1, num2) ? EXIT_SUCCESS : EXIT_FAILURE; }