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

Side by Side Diff: test/cctest/test-semaphore.cc

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 29 matching lines...) Expand all
40 public: 40 public:
41 explicit WaitAndSignalThread(v8::base::Semaphore* semaphore) 41 explicit WaitAndSignalThread(v8::base::Semaphore* semaphore)
42 : Thread("WaitAndSignalThread"), semaphore_(semaphore) {} 42 : Thread("WaitAndSignalThread"), semaphore_(semaphore) {}
43 virtual ~WaitAndSignalThread() {} 43 virtual ~WaitAndSignalThread() {}
44 44
45 virtual void Run() V8_OVERRIDE { 45 virtual void Run() V8_OVERRIDE {
46 for (int n = 0; n < 1000; ++n) { 46 for (int n = 0; n < 1000; ++n) {
47 semaphore_->Wait(); 47 semaphore_->Wait();
48 bool result = 48 bool result =
49 semaphore_->WaitFor(v8::base::TimeDelta::FromMicroseconds(1)); 49 semaphore_->WaitFor(v8::base::TimeDelta::FromMicroseconds(1));
50 ASSERT(!result); 50 DCHECK(!result);
51 USE(result); 51 USE(result);
52 semaphore_->Signal(); 52 semaphore_->Signal();
53 } 53 }
54 } 54 }
55 55
56 private: 56 private:
57 v8::base::Semaphore* semaphore_; 57 v8::base::Semaphore* semaphore_;
58 }; 58 };
59 59
60 60
61 TEST(WaitAndSignal) { 61 TEST(WaitAndSignal) {
62 v8::base::Semaphore semaphore(0); 62 v8::base::Semaphore semaphore(0);
63 WaitAndSignalThread t1(&semaphore); 63 WaitAndSignalThread t1(&semaphore);
64 WaitAndSignalThread t2(&semaphore); 64 WaitAndSignalThread t2(&semaphore);
65 65
66 t1.Start(); 66 t1.Start();
67 t2.Start(); 67 t2.Start();
68 68
69 // Make something available. 69 // Make something available.
70 semaphore.Signal(); 70 semaphore.Signal();
71 71
72 t1.Join(); 72 t1.Join();
73 t2.Join(); 73 t2.Join();
74 74
75 semaphore.Wait(); 75 semaphore.Wait();
76 76
77 bool result = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(1)); 77 bool result = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(1));
78 ASSERT(!result); 78 DCHECK(!result);
79 USE(result); 79 USE(result);
80 } 80 }
81 81
82 82
83 TEST(WaitFor) { 83 TEST(WaitFor) {
84 bool ok; 84 bool ok;
85 v8::base::Semaphore semaphore(0); 85 v8::base::Semaphore semaphore(0);
86 86
87 // Semaphore not signalled - timeout. 87 // Semaphore not signalled - timeout.
88 ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(0)); 88 ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(0));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 132
133 class ConsumerThread V8_FINAL : public v8::base::Thread { 133 class ConsumerThread V8_FINAL : public v8::base::Thread {
134 public: 134 public:
135 ConsumerThread() : Thread("ConsumerThread") {} 135 ConsumerThread() : Thread("ConsumerThread") {}
136 virtual ~ConsumerThread() {} 136 virtual ~ConsumerThread() {}
137 137
138 virtual void Run() V8_OVERRIDE { 138 virtual void Run() V8_OVERRIDE {
139 for (int n = 0; n < kDataSize; ++n) { 139 for (int n = 0; n < kDataSize; ++n) {
140 used_space.Wait(); 140 used_space.Wait();
141 ASSERT_EQ(static_cast<int>(alphabet[n % kAlphabetSize]), 141 DCHECK_EQ(static_cast<int>(alphabet[n % kAlphabetSize]),
142 static_cast<int>(buffer[n % kBufferSize])); 142 static_cast<int>(buffer[n % kBufferSize]));
143 free_space.Signal(); 143 free_space.Signal();
144 } 144 }
145 } 145 }
146 }; 146 };
147 147
148 148
149 TEST(ProducerConsumer) { 149 TEST(ProducerConsumer) {
150 ProducerThread producer_thread; 150 ProducerThread producer_thread;
151 ConsumerThread consumer_thread; 151 ConsumerThread consumer_thread;
152 producer_thread.Start(); 152 producer_thread.Start();
153 consumer_thread.Start(); 153 consumer_thread.Start();
154 producer_thread.Join(); 154 producer_thread.Join();
155 consumer_thread.Join(); 155 consumer_thread.Join();
156 } 156 }
OLDNEW
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698