Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agree to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <dirent.h> |
| 18 | #include <fcntl.h> |
Tao Bao | 49750f1 | 2018-07-11 16:32:10 -0700 | [diff] [blame] | 19 | #include <inttypes.h> |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | #include <stdlib.h> |
| 22 | #include <sys/stat.h> |
| 23 | #include <sys/types.h> |
| 24 | #include <time.h> |
| 25 | #include <unistd.h> |
| 26 | |
| 27 | #include <algorithm> |
| 28 | #include <memory> |
| 29 | #include <string> |
| 30 | #include <vector> |
| 31 | |
| 32 | #include <android-base/file.h> |
Tao Bao | 49750f1 | 2018-07-11 16:32:10 -0700 | [diff] [blame] | 33 | #include <android-base/logging.h> |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 34 | #include <android-base/stringprintf.h> |
| 35 | #include <android-base/test_utils.h> |
| 36 | #include <android-base/unique_fd.h> |
| 37 | #include <gtest/gtest.h> |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 38 | |
| 39 | #include "applypatch/applypatch.h" |
| 40 | #include "common/test_constants.h" |
| 41 | #include "otautil/paths.h" |
| 42 | #include "otautil/print_sha1.h" |
| 43 | |
| 44 | using namespace std::string_literals; |
| 45 | |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 46 | class ApplyPatchTest : public ::testing::Test { |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 47 | protected: |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 48 | void SetUp() override { |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 49 | source_file = from_testdata_base("boot.img"); |
| 50 | FileContents boot_fc; |
| 51 | ASSERT_EQ(0, LoadFileContents(source_file, &boot_fc)); |
| 52 | source_size = boot_fc.data.size(); |
| 53 | source_sha1 = print_sha1(boot_fc.sha1); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 54 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 55 | target_file = from_testdata_base("recovery.img"); |
| 56 | FileContents recovery_fc; |
| 57 | ASSERT_EQ(0, LoadFileContents(target_file, &recovery_fc)); |
| 58 | target_size = recovery_fc.data.size(); |
| 59 | target_sha1 = print_sha1(recovery_fc.sha1); |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 60 | |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 61 | srand(time(nullptr)); |
| 62 | bad_sha1_a = android::base::StringPrintf("%040x", rand()); |
| 63 | bad_sha1_b = android::base::StringPrintf("%040x", rand()); |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 64 | |
| 65 | // Reset the cache backup file. |
| 66 | Paths::Get().set_cache_temp_source("/cache/saved.file"); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 69 | std::string source_file; |
| 70 | std::string source_sha1; |
| 71 | size_t source_size; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 72 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 73 | std::string target_file; |
| 74 | std::string target_sha1; |
| 75 | size_t target_size; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 76 | |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 77 | std::string bad_sha1_a; |
| 78 | std::string bad_sha1_b; |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 81 | TEST_F(ApplyPatchTest, CheckMode) { |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 82 | std::string partition = |
| 83 | "EMMC:" + source_file + ":" + std::to_string(source_size) + ":" + source_sha1; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 84 | ASSERT_EQ(0, applypatch_check(partition, {})); |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 85 | ASSERT_EQ(0, applypatch_check(partition, { source_sha1 })); |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 86 | ASSERT_EQ(0, applypatch_check(partition, { bad_sha1_a, bad_sha1_b })); |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 87 | ASSERT_EQ(0, applypatch_check(partition, { bad_sha1_a, source_sha1, bad_sha1_b })); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 90 | TEST_F(ApplyPatchTest, CheckMode_NonEmmcTarget) { |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 91 | ASSERT_NE(0, applypatch_check(source_file, {})); |
| 92 | ASSERT_NE(0, applypatch_check(source_file, { source_sha1 })); |
| 93 | ASSERT_NE(0, applypatch_check(source_file, { bad_sha1_a, bad_sha1_b })); |
| 94 | ASSERT_NE(0, applypatch_check(source_file, { bad_sha1_a, source_sha1, bad_sha1_b })); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 97 | TEST_F(ApplyPatchTest, CheckMode_EmmcTarget) { |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 98 | // EMMC:source_file:size:sha1 should pass the check. |
| 99 | std::string src_file = |
| 100 | "EMMC:" + source_file + ":" + std::to_string(source_size) + ":" + source_sha1; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 101 | ASSERT_EQ(0, applypatch_check(src_file, {})); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 102 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 103 | // EMMC:source_file:(size-1):sha1:(size+1):sha1 should fail the check. |
| 104 | src_file = "EMMC:" + source_file + ":" + std::to_string(source_size - 1) + ":" + source_sha1 + |
| 105 | ":" + std::to_string(source_size + 1) + ":" + source_sha1; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 106 | ASSERT_NE(0, applypatch_check(src_file, {})); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 107 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 108 | // EMMC:source_file:(size-1):sha1:size:sha1:(size+1):sha1 should pass the check. |
| 109 | src_file = "EMMC:" + source_file + ":" + std::to_string(source_size - 1) + ":" + source_sha1 + |
| 110 | ":" + std::to_string(source_size) + ":" + source_sha1 + ":" + |
| 111 | std::to_string(source_size + 1) + ":" + source_sha1; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 112 | ASSERT_EQ(0, applypatch_check(src_file, {})); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 113 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 114 | // EMMC:source_file:(size+1):sha1:(size-1):sha1:size:sha1 should pass the check. |
| 115 | src_file = "EMMC:" + source_file + ":" + std::to_string(source_size + 1) + ":" + source_sha1 + |
| 116 | ":" + std::to_string(source_size - 1) + ":" + source_sha1 + ":" + |
| 117 | std::to_string(source_size) + ":" + source_sha1; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 118 | ASSERT_EQ(0, applypatch_check(src_file, {})); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 119 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 120 | // EMMC:target_file:(size+1):source_sha1:(size-1):source_sha1:size:source_sha1:size:target_sha1 |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 121 | // should pass the check. |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 122 | src_file = "EMMC:" + target_file + ":" + std::to_string(source_size + 1) + ":" + source_sha1 + |
| 123 | ":" + std::to_string(source_size - 1) + ":" + source_sha1 + ":" + |
| 124 | std::to_string(source_size) + ":" + source_sha1 + ":" + std::to_string(target_size) + |
| 125 | ":" + target_sha1; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 126 | ASSERT_EQ(0, applypatch_check(src_file, {})); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 129 | TEST_F(ApplyPatchTest, CheckMode_UseBackup) { |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 130 | std::string corrupted = |
| 131 | "EMMC:" + source_file + ":" + std::to_string(source_size) + ":" + bad_sha1_a; |
| 132 | ASSERT_NE(0, applypatch_check(corrupted, { source_sha1 })); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 133 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 134 | Paths::Get().set_cache_temp_source(source_file); |
| 135 | ASSERT_EQ(0, applypatch_check(corrupted, { source_sha1 })); |
| 136 | ASSERT_EQ(0, applypatch_check(corrupted, { bad_sha1_a, source_sha1, bad_sha1_b })); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 139 | TEST_F(ApplyPatchTest, CheckMode_UseBackup_BothCorrupted) { |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 140 | std::string corrupted = |
| 141 | "EMMC:" + source_file + ":" + std::to_string(source_size) + ":" + bad_sha1_a; |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 142 | ASSERT_NE(0, applypatch_check(corrupted, {})); |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 143 | ASSERT_NE(0, applypatch_check(corrupted, { source_sha1 })); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 144 | |
Tao Bao | cdbe58a | 2018-08-20 08:57:19 -0700 | [diff] [blame] | 145 | Paths::Get().set_cache_temp_source(source_file); |
Tao Bao | 7c1d426 | 2018-07-06 23:18:14 -0700 | [diff] [blame] | 146 | ASSERT_NE(0, applypatch_check(corrupted, { bad_sha1_a, bad_sha1_b })); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | class FreeCacheTest : public ::testing::Test { |
| 150 | protected: |
| 151 | static constexpr size_t PARTITION_SIZE = 4096 * 10; |
| 152 | |
| 153 | // Returns a sorted list of files in |dirname|. |
| 154 | static std::vector<std::string> FindFilesInDir(const std::string& dirname) { |
| 155 | std::vector<std::string> file_list; |
| 156 | |
| 157 | std::unique_ptr<DIR, decltype(&closedir)> d(opendir(dirname.c_str()), closedir); |
| 158 | struct dirent* de; |
| 159 | while ((de = readdir(d.get())) != 0) { |
| 160 | std::string path = dirname + "/" + de->d_name; |
| 161 | |
| 162 | struct stat st; |
| 163 | if (stat(path.c_str(), &st) == 0 && S_ISREG(st.st_mode)) { |
| 164 | file_list.emplace_back(de->d_name); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | std::sort(file_list.begin(), file_list.end()); |
| 169 | return file_list; |
| 170 | } |
| 171 | |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 172 | void AddFilesToDir(const std::string& dir, const std::vector<std::string>& files) { |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 173 | std::string zeros(4096, 0); |
| 174 | for (const auto& file : files) { |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 175 | temporary_files_.push_back(dir + "/" + file); |
| 176 | ASSERT_TRUE(android::base::WriteStringToFile(zeros, temporary_files_.back())); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | |
| 180 | void SetUp() override { |
| 181 | Paths::Get().set_cache_log_directory(mock_log_dir.path); |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 182 | temporary_files_.clear(); |
| 183 | } |
| 184 | |
| 185 | void TearDown() override { |
| 186 | for (const auto& file : temporary_files_) { |
| 187 | ASSERT_TRUE(android::base::RemoveFileIfExists(file)); |
| 188 | } |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | // A mock method to calculate the free space. It assumes the partition has a total size of 40960 |
| 192 | // bytes and all files are 4096 bytes in size. |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 193 | static size_t MockFreeSpaceChecker(const std::string& dirname) { |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 194 | std::vector<std::string> files = FindFilesInDir(dirname); |
| 195 | return PARTITION_SIZE - 4096 * files.size(); |
| 196 | } |
| 197 | |
| 198 | TemporaryDir mock_cache; |
| 199 | TemporaryDir mock_log_dir; |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 200 | |
| 201 | private: |
| 202 | std::vector<std::string> temporary_files_; |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | TEST_F(FreeCacheTest, FreeCacheSmoke) { |
| 206 | std::vector<std::string> files = { "file1", "file2", "file3" }; |
| 207 | AddFilesToDir(mock_cache.path, files); |
| 208 | ASSERT_EQ(files, FindFilesInDir(mock_cache.path)); |
| 209 | ASSERT_EQ(4096 * 7, MockFreeSpaceChecker(mock_cache.path)); |
| 210 | |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 211 | ASSERT_TRUE(RemoveFilesInDirectory(4096 * 9, mock_cache.path, MockFreeSpaceChecker)); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 212 | |
| 213 | ASSERT_EQ(std::vector<std::string>{ "file3" }, FindFilesInDir(mock_cache.path)); |
| 214 | ASSERT_EQ(4096 * 9, MockFreeSpaceChecker(mock_cache.path)); |
| 215 | } |
| 216 | |
Tao Bao | 49750f1 | 2018-07-11 16:32:10 -0700 | [diff] [blame] | 217 | TEST_F(FreeCacheTest, FreeCacheFreeSpaceCheckerError) { |
| 218 | std::vector<std::string> files{ "file1", "file2", "file3" }; |
| 219 | AddFilesToDir(mock_cache.path, files); |
| 220 | ASSERT_EQ(files, FindFilesInDir(mock_cache.path)); |
| 221 | ASSERT_EQ(4096 * 7, MockFreeSpaceChecker(mock_cache.path)); |
| 222 | |
| 223 | ASSERT_FALSE( |
| 224 | RemoveFilesInDirectory(4096 * 9, mock_cache.path, [](const std::string&) { return -1; })); |
| 225 | } |
| 226 | |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 227 | TEST_F(FreeCacheTest, FreeCacheOpenFile) { |
| 228 | std::vector<std::string> files = { "file1", "file2" }; |
| 229 | AddFilesToDir(mock_cache.path, files); |
| 230 | ASSERT_EQ(files, FindFilesInDir(mock_cache.path)); |
| 231 | ASSERT_EQ(4096 * 8, MockFreeSpaceChecker(mock_cache.path)); |
| 232 | |
| 233 | std::string file1_path = mock_cache.path + "/file1"s; |
| 234 | android::base::unique_fd fd(open(file1_path.c_str(), O_RDONLY)); |
| 235 | |
| 236 | // file1 can't be deleted as it's opened by us. |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 237 | ASSERT_FALSE(RemoveFilesInDirectory(4096 * 10, mock_cache.path, MockFreeSpaceChecker)); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 238 | |
| 239 | ASSERT_EQ(std::vector<std::string>{ "file1" }, FindFilesInDir(mock_cache.path)); |
| 240 | } |
| 241 | |
| 242 | TEST_F(FreeCacheTest, FreeCacheLogsSmoke) { |
| 243 | std::vector<std::string> log_files = { "last_log", "last_log.1", "last_kmsg.2", "last_log.5", |
| 244 | "last_log.10" }; |
| 245 | AddFilesToDir(mock_log_dir.path, log_files); |
| 246 | ASSERT_EQ(4096 * 5, MockFreeSpaceChecker(mock_log_dir.path)); |
| 247 | |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 248 | ASSERT_TRUE(RemoveFilesInDirectory(4096 * 8, mock_log_dir.path, MockFreeSpaceChecker)); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 249 | |
| 250 | // Logs with a higher index will be deleted first |
| 251 | std::vector<std::string> expected = { "last_log", "last_log.1" }; |
| 252 | ASSERT_EQ(expected, FindFilesInDir(mock_log_dir.path)); |
| 253 | ASSERT_EQ(4096 * 8, MockFreeSpaceChecker(mock_log_dir.path)); |
| 254 | } |
| 255 | |
| 256 | TEST_F(FreeCacheTest, FreeCacheLogsStringComparison) { |
| 257 | std::vector<std::string> log_files = { "last_log.1", "last_kmsg.1", "last_log.not_number", |
| 258 | "last_kmsgrandom" }; |
| 259 | AddFilesToDir(mock_log_dir.path, log_files); |
| 260 | ASSERT_EQ(4096 * 6, MockFreeSpaceChecker(mock_log_dir.path)); |
| 261 | |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 262 | ASSERT_TRUE(RemoveFilesInDirectory(4096 * 9, mock_log_dir.path, MockFreeSpaceChecker)); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 263 | |
| 264 | // Logs with incorrect format will be deleted first; and the last_kmsg with the same index is |
| 265 | // deleted before last_log. |
| 266 | std::vector<std::string> expected = { "last_log.1" }; |
| 267 | ASSERT_EQ(expected, FindFilesInDir(mock_log_dir.path)); |
| 268 | ASSERT_EQ(4096 * 9, MockFreeSpaceChecker(mock_log_dir.path)); |
| 269 | } |
| 270 | |
| 271 | TEST_F(FreeCacheTest, FreeCacheLogsOtherFiles) { |
| 272 | std::vector<std::string> log_files = { "last_install", "command", "block.map", "last_log", |
| 273 | "last_kmsg.1" }; |
| 274 | AddFilesToDir(mock_log_dir.path, log_files); |
| 275 | ASSERT_EQ(4096 * 5, MockFreeSpaceChecker(mock_log_dir.path)); |
| 276 | |
Tao Bao | b1c5b62 | 2018-07-12 11:49:05 -0700 | [diff] [blame] | 277 | ASSERT_FALSE(RemoveFilesInDirectory(4096 * 8, mock_log_dir.path, MockFreeSpaceChecker)); |
Tao Bao | b8cb2e6 | 2018-07-06 12:14:36 -0700 | [diff] [blame] | 278 | |
| 279 | // Non log files in /cache/recovery won't be deleted. |
| 280 | std::vector<std::string> expected = { "block.map", "command", "last_install" }; |
| 281 | ASSERT_EQ(expected, FindFilesInDir(mock_log_dir.path)); |
| 282 | } |