Revision: 23516
Author:   [email protected]
Date:     Fri Aug 29 10:53:08 2014 UTC
Log:      Merge base unit tests into src to be in line with Chrome.

We still need the test/base-unittests folder until the test driver is
updated to handle unittests without the boilerplate.

TEST=base-unittests
[email protected]
BUG=v8:3489
LOG=n

Review URL: https://codereview.chromium.org/520503004
https://code.google.com/p/v8/source/detail?r=23516

Added:
 /branches/bleeding_edge/src/base/base.gyp
 /branches/bleeding_edge/src/base/bits-unittest.cc
 /branches/bleeding_edge/src/base/cpu-unittest.cc
 /branches/bleeding_edge/src/base/flags-unittest.cc
 /branches/bleeding_edge/src/base/platform/condition-variable-unittest.cc
 /branches/bleeding_edge/src/base/platform/mutex-unittest.cc
 /branches/bleeding_edge/src/base/platform/platform-unittest.cc
 /branches/bleeding_edge/src/base/platform/semaphore-unittest.cc
 /branches/bleeding_edge/src/base/platform/time-unittest.cc
 /branches/bleeding_edge/src/base/sys-info-unittest.cc
 /branches/bleeding_edge/src/base/utils/random-number-generator-unittest.cc
Deleted:
 /branches/bleeding_edge/test/base-unittests/DEPS
 /branches/bleeding_edge/test/base-unittests/base-unittests.gyp
 /branches/bleeding_edge/test/base-unittests/bits-unittest.cc
 /branches/bleeding_edge/test/base-unittests/cpu-unittest.cc
 /branches/bleeding_edge/test/base-unittests/flags-unittest.cc
 /branches/bleeding_edge/test/base-unittests/platform
 /branches/bleeding_edge/test/base-unittests/sys-info-unittest.cc
 /branches/bleeding_edge/test/base-unittests/utils
Modified:
 /branches/bleeding_edge/build/all.gyp
 /branches/bleeding_edge/src/DEPS

=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/base.gyp   Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,45 @@
+# Copyright 2014 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'variables': {
+    'v8_code': 1,
+  },
+  'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
+  'targets': [
+    {
+      'target_name': 'base-unittests',
+      'type': 'executable',
+      'dependencies': [
+        '../../testing/gtest.gyp:gtest',
+        '../../testing/gtest.gyp:gtest_main',
+        '../../tools/gyp/v8.gyp:v8_libbase',
+      ],
+      'include_dirs': [
+        '../..',
+      ],
+      'sources': [  ### gcmole(all) ###
+        'bits-unittest.cc',
+        'cpu-unittest.cc',
+        'flags-unittest.cc',
+        'platform/condition-variable-unittest.cc',
+        'platform/mutex-unittest.cc',
+        'platform/platform-unittest.cc',
+        'platform/semaphore-unittest.cc',
+        'platform/time-unittest.cc',
+        'sys-info-unittest.cc',
+        'utils/random-number-generator-unittest.cc',
+      ],
+      'conditions': [
+        ['os_posix == 1', {
+ # TODO(svenpanne): This is a temporary work-around to fix the warnings
+          # that show up because we use -std=gnu++0x instead of -std=c++11.
+          'cflags!': [
+            '-pedantic',
+          ],
+        }],
+      ],
+    },
+  ],
+}
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/bits-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,64 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/bits.h"
+#include "src/base/macros.h"
+#include "testing/gtest-support.h"
+
+namespace v8 {
+namespace base {
+namespace bits {
+
+TEST(BitsTest, CountPopulation32) {
+  EXPECT_EQ(0u, CountPopulation32(0));
+  EXPECT_EQ(1u, CountPopulation32(1));
+  EXPECT_EQ(8u, CountPopulation32(0x11111111));
+  EXPECT_EQ(16u, CountPopulation32(0xf0f0f0f0));
+  EXPECT_EQ(24u, CountPopulation32(0xfff0f0ff));
+  EXPECT_EQ(32u, CountPopulation32(0xffffffff));
+}
+
+
+TEST(BitsTest, CountLeadingZeros32) {
+  EXPECT_EQ(32u, CountLeadingZeros32(0));
+  EXPECT_EQ(31u, CountLeadingZeros32(1));
+  TRACED_FORRANGE(uint32_t, shift, 0, 31) {
+    EXPECT_EQ(31u - shift, CountLeadingZeros32(1u << shift));
+  }
+  EXPECT_EQ(4u, CountLeadingZeros32(0x0f0f0f0f));
+}
+
+
+TEST(BitsTest, CountTrailingZeros32) {
+  EXPECT_EQ(32u, CountTrailingZeros32(0));
+  EXPECT_EQ(31u, CountTrailingZeros32(0x80000000));
+  TRACED_FORRANGE(uint32_t, shift, 0, 31) {
+    EXPECT_EQ(shift, CountTrailingZeros32(1u << shift));
+  }
+  EXPECT_EQ(4u, CountTrailingZeros32(0xf0f0f0f0));
+}
+
+
+TEST(BitsTest, RotateRight32) {
+  TRACED_FORRANGE(uint32_t, shift, 0, 31) {
+    EXPECT_EQ(0u, RotateRight32(0u, shift));
+  }
+  EXPECT_EQ(1u, RotateRight32(1, 0));
+  EXPECT_EQ(1u, RotateRight32(2, 1));
+  EXPECT_EQ(0x80000000u, RotateRight32(1, 1));
+}
+
+
+TEST(BitsTest, RotateRight64) {
+  TRACED_FORRANGE(uint64_t, shift, 0, 63) {
+    EXPECT_EQ(0u, RotateRight64(0u, shift));
+  }
+  EXPECT_EQ(1u, RotateRight64(1, 0));
+  EXPECT_EQ(1u, RotateRight64(2, 1));
+  EXPECT_EQ(V8_UINT64_C(0x8000000000000000), RotateRight64(1, 1));
+}
+
+}  // namespace bits
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/cpu-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,49 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/cpu.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+TEST(CPUTest, FeatureImplications) {
+  CPU cpu;
+
+  // ia32 and x64 features
+  EXPECT_TRUE(!cpu.has_sse() || cpu.has_mmx());
+  EXPECT_TRUE(!cpu.has_sse2() || cpu.has_sse());
+  EXPECT_TRUE(!cpu.has_sse3() || cpu.has_sse2());
+  EXPECT_TRUE(!cpu.has_ssse3() || cpu.has_sse3());
+  EXPECT_TRUE(!cpu.has_sse41() || cpu.has_sse3());
+  EXPECT_TRUE(!cpu.has_sse42() || cpu.has_sse41());
+
+  // arm features
+  EXPECT_TRUE(!cpu.has_vfp3_d32() || cpu.has_vfp3());
+}
+
+
+TEST(CPUTest, RequiredFeatures) {
+  CPU cpu;
+
+#if V8_HOST_ARCH_ARM
+  EXPECT_TRUE(cpu.has_fpu());
+#endif
+
+#if V8_HOST_ARCH_IA32
+  EXPECT_TRUE(cpu.has_fpu());
+  EXPECT_TRUE(cpu.has_sahf());
+#endif
+
+#if V8_HOST_ARCH_X64
+  EXPECT_TRUE(cpu.has_fpu());
+  EXPECT_TRUE(cpu.has_cmov());
+  EXPECT_TRUE(cpu.has_mmx());
+  EXPECT_TRUE(cpu.has_sse());
+  EXPECT_TRUE(cpu.has_sse2());
+#endif
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/flags-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,103 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/flags.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+namespace {
+
+enum Flag1 {
+  kFlag1None = 0,
+  kFlag1First = 1u << 1,
+  kFlag1Second = 1u << 2,
+  kFlag1All = kFlag1None | kFlag1First | kFlag1Second
+};
+DEFINE_FLAGS(Flags1, Flag1);
+
+
+DEFINE_OPERATORS_FOR_FLAGS(Flags1)
+
+
+Flags1 bar(Flags1 flags1) { return flags1; }
+
+}  // namespace
+
+
+TEST(FlagsTest, BasicOperations) {
+  Flags1 a;
+  EXPECT_EQ(kFlag1None, static_cast<int>(a));
+  a |= kFlag1First;
+  EXPECT_EQ(kFlag1First, static_cast<int>(a));
+  a = a | kFlag1Second;
+  EXPECT_EQ(kFlag1All, static_cast<int>(a));
+  a &= kFlag1Second;
+  EXPECT_EQ(kFlag1Second, static_cast<int>(a));
+  a = kFlag1None & a;
+  EXPECT_EQ(kFlag1None, static_cast<int>(a));
+  a ^= (kFlag1All | kFlag1None);
+  EXPECT_EQ(kFlag1All, static_cast<int>(a));
+  Flags1 b = ~a;
+  EXPECT_EQ(kFlag1All, static_cast<int>(a));
+  EXPECT_EQ(~static_cast<int>(a), static_cast<int>(b));
+  Flags1 c = a;
+  EXPECT_EQ(a, c);
+  EXPECT_NE(a, b);
+  EXPECT_EQ(a, bar(a));
+  EXPECT_EQ(a, bar(kFlag1All));
+}
+
+
+namespace {
+namespace foo {
+
+enum Option {
+  kNoOptions = 0,
+  kOption1 = 1,
+  kOption2 = 2,
+  kAllOptions = kNoOptions | kOption1 | kOption2
+};
+DEFINE_FLAGS(Options, Option);
+
+}  // namespace foo
+
+
+DEFINE_OPERATORS_FOR_FLAGS(foo::Options)
+
+}  // namespace
+
+
+TEST(FlagsTest, NamespaceScope) {
+  foo::Options options;
+  options ^= foo::kNoOptions;
+  options |= foo::kOption1 | foo::kOption2;
+  EXPECT_EQ(foo::kAllOptions, static_cast<int>(options));
+}
+
+
+namespace {
+
+struct Foo {
+  enum Enum { kEnum1 = 1, kEnum2 = 2 };
+  DEFINE_FLAGS(Enums, Enum);
+};
+
+
+DEFINE_OPERATORS_FOR_FLAGS(Foo::Enums)
+
+}  // namespace
+
+
+TEST(FlagsTest, ClassScope) {
+  Foo::Enums enums;
+  enums |= Foo::kEnum1;
+  enums |= Foo::kEnum2;
+  EXPECT_TRUE(enums & Foo::kEnum1);
+  EXPECT_TRUE(enums & Foo::kEnum2);
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/platform/condition-variable-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,301 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/platform/condition-variable.h"
+
+#include "src/base/platform/platform.h"
+#include "src/base/platform/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+TEST(ConditionVariable, WaitForAfterNofityOnSameThread) {
+  for (int n = 0; n < 10; ++n) {
+    Mutex mutex;
+    ConditionVariable cv;
+
+    LockGuard<Mutex> lock_guard(&mutex);
+
+    cv.NotifyOne();
+    EXPECT_FALSE(cv.WaitFor(&mutex, TimeDelta::FromMicroseconds(n)));
+
+    cv.NotifyAll();
+    EXPECT_FALSE(cv.WaitFor(&mutex, TimeDelta::FromMicroseconds(n)));
+  }
+}
+
+
+namespace {
+
+class ThreadWithMutexAndConditionVariable V8_FINAL : public Thread {
+ public:
+  ThreadWithMutexAndConditionVariable()
+      : Thread(Options("ThreadWithMutexAndConditionVariable")),
+        running_(false),
+        finished_(false) {}
+  virtual ~ThreadWithMutexAndConditionVariable() {}
+
+  virtual void Run() V8_OVERRIDE {
+    LockGuard<Mutex> lock_guard(&mutex_);
+    running_ = true;
+    cv_.NotifyOne();
+    while (running_) {
+      cv_.Wait(&mutex_);
+    }
+    finished_ = true;
+    cv_.NotifyAll();
+  }
+
+  bool running_;
+  bool finished_;
+  ConditionVariable cv_;
+  Mutex mutex_;
+};
+
+}  // namespace
+
+
+TEST(ConditionVariable, MultipleThreadsWithSeparateConditionVariables) {
+  static const int kThreadCount = 128;
+  ThreadWithMutexAndConditionVariable threads[kThreadCount];
+
+  for (int n = 0; n < kThreadCount; ++n) {
+    LockGuard<Mutex> lock_guard(&threads[n].mutex_);
+    EXPECT_FALSE(threads[n].running_);
+    EXPECT_FALSE(threads[n].finished_);
+    threads[n].Start();
+    // Wait for nth thread to start.
+    while (!threads[n].running_) {
+      threads[n].cv_.Wait(&threads[n].mutex_);
+    }
+  }
+
+  for (int n = kThreadCount - 1; n >= 0; --n) {
+    LockGuard<Mutex> lock_guard(&threads[n].mutex_);
+    EXPECT_TRUE(threads[n].running_);
+    EXPECT_FALSE(threads[n].finished_);
+  }
+
+  for (int n = 0; n < kThreadCount; ++n) {
+    LockGuard<Mutex> lock_guard(&threads[n].mutex_);
+    EXPECT_TRUE(threads[n].running_);
+    EXPECT_FALSE(threads[n].finished_);
+    // Tell the nth thread to quit.
+    threads[n].running_ = false;
+    threads[n].cv_.NotifyOne();
+  }
+
+  for (int n = kThreadCount - 1; n >= 0; --n) {
+    // Wait for nth thread to quit.
+    LockGuard<Mutex> lock_guard(&threads[n].mutex_);
+    while (!threads[n].finished_) {
+      threads[n].cv_.Wait(&threads[n].mutex_);
+    }
+    EXPECT_FALSE(threads[n].running_);
+    EXPECT_TRUE(threads[n].finished_);
+  }
+
+  for (int n = 0; n < kThreadCount; ++n) {
+    threads[n].Join();
+    LockGuard<Mutex> lock_guard(&threads[n].mutex_);
+    EXPECT_FALSE(threads[n].running_);
+    EXPECT_TRUE(threads[n].finished_);
+  }
+}
+
+
+namespace {
+
+class ThreadWithSharedMutexAndConditionVariable V8_FINAL : public Thread {
+ public:
+  ThreadWithSharedMutexAndConditionVariable()
+      : Thread(Options("ThreadWithSharedMutexAndConditionVariable")),
+        running_(false),
+        finished_(false),
+        cv_(NULL),
+        mutex_(NULL) {}
+  virtual ~ThreadWithSharedMutexAndConditionVariable() {}
+
+  virtual void Run() V8_OVERRIDE {
+    LockGuard<Mutex> lock_guard(mutex_);
+    running_ = true;
+    cv_->NotifyAll();
+    while (running_) {
+      cv_->Wait(mutex_);
+    }
+    finished_ = true;
+    cv_->NotifyAll();
+  }
+
+  bool running_;
+  bool finished_;
+  ConditionVariable* cv_;
+  Mutex* mutex_;
+};
+
+}  // namespace
+
+
+TEST(ConditionVariable, MultipleThreadsWithSharedSeparateConditionVariables) {
+  static const int kThreadCount = 128;
+  ThreadWithSharedMutexAndConditionVariable threads[kThreadCount];
+  ConditionVariable cv;
+  Mutex mutex;
+
+  for (int n = 0; n < kThreadCount; ++n) {
+    threads[n].mutex_ = &mutex;
+    threads[n].cv_ = &cv;
+  }
+
+  // Start all threads.
+  {
+    LockGuard<Mutex> lock_guard(&mutex);
+    for (int n = 0; n < kThreadCount; ++n) {
+      EXPECT_FALSE(threads[n].running_);
+      EXPECT_FALSE(threads[n].finished_);
+      threads[n].Start();
+    }
+  }
+
+  // Wait for all threads to start.
+  {
+    LockGuard<Mutex> lock_guard(&mutex);
+    for (int n = kThreadCount - 1; n >= 0; --n) {
+      while (!threads[n].running_) {
+        cv.Wait(&mutex);
+      }
+    }
+  }
+
+  // Make sure that all threads are running.
+  {
+    LockGuard<Mutex> lock_guard(&mutex);
+    for (int n = 0; n < kThreadCount; ++n) {
+      EXPECT_TRUE(threads[n].running_);
+      EXPECT_FALSE(threads[n].finished_);
+    }
+  }
+
+  // Tell all threads to quit.
+  {
+    LockGuard<Mutex> lock_guard(&mutex);
+    for (int n = kThreadCount - 1; n >= 0; --n) {
+      EXPECT_TRUE(threads[n].running_);
+      EXPECT_FALSE(threads[n].finished_);
+      // Tell the nth thread to quit.
+      threads[n].running_ = false;
+    }
+    cv.NotifyAll();
+  }
+
+  // Wait for all threads to quit.
+  {
+    LockGuard<Mutex> lock_guard(&mutex);
+    for (int n = 0; n < kThreadCount; ++n) {
+      while (!threads[n].finished_) {
+        cv.Wait(&mutex);
+      }
+    }
+  }
+
+  // Make sure all threads are finished.
+  {
+    LockGuard<Mutex> lock_guard(&mutex);
+    for (int n = kThreadCount - 1; n >= 0; --n) {
+      EXPECT_FALSE(threads[n].running_);
+      EXPECT_TRUE(threads[n].finished_);
+    }
+  }
+
+  // Join all threads.
+  for (int n = 0; n < kThreadCount; ++n) {
+    threads[n].Join();
+  }
+}
+
+
+namespace {
+
+class LoopIncrementThread V8_FINAL : public Thread {
+ public:
+  LoopIncrementThread(int rem, int* counter, int limit, int thread_count,
+                      ConditionVariable* cv, Mutex* mutex)
+      : Thread(Options("LoopIncrementThread")),
+        rem_(rem),
+        counter_(counter),
+        limit_(limit),
+        thread_count_(thread_count),
+        cv_(cv),
+        mutex_(mutex) {
+    EXPECT_LT(rem, thread_count);
+    EXPECT_EQ(0, limit % thread_count);
+  }
+
+  virtual void Run() V8_OVERRIDE {
+    int last_count = -1;
+    while (true) {
+      LockGuard<Mutex> lock_guard(mutex_);
+      int count = *counter_;
+      while (count % thread_count_ != rem_ && count < limit_) {
+        cv_->Wait(mutex_);
+        count = *counter_;
+      }
+      if (count >= limit_) break;
+      EXPECT_EQ(*counter_, count);
+      if (last_count != -1) {
+        EXPECT_EQ(last_count + (thread_count_ - 1), count);
+      }
+      count++;
+      *counter_ = count;
+      last_count = count;
+      cv_->NotifyAll();
+    }
+  }
+
+ private:
+  const int rem_;
+  int* counter_;
+  const int limit_;
+  const int thread_count_;
+  ConditionVariable* cv_;
+  Mutex* mutex_;
+};
+
+}  // namespace
+
+
+TEST(ConditionVariable, LoopIncrement) {
+  static const int kMaxThreadCount = 16;
+  Mutex mutex;
+  ConditionVariable cv;
+ for (int thread_count = 1; thread_count < kMaxThreadCount; ++thread_count) {
+    int limit = thread_count * 10;
+    int counter = 0;
+
+    // Setup the threads.
+    Thread** threads = new Thread* [thread_count];
+    for (int n = 0; n < thread_count; ++n) {
+ threads[n] = new LoopIncrementThread(n, &counter, limit, thread_count,
+                                           &cv, &mutex);
+    }
+
+    // Start all threads.
+    for (int n = thread_count - 1; n >= 0; --n) {
+      threads[n]->Start();
+    }
+
+    // Join and cleanup all threads.
+    for (int n = 0; n < thread_count; ++n) {
+      threads[n]->Join();
+      delete threads[n];
+    }
+    delete[] threads;
+
+    EXPECT_EQ(limit, counter);
+  }
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/platform/mutex-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,91 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/platform/mutex.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+TEST(Mutex, LockGuardMutex) {
+  Mutex mutex;
+  { LockGuard<Mutex> lock_guard(&mutex); }
+  { LockGuard<Mutex> lock_guard(&mutex); }
+}
+
+
+TEST(Mutex, LockGuardRecursiveMutex) {
+  RecursiveMutex recursive_mutex;
+  { LockGuard<RecursiveMutex> lock_guard(&recursive_mutex); }
+  {
+    LockGuard<RecursiveMutex> lock_guard1(&recursive_mutex);
+    LockGuard<RecursiveMutex> lock_guard2(&recursive_mutex);
+  }
+}
+
+
+TEST(Mutex, LockGuardLazyMutex) {
+  LazyMutex lazy_mutex = LAZY_MUTEX_INITIALIZER;
+  { LockGuard<Mutex> lock_guard(lazy_mutex.Pointer()); }
+  { LockGuard<Mutex> lock_guard(lazy_mutex.Pointer()); }
+}
+
+
+TEST(Mutex, LockGuardLazyRecursiveMutex) {
+ LazyRecursiveMutex lazy_recursive_mutex = LAZY_RECURSIVE_MUTEX_INITIALIZER;
+  { LockGuard<RecursiveMutex> lock_guard(lazy_recursive_mutex.Pointer()); }
+  {
+    LockGuard<RecursiveMutex> lock_guard1(lazy_recursive_mutex.Pointer());
+    LockGuard<RecursiveMutex> lock_guard2(lazy_recursive_mutex.Pointer());
+  }
+}
+
+
+TEST(Mutex, MultipleMutexes) {
+  Mutex mutex1;
+  Mutex mutex2;
+  Mutex mutex3;
+  // Order 1
+  mutex1.Lock();
+  mutex2.Lock();
+  mutex3.Lock();
+  mutex1.Unlock();
+  mutex2.Unlock();
+  mutex3.Unlock();
+  // Order 2
+  mutex1.Lock();
+  mutex2.Lock();
+  mutex3.Lock();
+  mutex3.Unlock();
+  mutex2.Unlock();
+  mutex1.Unlock();
+}
+
+
+TEST(Mutex, MultipleRecursiveMutexes) {
+  RecursiveMutex recursive_mutex1;
+  RecursiveMutex recursive_mutex2;
+  // Order 1
+  recursive_mutex1.Lock();
+  recursive_mutex2.Lock();
+  EXPECT_TRUE(recursive_mutex1.TryLock());
+  EXPECT_TRUE(recursive_mutex2.TryLock());
+  recursive_mutex1.Unlock();
+  recursive_mutex1.Unlock();
+  recursive_mutex2.Unlock();
+  recursive_mutex2.Unlock();
+  // Order 2
+  recursive_mutex1.Lock();
+  EXPECT_TRUE(recursive_mutex1.TryLock());
+  recursive_mutex2.Lock();
+  EXPECT_TRUE(recursive_mutex2.TryLock());
+  recursive_mutex2.Unlock();
+  recursive_mutex1.Unlock();
+  recursive_mutex2.Unlock();
+  recursive_mutex1.Unlock();
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/platform/platform-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,110 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/platform/platform.h"
+
+#if V8_OS_POSIX
+#include <unistd.h>  // NOLINT
+#endif
+
+#if V8_OS_WIN
+#include "src/base/win32-headers.h"
+#endif
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+TEST(OS, GetCurrentProcessId) {
+#if V8_OS_POSIX
+  EXPECT_EQ(static_cast<int>(getpid()), OS::GetCurrentProcessId());
+#endif
+
+#if V8_OS_WIN
+  EXPECT_EQ(static_cast<int>(::GetCurrentProcessId()),
+            OS::GetCurrentProcessId());
+#endif
+}
+
+
+namespace {
+
+class SelfJoinThread V8_FINAL : public Thread {
+ public:
+  SelfJoinThread() : Thread(Options("SelfJoinThread")) {}
+  virtual void Run() V8_OVERRIDE { Join(); }
+};
+
+}  // namespace
+
+
+TEST(Thread, SelfJoin) {
+  SelfJoinThread thread;
+  thread.Start();
+  thread.Join();
+}
+
+
+namespace {
+
+class ThreadLocalStorageTest : public Thread, public ::testing::Test {
+ public:
+  ThreadLocalStorageTest() : Thread(Options("ThreadLocalStorageTest")) {
+    for (size_t i = 0; i < arraysize(keys_); ++i) {
+      keys_[i] = Thread::CreateThreadLocalKey();
+    }
+  }
+  ~ThreadLocalStorageTest() {
+    for (size_t i = 0; i < arraysize(keys_); ++i) {
+      Thread::DeleteThreadLocalKey(keys_[i]);
+    }
+  }
+
+  virtual void Run() V8_FINAL V8_OVERRIDE {
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      CHECK(!Thread::HasThreadLocal(keys_[i]));
+    }
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      Thread::SetThreadLocal(keys_[i], GetValue(i));
+    }
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      CHECK(Thread::HasThreadLocal(keys_[i]));
+    }
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      CHECK_EQ(GetValue(i), Thread::GetThreadLocal(keys_[i]));
+      CHECK_EQ(GetValue(i), Thread::GetExistingThreadLocal(keys_[i]));
+    }
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      Thread::SetThreadLocal(keys_[i], GetValue(arraysize(keys_) - i - 1));
+    }
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      CHECK(Thread::HasThreadLocal(keys_[i]));
+    }
+    for (size_t i = 0; i < arraysize(keys_); i++) {
+      CHECK_EQ(GetValue(arraysize(keys_) - i - 1),
+               Thread::GetThreadLocal(keys_[i]));
+      CHECK_EQ(GetValue(arraysize(keys_) - i - 1),
+               Thread::GetExistingThreadLocal(keys_[i]));
+    }
+  }
+
+ private:
+  static void* GetValue(size_t x) {
+    return reinterpret_cast<void*>(static_cast<uintptr_t>(x + 1));
+  }
+
+  Thread::LocalStorageKey keys_[256];
+};
+
+}  // namespace
+
+
+TEST_F(ThreadLocalStorageTest, DoTest) {
+  Run();
+  Start();
+  Join();
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/platform/semaphore-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,145 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstring>
+
+#include "src/base/platform/platform.h"
+#include "src/base/platform/semaphore.h"
+#include "src/base/platform/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+namespace {
+
+static const char kAlphabet[] = "XKOAD";
+static const size_t kAlphabetSize = sizeof(kAlphabet) - 1;
+static const size_t kBufferSize = 987; // GCD(buffer size, alphabet size) = 1
+static const size_t kDataSize = kBufferSize * kAlphabetSize * 10;
+
+
+class ProducerThread V8_FINAL : public Thread {
+ public:
+ ProducerThread(char* buffer, Semaphore* free_space, Semaphore* used_space)
+      : Thread(Options("ProducerThread")),
+        buffer_(buffer),
+        free_space_(free_space),
+        used_space_(used_space) {}
+  virtual ~ProducerThread() {}
+
+  virtual void Run() V8_OVERRIDE {
+    for (size_t n = 0; n < kDataSize; ++n) {
+      free_space_->Wait();
+      buffer_[n % kBufferSize] = kAlphabet[n % kAlphabetSize];
+      used_space_->Signal();
+    }
+  }
+
+ private:
+  char* buffer_;
+  Semaphore* const free_space_;
+  Semaphore* const used_space_;
+};
+
+
+class ConsumerThread V8_FINAL : public Thread {
+ public:
+  ConsumerThread(const char* buffer, Semaphore* free_space,
+                 Semaphore* used_space)
+      : Thread(Options("ConsumerThread")),
+        buffer_(buffer),
+        free_space_(free_space),
+        used_space_(used_space) {}
+  virtual ~ConsumerThread() {}
+
+  virtual void Run() V8_OVERRIDE {
+    for (size_t n = 0; n < kDataSize; ++n) {
+      used_space_->Wait();
+      EXPECT_EQ(kAlphabet[n % kAlphabetSize], buffer_[n % kBufferSize]);
+      free_space_->Signal();
+    }
+  }
+
+ private:
+  const char* buffer_;
+  Semaphore* const free_space_;
+  Semaphore* const used_space_;
+};
+
+
+class WaitAndSignalThread V8_FINAL : public Thread {
+ public:
+  explicit WaitAndSignalThread(Semaphore* semaphore)
+      : Thread(Options("WaitAndSignalThread")), semaphore_(semaphore) {}
+  virtual ~WaitAndSignalThread() {}
+
+  virtual void Run() V8_OVERRIDE {
+    for (int n = 0; n < 100; ++n) {
+      semaphore_->Wait();
+      ASSERT_FALSE(semaphore_->WaitFor(TimeDelta::FromMicroseconds(1)));
+      semaphore_->Signal();
+    }
+  }
+
+ private:
+  Semaphore* const semaphore_;
+};
+
+}  // namespace
+
+
+TEST(Semaphore, ProducerConsumer) {
+  char buffer[kBufferSize];
+  std::memset(buffer, 0, sizeof(buffer));
+  Semaphore free_space(kBufferSize);
+  Semaphore used_space(0);
+  ProducerThread producer_thread(buffer, &free_space, &used_space);
+  ConsumerThread consumer_thread(buffer, &free_space, &used_space);
+  producer_thread.Start();
+  consumer_thread.Start();
+  producer_thread.Join();
+  consumer_thread.Join();
+}
+
+
+TEST(Semaphore, WaitAndSignal) {
+  Semaphore semaphore(0);
+  WaitAndSignalThread t1(&semaphore);
+  WaitAndSignalThread t2(&semaphore);
+
+  t1.Start();
+  t2.Start();
+
+  // Make something available.
+  semaphore.Signal();
+
+  t1.Join();
+  t2.Join();
+
+  semaphore.Wait();
+
+  EXPECT_FALSE(semaphore.WaitFor(TimeDelta::FromMicroseconds(1)));
+}
+
+
+TEST(Semaphore, WaitFor) {
+  Semaphore semaphore(0);
+
+  // Semaphore not signalled - timeout.
+  ASSERT_FALSE(semaphore.WaitFor(TimeDelta::FromMicroseconds(0)));
+  ASSERT_FALSE(semaphore.WaitFor(TimeDelta::FromMicroseconds(100)));
+  ASSERT_FALSE(semaphore.WaitFor(TimeDelta::FromMicroseconds(1000)));
+
+  // Semaphore signalled - no timeout.
+  semaphore.Signal();
+  ASSERT_TRUE(semaphore.WaitFor(TimeDelta::FromMicroseconds(0)));
+  semaphore.Signal();
+  ASSERT_TRUE(semaphore.WaitFor(TimeDelta::FromMicroseconds(100)));
+  semaphore.Signal();
+  ASSERT_TRUE(semaphore.WaitFor(TimeDelta::FromMicroseconds(1000)));
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/platform/time-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,186 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/platform/time.h"
+
+#if V8_OS_MACOSX
+#include <mach/mach_time.h>
+#endif
+#if V8_OS_POSIX
+#include <sys/time.h>
+#endif
+
+#if V8_OS_WIN
+#include "src/base/win32-headers.h"
+#endif
+
+#include "src/base/platform/elapsed-timer.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+TEST(TimeDelta, FromAndIn) {
+  EXPECT_EQ(TimeDelta::FromDays(2), TimeDelta::FromHours(48));
+  EXPECT_EQ(TimeDelta::FromHours(3), TimeDelta::FromMinutes(180));
+  EXPECT_EQ(TimeDelta::FromMinutes(2), TimeDelta::FromSeconds(120));
+  EXPECT_EQ(TimeDelta::FromSeconds(2), TimeDelta::FromMilliseconds(2000));
+ EXPECT_EQ(TimeDelta::FromMilliseconds(2), TimeDelta::FromMicroseconds(2000));
+  EXPECT_EQ(static_cast<int>(13), TimeDelta::FromDays(13).InDays());
+  EXPECT_EQ(static_cast<int>(13), TimeDelta::FromHours(13).InHours());
+  EXPECT_EQ(static_cast<int>(13), TimeDelta::FromMinutes(13).InMinutes());
+ EXPECT_EQ(static_cast<int64_t>(13), TimeDelta::FromSeconds(13).InSeconds());
+  EXPECT_DOUBLE_EQ(13.0, TimeDelta::FromSeconds(13).InSecondsF());
+  EXPECT_EQ(static_cast<int64_t>(13),
+            TimeDelta::FromMilliseconds(13).InMilliseconds());
+ EXPECT_DOUBLE_EQ(13.0, TimeDelta::FromMilliseconds(13).InMillisecondsF());
+  EXPECT_EQ(static_cast<int64_t>(13),
+            TimeDelta::FromMicroseconds(13).InMicroseconds());
+}
+
+
+#if V8_OS_MACOSX
+TEST(TimeDelta, MachTimespec) {
+  TimeDelta null = TimeDelta();
+  EXPECT_EQ(null, TimeDelta::FromMachTimespec(null.ToMachTimespec()));
+  TimeDelta delta1 = TimeDelta::FromMilliseconds(42);
+  EXPECT_EQ(delta1, TimeDelta::FromMachTimespec(delta1.ToMachTimespec()));
+  TimeDelta delta2 = TimeDelta::FromDays(42);
+  EXPECT_EQ(delta2, TimeDelta::FromMachTimespec(delta2.ToMachTimespec()));
+}
+#endif
+
+
+TEST(Time, JsTime) {
+  Time t = Time::FromJsTime(700000.3);
+  EXPECT_DOUBLE_EQ(700000.3, t.ToJsTime());
+}
+
+
+#if V8_OS_POSIX
+TEST(Time, Timespec) {
+  Time null;
+  EXPECT_TRUE(null.IsNull());
+  EXPECT_EQ(null, Time::FromTimespec(null.ToTimespec()));
+  Time now = Time::Now();
+  EXPECT_EQ(now, Time::FromTimespec(now.ToTimespec()));
+  Time now_sys = Time::NowFromSystemTime();
+  EXPECT_EQ(now_sys, Time::FromTimespec(now_sys.ToTimespec()));
+  Time unix_epoch = Time::UnixEpoch();
+  EXPECT_EQ(unix_epoch, Time::FromTimespec(unix_epoch.ToTimespec()));
+  Time max = Time::Max();
+  EXPECT_TRUE(max.IsMax());
+  EXPECT_EQ(max, Time::FromTimespec(max.ToTimespec()));
+}
+
+
+TEST(Time, Timeval) {
+  Time null;
+  EXPECT_TRUE(null.IsNull());
+  EXPECT_EQ(null, Time::FromTimeval(null.ToTimeval()));
+  Time now = Time::Now();
+  EXPECT_EQ(now, Time::FromTimeval(now.ToTimeval()));
+  Time now_sys = Time::NowFromSystemTime();
+  EXPECT_EQ(now_sys, Time::FromTimeval(now_sys.ToTimeval()));
+  Time unix_epoch = Time::UnixEpoch();
+  EXPECT_EQ(unix_epoch, Time::FromTimeval(unix_epoch.ToTimeval()));
+  Time max = Time::Max();
+  EXPECT_TRUE(max.IsMax());
+  EXPECT_EQ(max, Time::FromTimeval(max.ToTimeval()));
+}
+#endif
+
+
+#if V8_OS_WIN
+TEST(Time, Filetime) {
+  Time null;
+  EXPECT_TRUE(null.IsNull());
+  EXPECT_EQ(null, Time::FromFiletime(null.ToFiletime()));
+  Time now = Time::Now();
+  EXPECT_EQ(now, Time::FromFiletime(now.ToFiletime()));
+  Time now_sys = Time::NowFromSystemTime();
+  EXPECT_EQ(now_sys, Time::FromFiletime(now_sys.ToFiletime()));
+  Time unix_epoch = Time::UnixEpoch();
+  EXPECT_EQ(unix_epoch, Time::FromFiletime(unix_epoch.ToFiletime()));
+  Time max = Time::Max();
+  EXPECT_TRUE(max.IsMax());
+  EXPECT_EQ(max, Time::FromFiletime(max.ToFiletime()));
+}
+#endif
+
+
+namespace {
+
+template <typename T>
+static void ResolutionTest(T (*Now)(), TimeDelta target_granularity) {
+ // We're trying to measure that intervals increment in a VERY small amount + // of time -- according to the specified target granularity. Unfortunately,
+  // if we happen to have a context switch in the middle of our test, the
+  // context switch could easily exceed our limit. So, we iterate on this
+  // several times. As long as we're able to detect the fine-granularity
+  // timers at least once, then the test has succeeded.
+  static const TimeDelta kExpirationTimeout = TimeDelta::FromSeconds(1);
+  ElapsedTimer timer;
+  timer.Start();
+  TimeDelta delta;
+  do {
+    T start = Now();
+    T now = start;
+ // Loop until we can detect that the clock has changed. Non-HighRes timers + // will increment in chunks, i.e. 15ms. By spinning until we see a clock
+    // change, we detect the minimum time between measurements.
+    do {
+      now = Now();
+      delta = now - start;
+    } while (now <= start);
+    EXPECT_NE(static_cast<int64_t>(0), delta.InMicroseconds());
+ } while (delta > target_granularity && !timer.HasExpired(kExpirationTimeout));
+  EXPECT_LE(delta, target_granularity);
+}
+
+}  // namespace
+
+
+TEST(Time, NowResolution) {
+  // We assume that Time::Now() has at least 16ms resolution.
+ static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(16);
+  ResolutionTest<Time>(&Time::Now, kTargetGranularity);
+}
+
+
+TEST(TimeTicks, NowResolution) {
+  // We assume that TimeTicks::Now() has at least 16ms resolution.
+ static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(16);
+  ResolutionTest<TimeTicks>(&TimeTicks::Now, kTargetGranularity);
+}
+
+
+TEST(TimeTicks, HighResolutionNowResolution) {
+  if (!TimeTicks::IsHighResolutionClockWorking()) return;
+
+  // We assume that TimeTicks::HighResolutionNow() has sub-ms resolution.
+ static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(1); + ResolutionTest<TimeTicks>(&TimeTicks::HighResolutionNow, kTargetGranularity);
+}
+
+
+TEST(TimeTicks, IsMonotonic) {
+  TimeTicks previous_normal_ticks;
+  TimeTicks previous_highres_ticks;
+  ElapsedTimer timer;
+  timer.Start();
+  while (!timer.HasExpired(TimeDelta::FromMilliseconds(100))) {
+    TimeTicks normal_ticks = TimeTicks::Now();
+    TimeTicks highres_ticks = TimeTicks::HighResolutionNow();
+    EXPECT_GE(normal_ticks, previous_normal_ticks);
+    EXPECT_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0);
+    EXPECT_GE(highres_ticks, previous_highres_ticks);
+ EXPECT_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0);
+    previous_normal_ticks = normal_ticks;
+    previous_highres_ticks = highres_ticks;
+  }
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/sys-info-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,32 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/base/sys-info.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if V8_OS_NACL
+#define DISABLE_ON_NACL(Name) DISABLED_##Name
+#else
+#define DISABLE_ON_NACL(Name) Name
+#endif
+
+namespace v8 {
+namespace base {
+
+TEST(SysInfoTest, NumberOfProcessors) {
+  EXPECT_LT(0, SysInfo::NumberOfProcessors());
+}
+
+
+TEST(SysInfoTest, DISABLE_ON_NACL(AmountOfPhysicalMemory)) {
+  EXPECT_LT(0, SysInfo::AmountOfPhysicalMemory());
+}
+
+
+TEST(SysInfoTest, AmountOfVirtualMemory) {
+  EXPECT_LE(0, SysInfo::AmountOfVirtualMemory());
+}
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/src/base/utils/random-number-generator-unittest.cc Fri Aug 29 10:53:08 2014 UTC
@@ -0,0 +1,53 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <climits>
+
+#include "src/base/utils/random-number-generator.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace base {
+
+class RandomNumberGeneratorTest : public ::testing::TestWithParam<int> {};
+
+
+static const int kMaxRuns = 12345;
+
+
+TEST_P(RandomNumberGeneratorTest, NextIntWithMaxValue) {
+  RandomNumberGenerator rng(GetParam());
+  for (int max = 1; max <= kMaxRuns; ++max) {
+    int n = rng.NextInt(max);
+    EXPECT_LE(0, n);
+    EXPECT_LT(n, max);
+  }
+}
+
+
+TEST_P(RandomNumberGeneratorTest, NextBooleanReturnsFalseOrTrue) {
+  RandomNumberGenerator rng(GetParam());
+  for (int k = 0; k < kMaxRuns; ++k) {
+    bool b = rng.NextBool();
+    EXPECT_TRUE(b == false || b == true);
+  }
+}
+
+
+TEST_P(RandomNumberGeneratorTest, NextDoubleReturnsValueBetween0And1) {
+  RandomNumberGenerator rng(GetParam());
+  for (int k = 0; k < kMaxRuns; ++k) {
+    double d = rng.NextDouble();
+    EXPECT_LE(0.0, d);
+    EXPECT_LT(d, 1.0);
+  }
+}
+
+
+INSTANTIATE_TEST_CASE_P(RandomSeeds, RandomNumberGeneratorTest,
+                        ::testing::Values(INT_MIN, -1, 0, 1, 42, 100,
+                                          1234567890, 987654321, INT_MAX));
+
+}  // namespace base
+}  // namespace v8
=======================================
--- /branches/bleeding_edge/test/base-unittests/DEPS Thu Aug 14 09:07:58 2014 UTC
+++ /dev/null
@@ -1,9 +0,0 @@
-include_rules = [
-  "-include",
-  "+include/v8config.h",
-  "+include/v8stdint.h",
-  "-src",
-  "+src/base",
-  "+testing/gtest",
-  "+testing/gtest-support.h",
-]
=======================================
--- /branches/bleeding_edge/test/base-unittests/base-unittests.gyp Wed Aug 27 12:16:36 2014 UTC
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
-  'variables': {
-    'v8_code': 1,
-  },
-  'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
-  'targets': [
-    {
-      'target_name': 'base-unittests',
-      'type': 'executable',
-      'dependencies': [
-        '../../testing/gtest.gyp:gtest',
-        '../../testing/gtest.gyp:gtest_main',
-        '../../tools/gyp/v8.gyp:v8_libbase',
-      ],
-      'include_dirs': [
-        '../..',
-      ],
-      'sources': [  ### gcmole(all) ###
-        'bits-unittest.cc',
-        'cpu-unittest.cc',
-        'flags-unittest.cc',
-        'platform/condition-variable-unittest.cc',
-        'platform/mutex-unittest.cc',
-        'platform/platform-unittest.cc',
-        'platform/semaphore-unittest.cc',
-        'platform/time-unittest.cc',
-        'sys-info-unittest.cc',
-        'utils/random-number-generator-unittest.cc',
-      ],
-      'conditions': [
-        ['os_posix == 1', {
- # TODO(svenpanne): This is a temporary work-around to fix the warnings
-          # that show up because we use -std=gnu++0x instead of -std=c++11.
-          'cflags!': [
-            '-pedantic',
-          ],
-        }],
-      ],
-    },
-  ],
-}
=======================================
--- /branches/bleeding_edge/test/base-unittests/bits-unittest.cc Mon Aug 25 04:24:39 2014 UTC
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/base/bits.h"
-#include "src/base/macros.h"
-#include "testing/gtest-support.h"
-
-namespace v8 {
-namespace base {
-namespace bits {
-
-TEST(BitsTest, CountPopulation32) {
-  EXPECT_EQ(0u, CountPopulation32(0));
-  EXPECT_EQ(1u, CountPopulation32(1));
-  EXPECT_EQ(8u, CountPopulation32(0x11111111));
-  EXPECT_EQ(16u, CountPopulation32(0xf0f0f0f0));
-  EXPECT_EQ(24u, CountPopulation32(0xfff0f0ff));
-  EXPECT_EQ(32u, CountPopulation32(0xffffffff));
-}
-
-
-TEST(BitsTest, CountLeadingZeros32) {
-  EXPECT_EQ(32u, CountLeadingZeros32(0));
-  EXPECT_EQ(31u, CountLeadingZeros32(1));
-  TRACED_FORRANGE(uint32_t, shift, 0, 31) {
-    EXPECT_EQ(31u - shift, CountLeadingZeros32(1u << shift));
-  }
-  EXPECT_EQ(4u, CountLeadingZeros32(0x0f0f0f0f));
-}
-
-
-TEST(BitsTest, CountTrailingZeros32) {
-  EXPECT_EQ(32u, CountTrailingZeros32(0));
-  EXPECT_EQ(31u, CountTrailingZeros32(0x80000000));
-  TRACED_FORRANGE(uint32_t, shift, 0, 31) {
-    EXPECT_EQ(shift, CountTrailingZeros32(1u << shift));
-  }
-  EXPECT_EQ(4u, CountTrailingZeros32(0xf0f0f0f0));
-}
-
-
-TEST(BitsTest, RotateRight32) {
-  TRACED_FORRANGE(uint32_t, shift, 0, 31) {
-    EXPECT_EQ(0u, RotateRight32(0u, shift));
-  }
-  EXPECT_EQ(1u, RotateRight32(1, 0));
-  EXPECT_EQ(1u, RotateRight32(2, 1));
-  EXPECT_EQ(0x80000000u, RotateRight32(1, 1));
-}
-
-
-TEST(BitsTest, RotateRight64) {
-  TRACED_FORRANGE(uint64_t, shift, 0, 63) {
-    EXPECT_EQ(0u, RotateRight64(0u, shift));
-  }
-  EXPECT_EQ(1u, RotateRight64(1, 0));
-  EXPECT_EQ(1u, RotateRight64(2, 1));
-  EXPECT_EQ(V8_UINT64_C(0x8000000000000000), RotateRight64(1, 1));
-}
-
-}  // namespace bits
-}  // namespace base
-}  // namespace v8
=======================================
--- /branches/bleeding_edge/test/base-unittests/cpu-unittest.cc Wed Aug 6 09:35:21 2014 UTC
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/base/cpu.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace v8 {
-namespace base {
-
-TEST(CPUTest, FeatureImplications) {
-  CPU cpu;
-
-  // ia32 and x64 features
-  EXPECT_TRUE(!cpu.has_sse() || cpu.has_mmx());
-  EXPECT_TRUE(!cpu.has_sse2() || cpu.has_sse());
-  EXPECT_TRUE(!cpu.has_sse3() || cpu.has_sse2());
-  EXPECT_TRUE(!cpu.has_ssse3() || cpu.has_sse3());
-  EXPECT_TRUE(!cpu.has_sse41() || cpu.has_sse3());
-  EXPECT_TRUE(!cpu.has_sse42() || cpu.has_sse41());
-
-  // arm features
-  EXPECT_TRUE(!cpu.has_vfp3_d32() || cpu.has_vfp3());
-}
-
-
-TEST(CPUTest, RequiredFeatures) {
-  CPU cpu;
-
-#if V8_HOST_ARCH_ARM
-  EXPECT_TRUE(cpu.has_fpu());
-#endif
-
-#if V8_HOST_ARCH_IA32
-  EXPECT_TRUE(cpu.has_fpu());
-  EXPECT_TRUE(cpu.has_sahf());
-#endif
-
-#if V8_HOST_ARCH_X64
-  EXPECT_TRUE(cpu.has_fpu());
-  EXPECT_TRUE(cpu.has_cmov());
-  EXPECT_TRUE(cpu.has_mmx());
-  EXPECT_TRUE(cpu.has_sse());
-  EXPECT_TRUE(cpu.has_sse2());
-#endif
-}
-
-}  // namespace base
-}  // namespace v8
=======================================
--- /branches/bleeding_edge/test/base-unittests/flags-unittest.cc Wed Aug 27 12:16:36 2014 UTC
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/base/flags.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace v8 {
-namespace base {
-
-namespace {
-
-enum Flag1 {
-  kFlag1None = 0,
-  kFlag1First = 1u << 1,
-  kFlag1Second = 1u << 2,
-  kFlag1All = kFlag1None | kFlag1First | kFlag1Second
-};
-DEFINE_FLAGS(Flags1, Flag1);
-
-
-DEFINE_OPERATORS_FOR_FLAGS(Flags1)
-
-
-Flags1 bar(Flags1 flags1) { return flags1; }
-
-}  // namespace
-
-
-TEST(FlagsTest, BasicOperations) {
-  Flags1 a;
-  EXPECT_EQ(kFlag1None, static_cast<int>(a));
-  a |= kFlag1First;
-  EXPECT_EQ(kFlag1First, static_cast<int>(a));
-  a = a | kFlag1Second;
-  EXPECT_EQ(kFlag1All, static_cast<int>(a));
-  a &= kFlag1Second;
-  EXPECT_EQ(kFlag1Second, static_cast<int>(a));
-  a = kFlag1None & a;
-  EXPECT_EQ(kFlag1None, static_cast<int>(a));
-  a ^= (kFlag1All | kFlag1None);
-  EXPECT_EQ(kFlag1All, static_cast<int>(a));
-  Flags1 b = ~a;
-  EXPECT_EQ(kFlag1All, static_cast<int>(a));
-  EXPECT_EQ(~static_cast<int>(a), static_cast<int>(b));
-  Flags1 c = a;
-  EXPECT_EQ(a, c);
-  EXPECT_NE(a, b);
-  EXPECT_EQ(a, bar(a));
-  EXPECT_EQ(a, bar(kFlag1All));
-}
-
-
-namespace {
-namespace foo {
-
-enum Option {
-  kNoOptions = 0,
-  kOption1 = 1,
-  kOption2 = 2,
-  kAllOptions = kNoOptions | kOption1 | kOption2
-};
-DEFINE_FLAGS(Options, Option);
-
-}  // namespace foo
-
-
-DEFINE_OPERATORS_FOR_FLAGS(foo::Options)
-
-}  // namespace
-
-
-TEST(FlagsTest, NamespaceScope) {
-  foo::Options options;
-  options ^= foo::kNoOptions;
-  options |= foo::kOption1 | foo::kOption2;
-  EXPECT_EQ(foo::kAllOptions, static_cast<int>(options));
-}
-
-
-namespace {
-
-struct Foo {
-  enum Enum { kEnum1 = 1, kEnum2 = 2 };
-  DEFINE_FLAGS(Enums, Enum);
-};
-
-
-DEFINE_OPERATORS_FOR_FLAGS(Foo::Enums)
-
-}  // namespace
-
-
-TEST(FlagsTest, ClassScope) {
-  Foo::Enums enums;
-  enums |= Foo::kEnum1;
-  enums |= Foo::kEnum2;
-  EXPECT_TRUE(enums & Foo::kEnum1);
-  EXPECT_TRUE(enums & Foo::kEnum2);
-}
-
-}  // namespace base
-}  // namespace v8
=======================================
--- /branches/bleeding_edge/test/base-unittests/sys-info-unittest.cc Wed Aug 27 10:37:54 2014 UTC
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/base/sys-info.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-#if V8_OS_NACL
-#define DISABLE_ON_NACL(Name) DISABLED_##Name
-#else
-#define DISABLE_ON_NACL(Name) Name
-#endif
-
-namespace v8 {
-namespace base {
-
-TEST(SysInfoTest, NumberOfProcessors) {
-  EXPECT_LT(0, SysInfo::NumberOfProcessors());
-}
-
-
-TEST(SysInfoTest, DISABLE_ON_NACL(AmountOfPhysicalMemory)) {
-  EXPECT_LT(0, SysInfo::AmountOfPhysicalMemory());
-}
-
-
-TEST(SysInfoTest, AmountOfVirtualMemory) {
-  EXPECT_LE(0, SysInfo::AmountOfVirtualMemory());
-}
-
-}  // namespace base
-}  // namespace v8
=======================================
--- /branches/bleeding_edge/build/all.gyp       Tue Aug 19 10:54:54 2014 UTC
+++ /branches/bleeding_edge/build/all.gyp       Fri Aug 29 10:53:08 2014 UTC
@@ -9,8 +9,8 @@
       'type': 'none',
       'dependencies': [
         '../samples/samples.gyp:*',
+        '../src/base/base.gyp:*',
         '../src/d8.gyp:d8',
-        '../test/base-unittests/base-unittests.gyp:*',
         '../test/cctest/cctest.gyp:*',
         '../test/compiler-unittests/compiler-unittests.gyp:*',
         '../test/heap-unittests/heap-unittests.gyp:*',
=======================================
--- /branches/bleeding_edge/src/DEPS    Tue Aug  5 13:20:26 2014 UTC
+++ /branches/bleeding_edge/src/DEPS    Fri Aug 29 10:53:08 2014 UTC
@@ -4,6 +4,7 @@
   "+src/compiler/pipeline.h",
   "-src/libplatform",
   "-include/libplatform",
+  "+testing",
 ]

 specific_include_rules = {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to