| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <sys/mount.h> | 5 #include <sys/mount.h> |
| 6 #include <inttypes.h> | 6 #include <inttypes.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 unmounter_.reset(new ScopedFilesystemUnmounter(*mnt_path)); | 67 unmounter_.reset(new ScopedFilesystemUnmounter(*mnt_path)); |
| 68 } | 68 } |
| 69 private: | 69 private: |
| 70 scoped_ptr<ScopedDirRemover> dir_remover_; | 70 scoped_ptr<ScopedDirRemover> dir_remover_; |
| 71 scoped_ptr<ScopedLoopbackDeviceReleaser> loop_releaser_; | 71 scoped_ptr<ScopedLoopbackDeviceReleaser> loop_releaser_; |
| 72 scoped_ptr<ScopedFilesystemUnmounter> unmounter_; | 72 scoped_ptr<ScopedFilesystemUnmounter> unmounter_; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 void CompareFilesByBlock(const string& a_file, const string& b_file) { | 75 void CompareFilesByBlock(const string& a_file, const string& b_file) { |
| 76 vector<char> a_data, b_data; | 76 vector<char> a_data, b_data; |
| 77 EXPECT_TRUE(utils::ReadFile(a_file, &a_data)); | 77 EXPECT_TRUE(utils::ReadFile(a_file, &a_data)) << "file failed: " << a_file; |
| 78 EXPECT_TRUE(utils::ReadFile(b_file, &b_data)); | 78 EXPECT_TRUE(utils::ReadFile(b_file, &b_data)) << "file failed: " << b_file; |
| 79 | 79 |
| 80 EXPECT_EQ(a_data.size(), b_data.size()); | 80 EXPECT_EQ(a_data.size(), b_data.size()); |
| 81 size_t kBlockSize = 4096; | 81 size_t kBlockSize = 4096; |
| 82 EXPECT_EQ(0, a_data.size() % kBlockSize); | 82 EXPECT_EQ(0, a_data.size() % kBlockSize); |
| 83 for (size_t i = 0; i < a_data.size(); i += kBlockSize) { | 83 for (size_t i = 0; i < a_data.size(); i += kBlockSize) { |
| 84 EXPECT_EQ(0, i % kBlockSize); | 84 EXPECT_EQ(0, i % kBlockSize); |
| 85 vector<char> a_sub(&a_data[i], &a_data[i + kBlockSize]); | 85 vector<char> a_sub(&a_data[i], &a_data[i + kBlockSize]); |
| 86 vector<char> b_sub(&b_data[i], &b_data[i + kBlockSize]); | 86 vector<char> b_sub(&b_data[i], &b_data[i + kBlockSize]); |
| 87 EXPECT_TRUE(a_sub == b_sub) << "Block " << (i/kBlockSize) << " differs"; | 87 EXPECT_TRUE(a_sub == b_sub) << "Block " << (i/kBlockSize) << " differs"; |
| 88 } | 88 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 CompareFilesByBlock(old_kernel, new_kernel); | 217 CompareFilesByBlock(old_kernel, new_kernel); |
| 218 | 218 |
| 219 vector<char> updated_kernel_partition; | 219 vector<char> updated_kernel_partition; |
| 220 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition)); | 220 EXPECT_TRUE(utils::ReadFile(old_kernel, &updated_kernel_partition)); |
| 221 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string, | 221 EXPECT_EQ(0, strncmp(&updated_kernel_partition[0], new_data_string, |
| 222 strlen(new_data_string))); | 222 strlen(new_data_string))); |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace chromeos_update_engine | 225 } // namespace chromeos_update_engine |
| OLD | NEW |