1 // 2 // Copyright (C) 2015 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #include "update_engine/payload_generator/payload_generation_config.h" 18 19 #include <gtest/gtest.h> 20 21 namespace chromeos_update_engine { 22 23 class PayloadGenerationConfigTest : public ::testing::Test {}; 24 25 TEST_F(PayloadGenerationConfigTest, SimpleLoadPostInstallConfigTest) { 26 ImageConfig image_config; 27 image_config.partitions.emplace_back("root"); 28 brillo::KeyValueStore store; 29 EXPECT_TRUE( 30 store.LoadFromString("RUN_POSTINSTALL_root=true\n" 31 "POSTINSTALL_PATH_root=postinstall\n" 32 "FILESYSTEM_TYPE_root=ext4\n" 33 "POSTINSTALL_OPTIONAL_root=true")); 34 EXPECT_TRUE(image_config.LoadPostInstallConfig(store)); 35 EXPECT_FALSE(image_config.partitions[0].postinstall.IsEmpty()); 36 EXPECT_EQ(true, image_config.partitions[0].postinstall.run); 37 EXPECT_EQ("postinstall", image_config.partitions[0].postinstall.path); 38 EXPECT_EQ("ext4", image_config.partitions[0].postinstall.filesystem_type); 39 EXPECT_TRUE(image_config.partitions[0].postinstall.optional); 40 } 41 42 TEST_F(PayloadGenerationConfigTest, LoadPostInstallConfigNameMismatchTest) { 43 ImageConfig image_config; 44 image_config.partitions.emplace_back("system"); 45 brillo::KeyValueStore store; 46 EXPECT_TRUE( 47 store.LoadFromString("RUN_POSTINSTALL_root=true\n" 48 "POSTINSTALL_PATH_root=postinstall\n" 49 "FILESYSTEM_TYPE_root=ext4")); 50 EXPECT_FALSE(image_config.LoadPostInstallConfig(store)); 51 EXPECT_TRUE(image_config.partitions[0].postinstall.IsEmpty()); 52 } 53 54 } // namespace chromeos_update_engine 55