aboutsummaryrefslogtreecommitdiff
path: root/test_adb.py
AgeCommit message (Collapse)Author
2021-03-03Revert "Disable test broken by infra changes."Elliott Hughes
This reverts commit 4658efeb7831ec135f4642e3d4f3aeb7553e0c7e now the test infrastructure is fixed. Bug: http://b/178980410 Change-Id: Ie263f8211c383eb0b2fe3d42852a535758d2898c Test: none
2021-02-01Disable test broken by infra changes.Josh Gao
Bug: http://b/178980410 Test: none Change-Id: I5b56a053bf0aa31bbdca6ca0d84d9cb45818a3a9
2020-07-01[adb] Fix crash in mdns service removal.Joshua Duong
If std::remove_if is a no-op (no service name match), then std::vector::erase would crash. Bug: 160025305 Test: test_adb.py Test: Manual. 1) Enable wireless debugging on multiple devices 2) Disable wireless debugging on all devices Change-Id: If58b0dda0bb698fd3fd225d9b6a6726a88ae47e0
2020-06-02adb: don't use parameterized in test_adb.py.Josh Gao
The test bots don't have this module installed. Test: treehugger Change-Id: I849a075b784eac296608e45bec7b2fce38f56ac4
2020-05-18'adb connect' by mDNS service name.Joshua Duong
Bug: 152886765 Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test Test: test_adb.py Change-Id: I7e93ceca7cdf913060bbc5afe824593a9922c6d9
2020-05-05[adb client] Fix mdns discovery service registry.Joshua Duong
We were getting stale service ip addresses because we weren't destroying the sdref correctly. Also, we were leaking the ResolvedServices when removing it from the ServiceRegistry. Converted them to smart pointers to fix that. Bug: 153343580 Test: test_adb.py Change-Id: Ib7c1dbf54937d4ac6d9885cb5f7289bef616d12e
2020-04-22[adb client] Add "mdns services" command.Joshua Duong
This command list all discovered mdns services, so we can connect via service name later on. Bug: 152521166 Test: 'adb mdns services' Test: test_adb.py Change-Id: I23d42a7933e67a65bd0c9924afd6abe5915c0a11
2020-04-22[adb client] Add "adb mdns check" command.Joshua Duong
This command will check if the mdns daemon is available on the host machine. Bug: 152510294 Test: pkill -9 mdnsd; adb mdns check; mdnsd; adb mdns check; Test: test_adb.py Change-Id: If644678a339763817a8a7adcbdc545626d161aba
2020-02-27adb: don't hardcode ports in test_adb.Josh Gao
If we get unlucky and something else (or ourselves, in another thread) beats us to listening on our hardcoded ports, we can deadlock. Bug: http://b//149829737 Test: ./test_adb.py Change-Id: I8f14004a6b2e77366abad6e88786ea8941629020
2019-11-07Allow the adb server to bind on ::1Callum Ryan
Currently the adb server can only bind on 127.0.0.1 or * if -a is provided. This diff adds the ability for adb to bind on ::1 as well for use cases where you might want to force adb to be IPv6 only. To bind the adb server on ::1 ``` $ ./adb -L tcp:[::1]:1234 server $ lsof -nPi :1234 COMMAND ... NODE NAME adb ... TCP [::1]:1234 (LISTEN) ``` The original behaviour is also retained, so this would only affect users explicitly specifying ::1 in the socket spec ``` $ export ANDROID_ADB_SERVER_PORT=1234 $ ./adb server $ lsof -nPi :1234 COMMAND ... NODE NAME adb ... TCP 127.0.0.1:1234 (LISTEN) ``` Note: I've only implemented this behaviour for posix base systems, due to my limited understanding of networking on windows. If needed I can do some research to implement it there as well, but there is currently no IPv6 support at all on the windows side. Test: New unit test and the commands in the summary Change-Id: I23e4531e8dfda4de9348124ad7491d728aecdbf7
2019-02-20Temporarily @ignore test_reconnectJulien Desprez
For the purpose of on-boarding all the other tests, skip test_reconnect for now. Test: atest -v adb_integration_test_adb Bug: 123247844 Change-Id: I50269272adbfc3f946d71bae13677546566d541f
2019-02-07adb: hopefully deflake test_adb.py.Josh Gao
The reconnection test is spuriously failing on test infrastructure for unclear reasons, which might be due to a race between the connection attempt and the first command we send. Insert a sleep to hopefully reduce the flakiness. Bug: http://b/123247844 Test: ./test_adb.py (but it didn't fail for me in the first place) Change-Id: Ic36924c16bae424accfec700af4623794fd1f123
2018-10-16test_adb.py: silence ResourceWarning.Josh Gao
Test: ./adb_test.py Change-Id: If12558492e4edafd3568530a96eac2032526877d
2018-08-31adb: win32: test USB kick on resume from sleep/hibernationSpencer Low
Unittest for 9f1ba56b8aa2757ccbd41b711c6c78d3dd29d4da. Works by simulating resume from sleep/hibernation by sending a Windows message. Test: python3 -m unittest test_adb.PowerTest Change-Id: I78510f30c012f68eda39764da522dbf8d03f2576 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2018-08-21adb: fix test_adb.py's adb server spawning on Windows.Josh Gao
Test: test_adb.py on windows vm Change-Id: I918678be7ececd167969789ecff7cfb58829fa1d
2018-08-13adb: make disconnect stop reconnection immediately.Josh Gao
Make `adb disconnect` remove transports immediately, instead of on their next reconnection cycle. Test: adb connect unreachable:12345; adb devices; adb disconnect; adb devices Change-Id: I35c8b57344e847575596d09216fc636be47dde64
2018-08-08adb: switch test_adb.py over to double quotes.Josh Gao
Test: ./test_adb.py Change-Id: I3a568361d54f32cc895cea439de0f2c38aee5e2d
2018-08-08adb: make test_adb.py work on windows.Josh Gao
Switch from os.pipe to socket.socketpair for the fake adbd termination termination signaller, that we can select on it on windows. Test: test_adb.py on windows (2 failures on windows) Change-Id: I37df06e465ec8be28cfb18a5c21ef30125195004
2018-08-08adb: switch test_adb.py to python3.Josh Gao
Currently, test_adb.py doesn't work on Windows, because we're selecting on a pipe, which doesn't work on Windows. Python 3.5 adds socketpair support to Windows, so switch over to Python 3 to make it so we can use that. Test: python3 test_adb.py Change-Id: I0fbd1bca0b28324658831d5ef8ee08aefe2b0596
2018-05-16adb: Add a test for emulator connectionLuis Hector Chavez
This should prevent regressions in the future. Bug: 78991667 Test: python system/core/adb/test_adb.py Change-Id: I4d6da40da82c6d79797cec82ffaf071d4b56ddc7
2018-05-16adb: Improve test_adb a bit moreLuis Hector Chavez
This change: * uses unittest.main(), which allows for a subset of the tests to be selected. * drops the requirement to have a device already connected since all the tests that need a device now spin their own mock device. * Splits the monolithic test class into more granular classes. * Makes this file be pylint-compliant. Bug: None Test: python system/core/adb/test_adb.py Test: pylint system/core/adb/test_adb.py Change-Id: I91c7ced520c3c69f855d639e0dbf7e57bb690e97
2018-05-16adb: Add a way to reconnect TCP transportsLuis Hector Chavez
This change adds a reconnect handler that tracks all TCP transports that were connected at some point, but became disconnected. It does so by attempting to reconnect every 10s for up to a minute. Bug: 74411879 Test: system/core/adb/test_adb.py Test: adb connect chromebook:22 # This runs with sslh Test: CtsBootStatsTestCases Test: emulator -show-kernel ; adb -s emulator-5554 shell Change-Id: I7b9f6d181b71ccf5c26ff96c45d36aaf6409b992
2018-04-26adb: Add a way to distinguish between connection failures and successesLuis Hector Chavez
This change adds a callback that is invoked exactly once, either when the connection is fully established (i.e. CNXN packets have been sent and received) or the atransport object is deleted before that (because the connection failed). This helps in distinguishing between successful and failing connections for TCP. Especially when there is some kind of port forwarding/multiplexing in between (like an SSH tunnel or SSLH proxy). Bug: 74411879 Test: adb connect chromebook:22 (which runs an sslh tunnel to adbd). either succeeds or fails, but not fake-succeeds. Change-Id: I7e826c6f5d4c30338a03b2d376a857ac5d05672a
2018-04-17Improve test_adb.pyLuis Hector Chavez
This change uses a context manager to create the fake ADB servers (and cleanly tear them down. Bug: 74411879 Test: python system/core/adb/test_adb.py Change-Id: I722d2c4135259b1b0ef00a1510aa8402e87ecf72
2018-04-03adb: don't abort when connecting to the same address twice.Josh Gao
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-03-19adb: skip IPv6 test if IPv6 isn't available.Josh Gao
Bug: http://b/69813298 Test: none Change-Id: I0793e793bd52c5f1c639faedf09a513df263db78
2017-08-23Fix adb tcpip tests.Elliott Hughes
The test was assuming we still output the full help for every syntax error. While I'm here, make the diagnostics suck less. Bug: N/A Test: ran tests Change-Id: Idc28616f20c66391f32046cf4216f122998a84bd
2016-09-01libcutils: try all addresses in socket_network_client_timeout.Josh Gao
If a connection fails to an address that resolves to multiple sockaddrs, attempt connecting to subsequent addresses if the initial connection fails to a reason other than timeout. This is primarily useful for localhost, which can resolve to both an IPv4 and and IPv6 address. Also, add an adb test to verify that this behavior. Bug: http://b/30313466 Change-Id: Ib2df706a66cf6ef8c1097fdfd7aedb69b8df2d6e Test: python test_adb.py (+ the test fails before this patch)
2015-10-30adb: fix adb client running out of sockets on WindowsSpencer Low
Background ========== On Windows, if you run "adb shell exit" in a loop in two windows, eventually the adb client will be unable to connect to the adb server. I think connect() is returning WSAEADDRINUSE: "Only one usage of each socket address (protocol/network address/port) is normally permitted. (10048)". The Windows System Event Log may also show Event 4227, Tcpip. Netstat output is filled with: # for the adb server TCP 127.0.0.1:5037 127.0.0.1:65523 TIME_WAIT # for the adb client TCP 127.0.0.1:65523 127.0.0.1:5037 TIME_WAIT The error probably means that the client is running out of free address:port pairs. The first netstat line is unavoidable, but the second line exists because the adb client is not waiting for orderly/graceful shutdown of the socket, and that is apparently required on Windows to get rid of the second line. For more info, see https://github.com/CompareAndSwap/SocketCloseTest . This is exacerbated by the fact that "adb shell exit" makes 4 socket connections to the adb server: 1) host:version, 2) host:features, 3) host:version (again), 4) shell:exit. Also exacerbating is the fact that the adb protocol is length-prefixed so the client typically does not have to 'read() until zero' which effectively waits for orderly/graceful shutdown. The Fix ======= Introduce a function, ReadOrderlyShutdown(), that should be called in the adb client to wait for the server to close its socket, before closing the client socket. I reviewed all code where the adb client makes a connection to the adb server and added ReadOrderlyShutdown() when it made sense. I wasn't able to add it to the following: * interactive_shell: this doesn't matter because this is interactive and thus can't be run fast enough to use up ports. * adb sideload: I couldn't get enough test coverage and I don't think this is being called frequently enough to be a problem. * send_shell_command, backup, adb_connect_command, adb shell, adb exec-out, install_multiple_app, adb_send_emulator_command: These already wait for server socket shutdown since they already call recv() until zero. * restore, adb exec-in: protocol design can't have the server close first. * adb start-server: no fd is actually returned * create_local_service_socket, local_connect_arbitrary_ports, connect_device: probably called rarely enough not to be a problem. Also in this change =================== * Clarify comments in when adb_shutdown() is called before exit(). * add some missing adb_close() in adb sideload. * Fixup error handling and comments in adb_send_emulator_command(). * Make SyncConnection::SendQuit return a success boolean. * Add unittest for adb emu kill command. This gets code coverage over this very careful piece of code. Change-Id: Iad0b1336f5b74186af2cd35f7ea827d0fa77a17c Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-16adb unittest for win32 handle inheritanceSpencer Low
adb.cpp: launch_server() has a long comment about how stdin/stdout/stderr handles have to be made non-inheritable to prevent hangs in callers to adb.exe. It would be disastrous to do this wrong, and I've modified this code, so here's a unittest to verify that I'm doing it right. The test also runs fine on unix. Change-Id: I3672c3066bc7498635c19212f9e5c50757942439 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-27Create adb Python package.Dan Albert
This is mostly just the AdbWrapper that we used in our tests, but I've cleaned up the API to be a little more Pythonic (mostly in the sense that commands are passed as lists rather than strings that are shlex.split() by the shell command), and implemented the workaround error checking for adb shell. Move the tests up a directory. Having them buried a level down has only been annoying. There are now two files containing Python tests. test_device.py contains tests specifically checking the AndroidDevice API, and test_adb.py checks the ADB client program. To run both, use python -m unittest discover [-v] Change-Id: Ibd158c528d31126a5b048bd00bc93039dbc468bc