Commit Graph

529 Commits

Author SHA1 Message Date
Treehugger Robot
1da99cc99e Merge "c2a: add option to use Cargo.toml.orig" 2022-06-23 15:34:41 +00:00
Jeff Vander Stoep
2adbd7ed89 c2a: add option to use Cargo.toml.orig
`Cargo --publish` strips dev-dependencies from Cargo.toml, an issue
that won't be fixed until [1] is resolved, which doesn't seem
likely as it has been open for ~5 years now.

cargo2android needs dev-dependencies listed in Cargo.toml in order
to generate the rust_test in Android.bp, add an option that tells
cargo2android to use the cargo.toml.orig instead of the cargo.toml.

With this change there are now two options that temporarily
update Cargo.toml, so I've pulled these out into a separate class
to clean up the code a bit.

[1] https://github.com/rust-lang/cargo/issues/4242

Test: run against projects with --add_workspace and
--orig-cargo-toml

Change-Id: I3b8633a807c9734981ebde0bef9b73868acf6774
2022-06-23 16:38:08 +02:00
Treehugger Robot
d0e21e93fb Merge "c2a: Automatically make crates APEX available" 2022-06-22 19:25:58 +00:00
Matthew Maurer
a9fb65d155 c2a: Automatically make crates APEX available
The bulk of Rust packages in external/ are OS agnostic and do not care
about individual platform features. This change is intended to reduce
the churn of repeatedly adding new `apex_available` attributes to crates
by defaulting to availability. When landing a new crate which is either
platform revision specific or has an unstable file format, prefer to
set `apex_available: ["//apex_available:platform"]` until you have
thought things through.

Bug: 174862583
Test: Regenerate with no apex_available, see universal availability
Test: Regenerate with apex_available: [], see []
Test: Regenerate with apex_available: [foo], see [foo]
Change-Id: I958597789bfc966caec043d051996284dab7a927
2022-06-16 13:07:12 -07:00
Elliott Hughes
d70c7045c1 Merge "Work around an lldb bug with "localhost"." 2022-06-15 14:26:05 +00:00
Elliott Hughes
fc6da790d9 Work around an lldb bug with "localhost".
Bug: http://b/234034124
Test: reputed to work
Change-Id: I3414201712ffe0f808899e2a2f206e813bb609a7
2022-06-14 17:59:32 -07:00
Matthew Maurer
e1d07ba872 c2a: Only use postsubmit when configured
Previous logic would place tests in both presubmit and postsubmit if the
postsubmit_tests configuration was not specified. This is both
unnecessary and wastes resources because presubmit tests are also run in
postsubmit.

Bug: 236006683
Test: Regenerate all TEST_MAPPINGs, manually check postsubmit removal
Change-Id: Ie8ff0e351776711e07bf7646efd916d970254e9c
2022-06-14 16:28:36 -07:00
Matthew Maurer
037b445ed8 c2a: Denylist additional Rust tests modules
These modules are not suitable for direct execution on cuttlefish, but
are still built as `rust_test` to get the harness.

Bug: 233924440
Test: Regenerate all TEST_MAPPINGs, pass presubmit
Change-Id: I4aebdb5e36cf3a80780483e0a7ebeb83e9735d29
2022-06-14 14:32:15 -07:00
Matthew Maurer
3f7f7e2236 c2a: Do not assume test_mapping.json exists
update_crate_tests would previously assume test_mapping.json existed
when trying to generate a TEST_MAPPING update. This made updating
mappings for the majority of existing crates fail.

Bug: 233924440
Test: Regenerate all Rust TEST_MAPPINGs
Change-Id: I4d9b906f4db233ee0223a3035c1b63bf1ca681f4
2022-06-14 14:32:00 -07:00
Christopher Ferris
7d4d527a1c Modify any lines with libc.so!libc.so to libc.so.
I had made this change if there was an offset on the line,
but I didn't make if there is no offset present. Add the
no offset present case.

Bug: 206463081

Test: Ran unit tests.
Test: Modified a normal stack line with libart.so to be
Test: libart.so!libart.so and verified the line numbers
Test: are still present.
Change-Id: I75e3fbe5eaa3a5419a2dca2c4542731c61c7b971
2022-05-05 15:14:01 -07:00
Christopher Ferris
53c707781a Merge "Allow fixup of apex directories." 2022-05-03 19:02:24 +00:00
Ivan Lozano
d7438cff3b Add test_mapping_config to update_crate_tests
Adds support for configuring TEST_MAPPING output in
update_crate_tests.py by defining a test_mapping_config.json.

The initial option that can be set is whether a test should be a
postsubmit test instead of a presubmit test.

Bug: 229727993
Test: update_crate_tests.py with test_mapping_config.json produces
      postsubmit tests
Change-Id: I2f5a336c1af12630cc5df9d2c32ab63ac6099af8
2022-04-26 13:04:08 -04:00
Christopher Ferris
598cc3607b Allow fixup of apex directories.
For some reason, apex directory structure in the symbols directory
is not the same as on device.

This means that a directory on device like:

  /apex/com.android.art/lib64/libart.so

Is really found in symbols as:

  /apex/com.google.android.art/lib64/libart.so

Modify the script to look in both places for libraries.

Bug: 206463081

Test: Verified that libart.so in a backtrace now finds the symbols
Test: libart.so.
Change-Id: I67610e3a236765cc92397c70a769c4aa705f13ce
2022-04-22 14:37:56 -07:00
Edward Liaw
22e9c50ec0 gdbclient: use host ip when connecting to gdb
When the device is not on localhost, gdbclient won't connect to it
properly.  If the serial is a tcp address, parse the host and pass that
to gdb-remote.

Bug: 228371506
Test: gdbclient.py -r /system/bin/ls /bin
Change-Id: I635d4bdc483a66ab908f5aa02aa94e2504976a45
2022-04-07 00:46:07 +00:00
Roland Levillain
e6d2736cf4 Fix typo in documentation of script acov-llvm.py.
Test: n/a (comment-only change)
Change-Id: I1c10bfd65477dd2550ed86732f9bf077c59b5a59
2022-04-05 11:00:01 +01:00
David LeGare
d3bbf8cb7f Add open_then_run to TEST_EXCLUDE
Test: manual - Performed bulk update of crate TEST_MAPPING files
Change-Id: I39f7696eb1a0633d002a534ad21cc5f460eeee8c
2022-03-15 16:01:49 +00:00
Ivan Lozano
7abb3b9ee4 Merge "Exclude additional rust_tests." 2022-03-04 21:11:19 +00:00
Ivan Lozano
69030b3994 Exclude additional rust_tests.
aidl_test_rust_service_async is a helper binary and shouldn't be added
to TEST_MAPPINGs. diced_client_test does not work in presubmit yet.

Test: update_crate_tests.py no longer adds those tests.
Change-Id: I565680d2bee31e30bf5db224c46428385ed279a3
2022-03-04 14:24:24 -05:00
Peter Collingbourne
ba5482675f gdbclient.py: Implement --chroot argument.
This allows executables to be debugged inside a chroot (such as the ART
testing chroot).

Change-Id: I1b790c3c2307e240d37ed0afb9a930d00957acec
2022-03-03 12:33:26 -08:00
Thiébaud Weksteen
d5d033979f Require cargo_bin option
The prebuilt cargo (or more precisely, its libstd) cannot be used when
running cargo2android.py. Ensure that the upstream cargo binary is used.
This is automatically set when using the sandbox for Googlers. For
external contributors, raise an error if the option is not provided.

Test: As a googler, execute cargo2android.py directly; an error is
    raised.
Test: As a googler, use the sandbox; cargo2android.py is executed
    correctly.
Test: As an external contributor, execute cargo2android.py; an error is
    raised if cargo_bin is not provided.
Bug: 217810523
Change-Id: Id42ba777b3960b13f6ef91d36eaad94df939f48e
2022-02-09 11:25:15 +11:00
Christopher Ferris
27bee5adfa Fix exception when path not found.
Add a default return value in a call in the GetLibraryByBuildId()
function to avoid an exception if a file cannot be found in the
symbol directory.

Bug: 216232380

Test: Ran the input from the bug. Verified without the change, the
Test: exception occurs and with the fix, no exception.
Test: Ran unit tests of stack_core.py.
Change-Id: I015982eb835f5a3d7f03dcc3e0b1627b0c1a7cfe
2022-01-25 13:10:24 -08:00
Treehugger Robot
6bcf0f0530 Merge "Remove self from OWNERS" 2022-01-12 01:45:53 +00:00
Andrew Walbran
ca9f9f2266 Add --no-presubmit option to prevent host tests being run in presubmit.
For some unknown reason the change to merge rust_test and rust_test_host
targets caused some crosvm tests to be run (and fail) in prebsubmit which
were not previously being run, so this is necessary to work around it.

Test: Ran cargo2android.py on various crosvm crates.
Change-Id: I9b94d270148d8ce5fa97f88f460d8c03eac3873c
2022-01-10 16:02:53 +00:00
Andrew Walbran
0e65bba93d Ignore clippy configuration flags.
Test: Ran ./all2android.sh under external/crosvm
Change-Id: I29a50ee242bca5111004b6ba56867b1e68ccd8f3
2022-01-07 15:12:00 +00:00
Joel Galenson
973e63ab11 Remove self from OWNERS
Test: None
Change-Id: If2341f925c28953a522b0e0b96535a3126ff954b
2022-01-06 10:18:42 -08:00
Treehugger Robot
a3fe9b1729 Merge "Remove parameters from symbolized stack traces." 2022-01-06 17:52:54 +00:00
Andrew Walbran
a32a04851b Don't try to remove Cargo.lock if it doesn't exist.
Change-Id: Ibfad6d97988edb6305d7a237d038412ec5a6100f
2022-01-06 14:03:50 +00:00
David Srbecky
80547ae39d Remove parameters from symbolized stack traces.
The expanded parameters take a lot horizontal space
and almost always push the file:line of the screen,
or text-wrap generating multiple lines per frame.

This CL tries to make the output less cluttered by
removing parameters from the unmangled method names.

It is possible to add the parameters back using
the --verbose command line argument.

Test: Add unit tests, investigate crashes from logcat
Change-Id: I42d1e26dbc2fa9db8b7bd95ce449cb2bd93f93f8
2021-12-23 14:09:11 +00:00
Joel Galenson
79b55eadb6 Merge changes from topic "rust-tests-and-mappings-refactor"
* changes:
  cargo2android: Add tests to both test groups
  Use TEST_MAPPING imports for third-party crate tests.
2021-12-15 15:27:59 +00:00
Joel Galenson
376a19951b Merge "Stop generating separate rust_test_host." 2021-12-15 15:27:59 +00:00
Matthew Maurer
24758f89e2 cargo2android: Add tests to both test groups
"presubmit" will continue to handle x86_64 virtual device and host tests
"presubmit-rust" will run the test on a pool of physical arm64 devices

Bug: 204332926
Test: regenerated a few TEST_MAPPING files
Change-Id: Idd5cad5107a96031f67305b63875034b2e5a5c60
2021-12-10 20:43:21 +00:00
Joel Galenson
54d655345d Stop generating separate rust_test_host.
With b/196306316 hopefully fixed, we should be able to use a single
rust_test entry for both device and host tests.  This modifies
cargo2android.py so it generates these shared tests.

Test: Run on crates with simple tests, those with defaults, host-only,
and device-only tests.

Change-Id: Icfe8d1fb26a61bc9ed65b8a7b116a4ebcd782ce4
2021-12-06 16:17:06 -08:00
Joel Galenson
4a08c64965 Use TEST_MAPPING imports for third-party crate tests.
This script currently computes all transitive reverse dependencies for
a given crate and adds them to the generated TEST_MAPPING.  This
creates a very large file and makes it difficult to rename/remove
tests, as a given test can be in many TEST_MAPPING files in other
directories.  We fix this by instead importing the TEST_MAPPING files
of other third-party crates.

Note that we cannot do this for tests defined by this crate (as they
need to be in some TEST_MAPPING file) and for tests outside of
external.  For the latter, we do not auto-generate those TEST_MAPPING
files, so they might contain extra tests we do not want or not contain
the tests we do want.  We thus continue to list such tests
individually, which is suboptimal but at least is a strict improvement
over the current system.

Test: Run on a few crates.
Change-Id: Ibdf36e7844f5946c9e321ac60558792abd691b42
2021-12-06 16:15:49 -08:00
Treehugger Robot
445a4c4e19 Merge "Use input instead of raw_input in gdbclient.py" 2021-12-02 20:25:07 +00:00
Siarhei Vishniakou
9c4f1b3cac Use input instead of raw_input in gdbclient.py
Following suggestions in b/194659728, update the python script to work
under python3.

Previous failure:

Traceback (most recent call last):
  File "/android3/android/master/development/scripts/lldbclient.py", line 413, in <module>
    main()
  File "/android3/android/master/development/scripts/lldbclient.py", line 405, in main
    do_main()
  File "/android3/android/master/development/scripts/lldbclient.py", line 400, in do_main
    raw_input("Press enter to shut down lldb-server")
NameError: name 'raw_input' is not defined

Bug: none
Test: "lldbclient.py --setup-forwarding vscode-lldb -r
/data/nativetest64/inputflinger_tests/inputflinger_tests
--gtest_filter=PalmRejectorTest.GenericAxisValue_IsNotSet"

Change-Id: I21d977cbc580894d6e2eb2f2f56dec04c65b0416
2021-12-02 11:10:37 -08:00
Joel Galenson
d4b099d3fa Merge changes If5292d1d,Ib1a86d48
* changes:
  Stop cargo2android.py from printing the --cargo_bin argument.
  Revert "Enable LTO in cargo2android.py."
2021-12-02 14:46:56 +00:00
Joel Galenson
56b5f4be29 Comment out errors encountered when running cargo test.
A recent change to remove empty tests runs cargo test --list.  A few
crates produce build errors this way that they did not previously do.
This currently causes cargo2android.py to produce illegal Android.bp
files for these crates even though these should not be fatal errors.
We thus detect these errors and emit them as comments in the
Android.bp file, so developers can see them but the crate can still
compile.

Test: Run on crates with and without such errors.
Change-Id: I8664d3ca9a6b4c513ce0ef35821aa64d22949fc7
2021-11-30 10:34:14 -08:00
Joel Galenson
769c3c373f Stop cargo2android.py from printing the --cargo_bin argument.
cargo2android.py prints out all of its arguments to the top of the
Android.bp file (and into a config file if that option was set) as a
way of persisting them.  However, we do not want to persist the
--cargo_bin directory, as this is a proprety of the local setup and
not the crate itself.  Thus ensure we don't print this.

Test: Run with argument.
Change-Id: If5292d1d740b08755ba6d31654239e93232fdc49
2021-11-24 15:10:02 -08:00
Joel Galenson
903a0f8cb1 Revert "Enable LTO in cargo2android.py."
This reverts commit 4f4ac2f8f3.

This did not work for all crates (specifically, those with build.rs,
as they don't get passed RUSTFLAGS, as well as proc-macros, since they
get the flag but can't use LTO), so we're using a different approach
where this is not desired.

Test: Run script
Change-Id: Ib1a86d4822f51978cd8ec15ad657eb25c84e01a4
2021-11-24 15:09:45 -08:00
Joel Galenson
4f4ac2f8f3 Enable LTO in cargo2android.py.
The latest compiler roll also enabled LTO.  This broke
cargo2android.py, as the test prebuit uses LTO and so cannot be linked
with code built without.  We fix this by enabling it in
cargo2android.py (and ensuring it doesn't add the flag into
Android.bp).

Test: Run
Change-Id: I6c6a813ff58a9e5064752aa59b78247c4af77a26
2021-11-22 15:22:45 -08:00
David Srbecky
df6d482c25 Stack symbolization: Replace functools.cache
Use lru_cache(maxsize=None) instead which is equivalent,
and is available on older python versions as well.

Also fix a bug where null "lib" variable was dereferenced.

Bug: 204507951
Bug: 171980804
Test: Run script with python3.7
Change-Id: I922ee48451ad3c60c2237fb0554e1838c1bf81af
2021-10-29 10:45:23 +00:00
Treehugger Robot
b0f82fbc61 Merge "Try to locate symbols using build-id." 2021-10-28 23:12:12 +00:00
David Srbecky
3a3349eeeb Try to locate symbols using build-id.
If the parsed backtrace has ELF build-ids, use them to
brute-force search for files in the symbols directory.

The search only considers files with the same basename,
so the number of candidates to check is very small.

This fixes issues when compile time directory does not
match the runtime directory on device (e.g. for apex).

Bug: 171980804
Test: ART crashes can be symbolized again
Change-Id: I0311a10c1e2eab92ee44f1b32c523d4763a54ee1
2021-10-28 22:53:46 +01:00
Joel Galenson
0038349332 Merge "Document the expectations of two arguments." 2021-10-25 16:45:04 +00:00
Christopher Ferris
7ea56f02c8 Small script fixes.
Fix a problem with python3 and the zipinfo processing of an apk.

Add sorting of the zipinfo data since it's not guaranteed that
the zip entries will be in sorted order, so sort them.

Bug: https://github.com/android/ndk/issues/1587

Test: Ran a apk stack line through the script.
Test: Ran the stack core unit tests.
Change-Id: Ie5ea67ad54a6b2de077e53740c82265f6bf783c6
2021-10-21 00:35:13 +00:00
Joel Galenson
493c26a8d4 Document the expectations of two arguments.
To work with the updater, these files must have a certain prefix.

Test: Run with --help and upgrade a crate.
Change-Id: Icdc492479223865c39d6c6f10b84fe3d762f5d1d
2021-10-18 15:54:41 -07:00
Joel Galenson
7cfc6fe5de Do not generate empty Rust tests.
cargo2android.py currently builds whatever cargo does, which includes
empty tests.  We can filter those out by parsing the output of "cargo
test" and looking for things with no tests.

Fixes: 159039990
Test: Run on a crate with empty integration tests, one with empty unit
tests, and one with no empty tests.

Change-Id: If8b1126d82ce6c2851b90de738ea24b129b81feb
2021-10-15 13:35:41 -07:00
Joel Galenson
f78de4f942 Merge "Do not generate cargo_pkg_version when --no-pkg-vers is passed" 2021-10-08 21:12:41 +00:00
Joel Galenson
75fa9a110d Merge "Handle versions of the form -a.b.c+foo." 2021-10-01 23:58:30 +00:00
Joel Galenson
308f3521dd Handle versions of the form -a.b.c+foo.
Previously we would keep the +x.y.z part, which caused errors in Soong.

See the diff between the first two patchsets in aosp/1833319 for an
example.

Test: Fix the above CL and run on a crate without a +.
Change-Id: I791c85545e67b54e2c8952428211688e7bbf580d
2021-10-01 15:19:45 -07:00