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:
David Chisnall 2012-04-05 13:48:16 +00:00
parent ca917f5342
commit 4fa71de024
7 changed files with 18 additions and 16 deletions

View File

@ -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));

View File

@ -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,

View File

@ -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));

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}