summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nikita Ioffe <ioffe@google.com> 2019-02-02 17:26:18 +0000
committer Nikita Ioffe <ioffe@google.com> 2019-02-05 14:56:39 +0000
commit04c74f3e58fb24d8288103696b6be8001b73bc7e (patch)
tree0ab5a37043af3dc030b00497698c63bb0425c16b
parent580ae9ca0cde5039b728998d97c769e67f35f579 (diff)
installd_service_test: fix ServiceTest.CreateAppDataSnapshot_ClearsCache
This test is failing on cf_x86_phone-userdebug target, with an error: Failed copying /data/local/tmp/user_de/0/com.foo to /data/local/tmp/misc_de/0/rollback' Logs shows that cp fails with "No such file or directory error": 02-05 08:37:49.444 12746 12746 I cp : cp: /data/local/tmp/misc_de/0/rollback: No such file or directory 02-05 08:37:49.445 12746 12746 I cp : cp terminated by exit(1) Testcase is failing, because it doesn't create /data/local/tmp/misc_de/0/rollback directory. It is hard to spot, because other testcases in installd_service_test also create that directory, meaning that depending on the order in which testcases are run, CreateAppDataSnapshot_ClearsCache will either fail or succeed. Verified that this is the case by running only CreateAppDataSnapshot_ClearsCache testcase: ./data/nativetest/installd_service_test/installd_service_test --gtest_filter=*CreateAppDataSnapshot_ClearsCache* Bug: 123631551 Fixes: 123631551 Test: ./data/nativetest/installd_service_test/installd_service_test --gtest_filter=*CreateAppDataSnapshot_ClearsCache* Change-Id: I8277efe6076bac28fd07ea3705a21aae6b8cab14
-rw-r--r--cmds/installd/tests/installd_service_test.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/cmds/installd/tests/installd_service_test.cpp b/cmds/installd/tests/installd_service_test.cpp
index cf7f1ebca4..73277100d1 100644
--- a/cmds/installd/tests/installd_service_test.cpp
+++ b/cmds/installd/tests/installd_service_test.cpp
@@ -451,12 +451,12 @@ TEST_F(ServiceTest, SnapshotAppData_WrongVolumeUuid) {
TEST_F(ServiceTest, CreateAppDataSnapshot_ClearsCache) {
auto fake_package_ce_path = create_data_user_ce_package_path("TEST", 0, "com.foo");
auto fake_package_de_path = create_data_user_de_package_path("TEST", 0, "com.foo");
- auto fake_package_ce_cache_path = read_path_inode(fake_package_ce_path,
- "cache", kXattrInodeCache);
- auto fake_package_ce_code_cache_path = read_path_inode(fake_package_ce_path,
- "code_cache", kXattrInodeCache);
+ auto fake_package_ce_cache_path = fake_package_ce_path + "/cache";
+ auto fake_package_ce_code_cache_path = fake_package_ce_path + "/code_cache";
auto fake_package_de_cache_path = fake_package_de_path + "/cache";
auto fake_package_de_code_cache_path = fake_package_de_path + "/code_cache";
+ auto rollback_ce_dir = create_data_misc_ce_rollback_path("TEST", 0);
+ auto rollback_de_dir = create_data_misc_de_rollback_path("TEST", 0);
ASSERT_TRUE(mkdirs(fake_package_ce_path, 700));
ASSERT_TRUE(mkdirs(fake_package_de_path, 700));
@@ -464,20 +464,15 @@ TEST_F(ServiceTest, CreateAppDataSnapshot_ClearsCache) {
ASSERT_TRUE(mkdirs(fake_package_ce_code_cache_path, 700));
ASSERT_TRUE(mkdirs(fake_package_de_cache_path, 700));
ASSERT_TRUE(mkdirs(fake_package_de_code_cache_path, 700));
+ ASSERT_TRUE(mkdirs(rollback_ce_dir, 700));
+ ASSERT_TRUE(mkdirs(rollback_de_dir, 700));
auto deleter = [&fake_package_ce_path, &fake_package_de_path,
- &fake_package_ce_cache_path, &fake_package_ce_code_cache_path,
- &fake_package_de_cache_path, &fake_package_de_code_cache_path]() {
+ &rollback_ce_dir, &rollback_de_dir]() {
delete_dir_contents(fake_package_ce_path, true);
delete_dir_contents(fake_package_de_path, true);
- delete_dir_contents(fake_package_ce_cache_path, true);
- delete_dir_contents(fake_package_ce_code_cache_path, true);
- delete_dir_contents(fake_package_de_cache_path, true);
- delete_dir_contents(fake_package_de_code_cache_path, true);
- rmdir(fake_package_ce_cache_path.c_str());
- rmdir(fake_package_ce_code_cache_path.c_str());
- rmdir(fake_package_de_cache_path.c_str());
- rmdir(fake_package_de_code_cache_path.c_str());
+ delete_dir_contents_and_dir(rollback_ce_dir, true);
+ delete_dir_contents_and_dir(rollback_de_dir, true);
};
auto scope_guard = android::base::make_scope_guard(deleter);