blob: 90b98868e0f7f4465e283eda6cdec1a475780343 [file] [log] [blame]
Jiyong Park6446b622021-02-01 20:08:28 +09001// 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
15package kernel
16
17import (
Jiyong Park6446b622021-02-01 20:08:28 +090018 "os"
Jiyong Park6446b622021-02-01 20:08:28 +090019 "testing"
20
21 "android/soong/android"
22 "android/soong/cc"
23)
24
Jiyong Park6446b622021-02-01 20:08:28 +090025func TestKernelModulesFilelist(t *testing.T) {
Paul Duffine5ac2502021-03-29 01:24:49 +010026 ctx := android.GroupFixturePreparers(
27 cc.PrepareForTestWithCcDefaultModules,
28 android.FixtureRegisterWithContext(registerKernelBuildComponents),
29 android.MockFS{
30 "depmod.cpp": nil,
31 "mod1.ko": nil,
32 "mod2.ko": nil,
33 }.AddToFixture(),
34 ).RunTestWithBp(t, `
Jiyong Park6446b622021-02-01 20:08:28 +090035 prebuilt_kernel_modules {
36 name: "foo",
37 srcs: ["*.ko"],
38 kernel_version: "5.10",
39 }
Paul Duffine5ac2502021-03-29 01:24:49 +010040 `)
Jiyong Park6446b622021-02-01 20:08:28 +090041
42 expected := []string{
Jiyong Park599992b2021-02-04 19:40:56 +090043 "lib/modules/5.10/mod1.ko",
44 "lib/modules/5.10/mod2.ko",
45 "lib/modules/5.10/modules.load",
46 "lib/modules/5.10/modules.dep",
47 "lib/modules/5.10/modules.softdep",
48 "lib/modules/5.10/modules.alias",
Jiyong Park6446b622021-02-01 20:08:28 +090049 }
50
51 var actual []string
52 for _, ps := range ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().PackagingSpecs() {
53 actual = append(actual, ps.RelPathInPackage())
54 }
55 actual = android.SortedUniqueStrings(actual)
56 expected = android.SortedUniqueStrings(expected)
Paul Duffine5ac2502021-03-29 01:24:49 +010057 android.AssertDeepEquals(t, "foo packaging specs", expected, actual)
Jiyong Park6446b622021-02-01 20:08:28 +090058}
59
60func TestMain(m *testing.M) {
Paul Duffine5ac2502021-03-29 01:24:49 +010061 os.Exit(m.Run())
Jiyong Park6446b622021-02-01 20:08:28 +090062}