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

Unified Diff: util/test/thread_win.cc

Issue 1001673002: Add Locking calls to file_io.h plus implementations and test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: release load Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/test/thread_posix.cc ('k') | util/util.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/test/thread_win.cc
diff --git a/util/win/time_test.cc b/util/test/thread_win.cc
similarity index 52%
copy from util/win/time_test.cc
copy to util/test/thread_win.cc
index ad0771e38b7889ab92154490845a0c3aafe13782..797d9c23ccdfa438b4b512373a16e059bf0c5d67 100644
--- a/util/win/time_test.cc
+++ b/util/test/thread_win.cc
@@ -12,23 +12,34 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "util/win/time.h"
+#include "util/test/thread.h"
#include "gtest/gtest.h"
+#include "util/test/errors.h"
namespace crashpad {
namespace test {
-namespace {
-TEST(Time, Reasonable) {
- timeval t;
- GetTimeOfDay(&t);
- // Assume that time's time_t return is seconds from 1970.
- time_t approx_now = time(nullptr);
- EXPECT_GE(approx_now, t.tv_sec);
- EXPECT_LT(approx_now - 100, t.tv_sec);
+void Thread::Start() {
+ ASSERT_FALSE(platform_thread_);
+ platform_thread_ =
+ CreateThread(nullptr, 0, ThreadEntryThunk, this, 0, nullptr);
+ ASSERT_TRUE(platform_thread_) << ErrorMessage("CreateThread");
+}
+
+void Thread::Join() {
+ ASSERT_FALSE(platform_thread_);
+ DWORD result = WaitForSingleObject(platform_thread_, INFINITE);
+ EXPECT_EQ(WAIT_OBJECT_0, result) << ErrorMessage("WaitForSingleObject");
+ platform_thread_ = 0;
+}
+
+// static
+DWORD WINAPI Thread::ThreadEntryThunk(void* argument) {
+ Thread* self = reinterpret_cast<Thread*>(argument);
+ self->ThreadMain();
+ return 0;
}
-} // namespace
} // namespace test
} // namespace crashpad
« no previous file with comments | « util/test/thread_posix.cc ('k') | util/util.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698