forked from OSchip/llvm-project
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! llvm-svn: 154095
This commit is contained in:
parent
ca917f5342
commit
4fa71de024
|
@ -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…
Reference in New Issue