| 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 20 matching lines...) Expand all Loading... |
| 31 using std::min; | 31 using std::min; |
| 32 using std::string; | 32 using std::string; |
| 33 using std::vector; | 33 using std::vector; |
| 34 using testing::_; | 34 using testing::_; |
| 35 using testing::Return; | 35 using testing::Return; |
| 36 | 36 |
| 37 extern const char* kUnittestPrivateKeyPath; | 37 extern const char* kUnittestPrivateKeyPath; |
| 38 extern const char* kUnittestPublicKeyPath; | 38 extern const char* kUnittestPublicKeyPath; |
| 39 | 39 |
| 40 namespace { | 40 namespace { |
| 41 const size_t kBlockSize = 4096; | 41 const size_t kBlockSize = 4096; |
| 42 } // namespace {} | 42 } // namespace {} |
| 43 | 43 |
| 44 | 44 |
| 45 class DeltaPerformerTest : public ::testing::Test { }; | 45 class DeltaPerformerTest : public ::testing::Test { }; |
| 46 | 46 |
| 47 TEST(DeltaPerformerTest, ExtentsToByteStringTest) { | 47 TEST(DeltaPerformerTest, ExtentsToByteStringTest) { |
| 48 uint64_t test[] = {1, 1, 4, 2, kSparseHole, 1, 0, 1}; | 48 uint64_t test[] = {1, 1, 4, 2, kSparseHole, 1, 0, 1}; |
| 49 COMPILE_ASSERT(arraysize(test) % 2 == 0, array_size_uneven); | 49 COMPILE_ASSERT(arraysize(test) % 2 == 0, array_size_uneven); |
| 50 const uint64_t block_size = 4096; | 50 const uint64_t block_size = 4096; |
| 51 const uint64_t file_length = 5 * block_size - 13; | 51 const uint64_t file_length = 5 * block_size - 13; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 b_mnt.c_str()).c_str())); | 249 b_mnt.c_str()).c_str())); |
| 250 EXPECT_EQ(0, system(StringPrintf("echo foo > %s/foo", | 250 EXPECT_EQ(0, system(StringPrintf("echo foo > %s/foo", |
| 251 b_mnt.c_str()).c_str())); | 251 b_mnt.c_str()).c_str())); |
| 252 EXPECT_EQ(0, system(StringPrintf("touch %s/emptyfile", | 252 EXPECT_EQ(0, system(StringPrintf("touch %s/emptyfile", |
| 253 b_mnt.c_str()).c_str())); | 253 b_mnt.c_str()).c_str())); |
| 254 EXPECT_TRUE(WriteSparseFile(StringPrintf("%s/fullsparse", b_mnt.c_str()), | 254 EXPECT_TRUE(WriteSparseFile(StringPrintf("%s/fullsparse", b_mnt.c_str()), |
| 255 1024 * 1024)); | 255 1024 * 1024)); |
| 256 EXPECT_EQ(0, system(StringPrintf("dd if=/dev/zero of=%s/partsparese bs=1 " | 256 EXPECT_EQ(0, system(StringPrintf("dd if=/dev/zero of=%s/partsparese bs=1 " |
| 257 "seek=4096 count=1", | 257 "seek=4096 count=1", |
| 258 b_mnt.c_str()).c_str())); | 258 b_mnt.c_str()).c_str())); |
| 259 EXPECT_EQ(0, system(StringPrintf("cp %s/srchardlink0 %s/tmp && " |
| 260 "mv %s/tmp %s/srchardlink1", |
| 261 b_mnt.c_str(), b_mnt.c_str(), |
| 262 b_mnt.c_str(), b_mnt.c_str()).c_str())); |
| 259 EXPECT_TRUE(utils::WriteFile(StringPrintf("%s/hardtocompress", | 263 EXPECT_TRUE(utils::WriteFile(StringPrintf("%s/hardtocompress", |
| 260 b_mnt.c_str()).c_str(), | 264 b_mnt.c_str()).c_str(), |
| 261 reinterpret_cast<const char*>(kRandomString), | 265 reinterpret_cast<const char*>(kRandomString), |
| 262 sizeof(kRandomString))); | 266 sizeof(kRandomString))); |
| 263 } | 267 } |
| 264 | 268 |
| 265 string old_kernel; | 269 string old_kernel; |
| 266 EXPECT_TRUE(utils::MakeTempFile("/tmp/old_kernel.XXXXXX", &old_kernel, NULL)); | 270 EXPECT_TRUE(utils::MakeTempFile("/tmp/old_kernel.XXXXXX", &old_kernel, NULL)); |
| 267 ScopedPathUnlinker old_kernel_unlinker(old_kernel); | 271 ScopedPathUnlinker old_kernel_unlinker(old_kernel); |
| 268 | 272 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 op.clear_src_extents(); | 530 op.clear_src_extents(); |
| 527 *(op.add_src_extents()) = ExtentForRange(5, 3); | 531 *(op.add_src_extents()) = ExtentForRange(5, 3); |
| 528 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); | 532 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); |
| 529 *(op.add_dst_extents()) = ExtentForRange(20, 6); | 533 *(op.add_dst_extents()) = ExtentForRange(20, 6); |
| 530 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); | 534 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); |
| 531 *(op.add_src_extents()) = ExtentForRange(19, 2); | 535 *(op.add_src_extents()) = ExtentForRange(19, 2); |
| 532 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op)); | 536 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op)); |
| 533 } | 537 } |
| 534 | 538 |
| 535 } // namespace chromeos_update_engine | 539 } // namespace chromeos_update_engine |
| OLD | NEW |