]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- fix compile with older gcc versions
authorArvin Schnell <aschnell@suse.de>
Wed, 30 Jan 2013 17:32:00 +0000 (18:32 +0100)
committerArvin Schnell <aschnell@suse.de>
Wed, 30 Jan 2013 17:32:00 +0000 (18:32 +0100)
configure.in
testsuite-cmp/cmp.cc

index 18ffbc990f53c75a77f735e3b13efb49d8133096..84e13667de6f0795ba594959425f796e5aefdcd0 100644 (file)
@@ -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
 
index 98c0a9d938a0ea137c9db2d64ea2cbeb29f0bd69..106532f798fdd52c765485ccf7148a137cf8386f 100644 (file)
@@ -14,6 +14,16 @@ using namespace std;
 using namespace snapper;
 
 
+struct helper
+{
+    helper(vector<string>& result)
+       : result(result) {}
+    void operator()(const string& name, unsigned int status)
+       { result.push_back(name + " " + statusToString(status)); }
+    vector<string> 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<string>::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<string>::const_iterator it = result2.begin(); it != result2.end(); ++it)
+       fout2 << *it << endl;
 
-       std::ofstream fout1("/tmp/result1-" + decString(num1) + "-" + decString(num2));
-       for (vector<string>::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<string>::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;
 }