summaryrefslogtreecommitdiff
path: root/runtime/exec_utils_test.cc
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2024-07-26 17:37:50 +0100
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-08-12 12:32:39 +0000
commitf9af3fa4d54f253bcb42cf571bd309dea60bffb1 (patch)
tree19071b8b06d0238e6076f406de0916f94f1a4d1b /runtime/exec_utils_test.cc
parent8bf0b0a013dc3a6a5d06cfe30aee3f8506042ae4 (diff)
Fix big negative dex2oatWallTimeMillis.
We calculate dex2oatWallTimeMillis by (uptime - starttime). To get a reasonable result, both times need to be from the same clock. However, it's unclear which clock the kernel uses for the latter. proc_pid_stat(5) does not have anything helpful on this matter: (22) starttime %llu The time the process started after system boot. Before Linux 2.6, this value was expressed in jiffies. Since Linux 2.6, the value is expressed in clock ticks (divide by sysconf(_SC_CLK_TCK)). The format for this field was %lu before Linux 2.6. To make sure we use the same clock, we obtain the uptime on process start as the start time. Bug: 315061143 Test: Presubmit Change-Id: I5f344e953a945656474b3f625368c1ccb5aa52d8
Diffstat (limited to 'runtime/exec_utils_test.cc')
-rw-r--r--runtime/exec_utils_test.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/runtime/exec_utils_test.cc b/runtime/exec_utils_test.cc
index e1fc6272d5..eb21652c19 100644
--- a/runtime/exec_utils_test.cc
+++ b/runtime/exec_utils_test.cc
@@ -218,9 +218,11 @@ TEST_P(ExecUtilsTest, ExecStat) {
// The process filename is "a) b".
EXPECT_CALL(*exec_utils_, GetProcStat(_))
.WillOnce(Return(
- "14963 (a) b) Z 6067 14963 1 0 -1 4228108 105 0 0 0 94 5 0 0 39 19 1 0 162034388 0 0 "
+ "14963 (a) b) Z 6067 14963 1 0 -1 4228108 105 0 0 0 94 5 0 0 39 19 1 0 0 0 0 "
"18446744073709551615 0 0 0 0 0 0 20999 0 0 1 0 0 17 71 0 0 0 0 0 0 0 0 0 0 0 0 9"));
- EXPECT_CALL(*exec_utils_, DoGetUptimeMs()).WillOnce(Return(1620344887ll));
+ EXPECT_CALL(*exec_utils_, DoGetUptimeMs())
+ .WillOnce(Return(1620343880ll))
+ .WillOnce(Return(1620344887ll));
EXPECT_CALL(*exec_utils_, GetTicksPerSec()).WillOnce(Return(100));
ASSERT_EQ(exec_utils_
@@ -245,13 +247,8 @@ TEST_P(ExecUtilsTest, ExecStatNoStartTime) {
std::string error_msg;
ProcessStat stat;
- // The process filename is "a) b".
- EXPECT_CALL(*exec_utils_, GetProcStat(_))
- .WillOnce(Return(
- "14963 (a) b) Z 6067 14963 1 0 -1 4228108 105 0 0 0 94 5 0 0 39 19 1 0 0 0 0 "
- "18446744073709551615 0 0 0 0 0 0 20999 0 0 1 0 0 17 71 0 0 0 0 0 0 0 0 0 0 0 0 9"));
- EXPECT_CALL(*exec_utils_, DoGetUptimeMs()).WillOnce(Return(1620344887ll));
- EXPECT_CALL(*exec_utils_, GetTicksPerSec()).WillOnce(Return(100));
+ EXPECT_CALL(*exec_utils_, DoGetUptimeMs())
+ .WillOnce(Return(Result<int64_t>(Errorf("Failed to get uptime"))));
ASSERT_EQ(exec_utils_
->ExecAndReturnResult(command,
@@ -276,6 +273,7 @@ TEST_P(ExecUtilsTest, ExecStatNoUptime) {
ProcessStat stat;
EXPECT_CALL(*exec_utils_, DoGetUptimeMs())
+ .WillOnce(Return(162034388ll))
.WillOnce(Return(Result<int64_t>(Errorf("Failed to get uptime"))));
ASSERT_EQ(exec_utils_
@@ -301,9 +299,11 @@ TEST_P(ExecUtilsTest, ExecStatFailed) {
EXPECT_CALL(*exec_utils_, GetProcStat(_))
.WillOnce(Return(
- "14963 (a) b) Z 6067 14963 1 0 -1 4228108 105 0 0 0 94 5 0 0 39 19 1 0 162034388 0 0 "
+ "14963 (a) b) Z 6067 14963 1 0 -1 4228108 105 0 0 0 94 5 0 0 39 19 1 0 0 0 0 "
"18446744073709551615 0 0 0 0 0 0 20999 0 0 1 0 0 17 71 0 0 0 0 0 0 0 0 0 0 0 0 9"));
- EXPECT_CALL(*exec_utils_, DoGetUptimeMs()).WillOnce(Return(1620344887ll));
+ EXPECT_CALL(*exec_utils_, DoGetUptimeMs())
+ .WillOnce(Return(1620343880ll))
+ .WillOnce(Return(1620344887ll));
EXPECT_CALL(*exec_utils_, GetTicksPerSec()).WillOnce(Return(100));
// This will always time out.