| Jiyong Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 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 |  | 
|  | 15 | package kernel | 
|  | 16 |  | 
|  | 17 | import ( | 
| Jiyong Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 18 | "os" | 
| Jiyong Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 19 | "testing" | 
|  | 20 |  | 
|  | 21 | "android/soong/android" | 
|  | 22 | "android/soong/cc" | 
|  | 23 | ) | 
|  | 24 |  | 
| Jiyong Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 25 | func TestKernelModulesFilelist(t *testing.T) { | 
| Paul Duffin | e5ac250 | 2021-03-29 01:24:49 +0100 | [diff] [blame] | 26 | 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 Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 35 | prebuilt_kernel_modules { | 
|  | 36 | name: "foo", | 
|  | 37 | srcs: ["*.ko"], | 
|  | 38 | kernel_version: "5.10", | 
|  | 39 | } | 
| Paul Duffin | e5ac250 | 2021-03-29 01:24:49 +0100 | [diff] [blame] | 40 | `) | 
| Jiyong Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 41 |  | 
|  | 42 | expected := []string{ | 
| Jiyong Park | 599992b | 2021-02-04 19:40:56 +0900 | [diff] [blame] | 43 | "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 Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 49 | } | 
|  | 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 Duffin | e5ac250 | 2021-03-29 01:24:49 +0100 | [diff] [blame] | 57 | android.AssertDeepEquals(t, "foo packaging specs", expected, actual) | 
| Jiyong Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 58 | } | 
|  | 59 |  | 
|  | 60 | func TestMain(m *testing.M) { | 
| Paul Duffin | e5ac250 | 2021-03-29 01:24:49 +0100 | [diff] [blame] | 61 | os.Exit(m.Run()) | 
| Jiyong Park | 6446b62 | 2021-02-01 20:08:28 +0900 | [diff] [blame] | 62 | } |