diff options
author | Colin Cross | 2019-05-14 18:05:20 -0500 |
---|---|---|
committer | Colin Cross | 2019-05-17 10:43:36 -0500 |
commit | 815daf95b2a019cc997484841d318ee86e3f8c08 (patch) | |
tree | d1d141e594991c6349cbd724d4f94a71273edcdc | |
parent | 0d99f7cd8419a16132dc0aa3a6f37697dc473aad (diff) | |
download | platform-build-soong-815daf95b2a019cc997484841d318ee86e3f8c08.tar.gz platform-build-soong-815daf95b2a019cc997484841d318ee86e3f8c08.tar.xz platform-build-soong-815daf95b2a019cc997484841d318ee86e3f8c08.zip |
Add bpf_test.go to build and fix tests
bpf_test.go was not listed in testSrcs, which meant it was not run
during the build, but ran and failed with go test android/soong/...
Don't redeclare the cc module types and mutators, use exported
functions from cc/testing.go instead, which contain a new
dependency needed by cc modules.
This reapplies I4542640e8ff08e71565ed50617dbe67d86b29b69 after
fixes for mac tests.
Test: m
Test: go test android/soong/...
Change-Id: I3dc3fdedbd7063df4a2e0cadf2a4e0711b1823ad
-rw-r--r-- | bpf/Android.bp | 4 | ||||
-rw-r--r-- | bpf/bpf.go | 4 | ||||
-rw-r--r-- | bpf/bpf_test.go | 110 | ||||
-rw-r--r-- | cc/testing.go | 7 |
4 files changed, 18 insertions, 107 deletions
diff --git a/bpf/Android.bp b/bpf/Android.bp index 7bd4d443..882cd8af 100644 --- a/bpf/Android.bp +++ b/bpf/Android.bp | |||
@@ -21,10 +21,14 @@ bootstrap_go_package { | |||
21 | "blueprint", | 21 | "blueprint", |
22 | "blueprint-proptools", | 22 | "blueprint-proptools", |
23 | "soong-android", | 23 | "soong-android", |
24 | "soong-cc", | ||
24 | "soong-cc-config", | 25 | "soong-cc-config", |
25 | ], | 26 | ], |
26 | srcs: [ | 27 | srcs: [ |
27 | "bpf.go", | 28 | "bpf.go", |
28 | ], | 29 | ], |
30 | testSrcs: [ | ||
31 | "bpf_test.go", | ||
32 | ], | ||
29 | pluginFor: ["soong_build"], | 33 | pluginFor: ["soong_build"], |
30 | } | 34 | } |
@@ -33,7 +33,7 @@ func init() { | |||
33 | var ( | 33 | var ( |
34 | pctx = android.NewPackageContext("android/soong/bpf") | 34 | pctx = android.NewPackageContext("android/soong/bpf") |
35 | 35 | ||
36 | cc = pctx.AndroidGomaStaticRule("cc", | 36 | ccRule = pctx.AndroidGomaStaticRule("ccRule", |
37 | blueprint.RuleParams{ | 37 | blueprint.RuleParams{ |
38 | Depfile: "${out}.d", | 38 | Depfile: "${out}.d", |
39 | Deps: blueprint.DepsGCC, | 39 | Deps: blueprint.DepsGCC, |
@@ -82,7 +82,7 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) { | |||
82 | obj := android.ObjPathWithExt(ctx, "", src, "o") | 82 | obj := android.ObjPathWithExt(ctx, "", src, "o") |
83 | 83 | ||
84 | ctx.Build(pctx, android.BuildParams{ | 84 | ctx.Build(pctx, android.BuildParams{ |
85 | Rule: cc, | 85 | Rule: ccRule, |
86 | Input: src, | 86 | Input: src, |
87 | Output: obj, | 87 | Output: obj, |
88 | Args: map[string]string{ | 88 | Args: map[string]string{ |
diff --git a/bpf/bpf_test.go b/bpf/bpf_test.go index 1d53e413..cbb251fa 100644 --- a/bpf/bpf_test.go +++ b/bpf/bpf_test.go | |||
@@ -20,7 +20,7 @@ import ( | |||
20 | "testing" | 20 | "testing" |
21 | 21 | ||
22 | "android/soong/android" | 22 | "android/soong/android" |
23 | cc2 "android/soong/cc" | 23 | "android/soong/cc" |
24 | ) | 24 | ) |
25 | 25 | ||
26 | var buildDir string | 26 | var buildDir string |
@@ -49,115 +49,14 @@ func TestMain(m *testing.M) { | |||
49 | } | 49 | } |
50 | 50 | ||
51 | func testContext(bp string) *android.TestContext { | 51 | func testContext(bp string) *android.TestContext { |
52 | ctx := android.NewTestArchContext() | ||
53 | ctx.RegisterModuleType("bpf", android.ModuleFactoryAdaptor(bpfFactory)) | ||
54 | ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(cc2.TestFactory)) | ||
55 | ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc2.LibraryFactory)) | ||
56 | ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(cc2.LibraryStaticFactory)) | ||
57 | ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc2.ObjectFactory)) | ||
58 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc2.ToolchainLibraryFactory)) | ||
59 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { | ||
60 | ctx.BottomUp("link", cc2.LinkageMutator).Parallel() | ||
61 | }) | ||
62 | ctx.Register() | ||
63 | |||
64 | // Add some modules that are required by the compiler and/or linker | ||
65 | bp = bp + ` | ||
66 | toolchain_library { | ||
67 | name: "libatomic", | ||
68 | vendor_available: true, | ||
69 | recovery_available: true, | ||
70 | src: "", | ||
71 | } | ||
72 | |||
73 | toolchain_library { | ||
74 | name: "libclang_rt.builtins-arm-android", | ||
75 | vendor_available: true, | ||
76 | recovery_available: true, | ||
77 | src: "", | ||
78 | } | ||
79 | |||
80 | toolchain_library { | ||
81 | name: "libclang_rt.builtins-aarch64-android", | ||
82 | vendor_available: true, | ||
83 | recovery_available: true, | ||
84 | src: "", | ||
85 | } | ||
86 | |||
87 | toolchain_library { | ||
88 | name: "libgcc", | ||
89 | vendor_available: true, | ||
90 | recovery_available: true, | ||
91 | src: "", | ||
92 | } | ||
93 | |||
94 | cc_library { | ||
95 | name: "libc", | ||
96 | no_libgcc: true, | ||
97 | nocrt: true, | ||
98 | system_shared_libs: [], | ||
99 | recovery_available: true, | ||
100 | } | ||
101 | |||
102 | cc_library { | ||
103 | name: "libm", | ||
104 | no_libgcc: true, | ||
105 | nocrt: true, | ||
106 | system_shared_libs: [], | ||
107 | recovery_available: true, | ||
108 | } | ||
109 | |||
110 | cc_library { | ||
111 | name: "libdl", | ||
112 | no_libgcc: true, | ||
113 | nocrt: true, | ||
114 | system_shared_libs: [], | ||
115 | recovery_available: true, | ||
116 | } | ||
117 | |||
118 | cc_library { | ||
119 | name: "libgtest", | ||
120 | host_supported: true, | ||
121 | vendor_available: true, | ||
122 | } | ||
123 | |||
124 | cc_library { | ||
125 | name: "libgtest_main", | ||
126 | host_supported: true, | ||
127 | vendor_available: true, | ||
128 | } | ||
129 | |||
130 | cc_object { | ||
131 | name: "crtbegin_dynamic", | ||
132 | recovery_available: true, | ||
133 | vendor_available: true, | ||
134 | } | ||
135 | |||
136 | cc_object { | ||
137 | name: "crtend_android", | ||
138 | recovery_available: true, | ||
139 | vendor_available: true, | ||
140 | } | ||
141 | |||
142 | cc_object { | ||
143 | name: "crtbegin_so", | ||
144 | recovery_available: true, | ||
145 | vendor_available: true, | ||
146 | } | ||
147 | |||
148 | cc_object { | ||
149 | name: "crtend_so", | ||
150 | recovery_available: true, | ||
151 | vendor_available: true, | ||
152 | } | ||
153 | ` | ||
154 | mockFS := map[string][]byte{ | 52 | mockFS := map[string][]byte{ |
155 | "Android.bp": []byte(bp), | ||
156 | "bpf.c": nil, | 53 | "bpf.c": nil, |
157 | "BpfTest.cpp": nil, | 54 | "BpfTest.cpp": nil, |
158 | } | 55 | } |
159 | 56 | ||
160 | ctx.MockFileSystem(mockFS) | 57 | ctx := cc.CreateTestContext(bp, mockFS, android.Android) |
58 | ctx.RegisterModuleType("bpf", android.ModuleFactoryAdaptor(bpfFactory)) | ||
59 | ctx.Register() | ||
161 | 60 | ||
162 | return ctx | 61 | return ctx |
163 | } | 62 | } |
@@ -174,6 +73,7 @@ func TestBpfDataDependency(t *testing.T) { | |||
174 | name: "vts_test_binary_bpf_module", | 73 | name: "vts_test_binary_bpf_module", |
175 | srcs: ["BpfTest.cpp"], | 74 | srcs: ["BpfTest.cpp"], |
176 | data: [":bpf.o"], | 75 | data: [":bpf.o"], |
76 | gtest: false, | ||
177 | } | 77 | } |
178 | ` | 78 | ` |
179 | 79 | ||
diff --git a/cc/testing.go b/cc/testing.go index 162a7460..259fb19e 100644 --- a/cc/testing.go +++ b/cc/testing.go | |||
@@ -148,6 +148,12 @@ func GatherRequiredDepsForTest(os android.OsType) string { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | cc_object { | 150 | cc_object { |
151 | name: "crtbegin_dynamic", | ||
152 | recovery_available: true, | ||
153 | vendor_available: true, | ||
154 | } | ||
155 | |||
156 | cc_object { | ||
151 | name: "crtbegin_static", | 157 | name: "crtbegin_static", |
152 | recovery_available: true, | 158 | recovery_available: true, |
153 | vendor_available: true, | 159 | vendor_available: true, |
@@ -194,6 +200,7 @@ func CreateTestContext(bp string, fs map[string][]byte, | |||
194 | ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory)) | 200 | ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory)) |
195 | ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory)) | 201 | ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory)) |
196 | ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory)) | 202 | ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory)) |
203 | ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(TestFactory)) | ||
197 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory)) | 204 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory)) |
198 | ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory)) | 205 | ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory)) |
199 | ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory)) | 206 | ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory)) |