]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: fix make_pair() for c++11
authorJosh Durgin <josh.durgin@inktank.com>
Sat, 31 May 2014 00:30:04 +0000 (17:30 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Thu, 10 Jul 2014 01:15:56 +0000 (18:15 -0700)
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/test/TestTimers.cc
src/test/osd/Object.cc
src/test/osd/Object.h

index 6e6f47351e6ef8f56c1f2bea525745df46e54e78..0dc8a066e41226027c046b9c9a897724ebbff50e 100644 (file)
@@ -16,7 +16,7 @@ class TestContext;
 
 namespace
 {
-  int array[MAX_TEST_CONTEXTS];
+  int test_array[MAX_TEST_CONTEXTS];
   int array_idx;
   TestContext* test_contexts[MAX_TEST_CONTEXTS];
 
@@ -35,7 +35,7 @@ public:
   {
     array_lock.Lock();
     cout << "TestContext " << num << std::endl;
-    array[array_idx++] = num;
+    test_array[array_idx++] = num;
     array_lock.Unlock();
   }
 
@@ -59,7 +59,7 @@ public:
   {
     array_lock.Lock();
     cout << "StrictOrderTestContext " << num << std::endl;
-    array[num] = num;
+    test_array[num] = num;
     array_lock.Unlock();
   }
 
@@ -79,7 +79,7 @@ template <typename T>
 static int basic_timer_test(T &timer, Mutex *lock)
 {
   int ret = 0;
-  memset(&array, 0, sizeof(array));
+  memset(&test_array, 0, sizeof(test_array));
   array_idx = 0;
   memset(&test_contexts, 0, sizeof(test_contexts));
 
@@ -109,10 +109,10 @@ static int basic_timer_test(T &timer, Mutex *lock)
   } while (!done);
 
   for (int i = 0; i < MAX_TEST_CONTEXTS; ++i) {
-    if (array[i] != i) {
+    if (test_array[i] != i) {
       ret = 1;
-      cout << "error: expected array[" << i << "] = " << i
-          << "; got " << array[i] << " instead." << std::endl;
+      cout << "error: expected test_array[" << i << "] = " << i
+          << "; got " << test_array[i] << " instead." << std::endl;
     }
   }
 
@@ -122,7 +122,7 @@ static int basic_timer_test(T &timer, Mutex *lock)
 static int test_out_of_order_insertion(SafeTimer &timer, Mutex *lock)
 {
   int ret = 0;
-  memset(&array, 0, sizeof(array));
+  memset(&test_array, 0, sizeof(test_array));
   array_idx = 0;
   memset(&test_contexts, 0, sizeof(test_contexts));
 
@@ -151,7 +151,7 @@ static int test_out_of_order_insertion(SafeTimer &timer, Mutex *lock)
   for (; secs < 100 ; ++secs) {
     sleep(1);
     array_lock.Lock();
-    int a = array[1];
+    int a = test_array[1];
     array_lock.Unlock();
     if (a == 1)
       break;
@@ -159,8 +159,8 @@ static int test_out_of_order_insertion(SafeTimer &timer, Mutex *lock)
 
   if (secs == 100) {
     ret = 1;
-    cout << "error: expected array[" << 1 << "] = " << 1
-        << "; got " << array[1] << " instead." << std::endl;
+    cout << "error: expected test_array[" << 1 << "] = " << 1
+        << "; got " << test_array[1] << " instead." << std::endl;
   }
 
   return ret;
@@ -171,7 +171,7 @@ static int safe_timer_cancel_all_test(SafeTimer &safe_timer, Mutex& safe_timer_l
   cout << __PRETTY_FUNCTION__ << std::endl;
 
   int ret = 0;
-  memset(&array, 0, sizeof(array));
+  memset(&test_array, 0, sizeof(test_array));
   array_idx = 0;
   memset(&test_contexts, 0, sizeof(test_contexts));
 
@@ -194,10 +194,10 @@ static int safe_timer_cancel_all_test(SafeTimer &safe_timer, Mutex& safe_timer_l
   safe_timer_lock.Unlock();
 
   for (int i = 0; i < array_idx; ++i) {
-    if (array[i] != i) {
+    if (test_array[i] != i) {
       ret = 1;
-      cout << "error: expected array[" << i << "] = " << i
-          << "; got " << array[i] << " instead." << std::endl;
+      cout << "error: expected test_array[" << i << "] = " << i
+          << "; got " << test_array[i] << " instead." << std::endl;
     }
   }
 
@@ -209,7 +209,7 @@ static int safe_timer_cancellation_test(SafeTimer &safe_timer, Mutex& safe_timer
   cout << __PRETTY_FUNCTION__ << std::endl;
 
   int ret = 0;
-  memset(&array, 0, sizeof(array));
+  memset(&test_array, 0, sizeof(test_array));
   array_idx = 0;
   memset(&test_contexts, 0, sizeof(test_contexts));
 
@@ -239,10 +239,10 @@ static int safe_timer_cancellation_test(SafeTimer &safe_timer, Mutex& safe_timer
   safe_timer_lock.Unlock();
 
   for (int i = 1; i < array_idx; i += 2) {
-    if (array[i] != i) {
+    if (test_array[i] != i) {
       ret = 1;
-      cout << "error: expected array[" << i << "] = " << i
-          << "; got " << array[i] << " instead." << std::endl;
+      cout << "error: expected test_array[" << i << "] = " << i
+          << "; got " << test_array[i] << " instead." << std::endl;
     }
   }
 
index c98d62d2934e182dd37d1fc4bc05d8bd0611ca01..c5ff040eaf07310577f40dcb229fe12ada35af7f 100644 (file)
@@ -53,7 +53,7 @@ void AppendGenerator::get_ranges_map(
     }
     if (alignment)
       assert(segment_length % alignment == 0);
-    out.insert(make_pair(pos, segment_length));
+    out.insert(pair<uint64_t, uint64_t>(pos, segment_length));
     pos += segment_length;
   }
 }
@@ -72,7 +72,7 @@ void VarLenGenerator::get_ranges_map(
       segment_length = limit - pos;
     }
     if (include) {
-      out.insert(make_pair(pos, segment_length));
+      out.insert(pair<uint64_t, uint64_t>(pos, segment_length));
       include = false;
     } else {
       include = true;
@@ -108,7 +108,9 @@ ObjectDesc::iterator &ObjectDesc::iterator::advance(bool init) {
   interval_set<uint64_t> ranges;
   cur_cont->first->get_ranges(cur_cont->second, ranges);
   while (!ranges.contains(pos)) {
-    stack.push_front(make_pair(cur_cont, limit));
+    stack.push_front(pair<list<pair<ceph::shared_ptr<ContentsGenerator>,
+                                   ContDesc> >::iterator,
+                    uint64_t>(cur_cont, limit));
     uint64_t length = cur_cont->first->get_length(cur_cont->second);
     uint64_t next;
     if (pos >= length) {
@@ -153,7 +155,7 @@ const ContDesc &ObjectDesc::most_recent() {
 }
 
 void ObjectDesc::update(ContentsGenerator *gen, const ContDesc &next) {
-  layers.push_front(make_pair(gen, next));
+  layers.push_front(pair<ceph::shared_ptr<ContentsGenerator>, ContDesc>(ceph::shared_ptr<ContentsGenerator>(gen), next));
   return;
 }
 
index d39d36c6fd83d6cf4719ccd917cdb6559311c51d..b4cb447e75bd4221107e22b03308762abc0e9ce5 100644 (file)
@@ -220,7 +220,7 @@ public:
   AttrGenerator(uint64_t max_len) : max_len(max_len) {}
   void get_ranges_map(
     const ContDesc &cont, map<uint64_t, uint64_t> &out) {
-    out.insert(make_pair(0, get_length(cont)));
+    out.insert(pair<uint64_t, uint64_t>(0, get_length(cont)));
   }
   uint64_t get_length(const ContDesc &in) {
     RandWrap rand(in.seqnum);
@@ -282,7 +282,7 @@ public:
   ObjectDesc(const ContDesc &init, ContentsGenerator *cont_gen)
     : exists(false), dirty(false),
       version(0) {
-    layers.push_front(make_pair(cont_gen, init));
+    layers.push_front(pair<ceph::shared_ptr<ContentsGenerator>, ContDesc>(ceph::shared_ptr<ContentsGenerator>(cont_gen), init));
   }
 
   class iterator {