| // |
| // Copyright (C) 2021 The Android Open Source Project |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| // Integration test for the R8 retracing tool. |
| |
| // The retracing tool is a developer tool and part of the build tools. |
| // The following tests are structured so that the app and retrace tool |
| // are invoked exactly as a normal build would. The check that they |
| // produce the correct result is then postponed to a test so that a |
| // retrace tool failure will not result in a build failure. |
| |
| // Rule to dexdump the content of a sample app. |
| // The dexdump is used to simulate a raw stack trace from the app. |
| package { |
| // See: http://go/android-license-faq |
| // A large-scale-change added 'default_applicable_licenses' to import |
| // all of the 'license_kinds' from "prebuilts_r8_license" |
| // to get the below license kinds: |
| // SPDX-license-identifier-Apache-2.0 |
| default_applicable_licenses: ["prebuilts_r8_license"], |
| } |
| |
| genrule { |
| name: "r8retrace-dexdump-sample-app", |
| out: ["dexdump.txt"], |
| srcs: [":HelloActivityWithR8"], |
| tools: ["dexdump", "extractmarker"], |
| cmd: "$(location extractmarker) $(in) > $(out)" |
| + " && $(location dexdump) -d $(in) >> $(out)", |
| } |
| |
| // Tool and rule to create the raw stack trace from a dexdump. |
| java_binary_host { |
| name: "r8retrace-create-stacktrace-tool", |
| main_class: "com.android.tools.r8.CreateStacktraceFromDexDumpTool", |
| srcs: ["src/com/android/tools/r8/CreateStacktraceFromDexDumpTool.java"], |
| } |
| |
| genrule { |
| name: "r8retrace-create-stacktrace", |
| out: ["stacktrace.txt"], |
| srcs: [":r8retrace-dexdump-sample-app"], |
| tools: ["r8retrace-create-stacktrace-tool"], |
| cmd: "$(location r8retrace-create-stacktrace-tool) $(in) $(out)", |
| } |
| |
| // Run retrace on the stack trace to produce a retraced stack trace. |
| genrule { |
| name: "r8retrace-run-retrace", |
| out: ["retraced-stacktrace.txt"], |
| srcs: [":r8retrace-create-stacktrace", ":HelloActivityWithR8{.proguard_map}"], |
| tools: ["retrace"], |
| cmd: "$(location retrace)" |
| + " --map-search-path $(location :HelloActivityWithR8{.proguard_map})" |
| + " $(location :r8retrace-create-stacktrace)" |
| + " > $(out)", |
| } |
| |
| // Test checks that the raw and retraced stack traces are as expected. |
| // All the output files are added as resources here so that, in case of failure, their content |
| // can be included in the error message. |
| java_test_host { |
| name: "r8retrace-check-retraced-stacktrace", |
| test_suites: ["general-tests"], |
| srcs: ["src/com/android/tools/r8/CheckRetracedStacktraceTest.java"], |
| static_libs: ["junit"], |
| java_resources: [ |
| ":r8retrace-dexdump-sample-app", |
| ":HelloActivityWithR8{.proguard_map}", |
| ":r8retrace-create-stacktrace", |
| ":r8retrace-run-retrace", |
| ], |
| } |