blob: ed62ba72e9289224e1f18c32d7954cdae0027d40 [file] [log] [blame]
Ian Zerny1648f4b2021-11-17 09:03:49 +01001//
2// Copyright (C) 2021 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16// Integration test for the R8 retracing tool.
17
18// The retracing tool is a developer tool and part of the build tools.
19// The following tests are structured so that the app and retrace tool
20// are invoked exactly as a normal build would. The check that they
21// produce the correct result is then postponed to a test so that a
22// retrace tool failure will not result in a build failure.
23
24// Rule to dexdump the content of a sample app.
25// The dexdump is used to simulate a raw stack trace from the app.
Bob Badour0bc14d92022-01-13 11:52:30 -080026package {
27 // See: http://go/android-license-faq
28 // A large-scale-change added 'default_applicable_licenses' to import
29 // all of the 'license_kinds' from "prebuilts_r8_license"
30 // to get the below license kinds:
31 // SPDX-license-identifier-Apache-2.0
32 default_applicable_licenses: ["prebuilts_r8_license"],
33}
34
Ian Zerny1648f4b2021-11-17 09:03:49 +010035genrule {
36 name: "r8retrace-dexdump-sample-app",
37 out: ["dexdump.txt"],
38 srcs: [":HelloActivityWithR8"],
39 tools: ["dexdump", "extractmarker"],
40 cmd: "$(location extractmarker) $(in) > $(out)"
41 + " && $(location dexdump) -d $(in) >> $(out)",
42}
43
44// Tool and rule to create the raw stack trace from a dexdump.
45java_binary_host {
46 name: "r8retrace-create-stacktrace-tool",
47 main_class: "com.android.tools.r8.CreateStacktraceFromDexDumpTool",
48 srcs: ["src/com/android/tools/r8/CreateStacktraceFromDexDumpTool.java"],
49}
50
51genrule {
52 name: "r8retrace-create-stacktrace",
53 out: ["stacktrace.txt"],
54 srcs: [":r8retrace-dexdump-sample-app"],
55 tools: ["r8retrace-create-stacktrace-tool"],
56 cmd: "$(location r8retrace-create-stacktrace-tool) $(in) $(out)",
57}
58
59// Run retrace on the stack trace to produce a retraced stack trace.
60genrule {
61 name: "r8retrace-run-retrace",
62 out: ["retraced-stacktrace.txt"],
63 srcs: [":r8retrace-create-stacktrace", ":HelloActivityWithR8{.proguard_map}"],
64 tools: ["retrace"],
65 cmd: "$(location retrace)"
66 + " --map-search-path $(location :HelloActivityWithR8{.proguard_map})"
67 + " $(location :r8retrace-create-stacktrace)"
68 + " > $(out)",
69}
70
71// Test checks that the raw and retraced stack traces are as expected.
72// All the output files are added as resources here so that, in case of failure, their content
73// can be included in the error message.
74java_test_host {
75 name: "r8retrace-check-retraced-stacktrace",
76 test_suites: ["general-tests"],
77 srcs: ["src/com/android/tools/r8/CheckRetracedStacktraceTest.java"],
78 static_libs: ["junit"],
79 java_resources: [
80 ":r8retrace-dexdump-sample-app",
81 ":HelloActivityWithR8{.proguard_map}",
82 ":r8retrace-create-stacktrace",
83 ":r8retrace-run-retrace",
84 ],
85}