summaryrefslogtreecommitdiff
path: root/metrics_utils_unittest.cc
diff options
context:
space:
mode:
authorAmin Hassani <ahassani@chromium.org>2020-10-29 16:47:58 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-03 03:19:41 +0000
commitec7bc11c3103d9310568a391271be52baef273a7 (patch)
treec7d69b3c47c8ff86876cd662b4ace630c1e1362b /metrics_utils_unittest.cc
parent24e1d72aa2a1024417121b0d91bf9a6f3b883a96 (diff)
update_engine: Create cros vs. aosp boundary clear
Its time to make the boundary between Chrome OS and Android code more clear. This CL moves all CrOS only code to "chromeos" directory and the same for Android (in "android" directory). This way we would easily know which code is uses in which project and can keep the code cleaner and more maintainable. One big remaining problem is download_action* files. It seems like DownloadAction class does a lot of things that chrome OS needs and it depends on a lot of Chrome OS stuff, but Android is also using thie Action in a way that circumvent the Chrome OS stuff. For example Android checks for SystemState to be nullptr to not do things. This is really fragile and needs to change. Probably Android Team has to implement their own DownloadAction of some sort and not re use the Chrome OS one in a very fragile way. Removed a few android files that have not been used anywhere. Changed some clang-format and lint issues in order to pass preupload. BUG=b:171829801 TEST=cros_workon_make --board reef --test update_engine Change-Id: I3fff1d4a100a065a5c1484a845241b5521614d9f Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2508965 Tested-by: Amin Hassani <ahassani@chromium.org> Auto-Submit: Amin Hassani <ahassani@chromium.org> Reviewed-by: Jae Hoon Kim <kimjae@chromium.org> Reviewed-by: Tianjie Xu <xunchang@google.com> Reviewed-by: Kelvin Zhang <zhangkelvin@google.com> Commit-Queue: Amin Hassani <ahassani@chromium.org>
Diffstat (limited to 'metrics_utils_unittest.cc')
-rw-r--r--metrics_utils_unittest.cc112
1 files changed, 0 insertions, 112 deletions
diff --git a/metrics_utils_unittest.cc b/metrics_utils_unittest.cc
index 6ea996fa..cedd2691 100644
--- a/metrics_utils_unittest.cc
+++ b/metrics_utils_unittest.cc
@@ -20,7 +20,6 @@
#include "update_engine/common/fake_clock.h"
#include "update_engine/common/fake_prefs.h"
-#include "update_engine/fake_system_state.h"
namespace chromeos_update_engine {
namespace metrics_utils {
@@ -74,116 +73,5 @@ TEST(MetricsUtilsTest, GetConnectionType) {
GetConnectionType(ConnectionType::kWifi, ConnectionTethering::kUnknown));
}
-TEST(MetricsUtilsTest, WallclockDurationHelper) {
- FakeSystemState fake_system_state;
- FakeClock fake_clock;
- base::TimeDelta duration;
- const std::string state_variable_key = "test-prefs";
- FakePrefs fake_prefs;
-
- fake_system_state.set_clock(&fake_clock);
- fake_system_state.set_prefs(&fake_prefs);
-
- // Initialize wallclock to 1 sec.
- fake_clock.SetWallclockTime(base::Time::FromInternalValue(1000000));
-
- // First time called so no previous measurement available.
- EXPECT_FALSE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
-
- // Next time, we should get zero since the clock didn't advance.
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-
- // We can also call it as many times as we want with it being
- // considered a failure.
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-
- // Advance the clock one second, then we should get 1 sec on the
- // next call and 0 sec on the subsequent call.
- fake_clock.SetWallclockTime(base::Time::FromInternalValue(2000000));
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 1);
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-
- // Advance clock two seconds and we should get 2 sec and then 0 sec.
- fake_clock.SetWallclockTime(base::Time::FromInternalValue(4000000));
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 2);
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-
- // There's a possibility that the wallclock can go backwards (NTP
- // adjustments, for example) so check that we properly handle this
- // case.
- fake_clock.SetWallclockTime(base::Time::FromInternalValue(3000000));
- EXPECT_FALSE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- fake_clock.SetWallclockTime(base::Time::FromInternalValue(4000000));
- EXPECT_TRUE(metrics_utils::WallclockDurationHelper(
- &fake_system_state, state_variable_key, &duration));
- EXPECT_EQ(duration.InSeconds(), 1);
-}
-
-TEST(MetricsUtilsTest, MonotonicDurationHelper) {
- int64_t storage = 0;
- FakeSystemState fake_system_state;
- FakeClock fake_clock;
- base::TimeDelta duration;
-
- fake_system_state.set_clock(&fake_clock);
-
- // Initialize monotonic clock to 1 sec.
- fake_clock.SetMonotonicTime(base::Time::FromInternalValue(1000000));
-
- // First time called so no previous measurement available.
- EXPECT_FALSE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
-
- // Next time, we should get zero since the clock didn't advance.
- EXPECT_TRUE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-
- // We can also call it as many times as we want with it being
- // considered a failure.
- EXPECT_TRUE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
- EXPECT_TRUE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-
- // Advance the clock one second, then we should get 1 sec on the
- // next call and 0 sec on the subsequent call.
- fake_clock.SetMonotonicTime(base::Time::FromInternalValue(2000000));
- EXPECT_TRUE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
- EXPECT_EQ(duration.InSeconds(), 1);
- EXPECT_TRUE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-
- // Advance clock two seconds and we should get 2 sec and then 0 sec.
- fake_clock.SetMonotonicTime(base::Time::FromInternalValue(4000000));
- EXPECT_TRUE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
- EXPECT_EQ(duration.InSeconds(), 2);
- EXPECT_TRUE(metrics_utils::MonotonicDurationHelper(
- &fake_system_state, &storage, &duration));
- EXPECT_EQ(duration.InSeconds(), 0);
-}
-
} // namespace metrics_utils
} // namespace chromeos_update_engine