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

Unified Diff: util/test/thread_posix.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.cc ('k') | util/test/thread_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/test/thread_posix.cc
diff --git a/util/win/time_test.cc b/util/test/thread_posix.cc
similarity index 55%
copy from util/win/time_test.cc
copy to util/test/thread_posix.cc
index ad0771e38b7889ab92154490845a0c3aafe13782..3a908845c925d0105b39375e949defd9ea767e29 100644
--- a/util/win/time_test.cc
+++ b/util/test/thread_posix.cc
@@ -12,23 +12,33 @@
// 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_);
+ int rv = pthread_create(&platform_thread_, nullptr, ThreadEntryThunk, this);
+ ASSERT_EQ(0, rv) << ErrnoMessage(rv, "pthread_create");
+}
+
+void Thread::Join() {
+ ASSERT_TRUE(platform_thread_);
+ int rv = pthread_join(platform_thread_, nullptr);
+ EXPECT_EQ(0, rv) << ErrnoMessage(rv, "pthread_join");
+ platform_thread_ = 0;
+}
+
+// static
+void* Thread::ThreadEntryThunk(void* argument) {
+ Thread* self = reinterpret_cast<Thread*>(argument);
+ self->ThreadMain();
+ return nullptr;
}
-} // namespace
} // namespace test
} // namespace crashpad
« no previous file with comments | « util/test/thread.cc ('k') | util/test/thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698