From: Josh Durgin Date: Sat, 31 May 2014 00:30:04 +0000 (-0700) Subject: test: fix make_pair() for c++11 X-Git-Tag: v0.84~119^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f51f162ebd6da4457399fcc7d8714cd3a6256aa9;p=ceph.git test: fix make_pair() for c++11 Signed-off-by: Josh Durgin --- diff --git a/src/test/TestTimers.cc b/src/test/TestTimers.cc index 6e6f47351e6e..0dc8a066e412 100644 --- a/src/test/TestTimers.cc +++ b/src/test/TestTimers.cc @@ -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 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; } } diff --git a/src/test/osd/Object.cc b/src/test/osd/Object.cc index c98d62d2934e..c5ff040eaf07 100644 --- a/src/test/osd/Object.cc +++ b/src/test/osd/Object.cc @@ -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(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(pos, segment_length)); include = false; } else { include = true; @@ -108,7 +108,9 @@ ObjectDesc::iterator &ObjectDesc::iterator::advance(bool init) { interval_set 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, + 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, ContDesc>(ceph::shared_ptr(gen), next)); return; } diff --git a/src/test/osd/Object.h b/src/test/osd/Object.h index d39d36c6fd83..b4cb447e75bd 100644 --- a/src/test/osd/Object.h +++ b/src/test/osd/Object.h @@ -220,7 +220,7 @@ public: AttrGenerator(uint64_t max_len) : max_len(max_len) {} void get_ranges_map( const ContDesc &cont, map &out) { - out.insert(make_pair(0, get_length(cont))); + out.insert(pair(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, ContDesc>(ceph::shared_ptr(cont_gen), init)); } class iterator {