Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 1 | // Copyright 2016 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 5 | #include "imageloader_impl.h" |
| 6 | |
Greg Kerr | 6a5ee86 | 2016-10-19 11:32:43 -0700 | [diff] [blame] | 7 | #include <stdint.h> |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 8 | |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 9 | #include <list> |
Ben Chan | ea104dd | 2017-09-29 00:43:04 -0700 | [diff] [blame^] | 10 | #include <memory> |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 11 | #include <string> |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 12 | #include <vector> |
| 13 | |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 14 | #include "component.h" |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 15 | #include "mock_helper_process.h" |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 16 | #include "test_utilities.h" |
Greg Kerr | 2f76fde | 2016-08-29 16:39:45 -0700 | [diff] [blame] | 17 | #include "verity_mounter.h" |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 18 | |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 19 | #include <base/files/file_path.h> |
| 20 | #include <base/files/file_util.h> |
| 21 | #include <base/files/scoped_temp_dir.h> |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 22 | #include <gmock/gmock.h> |
| 23 | #include <gtest/gtest.h> |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 24 | |
| 25 | namespace imageloader { |
| 26 | |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 27 | using testing::_; |
| 28 | |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 29 | class ImageLoaderTest : public testing::Test { |
| 30 | public: |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 31 | ImageLoaderTest() { |
| 32 | CHECK(scoped_temp_dir_.CreateUniqueTempDir()); |
| 33 | temp_dir_ = scoped_temp_dir_.path(); |
| 34 | CHECK(base::SetPosixFilePermissions(temp_dir_, kComponentDirPerms)); |
| 35 | } |
| 36 | |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 37 | ImageLoaderConfig GetConfig(const char* path) { |
Eric Caruso | 0b79bc8 | 2017-03-21 13:44:34 -0700 | [diff] [blame] | 38 | Keys keys; |
| 39 | keys.push_back(std::vector<uint8_t>(std::begin(kDevPublicKey), |
| 40 | std::end(kDevPublicKey))); |
| 41 | keys.push_back(std::vector<uint8_t>(std::begin(kOciDevPublicKey), |
| 42 | std::end(kOciDevPublicKey))); |
| 43 | ImageLoaderConfig config(keys, path, "/foo"); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 44 | return config; |
| 45 | } |
| 46 | |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 47 | base::ScopedTempDir scoped_temp_dir_; |
| 48 | base::FilePath temp_dir_; |
Greg Kerr | 3e750f4 | 2016-06-29 15:20:21 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 51 | // Test the RegisterComponent public interface. |
| 52 | TEST_F(ImageLoaderTest, RegisterComponentAndGetVersion) { |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 53 | ImageLoaderImpl loader(GetConfig(temp_dir_.value().c_str())); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 54 | ASSERT_TRUE(loader.RegisterComponent(kTestComponentName, kTestDataVersion, |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 55 | GetTestComponentPath().value())); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 56 | |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 57 | base::FilePath comp_dir = temp_dir_.Append(kTestComponentName); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 58 | ASSERT_TRUE(base::DirectoryExists(comp_dir)); |
| 59 | |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 60 | base::FilePath hint_file = comp_dir.Append("latest-version"); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 61 | ASSERT_TRUE(base::PathExists(hint_file)); |
| 62 | |
| 63 | std::string hint_file_contents; |
| 64 | ASSERT_TRUE( |
| 65 | base::ReadFileToStringWithMaxSize(hint_file, &hint_file_contents, 4096)); |
| 66 | EXPECT_EQ(kTestDataVersion, hint_file_contents); |
| 67 | |
| 68 | base::FilePath version_dir = comp_dir.Append(kTestDataVersion); |
| 69 | ASSERT_TRUE(base::DirectoryExists(version_dir)); |
| 70 | |
Greg Kerr | f50e24a | 2017-01-06 17:12:32 -0800 | [diff] [blame] | 71 | // Make sure it actually checks the reported version against the real version. |
| 72 | EXPECT_FALSE(loader.RegisterComponent(kTestComponentName, kTestUpdatedVersion, |
| 73 | GetTestComponentPath().value())); |
| 74 | |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 75 | // Now copy a new version into place. |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 76 | EXPECT_TRUE( |
| 77 | loader.RegisterComponent(kTestComponentName, kTestUpdatedVersion, |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 78 | GetTestComponentPath(kTestUpdatedVersion).value())); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 79 | |
| 80 | std::string hint_file_contents2; |
| 81 | ASSERT_TRUE( |
| 82 | base::ReadFileToStringWithMaxSize(hint_file, &hint_file_contents2, 4096)); |
| 83 | EXPECT_EQ(kTestUpdatedVersion, hint_file_contents2); |
| 84 | |
| 85 | base::FilePath version_dir2 = comp_dir.Append(kTestUpdatedVersion); |
| 86 | ASSERT_TRUE(base::DirectoryExists(version_dir2)); |
| 87 | |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 88 | EXPECT_EQ(kTestUpdatedVersion, |
| 89 | loader.GetComponentVersion(kTestComponentName)); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 90 | |
| 91 | // Reject rollback to an older version. |
| 92 | EXPECT_FALSE(loader.RegisterComponent(kTestComponentName, kTestDataVersion, |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 93 | GetTestComponentPath().value())); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 94 | |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 95 | EXPECT_EQ(kTestUpdatedVersion, |
| 96 | loader.GetComponentVersion(kTestComponentName)); |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Greg Kerr | 1c7403c | 2016-11-11 11:57:44 -0800 | [diff] [blame] | 99 | // Pretend ImageLoader crashed, by creating an incomplete installation, and then |
| 100 | // attempt registration with ImageLoader. |
| 101 | TEST_F(ImageLoaderTest, RegisterComponentAfterCrash) { |
Greg Kerr | 1c7403c | 2016-11-11 11:57:44 -0800 | [diff] [blame] | 102 | // Now create the junk there. |
| 103 | const std::string junk_contents ="Bad file contents"; |
| 104 | const base::FilePath junk_path = |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 105 | temp_dir_.Append(kTestComponentName).Append(kTestDataVersion); |
Greg Kerr | 1c7403c | 2016-11-11 11:57:44 -0800 | [diff] [blame] | 106 | ASSERT_TRUE(base::CreateDirectory(junk_path)); |
| 107 | ASSERT_EQ(static_cast<int>(junk_contents.size()), |
| 108 | base::WriteFile(junk_path.Append("junkfile"), junk_contents.data(), |
| 109 | junk_contents.size())); |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 110 | ImageLoaderImpl loader(GetConfig(temp_dir_.value().c_str())); |
Greg Kerr | 1c7403c | 2016-11-11 11:57:44 -0800 | [diff] [blame] | 111 | ASSERT_TRUE(loader.RegisterComponent(kTestComponentName, kTestDataVersion, |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 112 | GetTestComponentPath().value())); |
Greg Kerr | 4bd7813 | 2016-07-19 11:51:16 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 115 | TEST_F(ImageLoaderTest, MountValidImage) { |
Eric Caruso | 0b79bc8 | 2017-03-21 13:44:34 -0700 | [diff] [blame] | 116 | Keys keys; |
| 117 | keys.push_back(std::vector<uint8_t>(std::begin(kDevPublicKey), |
| 118 | std::end(kDevPublicKey))); |
| 119 | |
Ben Chan | ea104dd | 2017-09-29 00:43:04 -0700 | [diff] [blame^] | 120 | auto helper_mock = std::make_unique<MockHelperProcess>(); |
Xiaochu Liu | c226434 | 2017-08-14 16:37:42 -0700 | [diff] [blame] | 121 | EXPECT_CALL(*helper_mock, SendMountCommand(_, _, FileSystem::kSquashFS, _)) |
| 122 | .Times(2); |
| 123 | ON_CALL(*helper_mock, SendMountCommand(_, _, _, _)) |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 124 | .WillByDefault(testing::Return(true)); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 125 | |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 126 | base::ScopedTempDir scoped_mount_dir; |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 127 | ASSERT_TRUE(scoped_mount_dir.CreateUniqueTempDir()); |
| 128 | |
Eric Caruso | 0b79bc8 | 2017-03-21 13:44:34 -0700 | [diff] [blame] | 129 | ImageLoaderConfig config(keys, temp_dir_.value().c_str(), |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 130 | scoped_mount_dir.path().value().c_str()); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 131 | ImageLoaderImpl loader(std::move(config)); |
| 132 | |
| 133 | // We previously tested RegisterComponent, so assume this works if it reports |
| 134 | // true. |
| 135 | ASSERT_TRUE(loader.RegisterComponent(kTestComponentName, kTestDataVersion, |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 136 | GetTestComponentPath().value())); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 137 | |
| 138 | const std::string expected_path = |
| 139 | scoped_mount_dir.path().value() + "/PepperFlashPlayer/22.0.0.158"; |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 140 | EXPECT_EQ(expected_path, |
| 141 | loader.LoadComponent(kTestComponentName, helper_mock.get())); |
Greg Kerr | c5b9169 | 2016-09-14 12:09:22 -0700 | [diff] [blame] | 142 | |
| 143 | // Let's also test mounting the component at a fixed point. |
| 144 | const std::string expected_path2 = |
| 145 | scoped_mount_dir.path().value() + "/FixedMountPoint"; |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 146 | EXPECT_TRUE(loader.LoadComponent(kTestComponentName, expected_path2, |
| 147 | helper_mock.get())); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Greg Kerr | 772abab | 2017-06-16 14:51:01 -0700 | [diff] [blame] | 150 | TEST_F(ImageLoaderTest, LoadComponentAtPath) { |
| 151 | Keys keys; |
| 152 | keys.push_back( |
| 153 | std::vector<uint8_t>(std::begin(kDevPublicKey), std::end(kDevPublicKey))); |
| 154 | |
Ben Chan | ea104dd | 2017-09-29 00:43:04 -0700 | [diff] [blame^] | 155 | auto helper_mock = std::make_unique<MockHelperProcess>(); |
Xiaochu Liu | c226434 | 2017-08-14 16:37:42 -0700 | [diff] [blame] | 156 | EXPECT_CALL(*helper_mock, SendMountCommand(_, _, FileSystem::kSquashFS, _)) |
| 157 | .Times(1); |
| 158 | ON_CALL(*helper_mock, SendMountCommand(_, _, _, _)) |
Greg Kerr | 772abab | 2017-06-16 14:51:01 -0700 | [diff] [blame] | 159 | .WillByDefault(testing::Return(true)); |
| 160 | |
| 161 | base::ScopedTempDir scoped_mount_dir; |
| 162 | ASSERT_TRUE(scoped_mount_dir.CreateUniqueTempDir()); |
| 163 | |
| 164 | ImageLoaderConfig config(keys, temp_dir_.value().c_str(), |
| 165 | scoped_mount_dir.path().value().c_str()); |
| 166 | ImageLoaderImpl loader(std::move(config)); |
| 167 | |
| 168 | const std::string expected_path = |
| 169 | scoped_mount_dir.path().value() + "/PepperFlashPlayer/22.0.0.158"; |
| 170 | const std::string mnt_path = loader.LoadComponentAtPath( |
| 171 | kTestComponentName, GetTestComponentPath(), helper_mock.get()); |
| 172 | EXPECT_EQ(expected_path, mnt_path); |
| 173 | } |
| 174 | |
Xiaochu Liu | c226434 | 2017-08-14 16:37:42 -0700 | [diff] [blame] | 175 | TEST_F(ImageLoaderTest, LoadExt4Image) { |
Greg Kerr | e870420 | 2017-07-27 12:54:31 -0700 | [diff] [blame] | 176 | Keys keys; |
Xiaochu Liu | c226434 | 2017-08-14 16:37:42 -0700 | [diff] [blame] | 177 | keys.push_back( |
| 178 | std::vector<uint8_t>(std::begin(kDevPublicKey), std::end(kDevPublicKey))); |
Greg Kerr | e870420 | 2017-07-27 12:54:31 -0700 | [diff] [blame] | 179 | |
Ben Chan | ea104dd | 2017-09-29 00:43:04 -0700 | [diff] [blame^] | 180 | auto helper_mock = std::make_unique<MockHelperProcess>(); |
Xiaochu Liu | c226434 | 2017-08-14 16:37:42 -0700 | [diff] [blame] | 181 | EXPECT_CALL(*helper_mock, SendMountCommand(_, _, FileSystem::kExt4, _)) |
| 182 | .Times(1); |
| 183 | ON_CALL(*helper_mock, SendMountCommand(_, _, _, _)) |
| 184 | .WillByDefault(testing::Return(true)); |
| 185 | |
| 186 | base::ScopedTempDir scoped_mount_dir; |
| 187 | ASSERT_TRUE(scoped_mount_dir.CreateUniqueTempDir()); |
| 188 | |
| 189 | ImageLoaderConfig config(keys, temp_dir_.value().c_str(), |
| 190 | scoped_mount_dir.path().value().c_str()); |
| 191 | ImageLoaderImpl loader(std::move(config)); |
| 192 | |
| 193 | const std::string expected_path = |
| 194 | scoped_mount_dir.path().value() + "/ext4/1.6.10.10"; |
| 195 | const std::string mnt_path = loader.LoadComponentAtPath( |
| 196 | "ext4", GetTestDataPath("ext4_component"), helper_mock.get()); |
| 197 | EXPECT_EQ(expected_path, mnt_path); |
| 198 | } |
| 199 | |
| 200 | TEST_F(ImageLoaderTest, MountInvalidImage) { |
| 201 | Keys keys; |
| 202 | keys.push_back( |
| 203 | std::vector<uint8_t>(std::begin(kDevPublicKey), std::end(kDevPublicKey))); |
| 204 | |
Ben Chan | ea104dd | 2017-09-29 00:43:04 -0700 | [diff] [blame^] | 205 | auto helper_mock = std::make_unique<MockHelperProcess>(); |
Xiaochu Liu | c226434 | 2017-08-14 16:37:42 -0700 | [diff] [blame] | 206 | EXPECT_CALL(*helper_mock, SendMountCommand(_, _, FileSystem::kSquashFS, _)) |
| 207 | .Times(0); |
| 208 | ON_CALL(*helper_mock, SendMountCommand(_, _, _, _)) |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 209 | .WillByDefault(testing::Return(true)); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 210 | |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 211 | base::ScopedTempDir scoped_mount_dir; |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 212 | ASSERT_TRUE(scoped_mount_dir.CreateUniqueTempDir()); |
| 213 | |
Eric Caruso | 0b79bc8 | 2017-03-21 13:44:34 -0700 | [diff] [blame] | 214 | ImageLoaderConfig config(keys, temp_dir_.value().c_str(), |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 215 | scoped_mount_dir.path().value().c_str()); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 216 | ImageLoaderImpl loader(std::move(config)); |
| 217 | |
| 218 | // We previously tested RegisterComponent, so assume this works if it reports |
| 219 | // true. |
| 220 | ASSERT_TRUE(loader.RegisterComponent(kTestComponentName, kTestDataVersion, |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 221 | GetTestComponentPath().value())); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 222 | |
Greg Kerr | 019d59c | 2016-11-17 14:28:49 -0800 | [diff] [blame] | 223 | base::FilePath table = temp_dir_.Append(kTestComponentName) |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 224 | .Append(kTestDataVersion) |
Greg Kerr | 30cd5fb | 2016-09-29 12:37:02 -0700 | [diff] [blame] | 225 | .Append("table"); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 226 | std::string contents = "corrupt"; |
| 227 | ASSERT_EQ(static_cast<int>(contents.size()), |
Greg Kerr | 30cd5fb | 2016-09-29 12:37:02 -0700 | [diff] [blame] | 228 | base::WriteFile(table, contents.data(), contents.size())); |
Greg Kerr | 9944e24 | 2017-01-26 15:09:31 -0800 | [diff] [blame] | 229 | ASSERT_EQ("", loader.LoadComponent(kTestComponentName, helper_mock.get())); |
Greg Kerr | 89be05f | 2016-07-27 10:40:32 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Greg Kerr | 2f76fde | 2016-08-29 16:39:45 -0700 | [diff] [blame] | 232 | TEST_F(ImageLoaderTest, SetupTable) { |
| 233 | std::string base_table = "0 40 verity payload=ROOT_DEV hashtree=HASH_DEV " |
| 234 | "hashstart=40 alg=sha256 root_hexdigest=" |
| 235 | "34663b9920632778d38a0943a5472cae196bd4bf1d7dfa191506e7a8e7ec84d2 " |
| 236 | "salt=fcfc9b5a329e44be73a323188ae75ca644122d920161f672f6935623831d07e2"; |
| 237 | |
| 238 | // Make sure excess newlines are rejected. |
| 239 | std::string bad_table = base_table + "\n\n"; |
| 240 | EXPECT_FALSE(VerityMounter::SetupTable(&bad_table, "/dev/loop6")); |
| 241 | |
| 242 | // Make sure it does the right replacements on a simple base table. |
| 243 | std::string good_table = base_table; |
| 244 | EXPECT_TRUE(VerityMounter::SetupTable(&good_table, "/dev/loop6")); |
| 245 | |
| 246 | std::string known_good_table = |
| 247 | "0 40 verity payload=/dev/loop6 hashtree=/dev/loop6 " |
| 248 | "hashstart=40 alg=sha256 root_hexdigest=" |
| 249 | "34663b9920632778d38a0943a5472cae196bd4bf1d7dfa191506e7a8e7ec84d2 " |
| 250 | "salt=fcfc9b5a329e44be73a323188ae75ca644122d920161f672f6935623831d07e2 " |
| 251 | "error_behavior=eio"; |
| 252 | EXPECT_EQ(known_good_table, good_table); |
| 253 | |
| 254 | // Make sure the newline is stripped. |
| 255 | std::string good_table_newline = base_table + "\n"; |
| 256 | EXPECT_TRUE(VerityMounter::SetupTable(&good_table_newline, "/dev/loop6")); |
| 257 | EXPECT_EQ(known_good_table, good_table_newline); |
| 258 | |
| 259 | // Make sure error_behavior isn't appended twice. |
| 260 | std::string good_table_error = base_table + " error_behavior=eio\n"; |
| 261 | EXPECT_TRUE(VerityMounter::SetupTable(&good_table_error, "/dev/loop6")); |
| 262 | EXPECT_EQ(known_good_table, good_table_error); |
| 263 | } |
| 264 | |
Eric Caruso | 0b79bc8 | 2017-03-21 13:44:34 -0700 | [diff] [blame] | 265 | TEST_F(ImageLoaderTest, SecondKey) { |
| 266 | ImageLoaderImpl loader(GetConfig(temp_dir_.value().c_str())); |
| 267 | ASSERT_TRUE(loader.RegisterComponent(kTestOciComponentName, |
| 268 | kTestOciComponentVersion, |
| 269 | GetTestOciComponentPath().value())); |
| 270 | |
| 271 | base::FilePath comp_dir = temp_dir_.Append(kTestOciComponentName); |
| 272 | ASSERT_TRUE(base::DirectoryExists(comp_dir)); |
| 273 | |
| 274 | base::FilePath version_dir = comp_dir.Append(kTestOciComponentVersion); |
| 275 | ASSERT_TRUE(base::DirectoryExists(version_dir)); |
| 276 | } |
| 277 | |
Greg Kerr | a6c0c52 | 2016-07-25 11:15:31 -0700 | [diff] [blame] | 278 | } // namespace imageloader |