prebuilt_kernel_modules_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2021 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. package kernel
  15. import (
  16. "os"
  17. "testing"
  18. "android/soong/android"
  19. "android/soong/cc"
  20. )
  21. func TestKernelModulesFilelist(t *testing.T) {
  22. ctx := android.GroupFixturePreparers(
  23. cc.PrepareForTestWithCcDefaultModules,
  24. android.FixtureRegisterWithContext(registerKernelBuildComponents),
  25. android.MockFS{
  26. "depmod.cpp": nil,
  27. "mod1.ko": nil,
  28. "mod2.ko": nil,
  29. }.AddToFixture(),
  30. ).RunTestWithBp(t, `
  31. prebuilt_kernel_modules {
  32. name: "foo",
  33. srcs: ["*.ko"],
  34. kernel_version: "5.10",
  35. }
  36. `)
  37. expected := []string{
  38. "lib/modules/5.10/mod1.ko",
  39. "lib/modules/5.10/mod2.ko",
  40. "lib/modules/5.10/modules.load",
  41. "lib/modules/5.10/modules.dep",
  42. "lib/modules/5.10/modules.softdep",
  43. "lib/modules/5.10/modules.alias",
  44. }
  45. var actual []string
  46. for _, ps := range ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().PackagingSpecs() {
  47. actual = append(actual, ps.RelPathInPackage())
  48. }
  49. actual = android.SortedUniqueStrings(actual)
  50. expected = android.SortedUniqueStrings(expected)
  51. android.AssertDeepEquals(t, "foo packaging specs", expected, actual)
  52. }
  53. func TestMain(m *testing.M) {
  54. os.Exit(m.Run())
  55. }