OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "tools/cygprofile/cygprofile.h" | 5 #include "tools/cygprofile/cygprofile.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include <sys/time.h> | 9 #include <sys/time.h> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 thread_log.AddEntry(reinterpret_cast<void*>(0x2)); | 40 thread_log.AddEntry(reinterpret_cast<void*>(0x2)); |
41 thread_log.AddEntry(reinterpret_cast<void*>(0x1)); | 41 thread_log.AddEntry(reinterpret_cast<void*>(0x1)); |
42 | 42 |
43 std::vector<LogEntry> entries; | 43 std::vector<LogEntry> entries; |
44 thread_log.TakeEntries(&entries); | 44 thread_log.TakeEntries(&entries); |
45 | 45 |
46 ASSERT_EQ(2U, entries.size()); | 46 ASSERT_EQ(2U, entries.size()); |
47 // The entries should appear in their insertion order. | 47 // The entries should appear in their insertion order. |
48 const LogEntry& first_entry = entries[0]; | 48 const LogEntry& first_entry = entries[0]; |
49 ASSERT_EQ(reinterpret_cast<int>(first_entry.address), 2); | 49 ASSERT_EQ(reinterpret_cast<uintptr_t>(first_entry.address), 2); |
50 ASSERT_EQ(getpid(), first_entry.pid); | 50 ASSERT_EQ(getpid(), first_entry.pid); |
51 ASSERT_LT(0, first_entry.tid); | 51 ASSERT_LT(0, first_entry.tid); |
52 | 52 |
53 const LogEntry& second_entry = entries[1]; | 53 const LogEntry& second_entry = entries[1]; |
54 ASSERT_EQ(1, reinterpret_cast<int>(second_entry.address)); | 54 ASSERT_EQ(1, reinterpret_cast<uintptr_t>(second_entry.address)); |
55 ASSERT_EQ(first_entry.pid, second_entry.pid); | 55 ASSERT_EQ(first_entry.pid, second_entry.pid); |
56 ASSERT_EQ(first_entry.tid, second_entry.tid); | 56 ASSERT_EQ(first_entry.tid, second_entry.tid); |
57 | 57 |
58 ASSERT_GE(GetUsecSecTimeFromTimeSpec(second_entry.time), | 58 ASSERT_GE(GetUsecSecTimeFromTimeSpec(second_entry.time), |
59 GetUsecSecTimeFromTimeSpec(first_entry.time)); | 59 GetUsecSecTimeFromTimeSpec(first_entry.time)); |
60 } | 60 } |
61 | 61 |
62 TEST(CygprofileTest, ManagerBasic) { | 62 TEST(CygprofileTest, ManagerBasic) { |
63 base::WaitableEvent wait_event(true, false); | 63 base::WaitableEvent wait_event(true, false); |
64 base::WaitableEvent notify_event(true, false); | 64 base::WaitableEvent notify_event(true, false); |
(...skipping 15 matching lines...) Expand all Loading... |
80 manager.AddLog(thread_log.Pass()); | 80 manager.AddLog(thread_log.Pass()); |
81 | 81 |
82 EXPECT_EQ(0U, entries.size()); | 82 EXPECT_EQ(0U, entries.size()); |
83 // This will wake up the internal thread. | 83 // This will wake up the internal thread. |
84 wait_event.Signal(); | 84 wait_event.Signal(); |
85 // Now it's our turn to wait until it performed the flush. | 85 // Now it's our turn to wait until it performed the flush. |
86 notify_event.Wait(); | 86 notify_event.Wait(); |
87 | 87 |
88 // The flush should have moved the data to the local vector of entries. | 88 // The flush should have moved the data to the local vector of entries. |
89 EXPECT_EQ(2U, entries.size()); | 89 EXPECT_EQ(2U, entries.size()); |
90 ASSERT_EQ(2, reinterpret_cast<int>(entries[0].address)); | 90 ASSERT_EQ(2, reinterpret_cast<uintptr_t>(entries[0].address)); |
91 ASSERT_EQ(3, reinterpret_cast<int>(entries[1].address)); | 91 ASSERT_EQ(3, reinterpret_cast<uintptr_t>(entries[1].address)); |
92 } | 92 } |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 } // namespace cygprofile | 95 } // namespace cygprofile |
96 | 96 |
97 // Custom runner implementation since base's one requires JNI on Android. | 97 // Custom runner implementation since base's one requires JNI on Android. |
98 int main(int argc, char** argv) { | 98 int main(int argc, char** argv) { |
99 testing::InitGoogleTest(&argc, argv); | 99 testing::InitGoogleTest(&argc, argv); |
100 return RUN_ALL_TESTS(); | 100 return RUN_ALL_TESTS(); |
101 } | 101 } |
OLD | NEW |