payload_generation_config_unittest.cc revision 05feee0fc8f4f10b425f04e1f5cdd4831bbfb969
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 21namespace chromeos_update_engine { 22 23class PayloadGenerationConfigTest : public ::testing::Test {}; 24 25TEST_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")); 33 EXPECT_TRUE(image_config.LoadPostInstallConfig(store)); 34 EXPECT_FALSE(image_config.partitions[0].postinstall.IsEmpty()); 35 EXPECT_EQ(true, image_config.partitions[0].postinstall.run); 36 EXPECT_EQ("postinstall", image_config.partitions[0].postinstall.path); 37 EXPECT_EQ("ext4", image_config.partitions[0].postinstall.filesystem_type); 38} 39 40TEST_F(PayloadGenerationConfigTest, LoadPostInstallConfigNameMismatchTest) { 41 ImageConfig image_config; 42 image_config.partitions.emplace_back("system"); 43 brillo::KeyValueStore store; 44 EXPECT_TRUE( 45 store.LoadFromString("RUN_POSTINSTALL_root=true\n" 46 "POSTINSTALL_PATH_root=postinstall\n" 47 "FILESYSTEM_TYPE_root=ext4")); 48 EXPECT_FALSE(image_config.LoadPostInstallConfig(store)); 49 EXPECT_TRUE(image_config.partitions[0].postinstall.IsEmpty()); 50} 51 52} // namespace chromeos_update_engine 53