testing.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. // Copyright (C) 2019 The Android Open Source Project
  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 cc
  15. import (
  16. "path/filepath"
  17. "testing"
  18. "android/soong/android"
  19. "android/soong/genrule"
  20. "android/soong/snapshot"
  21. )
  22. func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
  23. RegisterPrebuiltBuildComponents(ctx)
  24. RegisterCCBuildComponents(ctx)
  25. RegisterBinaryBuildComponents(ctx)
  26. RegisterLibraryBuildComponents(ctx)
  27. RegisterLibraryHeadersBuildComponents(ctx)
  28. RegisterLibraryStubBuildComponents(ctx)
  29. ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory)
  30. ctx.RegisterModuleType("cc_object", ObjectFactory)
  31. ctx.RegisterModuleType("cc_genrule", GenRuleFactory)
  32. ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
  33. ctx.RegisterModuleType("ndk_prebuilt_static_stl", NdkPrebuiltStaticStlFactory)
  34. ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
  35. ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
  36. }
  37. func GatherRequiredDepsForTest(oses ...android.OsType) string {
  38. ret := commonDefaultModules()
  39. supportLinuxBionic := false
  40. for _, os := range oses {
  41. if os == android.Windows {
  42. ret += withWindowsModules()
  43. }
  44. if os == android.LinuxBionic {
  45. supportLinuxBionic = true
  46. ret += withLinuxBionic()
  47. }
  48. }
  49. if !supportLinuxBionic {
  50. ret += withoutLinuxBionic()
  51. }
  52. return ret
  53. }
  54. func commonDefaultModules() string {
  55. return `
  56. cc_defaults {
  57. name: "toolchain_libs_defaults",
  58. vendor_available: true,
  59. product_available: true,
  60. recovery_available: true,
  61. no_libcrt: true,
  62. sdk_version: "minimum",
  63. nocrt: true,
  64. system_shared_libs: [],
  65. stl: "none",
  66. srcs: [""],
  67. check_elf_files: false,
  68. sanitize: {
  69. never: true,
  70. },
  71. }
  72. cc_prebuilt_library_static {
  73. name: "libcompiler_rt-extras",
  74. defaults: ["toolchain_libs_defaults"],
  75. vendor_ramdisk_available: true,
  76. }
  77. cc_prebuilt_library_static {
  78. name: "libclang_rt.builtins",
  79. defaults: ["toolchain_libs_defaults"],
  80. host_supported: true,
  81. vendor_available: true,
  82. vendor_ramdisk_available: true,
  83. native_bridge_supported: true,
  84. }
  85. cc_prebuilt_library_shared {
  86. name: "libclang_rt.hwasan",
  87. defaults: ["toolchain_libs_defaults"],
  88. }
  89. cc_prebuilt_library_static {
  90. name: "libunwind",
  91. defaults: [
  92. "linux_bionic_supported",
  93. "toolchain_libs_defaults",
  94. ],
  95. vendor_ramdisk_available: true,
  96. native_bridge_supported: true,
  97. }
  98. cc_prebuilt_library_static {
  99. name: "libclang_rt.fuzzer",
  100. defaults: [
  101. "linux_bionic_supported",
  102. "toolchain_libs_defaults",
  103. ],
  104. }
  105. // Needed for sanitizer
  106. cc_prebuilt_library_shared {
  107. name: "libclang_rt.ubsan_standalone",
  108. defaults: ["toolchain_libs_defaults"],
  109. }
  110. cc_prebuilt_library_static {
  111. name: "libclang_rt.ubsan_minimal",
  112. defaults: ["toolchain_libs_defaults"],
  113. }
  114. cc_library {
  115. name: "libc",
  116. defaults: ["linux_bionic_supported"],
  117. no_libcrt: true,
  118. nocrt: true,
  119. stl: "none",
  120. system_shared_libs: [],
  121. recovery_available: true,
  122. stubs: {
  123. versions: ["27", "28", "29"],
  124. },
  125. llndk: {
  126. symbol_file: "libc.map.txt",
  127. },
  128. }
  129. cc_library {
  130. name: "libm",
  131. defaults: ["linux_bionic_supported"],
  132. no_libcrt: true,
  133. nocrt: true,
  134. stl: "none",
  135. system_shared_libs: [],
  136. recovery_available: true,
  137. stubs: {
  138. versions: ["27", "28", "29"],
  139. },
  140. apex_available: [
  141. "//apex_available:platform",
  142. "myapex"
  143. ],
  144. llndk: {
  145. symbol_file: "libm.map.txt",
  146. },
  147. }
  148. // Coverage libraries
  149. cc_library {
  150. name: "libprofile-extras",
  151. vendor_available: true,
  152. vendor_ramdisk_available: true,
  153. product_available: true,
  154. recovery_available: true,
  155. native_coverage: false,
  156. system_shared_libs: [],
  157. stl: "none",
  158. notice: "custom_notice",
  159. }
  160. cc_library {
  161. name: "libprofile-clang-extras",
  162. vendor_available: true,
  163. vendor_ramdisk_available: true,
  164. product_available: true,
  165. recovery_available: true,
  166. native_coverage: false,
  167. system_shared_libs: [],
  168. stl: "none",
  169. notice: "custom_notice",
  170. }
  171. cc_library {
  172. name: "libprofile-extras_ndk",
  173. vendor_available: true,
  174. product_available: true,
  175. native_coverage: false,
  176. system_shared_libs: [],
  177. stl: "none",
  178. notice: "custom_notice",
  179. sdk_version: "current",
  180. }
  181. cc_library {
  182. name: "libprofile-clang-extras_ndk",
  183. vendor_available: true,
  184. product_available: true,
  185. native_coverage: false,
  186. system_shared_libs: [],
  187. stl: "none",
  188. notice: "custom_notice",
  189. sdk_version: "current",
  190. }
  191. cc_library {
  192. name: "libdl",
  193. defaults: ["linux_bionic_supported"],
  194. no_libcrt: true,
  195. nocrt: true,
  196. stl: "none",
  197. system_shared_libs: [],
  198. recovery_available: true,
  199. stubs: {
  200. versions: ["27", "28", "29"],
  201. },
  202. apex_available: [
  203. "//apex_available:platform",
  204. "myapex"
  205. ],
  206. llndk: {
  207. symbol_file: "libdl.map.txt",
  208. },
  209. }
  210. cc_library {
  211. name: "libft2",
  212. no_libcrt: true,
  213. nocrt: true,
  214. system_shared_libs: [],
  215. recovery_available: true,
  216. llndk: {
  217. symbol_file: "libft2.map.txt",
  218. private: true,
  219. }
  220. }
  221. cc_library {
  222. name: "libc++_static",
  223. no_libcrt: true,
  224. nocrt: true,
  225. system_shared_libs: [],
  226. stl: "none",
  227. vendor_available: true,
  228. vendor_ramdisk_available: true,
  229. product_available: true,
  230. recovery_available: true,
  231. host_supported: true,
  232. min_sdk_version: "29",
  233. apex_available: [
  234. "//apex_available:platform",
  235. "//apex_available:anyapex",
  236. ],
  237. }
  238. cc_library {
  239. name: "libc++",
  240. no_libcrt: true,
  241. nocrt: true,
  242. system_shared_libs: [],
  243. stl: "none",
  244. vendor_available: true,
  245. product_available: true,
  246. recovery_available: true,
  247. host_supported: true,
  248. min_sdk_version: "29",
  249. vndk: {
  250. enabled: true,
  251. support_system_process: true,
  252. },
  253. apex_available: [
  254. "//apex_available:platform",
  255. "//apex_available:anyapex",
  256. ],
  257. }
  258. cc_library {
  259. name: "libc++demangle",
  260. no_libcrt: true,
  261. nocrt: true,
  262. system_shared_libs: [],
  263. stl: "none",
  264. host_supported: false,
  265. vendor_available: true,
  266. vendor_ramdisk_available: true,
  267. product_available: true,
  268. recovery_available: true,
  269. min_sdk_version: "29",
  270. apex_available: [
  271. "//apex_available:platform",
  272. "//apex_available:anyapex",
  273. ],
  274. }
  275. cc_defaults {
  276. name: "crt_defaults",
  277. defaults: ["linux_bionic_supported"],
  278. recovery_available: true,
  279. vendor_available: true,
  280. vendor_ramdisk_available: true,
  281. product_available: true,
  282. native_bridge_supported: true,
  283. stl: "none",
  284. min_sdk_version: "16",
  285. crt: true,
  286. system_shared_libs: [],
  287. apex_available: [
  288. "//apex_available:platform",
  289. "//apex_available:anyapex",
  290. ],
  291. }
  292. cc_object {
  293. name: "crtbegin_so",
  294. defaults: ["crt_defaults"],
  295. srcs: ["crtbegin_so.c"],
  296. objs: ["crtbrand"],
  297. }
  298. cc_object {
  299. name: "crtbegin_dynamic",
  300. defaults: ["crt_defaults"],
  301. srcs: ["crtbegin.c"],
  302. objs: ["crtbrand"],
  303. }
  304. cc_object {
  305. name: "crtbegin_static",
  306. defaults: ["crt_defaults"],
  307. srcs: ["crtbegin.c"],
  308. objs: ["crtbrand"],
  309. }
  310. cc_object {
  311. name: "crtend_so",
  312. defaults: ["crt_defaults"],
  313. srcs: ["crtend_so.c"],
  314. objs: ["crtbrand"],
  315. }
  316. cc_object {
  317. name: "crtend_android",
  318. defaults: ["crt_defaults"],
  319. srcs: ["crtend.c"],
  320. objs: ["crtbrand"],
  321. }
  322. cc_object {
  323. name: "crtbrand",
  324. defaults: ["crt_defaults"],
  325. srcs: ["crtbrand.c"],
  326. }
  327. cc_library {
  328. name: "libprotobuf-cpp-lite",
  329. }
  330. cc_library {
  331. name: "ndk_libunwind",
  332. sdk_version: "minimum",
  333. stl: "none",
  334. system_shared_libs: [],
  335. }
  336. ndk_library {
  337. name: "libc",
  338. first_version: "minimum",
  339. symbol_file: "libc.map.txt",
  340. }
  341. ndk_library {
  342. name: "libm",
  343. first_version: "minimum",
  344. symbol_file: "libm.map.txt",
  345. }
  346. ndk_library {
  347. name: "libdl",
  348. first_version: "minimum",
  349. symbol_file: "libdl.map.txt",
  350. }
  351. ndk_prebuilt_shared_stl {
  352. name: "ndk_libc++_shared",
  353. export_include_dirs: ["ndk_libc++_shared"],
  354. }
  355. ndk_prebuilt_static_stl {
  356. name: "ndk_libandroid_support",
  357. export_include_dirs: ["ndk_libandroid_support"],
  358. }
  359. cc_library_static {
  360. name: "libgoogle-benchmark",
  361. sdk_version: "current",
  362. stl: "none",
  363. system_shared_libs: [],
  364. }
  365. cc_library_static {
  366. name: "note_memtag_heap_async",
  367. }
  368. cc_library_static {
  369. name: "note_memtag_heap_sync",
  370. }
  371. cc_library {
  372. name: "libc_musl",
  373. host_supported: true,
  374. no_libcrt: true,
  375. nocrt: true,
  376. system_shared_libs: [],
  377. stl: "none",
  378. }
  379. `
  380. }
  381. func withWindowsModules() string {
  382. return `
  383. cc_prebuilt_library_static {
  384. name: "libwinpthread",
  385. host_supported: true,
  386. enabled: false,
  387. target: {
  388. windows: {
  389. enabled: true,
  390. },
  391. },
  392. stl: "none",
  393. srcs:[""],
  394. }
  395. `
  396. }
  397. func withLinuxBionic() string {
  398. return `
  399. cc_binary {
  400. name: "linker",
  401. defaults: ["linux_bionic_supported"],
  402. recovery_available: true,
  403. stl: "none",
  404. nocrt: true,
  405. static_executable: true,
  406. native_coverage: false,
  407. system_shared_libs: [],
  408. }
  409. cc_genrule {
  410. name: "host_bionic_linker_script",
  411. host_supported: true,
  412. device_supported: false,
  413. target: {
  414. host: {
  415. enabled: false,
  416. },
  417. linux_bionic: {
  418. enabled: true,
  419. },
  420. },
  421. out: ["linker.script"],
  422. }
  423. cc_defaults {
  424. name: "linux_bionic_supported",
  425. host_supported: true,
  426. target: {
  427. host: {
  428. enabled: false,
  429. },
  430. linux_bionic: {
  431. enabled: true,
  432. },
  433. },
  434. }
  435. `
  436. }
  437. func withoutLinuxBionic() string {
  438. return `
  439. cc_defaults {
  440. name: "linux_bionic_supported",
  441. }
  442. `
  443. }
  444. func GatherRequiredFilesForTest(fs map[string][]byte) {
  445. }
  446. // The directory in which cc linux bionic default modules will be defined.
  447. //
  448. // Placing them here ensures that their location does not conflict with default test modules
  449. // defined by other packages.
  450. const linuxBionicDefaultsPath = "defaults/cc/linux-bionic/Android.bp"
  451. // The directory in which the default cc common test modules will be defined.
  452. //
  453. // Placing them here ensures that their location does not conflict with default test modules
  454. // defined by other packages.
  455. const DefaultCcCommonTestModulesDir = "defaults/cc/common/"
  456. // Test fixture preparer that will register most cc build components.
  457. //
  458. // Singletons and mutators should only be added here if they are needed for a majority of cc
  459. // module types, otherwise they should be added under a separate preparer to allow them to be
  460. // selected only when needed to reduce test execution time.
  461. //
  462. // Module types do not have much of an overhead unless they are used so this should include as many
  463. // module types as possible. The exceptions are those module types that require mutators and/or
  464. // singletons in order to function in which case they should be kept together in a separate
  465. // preparer.
  466. var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers(
  467. android.PrepareForTestWithAndroidBuildComponents,
  468. android.FixtureRegisterWithContext(RegisterRequiredBuildComponentsForTest),
  469. android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
  470. ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
  471. ctx.RegisterModuleType("cc_test", TestFactory)
  472. ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
  473. ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
  474. RegisterVndkLibraryTxtTypes(ctx)
  475. }),
  476. // Additional files needed in tests that disallow non-existent source files.
  477. // This includes files that are needed by all, or at least most, instances of a cc module type.
  478. android.MockFS{
  479. // Needed for ndk_prebuilt_(shared|static)_stl.
  480. "prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs": nil,
  481. }.AddToFixture(),
  482. )
  483. // Preparer that will define default cc modules, e.g. standard prebuilt modules.
  484. var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
  485. PrepareForTestWithCcBuildComponents,
  486. // Additional files needed in tests that disallow non-existent source.
  487. android.MockFS{
  488. "defaults/cc/common/libc.map.txt": nil,
  489. "defaults/cc/common/libdl.map.txt": nil,
  490. "defaults/cc/common/libm.map.txt": nil,
  491. "defaults/cc/common/ndk_libandroid_support": nil,
  492. "defaults/cc/common/ndk_libc++_shared": nil,
  493. "defaults/cc/common/crtbegin_so.c": nil,
  494. "defaults/cc/common/crtbegin.c": nil,
  495. "defaults/cc/common/crtend_so.c": nil,
  496. "defaults/cc/common/crtend.c": nil,
  497. "defaults/cc/common/crtbrand.c": nil,
  498. }.AddToFixture(),
  499. // Place the default cc test modules that are common to all platforms in a location that will not
  500. // conflict with default test modules defined by other packages.
  501. android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()),
  502. // Disable linux bionic by default.
  503. android.FixtureAddTextFile(linuxBionicDefaultsPath, withoutLinuxBionic()),
  504. )
  505. // Prepare a fixture to use all cc module types, mutators and singletons fully.
  506. //
  507. // This should only be used by tests that want to run with as much of the build enabled as possible.
  508. var PrepareForIntegrationTestWithCc = android.GroupFixturePreparers(
  509. android.PrepareForIntegrationTestWithAndroid,
  510. genrule.PrepareForIntegrationTestWithGenrule,
  511. PrepareForTestWithCcDefaultModules,
  512. )
  513. // The preparer to include if running a cc related test for windows.
  514. var PrepareForTestOnWindows = android.GroupFixturePreparers(
  515. // Place the default cc test modules for windows platforms in a location that will not conflict
  516. // with default test modules defined by other packages.
  517. android.FixtureAddTextFile("defaults/cc/windows/Android.bp", withWindowsModules()),
  518. )
  519. // The preparer to include if running a cc related test for linux bionic.
  520. var PrepareForTestOnLinuxBionic = android.GroupFixturePreparers(
  521. // Enable linux bionic
  522. //
  523. // Can be used after PrepareForTestWithCcDefaultModules to override its default behavior of
  524. // disabling linux bionic, hence why this uses FixtureOverrideTextFile.
  525. android.FixtureOverrideTextFile(linuxBionicDefaultsPath, withLinuxBionic()),
  526. )
  527. // This adds some additional modules and singletons which might negatively impact the performance
  528. // of tests so they are not included in the PrepareForIntegrationTestWithCc.
  529. var PrepareForTestWithCcIncludeVndk = android.GroupFixturePreparers(
  530. PrepareForIntegrationTestWithCc,
  531. android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
  532. snapshot.VendorSnapshotImageSingleton.Init(ctx)
  533. snapshot.RecoverySnapshotImageSingleton.Init(ctx)
  534. RegisterVendorSnapshotModules(ctx)
  535. RegisterRecoverySnapshotModules(ctx)
  536. ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
  537. }),
  538. )
  539. // TestConfig is the legacy way of creating a test Config for testing cc modules.
  540. //
  541. // See testCc for an explanation as to how to stop using this deprecated method.
  542. //
  543. // deprecated
  544. func TestConfig(buildDir string, os android.OsType, env map[string]string,
  545. bp string, fs map[string][]byte) android.Config {
  546. // add some modules that are required by the compiler and/or linker
  547. bp = bp + GatherRequiredDepsForTest(os)
  548. mockFS := map[string][]byte{}
  549. GatherRequiredFilesForTest(mockFS)
  550. for k, v := range fs {
  551. mockFS[k] = v
  552. }
  553. return android.TestArchConfig(buildDir, env, bp, mockFS)
  554. }
  555. // CreateTestContext is the legacy way of creating a TestContext for testing cc modules.
  556. //
  557. // See testCc for an explanation as to how to stop using this deprecated method.
  558. //
  559. // deprecated
  560. func CreateTestContext(config android.Config) *android.TestContext {
  561. ctx := android.NewTestArchContext(config)
  562. genrule.RegisterGenruleBuildComponents(ctx)
  563. ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
  564. ctx.RegisterModuleType("cc_test", TestFactory)
  565. ctx.RegisterModuleType("cc_test_library", TestLibraryFactory)
  566. ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
  567. ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
  568. snapshot.VendorSnapshotImageSingleton.Init(ctx)
  569. snapshot.RecoverySnapshotImageSingleton.Init(ctx)
  570. RegisterVendorSnapshotModules(ctx)
  571. RegisterRecoverySnapshotModules(ctx)
  572. ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
  573. RegisterVndkLibraryTxtTypes(ctx)
  574. ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
  575. android.RegisterPrebuiltMutators(ctx)
  576. RegisterRequiredBuildComponentsForTest(ctx)
  577. return ctx
  578. }
  579. func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool, fake bool) {
  580. t.Helper()
  581. mod := ctx.ModuleForTests(moduleName, variant)
  582. outputFiles := mod.OutputFiles(t, "")
  583. if len(outputFiles) != 1 {
  584. t.Errorf("%q must have single output\n", moduleName)
  585. return
  586. }
  587. snapshotPath := filepath.Join(subDir, snapshotFilename)
  588. if include {
  589. out := singleton.Output(snapshotPath)
  590. if fake {
  591. if out.Rule == nil {
  592. t.Errorf("Missing rule for module %q output file %q", moduleName, outputFiles[0])
  593. }
  594. } else {
  595. if out.Input.String() != outputFiles[0].String() {
  596. t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0])
  597. }
  598. }
  599. } else {
  600. out := singleton.MaybeOutput(snapshotPath)
  601. if out.Rule != nil {
  602. t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0])
  603. }
  604. }
  605. }
  606. func CheckSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
  607. t.Helper()
  608. checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, false)
  609. }
  610. func CheckSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
  611. t.Helper()
  612. checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false, false)
  613. }
  614. func CheckSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
  615. t.Helper()
  616. checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true)
  617. }
  618. func AssertExcludeFromVendorSnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool, variant string) {
  619. t.Helper()
  620. m := ctx.ModuleForTests(name, variant).Module().(LinkableInterface)
  621. if m.ExcludeFromVendorSnapshot() != expected {
  622. t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", m.String(), expected)
  623. }
  624. }
  625. func GetOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) {
  626. for _, moduleName := range moduleNames {
  627. module := ctx.ModuleForTests(moduleName, variant).Module().(*Module)
  628. output := module.outputFile.Path().RelativeToTop()
  629. paths = append(paths, output)
  630. }
  631. return paths
  632. }
  633. func AssertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool, variant string) {
  634. t.Helper()
  635. m := ctx.ModuleForTests(name, variant).Module().(LinkableInterface)
  636. if m.ExcludeFromRecoverySnapshot() != expected {
  637. t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected)
  638. }
  639. }