Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 1 | // Copyright 2019 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 java |
| 16 | |
| 17 | import ( |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 18 | "path/filepath" |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 19 | "strings" |
| 20 | "testing" |
| 21 | |
| 22 | "github.com/google/blueprint/proptools" |
Colin Cross | 60405e5 | 2019-04-18 12:31:22 -0700 | [diff] [blame] | 23 | |
| 24 | "android/soong/android" |
| 25 | "android/soong/java/config" |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 26 | ) |
| 27 | |
Paul Duffin | 0b3b36a | 2021-10-28 18:05:53 +0100 | [diff] [blame] | 28 | type classpathTestCase struct { |
| 29 | name string |
| 30 | unbundled bool |
| 31 | moduleType string |
| 32 | host android.OsClass |
| 33 | properties string |
| 34 | |
| 35 | // for java 8 |
| 36 | bootclasspath []string |
| 37 | java8classpath []string |
| 38 | |
| 39 | // for java 9 |
| 40 | system string |
| 41 | java9classpath []string |
| 42 | |
| 43 | forces8 bool // if set, javac will always be called with java 8 arguments |
| 44 | |
| 45 | aidl string |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 46 | |
| 47 | // Indicates how this test case is affected by the setting of Always_use_prebuilt_sdks. |
| 48 | // |
| 49 | // If this is nil then the test case is unaffected by the setting of Always_use_prebuilt_sdks. |
| 50 | // Otherwise, the test case can only be used when |
| 51 | // Always_use_prebuilt_sdks=*forAlwaysUsePrebuiltSdks. |
| 52 | forAlwaysUsePrebuiltSdks *bool |
Paul Duffin | 0b3b36a | 2021-10-28 18:05:53 +0100 | [diff] [blame] | 53 | } |
| 54 | |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 55 | func TestClasspath(t *testing.T) { |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 56 | const frameworkAidl = "-I" + defaultJavaDir + "/framework/aidl" |
Paul Duffin | 0b3b36a | 2021-10-28 18:05:53 +0100 | [diff] [blame] | 57 | var classpathTestcases = []classpathTestCase{ |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 58 | { |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 59 | name: "default", |
Pete Gillin | 84c3807 | 2020-07-09 18:03:41 +0100 | [diff] [blame] | 60 | bootclasspath: config.StableCorePlatformBootclasspathLibraries, |
| 61 | system: config.StableCorePlatformSystemModules, |
Pete Gillin | 0638dfc | 2020-07-01 10:48:14 +0100 | [diff] [blame] | 62 | java8classpath: config.FrameworkLibraries, |
| 63 | java9classpath: config.FrameworkLibraries, |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 64 | aidl: frameworkAidl, |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 65 | }, |
| 66 | { |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 67 | name: `sdk_version:"core_platform"`, |
| 68 | properties: `sdk_version:"core_platform"`, |
Pete Gillin | 84c3807 | 2020-07-09 18:03:41 +0100 | [diff] [blame] | 69 | bootclasspath: config.StableCorePlatformBootclasspathLibraries, |
| 70 | system: config.StableCorePlatformSystemModules, |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 71 | java8classpath: []string{}, |
| 72 | aidl: "", |
Paul Duffin | 50c217c | 2019-06-12 13:25:22 +0100 | [diff] [blame] | 73 | }, |
| 74 | { |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 75 | name: "blank sdk version", |
| 76 | properties: `sdk_version: "",`, |
Pete Gillin | 84c3807 | 2020-07-09 18:03:41 +0100 | [diff] [blame] | 77 | bootclasspath: config.StableCorePlatformBootclasspathLibraries, |
| 78 | system: config.StableCorePlatformSystemModules, |
Pete Gillin | 0638dfc | 2020-07-01 10:48:14 +0100 | [diff] [blame] | 79 | java8classpath: config.FrameworkLibraries, |
| 80 | java9classpath: config.FrameworkLibraries, |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 81 | aidl: frameworkAidl, |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 82 | }, |
| 83 | { |
| 84 | |
Colin Cross | 74362a4 | 2019-10-28 08:05:02 -0700 | [diff] [blame] | 85 | name: "sdk v29", |
| 86 | properties: `sdk_version: "29",`, |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 87 | bootclasspath: []string{`""`}, |
| 88 | forces8: true, |
Colin Cross | 74362a4 | 2019-10-28 08:05:02 -0700 | [diff] [blame] | 89 | java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 90 | aidl: "-pprebuilts/sdk/29/public/framework.aidl", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 91 | }, |
| 92 | { |
| 93 | |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 94 | name: "sdk v30", |
| 95 | properties: `sdk_version: "30",`, |
| 96 | bootclasspath: []string{`""`}, |
| 97 | system: "sdk_public_30_system_modules", |
| 98 | java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 99 | java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 100 | aidl: "-pprebuilts/sdk/30/public/framework.aidl", |
| 101 | }, |
| 102 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 103 | // Test case only applies when Always_use_prebuilt_sdks=false (the default). |
| 104 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false), |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 105 | |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 106 | name: "current", |
| 107 | properties: `sdk_version: "current",`, |
| 108 | bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"}, |
Paul Duffin | 10fb76f | 2021-11-03 16:53:31 +0000 | [diff] [blame] | 109 | system: "core-public-stubs-system-modules", |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 110 | java9classpath: []string{"android_stubs_current"}, |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 111 | aidl: "-pout/soong/framework.aidl", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 112 | }, |
| 113 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 114 | // Test case only applies when Always_use_prebuilt_sdks=true. |
| 115 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true), |
| 116 | |
| 117 | name: "current", |
| 118 | properties: `sdk_version: "current",`, |
| 119 | bootclasspath: []string{`""`}, |
| 120 | system: "sdk_public_current_system_modules", |
| 121 | java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 122 | java9classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 123 | aidl: "-pprebuilts/sdk/current/public/framework.aidl", |
| 124 | }, |
| 125 | { |
| 126 | // Test case only applies when Always_use_prebuilt_sdks=false (the default). |
| 127 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false), |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 128 | |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 129 | name: "system_current", |
| 130 | properties: `sdk_version: "system_current",`, |
| 131 | bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"}, |
Paul Duffin | 10fb76f | 2021-11-03 16:53:31 +0000 | [diff] [blame] | 132 | system: "core-public-stubs-system-modules", |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 133 | java9classpath: []string{"android_system_stubs_current"}, |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 134 | aidl: "-pout/soong/framework.aidl", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 135 | }, |
| 136 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 137 | // Test case only applies when Always_use_prebuilt_sdks=true. |
| 138 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true), |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 139 | |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 140 | name: "system_current", |
| 141 | properties: `sdk_version: "system_current",`, |
| 142 | bootclasspath: []string{`""`}, |
| 143 | system: "sdk_public_current_system_modules", |
| 144 | java8classpath: []string{"prebuilts/sdk/current/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 145 | java9classpath: []string{"prebuilts/sdk/current/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 146 | aidl: "-pprebuilts/sdk/current/public/framework.aidl", |
| 147 | }, |
| 148 | { |
Colin Cross | 74362a4 | 2019-10-28 08:05:02 -0700 | [diff] [blame] | 149 | name: "system_29", |
| 150 | properties: `sdk_version: "system_29",`, |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 151 | bootclasspath: []string{`""`}, |
| 152 | forces8: true, |
Colin Cross | 74362a4 | 2019-10-28 08:05:02 -0700 | [diff] [blame] | 153 | java8classpath: []string{"prebuilts/sdk/29/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 154 | aidl: "-pprebuilts/sdk/29/public/framework.aidl", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 155 | }, |
| 156 | { |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 157 | name: "system_30", |
| 158 | properties: `sdk_version: "system_30",`, |
| 159 | bootclasspath: []string{`""`}, |
| 160 | system: "sdk_public_30_system_modules", |
| 161 | java8classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 162 | java9classpath: []string{"prebuilts/sdk/30/system/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 163 | aidl: "-pprebuilts/sdk/30/public/framework.aidl", |
| 164 | }, |
| 165 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 166 | // Test case only applies when Always_use_prebuilt_sdks=false (the default). |
| 167 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false), |
| 168 | |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 169 | name: "test_current", |
| 170 | properties: `sdk_version: "test_current",`, |
| 171 | bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"}, |
Paul Duffin | 10fb76f | 2021-11-03 16:53:31 +0000 | [diff] [blame] | 172 | system: "core-public-stubs-system-modules", |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 173 | java9classpath: []string{"android_test_stubs_current"}, |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 174 | aidl: "-pout/soong/framework.aidl", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 175 | }, |
| 176 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 177 | // Test case only applies when Always_use_prebuilt_sdks=true. |
| 178 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true), |
| 179 | |
| 180 | name: "test_current", |
| 181 | properties: `sdk_version: "test_current",`, |
| 182 | bootclasspath: []string{`""`}, |
| 183 | system: "sdk_public_current_system_modules", |
| 184 | java8classpath: []string{"prebuilts/sdk/current/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 185 | java9classpath: []string{"prebuilts/sdk/current/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 186 | aidl: "-pprebuilts/sdk/current/public/framework.aidl", |
| 187 | }, |
| 188 | { |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 189 | name: "test_30", |
| 190 | properties: `sdk_version: "test_30",`, |
| 191 | bootclasspath: []string{`""`}, |
| 192 | system: "sdk_public_30_system_modules", |
| 193 | java8classpath: []string{"prebuilts/sdk/30/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 194 | java9classpath: []string{"prebuilts/sdk/30/test/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 195 | aidl: "-pprebuilts/sdk/30/public/framework.aidl", |
| 196 | }, |
| 197 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 198 | // Test case only applies when Always_use_prebuilt_sdks=false (the default). |
| 199 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false), |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 200 | |
Pete Gillin | 880f964 | 2020-07-01 13:17:16 +0100 | [diff] [blame] | 201 | name: "core_current", |
| 202 | properties: `sdk_version: "core_current",`, |
| 203 | bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"}, |
Paul Duffin | 10fb76f | 2021-11-03 16:53:31 +0000 | [diff] [blame] | 204 | system: "core-public-stubs-system-modules", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 205 | }, |
| 206 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 207 | // Test case only applies when Always_use_prebuilt_sdks=true. |
| 208 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true), |
| 209 | |
| 210 | name: "core_current", |
| 211 | properties: `sdk_version: "core_current",`, |
| 212 | bootclasspath: []string{`""`}, |
| 213 | system: "sdk_public_current_system_modules", |
| 214 | java8classpath: []string{"prebuilts/sdk/current/core/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 215 | java9classpath: []string{"prebuilts/sdk/current/core/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 216 | aidl: "-pprebuilts/sdk/current/public/framework.aidl", |
| 217 | }, |
| 218 | { |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 219 | |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 220 | name: "nostdlib", |
| 221 | properties: `sdk_version: "none", system_modules: "none"`, |
| 222 | system: "none", |
| 223 | bootclasspath: []string{`""`}, |
| 224 | java8classpath: []string{}, |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 225 | }, |
| 226 | { |
| 227 | |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 228 | name: "nostdlib system_modules", |
Pete Gillin | 84c3807 | 2020-07-09 18:03:41 +0100 | [diff] [blame] | 229 | properties: `sdk_version: "none", system_modules: "stable-core-platform-api-stubs-system-modules"`, |
| 230 | system: "stable-core-platform-api-stubs-system-modules", |
| 231 | bootclasspath: []string{"stable-core-platform-api-stubs-system-modules-lib"}, |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 232 | java8classpath: []string{}, |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 233 | }, |
| 234 | { |
| 235 | |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 236 | name: "host default", |
| 237 | moduleType: "java_library_host", |
| 238 | properties: ``, |
| 239 | host: android.Host, |
| 240 | bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"}, |
| 241 | java8classpath: []string{}, |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 242 | }, |
| 243 | { |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 244 | |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 245 | name: "host supported default", |
| 246 | host: android.Host, |
| 247 | properties: `host_supported: true,`, |
| 248 | java8classpath: []string{}, |
| 249 | bootclasspath: []string{"jdk8/jre/lib/jce.jar", "jdk8/jre/lib/rt.jar"}, |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 250 | }, |
| 251 | { |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 252 | name: "host supported nostdlib", |
| 253 | host: android.Host, |
| 254 | properties: `host_supported: true, sdk_version: "none", system_modules: "none"`, |
| 255 | java8classpath: []string{}, |
Paul Duffin | 52d398a | 2019-06-11 12:31:14 +0100 | [diff] [blame] | 256 | }, |
| 257 | { |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 258 | |
Colin Cross | 74362a4 | 2019-10-28 08:05:02 -0700 | [diff] [blame] | 259 | name: "unbundled sdk v29", |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 260 | unbundled: true, |
Colin Cross | 74362a4 | 2019-10-28 08:05:02 -0700 | [diff] [blame] | 261 | properties: `sdk_version: "29",`, |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 262 | bootclasspath: []string{`""`}, |
| 263 | forces8: true, |
Colin Cross | 74362a4 | 2019-10-28 08:05:02 -0700 | [diff] [blame] | 264 | java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 265 | aidl: "-pprebuilts/sdk/29/public/framework.aidl", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 266 | }, |
| 267 | { |
| 268 | |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 269 | name: "unbundled sdk v30", |
| 270 | unbundled: true, |
| 271 | properties: `sdk_version: "30",`, |
| 272 | bootclasspath: []string{`""`}, |
| 273 | system: "sdk_public_30_system_modules", |
| 274 | java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 275 | java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 276 | aidl: "-pprebuilts/sdk/30/public/framework.aidl", |
| 277 | }, |
| 278 | { |
| 279 | |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 280 | name: "unbundled current", |
| 281 | unbundled: true, |
| 282 | properties: `sdk_version: "current",`, |
| 283 | bootclasspath: []string{`""`}, |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 284 | system: "sdk_public_current_system_modules", |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 285 | java8classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 286 | java9classpath: []string{"prebuilts/sdk/current/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 287 | aidl: "-pprebuilts/sdk/current/public/framework.aidl", |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 288 | }, |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 289 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 290 | // Test case only applies when Always_use_prebuilt_sdks=false (the default). |
| 291 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false), |
| 292 | |
Jiyong Park | 50146e9 | 2020-01-30 18:00:15 +0900 | [diff] [blame] | 293 | name: "module_current", |
| 294 | properties: `sdk_version: "module_current",`, |
| 295 | bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"}, |
Victor Chang | b54f5aa | 2021-06-29 22:05:58 +0100 | [diff] [blame] | 296 | system: "core-module-lib-stubs-system-modules", |
Jiyong Park | 50146e9 | 2020-01-30 18:00:15 +0900 | [diff] [blame] | 297 | java9classpath: []string{"android_module_lib_stubs_current"}, |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 298 | aidl: "-pout/soong/framework_non_updatable.aidl", |
Jiyong Park | 50146e9 | 2020-01-30 18:00:15 +0900 | [diff] [blame] | 299 | }, |
Jiyong Park | aae9bd1 | 2020-02-12 04:36:43 +0900 | [diff] [blame] | 300 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 301 | // Test case only applies when Always_use_prebuilt_sdks=true. |
| 302 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true), |
| 303 | |
| 304 | name: "module_current", |
| 305 | properties: `sdk_version: "module_current",`, |
| 306 | bootclasspath: []string{`""`}, |
Paul Duffin | 004547f | 2021-10-29 13:50:24 +0100 | [diff] [blame] | 307 | system: "sdk_module-lib_current_system_modules", |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 308 | java8classpath: []string{"prebuilts/sdk/current/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 309 | java9classpath: []string{"prebuilts/sdk/current/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 310 | aidl: "-pprebuilts/sdk/current/public/framework.aidl", |
| 311 | }, |
| 312 | { |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 313 | name: "module_30", |
| 314 | properties: `sdk_version: "module_30",`, |
| 315 | bootclasspath: []string{`""`}, |
| 316 | system: "sdk_public_30_system_modules", |
| 317 | java8classpath: []string{"prebuilts/sdk/30/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 318 | java9classpath: []string{"prebuilts/sdk/30/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 319 | aidl: "-pprebuilts/sdk/30/public/framework.aidl", |
| 320 | }, |
| 321 | { |
| 322 | name: "module_31", |
| 323 | properties: `sdk_version: "module_31",`, |
| 324 | bootclasspath: []string{`""`}, |
| 325 | system: "sdk_public_31_system_modules", |
| 326 | java8classpath: []string{"prebuilts/sdk/31/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 327 | java9classpath: []string{"prebuilts/sdk/31/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 328 | aidl: "-pprebuilts/sdk/31/public/framework.aidl", |
| 329 | }, |
| 330 | { |
| 331 | name: "module_32", |
| 332 | properties: `sdk_version: "module_32",`, |
| 333 | bootclasspath: []string{`""`}, |
Paul Duffin | 004547f | 2021-10-29 13:50:24 +0100 | [diff] [blame] | 334 | system: "sdk_module-lib_32_system_modules", |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 335 | java8classpath: []string{"prebuilts/sdk/32/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 336 | java9classpath: []string{"prebuilts/sdk/32/module-lib/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 337 | aidl: "-pprebuilts/sdk/32/public/framework.aidl", |
| 338 | }, |
| 339 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 340 | // Test case only applies when Always_use_prebuilt_sdks=false (the default). |
| 341 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(false), |
| 342 | |
Jiyong Park | aae9bd1 | 2020-02-12 04:36:43 +0900 | [diff] [blame] | 343 | name: "system_server_current", |
| 344 | properties: `sdk_version: "system_server_current",`, |
Anton Hansson | ba6ab2e | 2020-03-19 15:23:38 +0000 | [diff] [blame] | 345 | bootclasspath: []string{"android_system_server_stubs_current", "core-lambda-stubs"}, |
Victor Chang | b54f5aa | 2021-06-29 22:05:58 +0100 | [diff] [blame] | 346 | system: "core-module-lib-stubs-system-modules", |
Anton Hansson | ba6ab2e | 2020-03-19 15:23:38 +0000 | [diff] [blame] | 347 | java9classpath: []string{"android_system_server_stubs_current"}, |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 348 | aidl: "-pout/soong/framework.aidl", |
Jiyong Park | aae9bd1 | 2020-02-12 04:36:43 +0900 | [diff] [blame] | 349 | }, |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 350 | { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 351 | // Test case only applies when Always_use_prebuilt_sdks=true. |
| 352 | forAlwaysUsePrebuiltSdks: proptools.BoolPtr(true), |
| 353 | |
| 354 | name: "system_server_current", |
| 355 | properties: `sdk_version: "system_server_current",`, |
| 356 | bootclasspath: []string{`""`}, |
Paul Duffin | 004547f | 2021-10-29 13:50:24 +0100 | [diff] [blame] | 357 | system: "sdk_module-lib_current_system_modules", |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 358 | java8classpath: []string{"prebuilts/sdk/current/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 359 | java9classpath: []string{"prebuilts/sdk/current/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 360 | aidl: "-pprebuilts/sdk/current/public/framework.aidl", |
| 361 | }, |
| 362 | { |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 363 | name: "system_server_30", |
| 364 | properties: `sdk_version: "system_server_30",`, |
| 365 | bootclasspath: []string{`""`}, |
| 366 | system: "sdk_public_30_system_modules", |
| 367 | java8classpath: []string{"prebuilts/sdk/30/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 368 | java9classpath: []string{"prebuilts/sdk/30/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 369 | aidl: "-pprebuilts/sdk/30/public/framework.aidl", |
| 370 | }, |
| 371 | { |
| 372 | name: "system_server_31", |
| 373 | properties: `sdk_version: "system_server_31",`, |
| 374 | bootclasspath: []string{`""`}, |
| 375 | system: "sdk_public_31_system_modules", |
| 376 | java8classpath: []string{"prebuilts/sdk/31/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 377 | java9classpath: []string{"prebuilts/sdk/31/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 378 | aidl: "-pprebuilts/sdk/31/public/framework.aidl", |
| 379 | }, |
| 380 | { |
| 381 | name: "system_server_32", |
| 382 | properties: `sdk_version: "system_server_32",`, |
| 383 | bootclasspath: []string{`""`}, |
Paul Duffin | 004547f | 2021-10-29 13:50:24 +0100 | [diff] [blame] | 384 | system: "sdk_module-lib_32_system_modules", |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 385 | java8classpath: []string{"prebuilts/sdk/32/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 386 | java9classpath: []string{"prebuilts/sdk/32/system-server/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, |
| 387 | aidl: "-pprebuilts/sdk/32/public/framework.aidl", |
| 388 | }, |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 391 | t.Run("basic", func(t *testing.T) { |
| 392 | testClasspathTestCases(t, classpathTestcases, false) |
| 393 | }) |
| 394 | |
| 395 | t.Run("Always_use_prebuilt_sdks=true", func(t *testing.T) { |
| 396 | testClasspathTestCases(t, classpathTestcases, true) |
| 397 | }) |
Paul Duffin | 0b3b36a | 2021-10-28 18:05:53 +0100 | [diff] [blame] | 398 | } |
| 399 | |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 400 | func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase, alwaysUsePrebuiltSdks bool) { |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 401 | for _, testcase := range classpathTestcases { |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 402 | if testcase.forAlwaysUsePrebuiltSdks != nil && *testcase.forAlwaysUsePrebuiltSdks != alwaysUsePrebuiltSdks { |
| 403 | continue |
| 404 | } |
| 405 | |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 406 | t.Run(testcase.name, func(t *testing.T) { |
| 407 | moduleType := "java_library" |
| 408 | if testcase.moduleType != "" { |
| 409 | moduleType = testcase.moduleType |
| 410 | } |
| 411 | |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 412 | props := ` |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 413 | name: "foo", |
| 414 | srcs: ["a.java"], |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 415 | target: { |
| 416 | android: { |
| 417 | srcs: ["bar-doc/IFoo.aidl"], |
| 418 | }, |
| 419 | }, |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 420 | ` |
| 421 | bp := moduleType + " {" + props + testcase.properties + ` |
| 422 | }` |
| 423 | bpJava8 := moduleType + " {" + props + `java_version: "1.8", |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 424 | ` + testcase.properties + ` |
| 425 | }` |
| 426 | |
Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 427 | variant := func(result *android.TestResult) string { |
| 428 | if testcase.host == android.Host { |
| 429 | return result.Config.BuildOS.String() + "_common" |
| 430 | } |
| 431 | return "android_common" |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | convertModulesToPaths := func(cp []string) []string { |
| 435 | ret := make([]string, len(cp)) |
| 436 | for i, e := range cp { |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 437 | ret[i] = defaultModuleToPath(e) |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 438 | } |
| 439 | return ret |
| 440 | } |
| 441 | |
| 442 | bootclasspath := convertModulesToPaths(testcase.bootclasspath) |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 443 | java8classpath := convertModulesToPaths(testcase.java8classpath) |
| 444 | java9classpath := convertModulesToPaths(testcase.java9classpath) |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 445 | |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 446 | bc := "" |
| 447 | var bcDeps []string |
| 448 | if len(bootclasspath) > 0 { |
| 449 | bc = "-bootclasspath " + strings.Join(bootclasspath, ":") |
| 450 | if bootclasspath[0] != `""` { |
| 451 | bcDeps = bootclasspath |
| 452 | } |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 453 | } |
| 454 | |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 455 | j8c := "" |
| 456 | if len(java8classpath) > 0 { |
| 457 | j8c = "-classpath " + strings.Join(java8classpath, ":") |
| 458 | } |
| 459 | |
| 460 | j9c := "" |
| 461 | if len(java9classpath) > 0 { |
| 462 | j9c = "-classpath " + strings.Join(java9classpath, ":") |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 463 | } |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 464 | |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 465 | system := "" |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 466 | var systemDeps []string |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 467 | if testcase.system == "none" { |
| 468 | system = "--system=none" |
| 469 | } else if testcase.system != "" { |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 470 | dir := "" |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 471 | // If the system modules name starts with sdk_ then it is a prebuilt module and so comes |
| 472 | // from the prebuilt directory. |
| 473 | if strings.HasPrefix(testcase.system, "sdk_") { |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 474 | dir = "prebuilts/sdk" |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 475 | } else { |
| 476 | dir = defaultJavaDir |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 477 | } |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 478 | system = "--system=" + filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system") |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 479 | // The module-relative parts of these paths are hardcoded in system_modules.go: |
| 480 | systemDeps = []string{ |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 481 | filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "lib", "modules"), |
| 482 | filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "lib", "jrt-fs.jar"), |
| 483 | filepath.Join("out", "soong", ".intermediates", dir, testcase.system, "android_common", "system", "release"), |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 484 | } |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 485 | } |
| 486 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 487 | checkClasspath := func(t *testing.T, result *android.TestResult, isJava8 bool) { |
Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 488 | foo := result.ModuleForTests("foo", variant(result)) |
Paul Duffin | a71a67a | 2021-03-29 00:42:57 +0100 | [diff] [blame] | 489 | javac := foo.Rule("javac") |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 490 | var deps []string |
Colin Cross | c080617 | 2019-06-14 18:51:47 -0700 | [diff] [blame] | 491 | |
Paul Duffin | a71a67a | 2021-03-29 00:42:57 +0100 | [diff] [blame] | 492 | aidl := foo.MaybeRule("aidl") |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 493 | if aidl.Rule != nil { |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 494 | deps = append(deps, android.PathRelativeToTop(aidl.Output)) |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 495 | } |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 496 | |
| 497 | got := javac.Args["bootClasspath"] |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 498 | expected := "" |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 499 | if isJava8 || testcase.forces8 { |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 500 | expected = bc |
| 501 | deps = append(deps, bcDeps...) |
| 502 | } else { |
| 503 | expected = system |
| 504 | deps = append(deps, systemDeps...) |
| 505 | } |
| 506 | if got != expected { |
| 507 | t.Errorf("bootclasspath expected %q != got %q", expected, got) |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 508 | } |
| 509 | |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 510 | if isJava8 || testcase.forces8 { |
| 511 | expected = j8c |
| 512 | deps = append(deps, java8classpath...) |
| 513 | } else { |
| 514 | expected = j9c |
| 515 | deps = append(deps, java9classpath...) |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 516 | } |
Colin Cross | 617b145 | 2019-10-25 15:22:50 -0700 | [diff] [blame] | 517 | got = javac.Args["classpath"] |
| 518 | if got != expected { |
| 519 | t.Errorf("classpath expected %q != got %q", expected, got) |
| 520 | } |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 521 | |
Paul Duffin | 414ea5e | 2021-03-22 17:31:52 +0000 | [diff] [blame] | 522 | android.AssertPathsRelativeToTopEquals(t, "implicits", deps, javac.Implicits) |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 525 | preparer := android.NullFixturePreparer |
| 526 | if alwaysUsePrebuiltSdks { |
| 527 | preparer = android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 528 | variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true) |
| 529 | }) |
| 530 | } |
| 531 | |
Paul Duffin | 71ae594 | 2021-03-22 15:36:52 +0000 | [diff] [blame] | 532 | fixtureFactory := android.GroupFixturePreparers( |
| 533 | prepareForJavaTest, |
Paul Duffin | 171de3e | 2021-03-13 10:18:26 +0000 | [diff] [blame] | 534 | FixtureWithPrebuiltApis(map[string][]string{ |
| 535 | "29": {}, |
| 536 | "30": {}, |
Paul Duffin | 12e311d | 2021-10-28 17:42:16 +0100 | [diff] [blame] | 537 | "31": {}, |
| 538 | "32": {}, |
Paul Duffin | 171de3e | 2021-03-13 10:18:26 +0000 | [diff] [blame] | 539 | "current": {}, |
| 540 | }), |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 541 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 542 | if testcase.unbundled { |
| 543 | variables.Unbundled_build = proptools.BoolPtr(true) |
| 544 | variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true) |
| 545 | } |
| 546 | }), |
| 547 | android.FixtureModifyEnv(func(env map[string]string) { |
| 548 | if env["ANDROID_JAVA8_HOME"] == "" { |
| 549 | env["ANDROID_JAVA8_HOME"] = "jdk8" |
| 550 | } |
| 551 | }), |
Paul Duffin | 132c3e6 | 2021-10-28 18:16:14 +0100 | [diff] [blame] | 552 | preparer, |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 553 | ) |
| 554 | |
Pete Gillin | 1b3370f | 2019-10-01 13:57:31 +0100 | [diff] [blame] | 555 | // Test with legacy javac -source 1.8 -target 1.8 |
Pete Gillin | 0c2143e | 2019-05-02 15:32:11 +0100 | [diff] [blame] | 556 | t.Run("Java language level 8", func(t *testing.T) { |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 557 | result := fixtureFactory.RunTestWithBp(t, bpJava8) |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 558 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 559 | checkClasspath(t, result, true /* isJava8 */) |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 560 | |
| 561 | if testcase.host != android.Host { |
Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 562 | aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl") |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 563 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 564 | android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.") |
Colin Cross | 3047fa2 | 2019-04-18 10:56:44 -0700 | [diff] [blame] | 565 | } |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 566 | }) |
| 567 | |
Pete Gillin | 1b3370f | 2019-10-01 13:57:31 +0100 | [diff] [blame] | 568 | // Test with default javac -source 9 -target 9 |
Pete Gillin | 0c2143e | 2019-05-02 15:32:11 +0100 | [diff] [blame] | 569 | t.Run("Java language level 9", func(t *testing.T) { |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 570 | result := fixtureFactory.RunTestWithBp(t, bp) |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 571 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 572 | checkClasspath(t, result, false /* isJava8 */) |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 573 | |
| 574 | if testcase.host != android.Host { |
Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 575 | aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl") |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 576 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 577 | android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.") |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 578 | } |
| 579 | }) |
Colin Cross | ff0daf4 | 2019-04-02 16:10:56 -0700 | [diff] [blame] | 580 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 581 | prepareWithPlatformVersionRel := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 582 | variables.Platform_sdk_codename = proptools.StringPtr("REL") |
| 583 | variables.Platform_sdk_final = proptools.BoolPtr(true) |
| 584 | }) |
| 585 | |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 586 | // Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 8 -target 8 |
| 587 | t.Run("REL + Java language level 8", func(t *testing.T) { |
Paul Duffin | 79abe57 | 2021-03-29 02:16:14 +0100 | [diff] [blame] | 588 | result := android.GroupFixturePreparers( |
| 589 | fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bpJava8) |
Colin Cross | ff0daf4 | 2019-04-02 16:10:56 -0700 | [diff] [blame] | 590 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 591 | checkClasspath(t, result, true /* isJava8 */) |
Colin Cross | ff0daf4 | 2019-04-02 16:10:56 -0700 | [diff] [blame] | 592 | }) |
Pete Gillin | bdf5d71 | 2019-10-21 14:29:58 +0100 | [diff] [blame] | 593 | |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 594 | // Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9 |
| 595 | t.Run("REL + Java language level 9", func(t *testing.T) { |
Paul Duffin | 79abe57 | 2021-03-29 02:16:14 +0100 | [diff] [blame] | 596 | result := android.GroupFixturePreparers( |
| 597 | fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bp) |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 598 | |
Paul Duffin | 76101fa | 2021-03-13 09:55:25 +0000 | [diff] [blame] | 599 | checkClasspath(t, result, false /* isJava8 */) |
Colin Cross | 6cef481 | 2019-10-17 14:23:50 -0700 | [diff] [blame] | 600 | }) |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 601 | }) |
| 602 | } |
Colin Cross | fb6d781 | 2019-01-09 22:17:55 -0800 | [diff] [blame] | 603 | } |