| Amin Hassani | 2379503 | 2020-11-24 14:38:55 -0800 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2020 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 <gtest/gtest.h> | 
|  | 18 |  | 
|  | 19 | #include "update_engine/payload_consumer/install_plan.h" | 
|  | 20 |  | 
|  | 21 | namespace chromeos_update_engine { | 
|  | 22 |  | 
|  | 23 | TEST(InstallPlanTest, Dump) { | 
|  | 24 | InstallPlan install_plan{ | 
|  | 25 | .download_url = "foo-download-url", | 
|  | 26 | .version = "foo-version", | 
|  | 27 | .payloads = {{ | 
|  | 28 | .payload_urls = {"url1", "url2"}, | 
|  | 29 | .metadata_signature = "foo-signature", | 
|  | 30 | .hash = {0xb2, 0xb3}, | 
|  | 31 | .fp = "foo-fp", | 
|  | 32 | .app_id = "foo-app-id", | 
|  | 33 | }}, | 
|  | 34 | .source_slot = BootControlInterface::kInvalidSlot, | 
|  | 35 | .target_slot = BootControlInterface::kInvalidSlot, | 
|  | 36 | .partitions = {{ | 
|  | 37 | .name = "foo-partition_name", | 
|  | 38 | .source_path = "foo-source-path", | 
|  | 39 | .source_hash = {0xb1, 0xb2}, | 
|  | 40 | .target_path = "foo-target-path", | 
| Kelvin Zhang | a9b5d8c | 2021-05-05 09:17:46 -0400 | [diff] [blame] | 41 | .readonly_target_path = "mountable-device", | 
| Amin Hassani | 2379503 | 2020-11-24 14:38:55 -0800 | [diff] [blame] | 42 | .target_hash = {0xb3, 0xb4}, | 
|  | 43 | .postinstall_path = "foo-path", | 
|  | 44 | .filesystem_type = "foo-type", | 
|  | 45 | }}, | 
|  | 46 | }; | 
|  | 47 |  | 
|  | 48 | EXPECT_EQ(install_plan.ToString(), | 
|  | 49 | R"(type: new_update | 
|  | 50 | version: foo-version | 
|  | 51 | source_slot: INVALID | 
|  | 52 | target_slot: INVALID | 
|  | 53 | initial url: foo-download-url | 
|  | 54 | hash_checks_mandatory: false | 
|  | 55 | powerwash_required: false | 
|  | 56 | switch_slot_on_reboot: true | 
|  | 57 | run_post_install: true | 
|  | 58 | is_rollback: false | 
|  | 59 | rollback_data_save_requested: false | 
|  | 60 | write_verity: true | 
|  | 61 | Partition: foo-partition_name | 
|  | 62 | source_size: 0 | 
|  | 63 | source_path: foo-source-path | 
|  | 64 | source_hash: B1B2 | 
|  | 65 | target_size: 0 | 
|  | 66 | target_path: foo-target-path | 
|  | 67 | target_hash: B3B4 | 
|  | 68 | run_postinstall: false | 
|  | 69 | postinstall_path: foo-path | 
| Kelvin Zhang | a9b5d8c | 2021-05-05 09:17:46 -0400 | [diff] [blame] | 70 | readonly_target_path: mountable-device | 
| Amin Hassani | 2379503 | 2020-11-24 14:38:55 -0800 | [diff] [blame] | 71 | filesystem_type: foo-type | 
|  | 72 | Payload: 0 | 
|  | 73 | urls: (url1,url2) | 
|  | 74 | size: 0 | 
|  | 75 | metadata_size: 0 | 
|  | 76 | metadata_signature: foo-signature | 
|  | 77 | hash: B2B3 | 
|  | 78 | type: unknown | 
|  | 79 | fingerprint: foo-fp | 
|  | 80 | app_id: foo-app-id | 
|  | 81 | already_applied: false)"); | 
|  | 82 | } | 
|  | 83 |  | 
|  | 84 | }  // namespace chromeos_update_engine |