provenance_singleton_test.go 2.0 KB

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