| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 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/types.h> | 5 #include <sys/types.h> |
| 6 #include <sys/stat.h> | 6 #include <sys/stat.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 |
| 9 #include <set> | 10 #include <set> |
| 10 #include <sstream> | 11 #include <sstream> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <utility> | 13 #include <utility> |
| 13 #include <vector> | 14 #include <vector> |
| 15 |
| 16 #include <base/logging.h> |
| 17 #include <base/string_util.h> |
| 14 #include <gtest/gtest.h> | 18 #include <gtest/gtest.h> |
| 15 #include "base/logging.h" | 19 |
| 16 #include "update_engine/cycle_breaker.h" | 20 #include "update_engine/cycle_breaker.h" |
| 17 #include "update_engine/delta_diff_generator.h" | 21 #include "update_engine/delta_diff_generator.h" |
| 18 #include "update_engine/delta_performer.h" | 22 #include "update_engine/delta_performer.h" |
| 19 #include "update_engine/extent_ranges.h" | 23 #include "update_engine/extent_ranges.h" |
| 20 #include "update_engine/graph_types.h" | 24 #include "update_engine/graph_types.h" |
| 21 #include "update_engine/graph_utils.h" | 25 #include "update_engine/graph_utils.h" |
| 22 #include "update_engine/subprocess.h" | 26 #include "update_engine/subprocess.h" |
| 23 #include "update_engine/test_utils.h" | 27 #include "update_engine/test_utils.h" |
| 24 #include "update_engine/topological_sort.h" | 28 #include "update_engine/topological_sort.h" |
| 25 #include "update_engine/utils.h" | 29 #include "update_engine/utils.h" |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 FillWithData(&temp_data); | 710 FillWithData(&temp_data); |
| 707 EXPECT_TRUE(WriteFileVector(temp_dir + kFilename, temp_data)); | 711 EXPECT_TRUE(WriteFileVector(temp_dir + kFilename, temp_data)); |
| 708 ScopedPathUnlinker filename_unlinker(temp_dir + kFilename); | 712 ScopedPathUnlinker filename_unlinker(temp_dir + kFilename); |
| 709 | 713 |
| 710 int fd; | 714 int fd; |
| 711 EXPECT_TRUE(utils::MakeTempFile("/tmp/AssignTempBlocksReuseTest.XXXXXX", | 715 EXPECT_TRUE(utils::MakeTempFile("/tmp/AssignTempBlocksReuseTest.XXXXXX", |
| 712 NULL, | 716 NULL, |
| 713 &fd)); | 717 &fd)); |
| 714 ScopedFdCloser fd_closer(&fd); | 718 ScopedFdCloser fd_closer(&fd); |
| 715 off_t data_file_size = 0; | 719 off_t data_file_size = 0; |
| 716 | 720 |
| 717 EXPECT_TRUE(DeltaDiffGenerator::AssignTempBlocks(&graph, | 721 EXPECT_TRUE(DeltaDiffGenerator::AssignTempBlocks(&graph, |
| 718 temp_dir, | 722 temp_dir, |
| 719 fd, | 723 fd, |
| 720 &data_file_size, | 724 &data_file_size, |
| 721 &op_indexes, | 725 &op_indexes, |
| 722 &reverse_op_indexes, | 726 &reverse_op_indexes, |
| 723 cuts)); | 727 cuts)); |
| 724 EXPECT_FALSE(graph[6].valid); | 728 EXPECT_FALSE(graph[6].valid); |
| 725 EXPECT_FALSE(graph[7].valid); | 729 EXPECT_FALSE(graph[7].valid); |
| 726 EXPECT_EQ(1, graph[1].op.src_extents_size()); | 730 EXPECT_EQ(1, graph[1].op.src_extents_size()); |
| 727 EXPECT_EQ(2, graph[1].op.src_extents(0).start_block()); | 731 EXPECT_EQ(2, graph[1].op.src_extents(0).start_block()); |
| 728 EXPECT_EQ(1, graph[1].op.src_extents(0).num_blocks()); | 732 EXPECT_EQ(1, graph[1].op.src_extents(0).num_blocks()); |
| 729 EXPECT_EQ(OP_REPLACE_BZ, graph[5].op.type()); | 733 EXPECT_EQ(OP_REPLACE_BZ, graph[5].op.type()); |
| 730 } | 734 } |
| 731 | 735 |
| 732 TEST_F(DeltaDiffGeneratorTest, CreateScratchNodeTest) { | 736 TEST_F(DeltaDiffGeneratorTest, CreateScratchNodeTest) { |
| 733 Vertex vertex; | 737 Vertex vertex; |
| 734 DeltaDiffGenerator::CreateScratchNode(12, 34, &vertex); | 738 DeltaDiffGenerator::CreateScratchNode(12, 34, &vertex); |
| 735 EXPECT_EQ(DeltaArchiveManifest_InstallOperation_Type_REPLACE_BZ, | 739 EXPECT_EQ(DeltaArchiveManifest_InstallOperation_Type_REPLACE_BZ, |
| 736 vertex.op.type()); | 740 vertex.op.type()); |
| 737 EXPECT_EQ(0, vertex.op.data_offset()); | 741 EXPECT_EQ(0, vertex.op.data_offset()); |
| 738 EXPECT_EQ(0, vertex.op.data_length()); | 742 EXPECT_EQ(0, vertex.op.data_length()); |
| 739 EXPECT_EQ(1, vertex.op.dst_extents_size()); | 743 EXPECT_EQ(1, vertex.op.dst_extents_size()); |
| 740 EXPECT_EQ(12, vertex.op.dst_extents(0).start_block()); | 744 EXPECT_EQ(12, vertex.op.dst_extents(0).start_block()); |
| 741 EXPECT_EQ(34, vertex.op.dst_extents(0).num_blocks()); | 745 EXPECT_EQ(34, vertex.op.dst_extents(0).num_blocks()); |
| 742 } | 746 } |
| 743 | 747 |
| 744 } // namespace chromeos_update_engine | 748 } // namespace chromeos_update_engine |
| OLD | NEW |