summaryrefslogtreecommitdiff
path: root/apexd/apexservice_test.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-01-23 00:09:59 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-01-23 00:09:59 +0000
commit35be45b7d948ac0ba773735d1671bea12d56d908 (patch)
treeb83253037c2515255867bf9e24cbbd49191a291f /apexd/apexservice_test.cpp
parent22613b7917e90d3f75cbd107bc49f82895381388 (diff)
parent66bd61adb95077787c37bf4aa914cb242a52d413 (diff)
Snap for 7097726 from 66bd61adb95077787c37bf4aa914cb242a52d413 to rvc-qpr3-release
Change-Id: Ibf9fda7c4c4a5deab725fb8cd1c41ed9eef3587e
Diffstat (limited to 'apexd/apexservice_test.cpp')
-rw-r--r--apexd/apexservice_test.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/apexd/apexservice_test.cpp b/apexd/apexservice_test.cpp
index 4c054f1..024cf50 100644
--- a/apexd/apexservice_test.cpp
+++ b/apexd/apexservice_test.cpp
@@ -94,6 +94,26 @@ using MountedApexData = MountedApexDatabase::MountedApexData;
namespace fs = std::filesystem;
+static void CleanDir(const std::string& dir) {
+ if (access(dir.c_str(), F_OK) != 0 && errno == ENOENT) {
+ LOG(WARNING) << dir << " does not exist";
+ return;
+ }
+ auto status = WalkDir(dir, [](const fs::directory_entry& p) {
+ std::error_code ec;
+ fs::file_status status = p.status(ec);
+ ASSERT_FALSE(ec) << "Failed to stat " << p.path() << " : " << ec.message();
+ if (fs::is_directory(status)) {
+ fs::remove_all(p.path(), ec);
+ } else {
+ fs::remove(p.path(), ec);
+ }
+ ASSERT_FALSE(ec) << "Failed to delete " << p.path() << " : "
+ << ec.message();
+ });
+ ASSERT_TRUE(IsOk(status));
+}
+
class ApexServiceTest : public ::testing::Test {
public:
ApexServiceTest() {
@@ -447,21 +467,10 @@ class ApexServiceTest : public ::testing::Test {
private:
void CleanUp() {
- auto status = WalkDir(kApexDataDir, [](const fs::directory_entry& p) {
- std::error_code ec;
- fs::file_status status = p.status(ec);
- ASSERT_FALSE(ec) << "Failed to stat " << p.path() << " : "
- << ec.message();
- if (fs::is_directory(status)) {
- fs::remove_all(p.path(), ec);
- } else {
- fs::remove(p.path(), ec);
- }
- ASSERT_FALSE(ec) << "Failed to delete " << p.path() << " : "
- << ec.message();
- });
- fs::remove_all(kApexSessionsDir);
- ASSERT_TRUE(IsOk(status));
+ CleanDir(kActiveApexPackagesDataDir);
+ CleanDir(kApexBackupDir);
+ CleanDir(kApexHashTreeDir);
+ CleanDir(ApexSession::GetSessionsDir());
DeleteIfExists("/data/misc_ce/0/apexdata/apex.apexd_test");
DeleteIfExists("/data/misc_ce/0/apexrollback/123456");