Jihoon Kang | 98047cf | 2024-10-02 17:13:54 +0000 | [diff] [blame] | 1 | // Copyright 2024 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package fsgen |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "android/soong/filesystem" |
| 20 | "testing" |
| 21 | |
| 22 | "github.com/google/blueprint/proptools" |
| 23 | ) |
| 24 | |
| 25 | var prepareForTestWithFsgenBuildComponents = android.FixtureRegisterWithContext(registerBuildComponents) |
| 26 | |
| 27 | func TestFileSystemCreatorSystemImageProps(t *testing.T) { |
| 28 | result := android.GroupFixturePreparers( |
| 29 | android.PrepareForIntegrationTestWithAndroid, |
| 30 | android.PrepareForTestWithAndroidBuildComponents, |
| 31 | filesystem.PrepareForTestWithFilesystemBuildComponents, |
| 32 | prepareForTestWithFsgenBuildComponents, |
| 33 | android.FixtureModifyConfig(func(config android.Config) { |
| 34 | config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.BoardAvbEnable = true |
| 35 | config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables = |
| 36 | map[string]android.PartitionQualifiedVariablesType{ |
| 37 | "system": { |
| 38 | BoardAvbKeyPath: "external/avb/test/data/testkey_rsa4096.pem", |
| 39 | BoardAvbAlgorithm: "SHA256_RSA4096", |
| 40 | BoardAvbRollbackIndex: "0", |
| 41 | BoardFileSystemType: "ext4", |
| 42 | }, |
| 43 | } |
| 44 | }), |
| 45 | android.FixtureMergeMockFs(android.MockFS{ |
| 46 | "external/avb/test/data/testkey_rsa4096.pem": nil, |
Cole Faust | 92ccbe2 | 2024-10-03 14:38:37 -0700 | [diff] [blame^] | 47 | "build/soong/fsgen/Android.bp": []byte(` |
| 48 | soong_filesystem_creator { |
| 49 | name: "foo", |
| 50 | } |
| 51 | `), |
Jihoon Kang | 98047cf | 2024-10-02 17:13:54 +0000 | [diff] [blame] | 52 | }), |
Cole Faust | 92ccbe2 | 2024-10-03 14:38:37 -0700 | [diff] [blame^] | 53 | ).RunTest(t) |
Jihoon Kang | 98047cf | 2024-10-02 17:13:54 +0000 | [diff] [blame] | 54 | |
| 55 | fooSystem := result.ModuleForTests("test_product_generated_system_image", "android_common").Module().(interface { |
| 56 | FsProps() filesystem.FilesystemProperties |
| 57 | }) |
| 58 | android.AssertBoolEquals( |
| 59 | t, |
| 60 | "Property expected to match the product variable 'BOARD_AVB_ENABLE'", |
| 61 | true, |
| 62 | proptools.Bool(fooSystem.FsProps().Use_avb), |
| 63 | ) |
| 64 | android.AssertStringEquals( |
| 65 | t, |
| 66 | "Property expected to match the product variable 'BOARD_AVB_KEY_PATH'", |
| 67 | "external/avb/test/data/testkey_rsa4096.pem", |
| 68 | proptools.String(fooSystem.FsProps().Avb_private_key), |
| 69 | ) |
| 70 | android.AssertStringEquals( |
| 71 | t, |
| 72 | "Property expected to match the product variable 'BOARD_AVB_ALGORITHM'", |
| 73 | "SHA256_RSA4096", |
| 74 | proptools.String(fooSystem.FsProps().Avb_algorithm), |
| 75 | ) |
| 76 | android.AssertIntEquals( |
| 77 | t, |
| 78 | "Property expected to match the product variable 'BOARD_AVB_SYSTEM_ROLLBACK_INDEX'", |
| 79 | 0, |
| 80 | proptools.Int(fooSystem.FsProps().Rollback_index), |
| 81 | ) |
| 82 | android.AssertStringEquals( |
| 83 | t, |
| 84 | "Property expected to match the product variable 'BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE'", |
| 85 | "ext4", |
| 86 | proptools.String(fooSystem.FsProps().Type), |
| 87 | ) |
| 88 | } |