Commit 471e739b authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[test] Move cctest/test-atomicops to unittests/

... base/atomicops-unittest.

Bug: v8:12781
Change-Id: Iac23576cca9c50c2281a2d7e781dde4750e54c03
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3711344Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#81394}
parent 114a03ac
...@@ -173,7 +173,6 @@ v8_source_set("cctest_sources") { ...@@ -173,7 +173,6 @@ v8_source_set("cctest_sources") {
"test-api-typed-array.cc", "test-api-typed-array.cc",
"test-api.cc", "test-api.cc",
"test-api.h", "test-api.h",
"test-atomicops.cc",
"test-code-stub-assembler.cc", "test-code-stub-assembler.cc",
"test-constantpool.cc", "test-constantpool.cc",
"test-cpu-profiler.cc", "test-cpu-profiler.cc",
......
...@@ -224,6 +224,7 @@ v8_source_set("unittests_sources") { ...@@ -224,6 +224,7 @@ v8_source_set("unittests_sources") {
"api/v8-script-unittest.cc", "api/v8-script-unittest.cc",
"base/address-region-unittest.cc", "base/address-region-unittest.cc",
"base/atomic-utils-unittest.cc", "base/atomic-utils-unittest.cc",
"base/atomicops-unittest.cc",
"base/bignum-dtoa-unittest.cc", "base/bignum-dtoa-unittest.cc",
"base/bignum-unittest.cc", "base/bignum-unittest.cc",
"base/bits-unittest.cc", "base/bits-unittest.cc",
......
...@@ -25,10 +25,11 @@ ...@@ -25,10 +25,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/init/v8.h"
#include "src/base/atomicops.h" #include "src/base/atomicops.h"
#include "test/cctest/cctest.h"
#include "src/init/v8.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 { namespace v8 {
namespace base { namespace base {
...@@ -38,7 +39,6 @@ namespace base { ...@@ -38,7 +39,6 @@ namespace base {
#define NUM_BITS(T) (sizeof(T) * 8) #define NUM_BITS(T) (sizeof(T) * 8)
template <class AtomicType> template <class AtomicType>
static void TestAtomicIncrement() { static void TestAtomicIncrement() {
// For now, we just test the single-threaded execution. // For now, we just test the single-threaded execution.
...@@ -107,7 +107,6 @@ static void TestAtomicIncrement() { ...@@ -107,7 +107,6 @@ static void TestAtomicIncrement() {
CHECK_EQU(s.next_word, next_word_value); CHECK_EQU(s.next_word, next_word_value);
} }
template <class AtomicType> template <class AtomicType>
static void TestCompareAndSwap() { static void TestCompareAndSwap() {
AtomicType value = 0; AtomicType value = 0;
...@@ -130,7 +129,6 @@ static void TestCompareAndSwap() { ...@@ -130,7 +129,6 @@ static void TestCompareAndSwap() {
CHECK_EQU(k_test_val, prev); CHECK_EQU(k_test_val, prev);
} }
template <class AtomicType> template <class AtomicType>
static void TestAtomicExchange() { static void TestAtomicExchange() {
AtomicType value = 0; AtomicType value = 0;
...@@ -153,7 +151,6 @@ static void TestAtomicExchange() { ...@@ -153,7 +151,6 @@ static void TestAtomicExchange() {
CHECK_EQU(k_test_val, new_value); CHECK_EQU(k_test_val, new_value);
} }
template <class AtomicType> template <class AtomicType>
static void TestAtomicIncrementBounds() { static void TestAtomicIncrementBounds() {
// Test at 32-bit boundary for 64-bit atomic type. // Test at 32-bit boundary for 64-bit atomic type.
...@@ -176,7 +173,6 @@ static AtomicType TestFillValue() { ...@@ -176,7 +173,6 @@ static AtomicType TestFillValue() {
return val; return val;
} }
// This is a simple sanity check to ensure that values are correct. // This is a simple sanity check to ensure that values are correct.
// Not testing atomicity. // Not testing atomicity.
template <class AtomicType> template <class AtomicType>
...@@ -197,7 +193,6 @@ static void TestStore() { ...@@ -197,7 +193,6 @@ static void TestStore() {
CHECK_EQU(kVal2, value); CHECK_EQU(kVal2, value);
} }
// Merge this test with TestStore as soon as we have Atomic8 acquire // Merge this test with TestStore as soon as we have Atomic8 acquire
// and release stores. // and release stores.
static void TestStoreAtomic8() { static void TestStoreAtomic8() {
...@@ -212,7 +207,6 @@ static void TestStoreAtomic8() { ...@@ -212,7 +207,6 @@ static void TestStoreAtomic8() {
CHECK_EQU(kVal2, value); CHECK_EQU(kVal2, value);
} }
// This is a simple sanity check to ensure that values are correct. // This is a simple sanity check to ensure that values are correct.
// Not testing atomicity. // Not testing atomicity.
template <class AtomicType> template <class AtomicType>
...@@ -233,7 +227,6 @@ static void TestLoad() { ...@@ -233,7 +227,6 @@ static void TestLoad() {
CHECK_EQU(kVal2, Acquire_Load(&value)); CHECK_EQU(kVal2, Acquire_Load(&value));
} }
// Merge this test with TestLoad as soon as we have Atomic8 acquire // Merge this test with TestLoad as soon as we have Atomic8 acquire
// and release loads. // and release loads.
static void TestLoadAtomic8() { static void TestLoadAtomic8() {
...@@ -248,45 +241,39 @@ static void TestLoadAtomic8() { ...@@ -248,45 +241,39 @@ static void TestLoadAtomic8() {
CHECK_EQU(kVal2, Relaxed_Load(&value)); CHECK_EQU(kVal2, Relaxed_Load(&value));
} }
TEST(Atomicops, AtomicIncrement) {
TEST(AtomicIncrement) {
TestAtomicIncrement<Atomic32>(); TestAtomicIncrement<Atomic32>();
TestAtomicIncrement<AtomicWord>(); TestAtomicIncrement<AtomicWord>();
} }
TEST(Atomicops, CompareAndSwap) {
TEST(CompareAndSwap) {
TestCompareAndSwap<Atomic32>(); TestCompareAndSwap<Atomic32>();
TestCompareAndSwap<AtomicWord>(); TestCompareAndSwap<AtomicWord>();
} }
TEST(Atomicops, AtomicExchange) {
TEST(AtomicExchange) {
TestAtomicExchange<Atomic32>(); TestAtomicExchange<Atomic32>();
TestAtomicExchange<AtomicWord>(); TestAtomicExchange<AtomicWord>();
} }
TEST(Atomicops, AtomicIncrementBounds) {
TEST(AtomicIncrementBounds) {
TestAtomicIncrementBounds<Atomic32>(); TestAtomicIncrementBounds<Atomic32>();
TestAtomicIncrementBounds<AtomicWord>(); TestAtomicIncrementBounds<AtomicWord>();
} }
TEST(Atomicops, Store) {
TEST(Store) {
TestStoreAtomic8(); TestStoreAtomic8();
TestStore<Atomic32>(); TestStore<Atomic32>();
TestStore<AtomicWord>(); TestStore<AtomicWord>();
} }
TEST(Atomicops, Load) {
TEST(Load) {
TestLoadAtomic8(); TestLoadAtomic8();
TestLoad<Atomic32>(); TestLoad<Atomic32>();
TestLoad<AtomicWord>(); TestLoad<AtomicWord>();
} }
TEST(Relaxed_Memmove) { TEST(Atomicops, Relaxed_Memmove) {
constexpr size_t kLen = 6; constexpr size_t kLen = 6;
Atomic8 arr[kLen]; Atomic8 arr[kLen];
{ {
...@@ -303,7 +290,7 @@ TEST(Relaxed_Memmove) { ...@@ -303,7 +290,7 @@ TEST(Relaxed_Memmove) {
} }
} }
TEST(Relaxed_Memcmp) { TEST(Atomicops, Relaxed_Memcmp) {
constexpr size_t kLen = 50; constexpr size_t kLen = 50;
Atomic8 arr1[kLen]; Atomic8 arr1[kLen];
Atomic8 arr1_same[kLen]; Atomic8 arr1_same[kLen];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment