Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: test/cctest/test-libplatform.h

Issue 104583003: [platform] Implement a worker pool (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-libplatform.h
diff --git a/test/cctest/test-cpu.cc b/test/cctest/test-libplatform.h
similarity index 57%
copy from test/cctest/test-cpu.cc
copy to test/cctest/test-libplatform.h
index 06966c68c86296e510edb8899f4d7deb0343f108..a8dd0cc307800699ad43160411d0761385b7c32f 100644
--- a/test/cctest/test-cpu.cc
+++ b/test/cctest/test-libplatform.h
@@ -25,31 +25,66 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#ifndef TEST_LIBPLATFORM_H_
+#define TEST_LIBPLATFORM_H_
+
#include "v8.h"
#include "cctest.h"
-#include "cpu.h"
using namespace v8::internal;
+class TestTask : public v8::Task {
+ public:
+ TestTask(int* task_counter, bool expected_to_run)
+ : task_counter_(task_counter),
+ expected_to_run_(expected_to_run),
+ executed_(false) {
+ ++*task_counter_;
+ }
+ explicit TestTask(int* task_counter)
+ : task_counter_(task_counter), expected_to_run_(false), executed_(false) {
+ ++*task_counter_;
+ }
+ virtual ~TestTask() {
+ CHECK_EQ(expected_to_run_, executed_);
+ --*task_counter_;
Hannes Payer (out of office) 2013/12/09 18:50:51 I guess this operation has to be done atomic, othe
jochen (gone - plz use gerrit) 2013/12/09 19:04:31 good point. Will update.
+ }
+
+ // v8::Task implementation.
+ virtual void Run() V8_OVERRIDE { executed_ = true; }
+
+ private:
+ int* task_counter_;
+ bool expected_to_run_;
+ bool executed_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestTask);
+};
+
+
+class TestThread : public Thread {
+ public:
+ explicit TestThread(v8::Task* task)
+ : Thread("libplatform TestThread"), semaphore_(0), task_(task) {}
+ virtual ~TestThread() {}
-TEST(FeatureImplications) {
- // Test for features implied by other features.
- CPU cpu;
+ void Signal() { semaphore_.Signal(); }
- // ia32 and x64 features
- CHECK(!cpu.has_sse() || cpu.has_mmx());
- CHECK(!cpu.has_sse2() || cpu.has_sse());
- CHECK(!cpu.has_sse3() || cpu.has_sse2());
- CHECK(!cpu.has_ssse3() || cpu.has_sse3());
- CHECK(!cpu.has_sse41() || cpu.has_sse3());
- CHECK(!cpu.has_sse42() || cpu.has_sse41());
+ // Thread implementation.
+ virtual void Run() V8_OVERRIDE {
+ semaphore_.Wait();
+ if (task_) {
+ task_->Run();
+ delete task_;
+ }
+ }
- // arm features
- CHECK(!cpu.has_vfp3_d32() || cpu.has_vfp3());
-}
+ private:
+ Semaphore semaphore_;
+ v8::Task* task_;
+ DISALLOW_COPY_AND_ASSIGN(TestThread);
+};
-TEST(NumberOfProcessorsOnline) {
- CHECK_GT(CPU::NumberOfProcessorsOnline(), 0);
-}
+#endif // TEST_LIBPLATFORM_H_

Powered by Google App Engine
This is Rietveld 408576698