| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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/stat.h> | 5 #include <sys/stat.h> |
| 6 #include <sys/types.h> | 6 #include <sys/types.h> |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 }; | 44 }; |
| 45 static const char* kTestDir; | 45 static const char* kTestDir; |
| 46 virtual void SetUp() { | 46 virtual void SetUp() { |
| 47 EXPECT_EQ(0, mkdir(kTestDir, 0755)); | 47 EXPECT_EQ(0, mkdir(kTestDir, 0755)); |
| 48 } | 48 } |
| 49 virtual void TearDown() { | 49 virtual void TearDown() { |
| 50 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir)); | 50 EXPECT_EQ(0, System(string("rm -rf ") + kTestDir)); |
| 51 } | 51 } |
| 52 vector<char> DoTest(vector<char> mbr_in, | 52 vector<char> DoTest(vector<char> mbr_in, |
| 53 const string& filename, | 53 const string& filename, |
| 54 uint32 test_flags); | 54 uint32_t test_flags); |
| 55 // first partition bootable, no others bootable | 55 // first partition bootable, no others bootable |
| 56 const vector<char> sample_mbr_; | 56 const vector<char> sample_mbr_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 const char* SetBootableFlagActionTest::kTestDir = | 59 const char* SetBootableFlagActionTest::kTestDir = |
| 60 "SetBootableFlagActionTestDir"; | 60 "SetBootableFlagActionTestDir"; |
| 61 | 61 |
| 62 SetBootableFlagActionTest::SetBootableFlagActionTest() | 62 SetBootableFlagActionTest::SetBootableFlagActionTest() |
| 63 : sample_mbr_(GenerateSampleMbr()) {} | 63 : sample_mbr_(GenerateSampleMbr()) {} |
| 64 | 64 |
| 65 vector<char> SetBootableFlagActionTest::DoTest(vector<char> mbr_in, | 65 vector<char> SetBootableFlagActionTest::DoTest(vector<char> mbr_in, |
| 66 const string& filename, | 66 const string& filename, |
| 67 uint32 flags) { | 67 uint32_t flags) { |
| 68 CHECK(!filename.empty()); | 68 CHECK(!filename.empty()); |
| 69 const string root_filename(filename.begin(), --filename.end()); | 69 const string root_filename(filename.begin(), --filename.end()); |
| 70 if (flags & WRITE_FILE) | 70 if (flags & WRITE_FILE) |
| 71 EXPECT_TRUE(WriteFileVector(root_filename, mbr_in)); | 71 EXPECT_TRUE(WriteFileVector(root_filename, mbr_in)); |
| 72 | 72 |
| 73 ActionProcessor processor; | 73 ActionProcessor processor; |
| 74 SetBootableFlagActionProcessorDelegate delegate; | 74 SetBootableFlagActionProcessorDelegate delegate; |
| 75 processor.set_delegate(&delegate); | 75 processor.set_delegate(&delegate); |
| 76 | 76 |
| 77 ObjectFeederAction<string> feeder_action; | 77 ObjectFeederAction<string> feeder_action; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 TEST_F(SetBootableFlagActionTest, NoInputObjectTest) { | 145 TEST_F(SetBootableFlagActionTest, NoInputObjectTest) { |
| 146 vector<char> actual_new_mbr = DoTest(sample_mbr_, | 146 vector<char> actual_new_mbr = DoTest(sample_mbr_, |
| 147 string(kTestDir) + | 147 string(kTestDir) + |
| 148 "SetBootableFlagActionTest.dev5", | 148 "SetBootableFlagActionTest.dev5", |
| 149 WRITE_FILE | SKIP_INPUT_OBJECT); | 149 WRITE_FILE | SKIP_INPUT_OBJECT); |
| 150 ExpectVectorsEq(sample_mbr_, actual_new_mbr); // no change | 150 ExpectVectorsEq(sample_mbr_, actual_new_mbr); // no change |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace chromeos_update_engine | 153 } // namespace chromeos_update_engine |
| OLD | NEW |