Commit Graph

43 Commits

Author SHA1 Message Date
Josh Gao
e955f07799 Support lists of files in adb.AndroidDevice.push.
Bug: http://b/166155032
Test: system/core/adb/test_device.py
Change-Id: I7a6514070b5bbb379f2652053de64a7603e988ae
2020-09-08 18:09:32 -07:00
Dan Albert
be37f5542d Add Python git ignore.
Test: git status (after having built this package)
Bug: None
Change-Id: I63c36eef51b7ecb950af0ad06385e13a3b0cd870
2018-04-26 12:48:30 -07:00
Dan Albert
1b06c6e40d Python 3 compatibility.
Test: ndk/run_tests.py
Bug: None
Change-Id: Id0d2d8024adec880c1a41b524704df1641cda065
2018-02-14 12:46:58 -08:00
Josh Gao
908c4dbd10 Move GetDeviceTest from adb's test_device.py to adb package.
This test actually belongs with the adb python wrapper, since it's not
affected by changes to adb itself.

Bug: http://b/64260633
Test: python test.py
Change-Id: Ia70a5529e30d91ea6232c65c9d50b2dabd07b925
2017-11-08 14:39:34 -08:00
Ryan Prichard
5b1219eaaa Record the path to adb used for the device
Test: run ndk-gdb.py
Change-Id: I12487c63ee00aae46adba9c98056f295a341c64a
2017-10-19 17:40:28 -07:00
Elliott Hughes
c34da2dcc7 Remove device.get_props.
Bug: https://issuetracker.google.com/37093233
Test: N/A
Change-Id: I6f516904475354e51071544bf1bf6ccb0f30f583
2017-06-02 17:22:37 -07:00
Dan Albert
c52723d77d Add support for push --sync.
Test: nose2 in system/core/adb
Bug: None
Change-Id: I6dcea2ff38a721f941c4abeba2949a319ea8c75f
2017-05-19 11:11:43 -07:00
Josh Gao
016c18c73d Fix adb.py.
oops

Change-Id: Id3e11ebc89d32f1d0a606047f9b69469fe701098
2016-03-29 11:33:30 -07:00
Josh Gao
1d404e6c92 adb.py: require adb version >= 35 to use shell protocol.
Change-Id: I2513db8a88e1a1bd96ce642251882de97ca37df6
2016-03-28 14:10:57 -07:00
Josh Gao
7f6e8ddb79 gdbrunner: expose adb.split_lines, use it.
Change-Id: I895aacaababf87c1e82ff5604c028cc475207304
2016-03-28 11:26:03 -07:00
Dan Albert
9bee8c209c Replace splitlines() with something more tolerant.
Old devices suck. Old devices on Windows seem to suck harder.

Change-Id: I88df25d2c480439859c913e9d8f8fb7ef04b7d5b
2016-02-24 12:28:45 -08:00
Dan Albert
aaf5455b16 Add a fix for old, broken devices.
Not sure exactly why this happens, but it keeps cropping up on my JB
nakasi when running the NDK tests.

Change-Id: Ic5c35f9ab01c0a83f98a6d074220c89ec765a812
2016-02-24 11:39:42 -08:00
Dan Albert
5ca14aa777 Fix the pylint issues that have built up...
Change-Id: I73b14c468a27dffb5c3524b2141682f9e1cafe35
2016-02-24 11:39:14 -08:00
Josh Gao
5cd0f10ebc Move adb tests to system/core/adb.
Change-Id: Ieeb0e1122a7b13a784ec8c19cf360c7699dcd9ff
2015-12-09 11:25:57 -08:00
Spencer Low
82aa7da5a6 win32: for Unicode cmdline args, switch from cmd.exe to powershell.exe
Previously, to pass a subprocess cmdline args with Unicode characters,
we'd write the command line to a batch file and run it with cmd.exe. The
problem was that the batch file used chcp to get cmd.exe to be able to
read UTF-8 from the batch file, but this had the side-effect of changing
the codepage of the user's console window.

Instead of saving & restoring the codepage (which would always have the
risk of somehow leaving the console in the wrong codepage if a Ctrl-C
handler somehow wasn't called, or if Task Manager was used manually,
etc.), we use Windows PowerShell as the helper instead of cmd.exe.

PowerShell is installed on every version of Windows since Windows 7 and
is a separate free download for Windows XP and Windows Vista, but
realistically Windows XP is no longer supported by Microsoft and
probably no one chooses to run Windows Vista over Windows 7. Plus, this
change only uses PowerShell if Unicode args are passed.

Switching to PowerShell allows us to get rid of the temp file, context
manager, and messy __del__ that caused a variety of problems in the
past.

Change-Id: Ia3df533f7747f7b9b28a093f8ca24117371e5e59
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-21 20:39:56 -08:00
Josh Gao
95e0260252 Merge "adb: update tests for push/pull directory change." 2015-11-11 23:22:47 +00:00
Spencer Low
08d0622fa5 adb unittest: make test_unicode_paths stricter
After pushing to a Unicode path, use 'adb shell ls' to verify that the
path was created with the right name. This verifies that the UTF-16 to
UTF-8 conversion is done properly.

When pulling to a Unicode path, verify that the local file has been
created with the expected name. This should test UTF-16 to UTF-8
(command line to internal data structures) and UTF-8 to UTF-16 (internal
data structures to CreateFileW()).

Change-Id: I8b80aae731cf0d058cb0c3259e7f58256e86b771
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-10 23:30:35 -08:00
Josh Gao
7fe79d6515 adb: update tests for push/pull directory change.
Bug: http://b/25394682
Change-Id: Iaae5ceedc7a38e9981503a81136966939c6d7280
2015-11-07 17:56:19 -08:00
Josh Gao
084d084bbc Merge "adb: add tests for pushing/pulling empty dirs." 2015-11-07 00:53:02 +00:00
Josh Gao
cdf675849c adb: add tests for pushing/pulling empty dirs.
Change-Id: I840a31fc8f37939a1166ac39700363a8b79cc3be
2015-11-06 15:01:48 -08:00
David Pursell
51f2cc2185 adb: fix device module for non-shell_v2 usage.
The device.py module was incorrectly querying the return code when the
shell_v2 return code isn't available.

This CL fixes it by specifying the return code probe as an argument
list rather than a single string argument. This means that before the
device was executing something like this:

  /system/bin/sh getprop '; echo $?'

which didn't do what we wanted. Now it does something like this:

  /system/bin/sh getprop ; echo $?

Bug: http://b/25470461
Change-Id: I5e20da31ec7ecc782c6146d8b38d752d52082860
2015-11-05 11:26:42 -08:00
Spencer Low
5e50d6b443 unittest for sending data thru adb forward/reverse; --no-rebind unittest
Added --no-rebind unittest to test fix
a6b340af123b82e3aaa33cb2a0d45f637eeb4759

Change-Id: I2286b7f652c84fbc79d8860c9a04594d3284ee68
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-04 22:12:26 -08:00
Josh Gao
6b8dcee6e6 adb: add more push/pull tests.
Bug: http://b/25324823
Change-Id: I7a24fcd7c0c76469877b4af4d5a3b99750aea750
2015-11-02 18:21:04 -08:00
Yabin Cui
0e54d10df7 adb: add test for forward/reverse commands.
Bug: 25355808
Change-Id: Idc636569b0699c2acc3bf674fdcfd25c74b83121
2015-11-02 12:21:52 -08:00
Josh Gao
3fd43b5bf4 Allow selection of adb command.
This is useful for ndk-gdb.py on Windows.

Change-Id: I2a2b6b50ae00bcfc530c555f06c945b4f53f9999
2015-10-28 14:18:55 -07:00
David Pursell
303d809adf Merge "adb: update adb PTY tests." 2015-10-27 15:39:32 +00:00
David Pursell
e0146c4335 adb: update adb PTY tests.
adb PTY behavior has been updated to match ssh more closely. This CL
updates the PTY tests accordingly.

Bug: http://b/24565284
Change-Id: I01208eac62c54eba1c2f97b334a18c4c19d77ea2
2015-10-26 10:12:08 -07:00
Elliott Hughes
a7aa6e2b1d Add a test for "adb pull" error reporting.
Bug: http://b/6205106
Change-Id: I2093c3d451361d48056b85c8017acb032a3ff478
2015-10-23 21:55:31 -07:00
Josh Gao
a80834e943 Merge "adb/test_device.py: fix finding md5 command on pre-L platforms" 2015-10-22 01:05:59 +00:00
David Pursell
cebec2b69b device.py: fix _subprocess_Popen cleanup.
Every time gdbclient.py finishes it's giving this error:

Exception TypeError: 'must be type, not None' in <bound method
_subprocess_Popen.__del__ of <adb.device._subprocess_Popen object at
0x7fdd48e76850>> ignored

Basically super(_subprocess_Popen, self) was failing because at that
point _subprocess_Popen is None since global teardown had already
deleted the reference.

This fix saves local references to required global objects so that they
stick around until we're done with them. We may want to start looking
into making _subprocess_Popen a context manager instead, usage won't be
as convenient but __del__() does not scale to general use well. For now
though this CL seems to solve the problem for gdbclient.py.

Change-Id: I6c2a9fe0c108ae600cf05eb3b887d56959c7308e
2015-10-20 10:29:21 -07:00
David Pursell
3b863f24b4 Merge "adb: add test for non-interactive stdin." 2015-10-15 21:37:02 +00:00
Spencer Low
4160958015 adb unittest: fix Windows Unicode
adb.shell() was recently changed to use subprocess.Popen(), which
doesn't work properly with Unicode on Windows. The fix is to use the
same work-around that I did for subprocess.check_output(): write UTF-8
to a batch file and run it. The change is primarily refactoring to
enable code reuse.

Change-Id: I88e9b9b35e5318533c0cd932d92e13bc9e734092
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-10-13 19:51:30 -07:00
David Pursell
45d61d070f adb: fix docstring for shell functions.
Change-Id: Iaae8605b18583c38e517f865083012204d236832
2015-10-12 15:55:38 -07:00
Spencer Low
ebbc3fe2d0 adb/test_device.py: fix finding md5 command on pre-L platforms
606835ae5c4b9519009cdff8b1c33169cff32cb1 in platform/system/core made
adb.device.shell() throw adb.ShellError instead of
subprocess.CalledProcessError.

Change-Id: I7f579887a9aab8d11cbb2c419b8406f51d6b1bd6
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-10-11 22:36:44 -07:00
David Pursell
fa1d9db173 adb: add test for non-interactive stdin.
Add a test to send stdin to non-interactive `adb shell`.

This new test will hang on ToT devices that support shell_v2 until they
are rebuilt with the corresponding adb CL. A new feature could be added
instead to filter those devices out, but it doesn't seem worth it as no
devices have yet been released with shell_v2.

This CL also fixes a mistake I made earlier with device.linesep; this
is used to check device output, not separate device input. Using it
added unnecessary newline characters on Windows.

Bug: http://b/24565284
Change-Id: Ic123402975033d74688f56a36acac993af6815e6
2015-10-09 16:51:12 -07:00
David Pursell
46e268e990 adb: make shell protocol work again.
http://r.android.com/173810 changed the shell feature name. This CL
updates the python scripts to re-enable shell protocol tests, and adds
an additional test for `adb shell -x`.

Change-Id: I961adf7abd1782ea98f3f82d8af11dcaa02f9570
2015-09-30 17:22:32 -07:00
Josh Gao
87df6ff2c8 Add get_props to adb.py's AndroidDevice.
Saves adb shell roundtrips if multiple properties are needed.

Change-Id: I3a9fc0354b6eb0ee5389984e3f345c380404658c
2015-09-30 14:36:35 -07:00
Josh Gao
cac4e977bb Add remount to adb.py's AndroidDevice.
Change-Id: If1e17a49e81af840b76eab52db89bc9de09958fe
2015-09-30 14:36:35 -07:00
Josh Gao
21f984939b Add shell_popen method to adb.py.
This is mostly to allow backgrounding of processes run through adb
(gdbserver in particular).

Bug: http://b/23715403
Change-Id: I47fbebbd05d58044b4c447ffa86e0ab97d920278
2015-09-30 14:36:35 -07:00
Josh Gao
a8731c4be0 Add helper functions for adb -e/-d to adb.py.
Bug: http://b/22946322
Change-Id: I847f561d617b17f4e6323e0abb46dd270d041782
2015-09-30 14:36:35 -07:00
David Pursell
9278d96e77 adb: fix install escaping test.
The install escaping test fails if the device supports exit codes. This
fixes the test to ignore the exit code since we expect the install to
fail.

Change-Id: I37bb39552a6e9068ac088a25d831f45d81b28155
2015-09-22 14:07:36 -07:00
David Pursell
d89fcd4f76 adb: add tests for -Tt shell arguments.
Adds python tests to check that -T (disable PTY) and -t (force PTY)
arguments work as expected for `adb shell`.

Bug: http://b/23825231
Change-Id: I5343fae35b2be8459a9b95125f66def46c26adf4
2015-09-22 12:50:39 -07:00
Dan Albert
32e1307f45 Move python-adb from system/core/adb.
This really ought to be maintained as a separate project. Also adds a
setup.py for distribution.

Bug: http://b/22881740
Change-Id: I8e11e4154fac21d3196a533613822b236b2b73e6
2015-09-18 13:41:56 -07:00