blob: 0f1eae22083718ab14717c382d5d6ec9f9a7d798 [file] [log] [blame]
Wei Li340ee8e2022-03-18 17:33:24 -07001/*
2 * Copyright (C) 2022 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
17package provenance
18
19import (
20 "strings"
21 "testing"
22
23 "android/soong/android"
24)
25
26func TestProvenanceSingleton(t *testing.T) {
27 result := android.GroupFixturePreparers(
28 PrepareForTestWithProvenanceSingleton,
29 android.PrepareForTestWithAndroidMk).RunTestWithBp(t, "")
30
31 outputs := result.SingletonForTests("provenance_metadata_singleton").AllOutputs()
32 for _, output := range outputs {
33 testingBuildParam := result.SingletonForTests("provenance_metadata_singleton").Output(output)
34 switch {
35 case strings.Contains(output, "soong/provenance_metadata.textproto"):
36 android.AssertStringEquals(t, "Invalid build rule", "android/soong/provenance.mergeProvenanceMetaData", testingBuildParam.Rule.String())
37 android.AssertIntEquals(t, "Invalid input", len(testingBuildParam.Inputs), 0)
38 android.AssertStringDoesContain(t, "Invalid output path", output, "soong/provenance_metadata.textproto")
39 android.AssertIntEquals(t, "Invalid args", len(testingBuildParam.Args), 0)
40
41 case strings.HasSuffix(output, "provenance_metadata"):
42 android.AssertStringEquals(t, "Invalid build rule", "<builtin>:phony", testingBuildParam.Rule.String())
43 android.AssertStringEquals(t, "Invalid input", testingBuildParam.Inputs[0].String(), "out/soong/provenance_metadata.textproto")
44 android.AssertStringEquals(t, "Invalid output path", output, "provenance_metadata")
45 android.AssertIntEquals(t, "Invalid args", len(testingBuildParam.Args), 0)
46 }
47 }
48}