Commit Graph

2629 Commits

Author SHA1 Message Date
Elliott Hughes c6dbacd50d Merge "Move adb/fastboot bash completion into adb/fastboot." am: 9c8c03896e
am: 081e7f5eaa

Change-Id: I6a7e26de30a3c0a18ef6a0967077e38b4bda38c7
2018-04-04 13:09:03 -07:00
Elliott Hughes 9c8c03896e Merge "Move adb/fastboot bash completion into adb/fastboot." 2018-04-04 19:44:37 +00:00
Elliott Hughes fbfa0e8781 Move adb/fastboot bash completion into adb/fastboot.
Bug: http://b/74443706
Test: bash completion still works.
Change-Id: I9da3a0ae748a202407652f513c990e9d05f8b01a
2018-04-04 08:33:33 -07:00
David Brazdil 20ab3df0a6 Merge "Revert "adb: add transport benchmark."" am: 3876e37319
am: 566cf781cf

Change-Id: I30b46eb5392468bc3542d0ee6d36240c361178ad
2018-04-04 04:59:55 -07:00
David Brazdil 3876e37319 Merge "Revert "adb: add transport benchmark."" 2018-04-04 11:42:39 +00:00
David Brazdil 2ef56a1174 Revert "adb: add transport benchmark."
This reverts commit d78f59ca53.

Reason for revert: Breaks aosp-master renderscript and sdk_mac:
  error: system/core/adb/Android.bp:199:19: unrecognized property "host_supported"

Change-Id: Ifd75921dcdf5dce57f98833a913540914984b293
2018-04-04 10:32:08 +00:00
Josh Gao ad45a986c8 Merge "adb: add transport benchmark." am: 3f6ef0d2d2
am: 643187d895

Change-Id: I224207a522ced476aa1cbf5a23e93a9fd6120d75
2018-04-04 00:15:24 -07:00
Josh Gao 937a60634f Merge "adb: don't abort when connecting to the same address twice." am: 60c6023902
am: d550ab0c16

Change-Id: I56b76c960cf9f5270cd7ea97cb4307d3323053c9
2018-04-04 00:14:49 -07:00
Josh Gao 3f6ef0d2d2 Merge "adb: add transport benchmark." 2018-04-04 07:02:07 +00:00
Josh Gao d78f59ca53 adb: add transport benchmark.
Add some basic benchmarks for the underlying transport.

Test: adb_benchmark
Change-Id: I6475a66eb5a43a241c907046c23fea68263db945
2018-04-03 16:54:51 -07:00
Josh Gao c251ec55d3 adb: don't abort when connecting to the same address twice.
When connecting to an address, we construct a transport first, and then
check whether we've already connected to that address. The consequent
destruction of the BlockingConnectionAdapter attempts to join threads
that haven't been started, which aborts.

Make it safe to destruct a BlockingConnectionAdapter without calling
Start on it first, to solve this.

Bug: http://b/69137547
Test: nc -l 12345 & (adb connect localhost:12345; adb connect localhost:12345)
Test: python test_adb.py
Change-Id: I6cb968a62dbac6332907e06575893d764905ee62
2018-04-03 13:58:21 -07:00
Josh Gao 078c49f79d Merge changes Iff1ec14b,I32123c51,I517dbcba,Ic215c7fe am: b9b967e2fc
am: 606c83bcab

Change-Id: Ic21cdfcd9dbad36b7480ccb05be667e1a2c31693
2018-04-02 18:57:02 -07:00
Josh Gao 7651eb9ef7 adb: try harder to fill our test sockets.
On platforms that implement sockets via underlying sockets (e.g. Wine),
a socket can appear to be full, and then become available for writes
again without read being called on the other end. Add a sleep after
each write to give the underlying implementation time to flush.

This doesn't help us if the buffer size is smaller than MAX_PAYLOAD,
but at least in the case of Wine, that doesn't seem to be the case.

Test: adb_test
Test: wine adb_test.exe
Change-Id: Iff1ec14bbf318b9742ec7e2fb72e34e3d6bbe6ad
2018-04-02 14:18:50 -07:00
Josh Gao 954e1280d7 adb: don't set has_write_error on success.
Whoops.

Test: adb_test
Change-Id: I32123c51446a22d4423eef0753b0a0b00b500a90
2018-04-02 14:18:27 -07:00
Josh Gao 7ab55713cc adb: move ownership of the fdevent thread into FdeventTest.
Previously, each of the tests was spawning the fdevent thread manually,
in order to be able to set up listeners and such before running
fdevent_loop. Now that we have a way to run arbitrary code on the
fdevent thread, switch to having a generic fdevent thread and running
setup code via fdevent_run_on_main_thread.

Test: adb_test
Test: wine adb_test.exe
Change-Id: I517dbcbad31067b45087d9fbed67a75b75a75aec
2018-03-30 14:57:09 -07:00
Josh Gao d5655d7e5c Merge changes I06ccca30,Iee86b058 am: e6ae06e687
am: 3504d5a535

Change-Id: Idb80639b32c461b573553ca5da8e8a388236b8e1
2018-03-30 21:54:49 +00:00
Josh Gao fa30bf3932 adb: guarantee that fdevent_run_on_main_thread happens last.
Make it so that we handle run_on_main_thread calls after regular socket
events, so that we can use it as a way to ensure we've processed all
pending socket events.

Test: adb_test
Test: wine adb_test.exe
Change-Id: Ic215c7fed19a8e1699e759970658b3775aa08c45
2018-03-30 14:38:25 -07:00
Josh Gao 05fb45be17 adb: fix FdeventTest.invalid_fd on Windows.
Bail out immediately in our poll emulation if we have any invalid file
descriptors, instead of actually calling WSAPoll (which might block
forever).

Test: wine adb_test.exe
Change-Id: I06ccca305783ee7a1721b1585ddf73e022bd02d7
2018-03-29 14:24:03 -07:00
Josh Gao 09f051ff16 Merge "adbd: spawn login shell when run without a command." am: 31ed2a5c04
am: a7a66f40fd

Change-Id: I7389663e6408154dfc4ca0c81349fe6dc9cefd0e
2018-03-29 20:52:34 +00:00
Josh Gao 1702852f60 Merge "adbd: increase oom_score_adj for `adb shell`" am: db9671090d
am: 1919289d12

Change-Id: If584fabf576841b41a52df2c0c9538a6d4262dd3
2018-03-29 20:51:50 +00:00
Josh Gao 26cc303ba0 Merge "adb: restore adb/adb.exe in the list of artifacts." am: 8043633922
am: b0d408f2f3

Change-Id: Ieeb35e8ade7ed7fb0a9e022ad6e799f990849080
2018-03-29 20:51:19 +00:00
Josh Gao fd7486fb42 adb: extract the sleep in socket_test to its own function.
Make it easier to replace the sleep with something that actually waits
for the event loop to quiesce.

Test: adb_test
Change-Id: Iee86b058abbb607256dbfce43d8c70252b6bb0f6
2018-03-29 13:21:58 -07:00
Josh Gao 31ed2a5c04 Merge "adbd: spawn login shell when run without a command." 2018-03-29 20:19:27 +00:00
Josh Gao db9671090d Merge "adbd: increase oom_score_adj for `adb shell`" 2018-03-29 20:19:03 +00:00
Josh Gao 8043633922 Merge "adb: restore adb/adb.exe in the list of artifacts." 2018-03-29 20:18:58 +00:00
Josh Gao d8ff614f69 Merge changes Iea2a3055,I6582cfc6 am: 45562bfb63
am: 54b603ee56

Change-Id: I7fd99aa08ac1911eba06255a77e693d76b3d06ee
2018-03-29 00:29:35 +00:00
Josh Gao 2de2ade387 adbd: increase oom_score_adj for `adb shell`
Previously, processes started via `adb shell` have an oom_score_adj of
-1000, making them invisible to the oom killer. This makes running a
process that consumes all memory (e.g. by leaking in a loop) lead to
the entire rest of the system (including adbd, because of bad
heuristics in the kernel) being oom killed before getting to it.

Bug: http://b/63143027
Test: `adb shell cat /proc/self/oom_score_adj` with adb root
Change-Id: I59111134e36dc271adf4c1dd4bd4400d4fe6aee0
2018-03-28 15:01:23 -07:00
Treehugger Robot 45562bfb63 Merge changes Iea2a3055,I6582cfc6
* changes:
  adb: start building windows test again.
  adb: fix windows test build.
2018-03-28 21:59:33 +00:00
Josh Gao 541a8656c4 adb: restore adb/adb.exe in the list of artifacts.
Test: m dist
Change-Id: Iba44a03e79af9242bfe36efb736496f8db720ebf
2018-03-28 12:57:48 -07:00
Luis Hector Chavez 006cf308f8 Merge "adb: Open FunctionFS files with more restrictive access modes" am: f78ff013d0
am: e74b0f224c

Change-Id: I0d11be7750f0a05838ecb9b9accd02e6a0b0fb2f
2018-03-26 19:03:48 +00:00
Treehugger Robot f78ff013d0 Merge "adb: Open FunctionFS files with more restrictive access modes" 2018-03-26 18:48:25 +00:00
Josh Gao f8a97c1f14 adb: start building windows test again.
Test: mma
Change-Id: Iea2a3055cc3642905a1bbdd18550a9fc12702da8
2018-03-23 15:37:20 -07:00
Josh Gao 2e1e789e2a adb: fix windows test build.
The switch over to soong unintentionally turned off building the
Windows tests (and there's a bug preventing them from being turned on).
Preemptively fix the build breakages that'll happen when we turn them
back on.

Test: mma with Android.bp 's/cc_test_host/cc_binary_host' hacks
Change-Id: I6582cfc61b96052537d50d8ba90533dbb66e3e1d
2018-03-23 13:03:28 -07:00
Jerry Zhang d3d2461662 adb: Retry io in case of interrupt
am: 6e9a327504

Change-Id: Icd93e7cd983924c3b8b85af2987d1e36b385030b
2018-03-23 05:12:41 +00:00
Jerry Zhang 6e9a327504 adb: Retry io in case of interrupt
io_submit sleeps waiting for the gadget
to be enabled. Currently if that sleep
is interrupted it will shut down adb,
causing it to have to start back up again.

Rather than return EINTR if interrupted,
io_submit actually completes and the EINTR
is found later when looking through events.
Since an io that is interrupted will be
small anyway, add a loop to retry small ios.

Also upgrade aio logs in accordance with
their importance.

Fixes: 75981904
Test: adb works, logs show successful interrupt handling
Change-Id: I35973fce130ee849ce59fef80d15b65afb816ba4
2018-03-23 00:11:05 +00:00
Josh Gao 5651db553a Merge changes I5fe02059,Iea8bf298,I0630c302,Ifc4b8fe9,I29319bda am: d888e343b7
am: 32e239f139

Change-Id: I49fa0688d55b5e02637990f05cfd7f19cbb3d327
2018-03-22 04:07:46 +00:00
Josh Gao 8f7ff94762 adbd: spawn login shell when run without a command.
Match openssh's behavior with regards to login shells.

Bug: http://b/76116378
Test: `adb shell -T set -o` vs `ssh localhost -T set -o`
Test: `adb shell -tt set -o` vs `ssh localhost -tt set -o`
Test: `echo set -o | adb shell -T` vs `echo set -o | ssh localhost -T`
Test: `echo set -o | adb shell -tt` vs `echo set -o | ssh localhost -tt`
Change-Id: I6ed69b43e2ac79c947c242948b5617ece08a713e
2018-03-21 18:23:09 -07:00
Josh Gao bf243a6128 adb: bump the local socket backlog to the maximum.
The listen backlog seems to be more meaningful on Darwin than on Linux,
resulting in connections failing with ECONNRESET. Bump it up to the
maximum supported value to make this less likely. 128 pending
connections ought to be enough for anybody.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I5fe0205924188cf18ca1fc1204f923ab5523eeb2
2018-03-21 15:13:07 -07:00
Josh Gao 2c621ae741 adb: fix unicode file path test.
This test is failing due to:

     UnicodeWarning: Unicode equal comparison failed to convert both
     arguments to Unicode - interpreting them as being unequal'

Both arguments are already unicode, so stop encoding one side.

Test: python -m unittest test_device.FileOperationsTest.test_unicode_paths
Change-Id: Iea8bf29845ab3008ccf4c7dbd6969196e57ea25d
2018-03-21 15:13:07 -07:00
Josh Gao dcc055af64 adb: delete vestigial SHELL_EXIT_NOTIFY_FD.
There exists no path through which a value other than -1 can be written
to the SHELL_EXIT_NOTIFY_FD.

Test: adb_test
Test: adbd_test
Test: python test_device.py
Change-Id: I0630c302ba06bc76917f0445aea75d2dbe1dc865
2018-03-21 15:13:07 -07:00
Josh Gao 184f480547 adb: don't immediately close a socket when write fails.
When we fail to write to a local socket peer, we might still have data
queued up to send to the other side. Defer closing the socket until
we've failed to both read and write.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: Ifc4b8fe95369b4872e475c2ae4ee611dd2d8b9d7
2018-03-21 15:13:07 -07:00
Josh Gao 1222abc75b adb: make fdevent_run_on_main_thread's fd nonblocking.
If we get a ton of fdevent_run_on_main_thread calls while running one
of the handlers, the socket might become full, which will result in a
deadlock in fdevent_run_on_main_thread when a write to the fd blocks
with the mutex taken. Resolve this by making the fd nonblocking, which
is safe because we always write after appending to the list, and read
before emptying the list, which guarantees that if the byte we write is
consumed, the std::function we appended will be run.

Bug: http://b/74616284
Test: adb_test
Test: python test_device.py
Change-Id: I29319bda2ad7b5a5cdcd91d1d0ddf39f7ab7d115
2018-03-20 13:23:06 -07:00
Josh Gao 371cfe44ad Merge changes I6a842960,If618c26b am: 7920502065
am: c08a536a32

Change-Id: I29c44864fb1a955d3f2e07deb8bc970ee6c3faaf
2018-03-20 07:34:52 +00:00
Josh Gao fb2f969286 Merge "adb: skip IPv6 test if IPv6 isn't available." am: 46e59af921
am: c4072ed605

Change-Id: I5e66a4c56247e7f588feece0d1d8f6dee2dda278
2018-03-20 07:34:18 +00:00
Josh Gao 7920502065 Merge changes I6a842960,If618c26b
* changes:
  adb: add `adb shell exit 42` stress test.
  adb: improve socket tests.
2018-03-20 07:19:01 +00:00
Josh Gao 4abb5074be adb: skip IPv6 test if IPv6 isn't available.
Bug: http://b/69813298
Test: none
Change-Id: I0793e793bd52c5f1c639faedf09a513df263db78
2018-03-19 18:19:47 -07:00
Josh Gao c970aefada adb: add `adb shell exit 42` stress test.
Add a test to hammer on `adb shell exit $n` for flakiness.

Bug: http://b/74616284
Test: python test_device.py
Change-Id: I6a842960f5b55ff739044698f5c9683992fc42f1
2018-03-19 16:14:53 -07:00
Josh Gao ecb96ac04d adb: improve socket tests.
Make it so that the socket tests don't leak until your machine blows up
by switching an infinite loop into an assertion failure.

Bug: http://b/74616284
Test: adb_test
Change-Id: If618c26b224b660548454f542cab79bebe46f80e
2018-03-19 16:14:53 -07:00
Josh Gao 48aa138ac6 Merge changes I99b85f07,If28f6c8d am: 6156420fb7
am: 0204f8c2f2

Change-Id: I20b80d869279af82393c382ea837197633e4757c
2018-03-19 20:36:53 +00:00
Treehugger Robot 6156420fb7 Merge changes I99b85f07,If28f6c8d
* changes:
  adb: implement std::make_unique, start using it.
  base: export GetThreadId.
2018-03-19 20:14:33 +00:00