Fix the remaining atomic tests, all of which were wrong for the case where a
compare-and-exchange failed (it should update the expected value to the current value, and the tests were checking that it didn't...). Results of the atomics part of the test suite on FreeBSD with clang trunk and the atomic.c from compiler-rt (currently kludged into the test, not installed properly): **************************************************** Results for /root/libc++/test/atomics: using clang version 3.1 (trunk 153415) Target: x86_64-unknown-freebsd10.0 Thread model: posix with -std=c++0x -stdlib=libc++ -pthread /tmp/atomic.o ---------------------------------------------------- sections without tests : 0 sections with failures : 0 sections without failures: 14 + ---- total number of sections : 14 ---------------------------------------------------- number of tests failed : 0 number of tests passed : 52 + ---- total number of tests : 52 **************************************************** Yay! git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@154095 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1ee87fa41a
commit
d3eca759a2
@ -96,14 +96,14 @@ do_test()
|
||||
assert(x == T(3));
|
||||
assert(obj.compare_exchange_weak(x, T(1)) == false);
|
||||
assert(obj == T(2));
|
||||
assert(x == T(1));
|
||||
assert(x == T(2));
|
||||
x = T(2);
|
||||
assert(obj.compare_exchange_strong(x, T(1)) == true);
|
||||
assert(obj == T(1));
|
||||
assert(x == T(2));
|
||||
assert(obj.compare_exchange_strong(x, T(0)) == false);
|
||||
assert(obj == T(1));
|
||||
assert(x == T(0));
|
||||
assert(x == T(1));
|
||||
assert((obj = T(0)) == T(0));
|
||||
assert(obj == T(0));
|
||||
obj = T(2*sizeof(X));
|
||||
|
@ -78,8 +78,9 @@ int main()
|
||||
assert(obj.compare_exchange_weak(x, true,
|
||||
std::memory_order_seq_cst) == false);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
assert(x == false);
|
||||
obj.store(true);
|
||||
x = true;
|
||||
assert(obj.compare_exchange_weak(x, false,
|
||||
std::memory_order_seq_cst,
|
||||
std::memory_order_seq_cst) == true);
|
||||
@ -93,7 +94,7 @@ int main()
|
||||
assert(obj.compare_exchange_strong(x, true,
|
||||
std::memory_order_seq_cst) == false);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
assert(x == false);
|
||||
x = true;
|
||||
obj.store(true);
|
||||
assert(obj.compare_exchange_strong(x, false,
|
||||
@ -132,8 +133,9 @@ int main()
|
||||
assert(obj.compare_exchange_weak(x, true,
|
||||
std::memory_order_seq_cst) == false);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
assert(x == false);
|
||||
obj.store(true);
|
||||
x = true;
|
||||
assert(obj.compare_exchange_weak(x, false,
|
||||
std::memory_order_seq_cst,
|
||||
std::memory_order_seq_cst) == true);
|
||||
@ -147,7 +149,7 @@ int main()
|
||||
assert(obj.compare_exchange_strong(x, true,
|
||||
std::memory_order_seq_cst) == false);
|
||||
assert(obj == false);
|
||||
assert(x == true);
|
||||
assert(x == false);
|
||||
x = true;
|
||||
obj.store(true);
|
||||
assert(obj.compare_exchange_strong(x, false,
|
||||
|
@ -114,14 +114,14 @@ do_test()
|
||||
assert(x == T(3));
|
||||
assert(obj.compare_exchange_weak(x, T(1)) == false);
|
||||
assert(obj == T(2));
|
||||
assert(x == T(1));
|
||||
assert(x == T(2));
|
||||
x = T(2);
|
||||
assert(obj.compare_exchange_strong(x, T(1)) == true);
|
||||
assert(obj == T(1));
|
||||
assert(x == T(2));
|
||||
assert(obj.compare_exchange_strong(x, T(0)) == false);
|
||||
assert(obj == T(1));
|
||||
assert(x == T(0));
|
||||
assert(x == T(1));
|
||||
assert((obj = T(0)) == T(0));
|
||||
assert(obj == T(0));
|
||||
assert(obj++ == T(0));
|
||||
|
@ -34,7 +34,7 @@ test()
|
||||
assert(t == T(1));
|
||||
assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
{
|
||||
typedef std::atomic<T> A;
|
||||
@ -46,7 +46,7 @@ test()
|
||||
assert(t == T(1));
|
||||
assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ test()
|
||||
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
|
||||
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
{
|
||||
typedef std::atomic<T> A;
|
||||
@ -53,7 +53,7 @@ test()
|
||||
assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
|
||||
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ test()
|
||||
assert(t == T(1));
|
||||
assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
{
|
||||
typedef std::atomic<T> A;
|
||||
@ -46,7 +46,7 @@ test()
|
||||
assert(t == T(1));
|
||||
assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ test()
|
||||
assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
|
||||
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
{
|
||||
typedef std::atomic<T> A;
|
||||
@ -53,7 +53,7 @@ test()
|
||||
assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
|
||||
std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
|
||||
assert(a == T(2));
|
||||
assert(t == T(3));
|
||||
assert(t == T(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user