Commit graph

1039 commits

Author SHA1 Message Date
Elliott Hughes
c672cb0743 Merge "Include the error code if GetPipeProperties fails." 2015-08-06 17:49:41 +00:00
Elliott Hughes
6e02c24cfc Include the error code if GetPipeProperties fails.
Bug: http://b/22829602
Change-Id: I90a89e70518053a4581e1862a7dbd5d09e06dadc
2015-08-06 10:48:19 -07:00
Yasuhiro Matsuda
c0822e83ad Enable perfboot.py to install APKs before measurement.
This CL adds --apk-dir option, which specifies the directory
that contains APK files to be installed before measuring
boot time.

BUG: 22207911
Change-Id: Ifeacf34c779248686443a9ef02485272c140a456
2015-08-06 11:02:17 +09:00
Elliott Hughes
3cf2a8e0ee Merge "Fix a comment typo." 2015-08-04 00:51:38 +00:00
Elliott Hughes
feacf20d1e Merge "adb: win32: file descriptor reliability improvements" 2015-08-04 00:50:43 +00:00
Elliott Hughes
bfa7c7d9e2 Fix a comment typo.
Change-Id: Ifacb19b9c31ac81fbf02c8382eb0324ea79075b9
2015-08-03 16:26:13 -07:00
Elliott Hughes
6b940e1349 Merge "adb: win32: define UNICODE/_UNICODE, Unicode error messages, misc" 2015-08-03 21:16:26 +00:00
Elliott Hughes
6355f2c140 Merge "adb: win32: call SystemErrorCodeToString() from more places" 2015-08-03 21:04:01 +00:00
Elliott Hughes
3841a9f7cb Leave the evidence lying around if an adb test fails.
Not seeing the full output from the failed adb command is probably
the biggest issue when debugging a test failure, but this doesn't
help either.

Change-Id: Ic42cbced8be252185a799b27c210a744188a4201
2015-08-03 13:58:49 -07:00
Spencer Low
22191c30a6 adb: fix mkdirs / adb pull with relative paths, fix win32 issues
Relative paths were being prefixed with OS_PATH_SEPARATOR on unix and
win32 causing adb to incorrectly try to make directories at the root.
Plus, absolute paths didn't work on win32 (C: got prefixed into \C:).

This fix is to use dirname (available on win32 via mingw's crt) to do
the messy parsing.

I added a test for the relative path case.

Change-Id: Ibb0a4a8ec7756351d252a4d267122ab18e182858
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-03 13:24:18 -07:00
Spencer Low
cf168a82e9 adb_test/libbase_test: win32: get some tests working
adb_test:

* Fix adb_utils directory_exists test for Windows. The test actually
fails because directory_exists() is not aware of junctions or symlinks,
but I'm not really sure if that is a bad thing (since these are rare on
Windows to begin with).

* Fix crash during transport tests due to mutex not being initialized.

* io tests fail for various reasons (see adb_io_test.cpp for more info).

libbase_test:

* Get it building on Win32 by implementing mkstemp() and mkdtemp().

* Run StringPrintf %z test on Windows because it passes because we build
with __USE_MINGW_ANSI_STDIO which implements %z.

* I didn't fixup the logging tests: some logging tests fail because when
abort() is called on Windows, by default it pops up UI asking whether a
crash dump should be sent to Microsoft. To some degree this makes sense,
as I think LOG(FATAL) does crash dumping in Chromium. This should be
revisited in the future.

Change-Id: Iaa2433e5294ff162e0b2aa9fe6e4ec09a6893f7a
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-03 12:44:43 -07:00
Spencer Low
8df9032176 adb: win32: call SystemErrorCodeToString() from more places
Improve some error messages, or trace output.

Change-Id: Ib09fac33a296f090d37f125cad7556fc5b5e928e
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-02 18:50:17 -07:00
Spencer Low
e347c1dd47 adb: win32: define UNICODE/_UNICODE, Unicode error messages, misc
Define the UNICODE and _UNICODE preprocessor symbols to make passing
char* to Ansi/Unicode-agnostic Windows and C Runtime APIs break the
build. The solution is to call wide Windows and C Runtime APIs and use
widen(utf8).c_str(). Most code was already calling wide APIs. Defining
these symbols makes a call to CreateEvent() (which previously mapped to
CreateEventA()) turn into a call to CreateEventW().

Make SystemErrorCodeToString() use Unicode.

Add various comments.

Change-Id: I9b212412348a29826718e897a486489e1f142d16
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-02 18:13:54 -07:00
Elliott Hughes
16d79c7318 Remove adb's unused get_my_path for Windows.
Change-Id: I3cfb4677acaf6acaf512b3cdce6c11bdb2bd0578
2015-07-31 17:54:24 -07:00
Yabin Cui
c70ac57db0 Merge "adb: poll for emulator connection." 2015-08-01 00:50:39 +00:00
Elliott Hughes
367fb50333 Merge "adb: win32: Unicode path names, env vars, some console support" 2015-07-31 23:50:52 +00:00
Spencer Low
c3211557b3 adb: win32: file descriptor reliability improvements
When repeatedly opening and closing a file descriptor, the sequence of
fds returned was: 100...227,100,100,100,100,100... Basically, the first
wave was constantly increasing fds, but after the entire fd table was
traversed once, the alloc algorithm would switch to returning the first
free fd. This is sub-optimal for reliability because use-after-free bugs
would be more likely to be hit because right after a close, the same fd
would be given out next.

This change makes the alloc algorithm use a persistent clock hand that
walks forward through the fd table (wrapping around if necessary),
searching for a free fd.

This change adds locking for fd closing:

 - This prevents multiple concurrent closes of the same fd.

 - There was a race between alloc and close that wasn't guaranteed to be
   correct: close would set f->clazz to NULL last, but without any
   preceding memory barrier/fence, then the alloc thread would check for
   NULL. It probably worked out ok in practice, but it is probably best
   to fix this up with a lock (as in this change) or a memory barrier/fence
   (but this code isn't about performance, so why go with a complicated
   barrier/fence?)

Also in this change:

 - Use errno = EMFILE for the out of fds case.

 - Clear FH->name

Change-Id: Ic11d2a1a9d53996edfc1ca13566a2f46de4a4316
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-31 15:13:52 -07:00
Yabin Cui
0e2c194659 adb: poll for emulator connection.
Bug: 19974213
Change-Id: I336f3ad6f428277c54479e5b8c45d5343c64f472
2015-07-31 14:25:19 -07:00
Spencer Low
cf4ff64f2d adb: win32: Unicode path names, env vars, some console support
Initial support for Unicode file/dir names. Unicode paths can be passed
on the command line, directory enumeration can enumerate Unicode paths,
Unicode paths are used for file access, and Unicode paths can be output
on the console correctly.

Also Unicode environment variable access.

Initial support for Unicode output from adb shell (which uses
adb_fwrite()). This is partial because the corner case of an
adb_fwrite() call with an incomplete UTF-8 multi-byte sequence does not
output correctly, but this should be uncommon, is better than what we
had before (*always* incorrect UTF-8 multi-byte sequences) and can be
fixed in the future.

Calls to Windows APIs with char strings were changed to pass wchar_t
strings to the FooW() variants.

For more details, see the giant comment in sysdeps_win32.cpp.

https://code.google.com/p/android/issues/detail?id=8185

Change-Id: I7ebf6713bb635638b986ccee97b354428837c9c5
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-31 13:30:41 -07:00
Elliott Hughes
048b27c066 Clean up -p handling slightly.
Change-Id: I8a5cd4a7adb0dde9d09e0cbb620874b1bca35e43
2015-07-31 13:18:22 -07:00
Elliott Hughes
cf4dba5ab3 Merge "adb: win32: initial IPv6 support and improved Winsock error reporting" 2015-07-31 18:11:45 +00:00
Spencer Low
5200c6670f adb: win32: initial IPv6 support and improved Winsock error reporting
Call getaddrinfo() for connecting to IPv6 destinations.

Winsock APIs do not set errno. WSAGetLastError() returns Winsock errors
that are more numerous than BSD sockets, so it really doesn't make sense
to map those to BSD socket errors. Plus, even if we did that, the
Windows C Runtime (that mingw binaries use) has a strerror() that does
not recognize BSD socket error codes.

The solution is to wrap the various libcutils socket_* APIs with
sysdeps.h network_* APIs. For POSIX, the network_* APIs just call
strerror(). For Windows, they call SystemErrorCodeToString() (adapted
from Chromium).

Also in this change:

 - Various other code was modified to return errors in a std::string*
   argument, to be able to surface the error string to the end-user.

 - Improved error checking and use of D() to log Winsock errors for
   improved debuggability.

 - For sysdeps_win32.cpp, added unique_fh class that works like
   std::unique_ptr, for calling _fh_close().

 - Fix win32 adb_socketpair() setting of errno in error case.

 - Improve _socket_set_errno() D() logging to reduce confusion. Map
   a few extra error codes.

 - Move adb_shutdown() lower in sysdeps_win32.cpp so it can call
   _socket_set_errno().

 - Move network_connect() from adb_utils.cpp to sysdeps.h.

 - Merge socket_loopback_server() and socket_inaddr_any_server() into
   _network_server() since most of the code was identical.

Change-Id: I945f36870f320578b3a11ba093852ba6f7b93400
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-30 23:07:55 -07:00
Yabin Cui
6264129434 Make clear of the data length sent by write_packet.
Change-Id: If51b4feaa19a710874999ad7e6131ff2e56a9f8a
2015-07-30 20:01:10 -07:00
Elliott Hughes
5c74270f95 More adb cleanup.
This removes adb_dirstart and adb_dirstop. It also fixes a couple of memory
leaks by switching to std::string. This also fixes the bug in the previous
change --- mkdirs is given input like "/system/bin/sh" and only expected to
create "/system/bin". In a later change, we should remove mkdirs and only
expose the intended "unlink && mkdirs && create" functionality.

Change-Id: I30289dc1b3dff575cc1b158d993652178f587552
2015-07-30 17:46:58 -07:00
Alex Vallée
47d67c96ec Write mkdirs in more idiomatic C++ style.
~ Rewrote mkdirs to be in C++ style.
~ Replaced adb_dir{start,stop} with std::string params and (r)find.
+ Added test for mkdirs.

Also make base/test_utils.h public and support temporary directories
as well as files.

Change-Id: I6fcbdc5e0099f3359d3aac6b00c436f250ca1329
2015-07-30 15:08:53 -07:00
Dan Albert
480bea3372 Merge "Add top level sanitize options for ADB." 2015-07-30 18:44:37 +00:00
Dan Albert
9113b47eac Add top level sanitize options for ADB.
Host and target are split here because the target can really only use
ubsan (most sanitizers don't support static executables).

Change-Id: I8a5a5adeeef5c27aaaa3d8145b1570760b764ce3
2015-07-30 10:25:32 -07:00
Dan Albert
3b5b132817 Merge "adb/test_device.py fixes for win32 and no use of ANDROID_SERIAL" 2015-07-30 17:04:52 +00:00
Elliott Hughes
44443bead6 Merge "Use _WIN32 rather than HAVE_WINSOCK." 2015-07-30 14:49:56 +00:00
Spencer Low
3e7feda3c5 adb/test_device.py fixes for win32 and no use of ANDROID_SERIAL
If ANDROID_SERIAL was not set, test_device.py was failing.

Use posixpath.join instead of os.path.join for make_random_device_files.

Change-Id: I24bfa43ba2a89a9a768f505fc0bba9d873082b2f
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-30 01:19:52 -07:00
Yasuhiro Matsuda
dcf890914c Merge "Add a script to record Android boot time." 2015-07-30 05:21:41 +00:00
Yasuhiro Matsuda
ab3798399d Add a script to record Android boot time.
perfboot.py repeats the record of each event log during Android
boot specified times. By default, interval between measurements
is adjusted in such a way that CPUs are cooled down sufficiently
to avoid boot time slowdown caused by CPU thermal throttling.
This script also works around the issue of dropbox slowing down
boot time on userdebug build (http://b/20890386) by limiting
the number of files to be created by dropbox.
The result is output in a tab-separated value format.

BUG: 22207911
Change-Id: I0ddbac5d1c941efda87bc6db6388d8194d4bb3dd
2015-07-30 14:16:15 +09:00
Elliott Hughes
adbf442a51 Use _WIN32 rather than HAVE_WINSOCK.
Change-Id: I9855b6fe72e2f2f3a8360c0993a67cb988024ee4
2015-07-29 17:45:24 -07:00
Spencer Low
a6b340af12 fix adb {forward,reverse} --no-rebind
adb forward --no-rebind (and the matching reverse command) seem to have
been broken by 424af02f36. I fixed-up the
string parsing and also fixed the error message not to include
strerror(errno) since that does not apply because it is an
application-level error that doesn't have anything to do with the
OS/libc.

Change-Id: Iba7286283bfcf1782076355edcd9c355c0a0edfd
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-07-29 17:21:21 -07:00
Dan Albert
c0e8d0fc50 Merge "Fix AndroidDevice.get_prop, add tests." 2015-07-28 23:46:10 +00:00
Dan Albert
e2b4a5fee0 Fix AndroidDevice.get_prop, add tests.
Had messed this up while refactoring before I submitted and neglected
to add a test. Thanks to mazda@ for catching this.

Also disabled the root/unroot tests for user builds.

Change-Id: Icb819a820a2afa227d548d678ae471d5195f0b96
2015-07-28 16:42:58 -07:00
Elliott Hughes
3e7048c027 Fix const-ness of strrchr callers.
This causes build failures in google3 where they use GCC. glibc only
provides const-correct overloads for string functions for GCC >= 4.4,
but clang -- which is what we use -- pretends to be GCC 4.2.

Change-Id: I2a054823ea6201ebcea46d5e77b80a975eefc622
2015-07-28 08:07:21 -07:00
Dan Albert
8e1fdd7806 Create adb Python package.
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
2015-07-27 15:52:15 -07:00
Elliott Hughes
3fe6de1c39 Merge "Add a simple test for using non-ASCII paths with adb." 2015-07-24 23:07:56 +00:00
Elliott Hughes
614e0a47d3 Add a simple test for using non-ASCII paths with adb.
Bug: https://code.google.com/p/android/issues/detail?id=8185
Change-Id: If28a0ff345f44b60d6651bb36afb0bf72fe55e16
2015-07-24 15:26:46 -07:00
Elliott Hughes
4f1d7b55d7 Fix Win32 adb build (for the second time today).
Change-Id: I83cb407660cd8b5ed65a80574875fe261e8a8926
2015-07-24 14:32:46 -07:00
Elliott Hughes
9dad4ec440 Merge "Clean up the locking in usb_linux.cpp." 2015-07-24 20:21:53 +00:00
Elliott Hughes
812f030477 Clean up the locking in usb_linux.cpp.
tsan complained that usb_bulk_write accesses usb_handle members outside
a lock. Fix that, but by moving everything over to C++11 locking.

Note that the old code was checking whether pthread_cond_timedwait returned
a negative value, which it will never do --- it will signal timeout (or
any other error) by returning a positive errno value. The rewrite does
what they appeared to intend to do (break out on timeout), rather than
what they actually did (keep trying forever).

Bug: http://b/22598587
Change-Id: Iab6869ffed4874143a7da97193d6b09e34cf2933
2015-07-24 12:35:50 -07:00
Elliott Hughes
d48dbd89c8 Fix Win32 adb build.
Change-Id: I0a07379c470b7fa7f9bdef68c17ccb7bd0bd2079
2015-07-24 11:35:40 -07:00
Elliott Hughes
381cfa9a8b Report getaddrinfo failures correctly.
Also move us off the "convenience" function because you can't get useful
error reporting from it.

Change-Id: I5fcc6a6d762f5f60906980a7835f01a35045be65
2015-07-23 21:14:38 -07:00
Elliott Hughes
61ee830ec9 Don't limit Windows USB reads.
In 3d2904cdf2 we removed the code that broke
Linux USB reads into 4KiB chunks. This patch does the same for Windows. This
improves Windows "adb pull" speeds 6x in my VM. (There was no equivalent
problem with writes, so this change only affects pull speeds.)

Change-Id: If19013e5f51975f4824bf9147b7b76cebd305b96
2015-07-22 15:59:06 -07:00
Elliott Hughes
6b40d0aaa1 Merge "adb: win32: fix exec-in and exec-out to use binary mode" 2015-07-22 22:43:45 +00:00
Tamas Berghammer
3d2904cdf2 Increase size of the the adb packets sent over the wire
The reason behing this change is to increase the adb push/pull speed
with reduceing the number of packets sent between the host and the
device because the communication is heavily bound by packet latency.

The change maintains two way compatibility in the communication
protocol with negotiating a packet size between the target and the
host with the CONNECT packets.

After this change the push/pull speeds improved significantly
(measured from Linux-x86_64 with 100MB of data):

           | Old push | Old pull || New push  | New pull  |
-----------------------------------------------------------
Hammerhead | 4.6 MB/s | 3.9 MB/s || 13.1 MB/s | 16.5 MB/s |
-----------------------------------------------------------
Volantis   | 6.0 MB/s | 6.2 MS/s || 25.9 MB/s | 29.0 MB/s |
-----------------------------------------------------------
Fugu       | 6.0 MB/s | 5.1 MB/s || 27.9 MB/s | 33.2 MB/s |
-----------------------------------------------------------

Change-Id: Id9625de31266e43394289e325c7e7e473379c5d8
2015-07-22 13:06:06 -07:00
Elliott Hughes
a5d0ca4f16 Merge "Show "(reverse)" in "adb reverse --list"." 2015-07-22 00:25:41 +00:00
Elliott Hughes
34c20bbdff Show "(reverse)" in "adb reverse --list".
Bug: http://b/17788586
Change-Id: I250a1459295ed38e8d962da8bea2a8d2f83c7ef0
2015-07-21 17:09:06 -07:00