diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-03-26 22:07:02 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-03-26 22:07:02 +0000 |
commit | 489841fe0a67d60cf43a4c09b27622a6f4876028 (patch) | |
tree | 4e65b14d1000468995e05f296c43fe2d56c321cd | |
parent | 35be45b7d948ac0ba773735d1671bea12d56d908 (diff) | |
parent | fbb86e1f6f45da6ded3a3692ed56038ebfae409d (diff) |
Snap for 7238877 from fbb86e1f6f45da6ded3a3692ed56038ebfae409d to rvc-qpr3-release
Change-Id: Ic9a62905855b2e27eb8d206ecd8949902d0ec0e9
-rw-r--r-- | apexd/apexd_session_test.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/apexd/apexd_session_test.cpp b/apexd/apexd_session_test.cpp index bec0561..0dc3a78 100644 --- a/apexd/apexd_session_test.cpp +++ b/apexd/apexd_session_test.cpp @@ -24,6 +24,7 @@ #include <android-base/result.h> #include <android-base/scopeguard.h> #include <android-base/stringprintf.h> +#include <android-base/strings.h> #include <gtest/gtest.h> #include "apexd_session.h" @@ -36,6 +37,7 @@ namespace apex { namespace { using android::apex::testing::IsOk; +using android::base::Join; using android::base::make_scope_guard; // TODO(b/170329726): add unit tests for apexd_sessions.h @@ -65,6 +67,12 @@ TEST(ApexdSessionTest, MigrateToMetadataSessionsDir) { GTEST_SKIP() << "Device doesn't have /metadata partition"; } + // This is ugly, but does the job. To have a truly hermetic unit tests we + // need to refactor ApexSession class. + for (const auto& entry : fs::directory_iterator("/metadata/apex/sessions")) { + fs::remove_all(entry.path()); + } + // This is a very ugly test set up, but to have something better we need to // refactor ApexSession class. class TestApexSession { @@ -101,7 +109,8 @@ TEST(ApexdSessionTest, MigrateToMetadataSessionsDir) { ASSERT_TRUE(IsOk(ApexSession::MigrateToMetadataSessionsDir())); - ASSERT_EQ(2u, ApexSession::GetSessions().size()); + auto sessions = ApexSession::GetSessions(); + ASSERT_EQ(2u, sessions.size()) << Join(sessions, ','); auto migrated_session_1 = ApexSession::GetSession(239); ASSERT_TRUE(IsOk(migrated_session_1)); |