blob: 6bb0e775b479ff5d102267cc6cd30bbe96c40b64 [file] [log] [blame]
Jihoon Kang98047cf2024-10-02 17:13:54 +00001// 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
15package fsgen
16
17import (
18 "android/soong/android"
19 "android/soong/filesystem"
20 "testing"
21
22 "github.com/google/blueprint/proptools"
23)
24
25var prepareForTestWithFsgenBuildComponents = android.FixtureRegisterWithContext(registerBuildComponents)
26
27func 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,
47 }),
PODISHETTY KUMAR (xWF)7f9bcd02024-10-04 07:39:10 +000048 ).RunTestWithBp(t, `
49 soong_filesystem_creator {
50 name: "foo",
51 }
52 `)
Jihoon Kang98047cf2024-10-02 17:13:54 +000053
54 fooSystem := result.ModuleForTests("test_product_generated_system_image", "android_common").Module().(interface {
55 FsProps() filesystem.FilesystemProperties
56 })
57 android.AssertBoolEquals(
58 t,
59 "Property expected to match the product variable 'BOARD_AVB_ENABLE'",
60 true,
61 proptools.Bool(fooSystem.FsProps().Use_avb),
62 )
63 android.AssertStringEquals(
64 t,
65 "Property expected to match the product variable 'BOARD_AVB_KEY_PATH'",
66 "external/avb/test/data/testkey_rsa4096.pem",
67 proptools.String(fooSystem.FsProps().Avb_private_key),
68 )
69 android.AssertStringEquals(
70 t,
71 "Property expected to match the product variable 'BOARD_AVB_ALGORITHM'",
72 "SHA256_RSA4096",
73 proptools.String(fooSystem.FsProps().Avb_algorithm),
74 )
75 android.AssertIntEquals(
76 t,
77 "Property expected to match the product variable 'BOARD_AVB_SYSTEM_ROLLBACK_INDEX'",
78 0,
79 proptools.Int(fooSystem.FsProps().Rollback_index),
80 )
81 android.AssertStringEquals(
82 t,
83 "Property expected to match the product variable 'BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE'",
84 "ext4",
85 proptools.String(fooSystem.FsProps().Type),
86 )
87}