summaryrefslogtreecommitdiff
path: root/adb/adb_utils_test.cpp
AgeCommit message (Collapse)Author
2020-10-22Migrate system/core/adb to packages/modules/adbBaligh Uddin
BUG: 167963357 Test: TH Change-Id: Ie1f82db2fb14e1bdd183bf8d3d93d5e9f974be5d Ignore-AOSP-First: Unable to Merge into aosp/master due to downstream conflicts, so working from bottom up.
2019-05-06Revert "Revert "Add a way to turn off unique_fd's operator int.""Josh Gao
The original commit broke aosp-master-with-phones, because of vendor libraries the depended on the int versions of libbase functions. This patch reverts the revert, and also adds ABI-compatibility shims for the replaced functions. This reverts commit 2c58e1924a7bf1b44049764fddb40c1704dc288f. Bug: http://b/131312539 Test: treehugger Test: forrest run of aosp-master-with-phones Change-Id: I75cc84ec8d963e20862f7662e8e2f409471f41cc
2019-04-25Revert "Add a way to turn off unique_fd's operator int."Ian Kasprzak
This reverts commit 93d63c010ae24ff58acb70216bfcb93e3c73019a. Reason for revert: b/131312539 - All aosp-master-with-phones phones failing boot / health check. Change-Id: Id4239f93484b7d6b8d9bcd355a59cbd40d9766e2
2019-04-24Add a way to turn off unique_fd's operator int.Josh Gao
unique_fd's implicit conversion to int has led to tons of problems (see all of the overloads for close, fdopen, fdopendir, etc.). Add a switch that can turn it off, and reduce the ridiculous amount of work to fix up callers by introducing a borrowed_fd type that can be constructed from either int or unique_fd. Test: treehugger Change-Id: If77cf5cbcaddacdaec5919a15b3520fb68f51a62
2019-02-25adb: make ParseUint reject garbage at the end by default.Josh Gao
Test: adb_test on host Change-Id: Ie63d89bd08f0b296a3d54ff66aae85fe52d8cd0f
2019-01-23adb: convert more stuff to unique_fd.Josh Gao
Test: adb_test Test: adbd_test Test: test_device.py Change-Id: Ie75f0b811d2c75d508e6ecffb40579308f5789d0
2018-12-26adb: add stroll equivalent for string_view.Josh Gao
Test: $ANDROID_HOST_OUT/nativetest64/adb_test/adb_test Test: adb shell /data/nativetest64/adbd_test/adbd_test Change-Id: I1d89913474fcd1aa4a856b5e4583a3c1f076ddd4
2018-11-14switch to using android-base/file.h instead of android-base/test_utils.hMark Salyzyn
Test: compile Bug: 119313545 Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-07-10adb: fix escape_arg for multiple quotesRyan Prichard
escape_arg reuses the same index for the source (s) and the destination (result), so it breaks on strings containing more than one quote, e.g: * a'b'c ==> 'a'\''b'c' * a'bcde'f ==> 'a'\''b'\'cde'f' Also make the function more efficient by doing fewer string copies. This code is based on the android::base::Split code. Use EXPECT_EQ because the tests can keep going if one fails. Bug: none Test: adb_test --gtest_filter=adb_utils.escape_arg Change-Id: I6ca6e905fa53cc61b9a87276cb7116a5df7e8017
2017-03-23adb: allow symlinks to directories in directory_exists.Josh Gao
Bug: http://b/36516955 Test: python test_device.py Change-Id: Ie81e87aac3b157182bde0955bdba23d48bfea873
2017-02-27Move adb_dirname and adb_basename to libbaseColin Cross
adb already provides an implementation of dirname and basename that take and produce std::strings, move it into libbase so it can be used in the implementation of GetExecutableDirectory. Test: out/host/linux-x86/nativetest64/adb_test/adb_test Test: out/host/linux-x86/nativetest64/libbase_test/libbase_test Test: adb shell /data/nativetest64/libbase_test/libbase_test64 Change-Id: Ideb1627607b14562121316d4ed27fa6fb0930684
2016-08-01Merge changes I1d398d19,I8f20b3cdTreehugger Robot
* changes: adb: fix stat on Windows. adb: extract Windows bits out of directory_exists test.
2016-08-01adb: fix stat on Windows.Josh Gao
stat on Windows fails with ENOENT when passed a path with a trailing slash or backslash, regardless of whether the target is actually a directory. Emulate the correct POSIX behavior by stripping trailing path separators and then checking if the target is a directory if successful. Bug: http://b/30481559 Bug: https://code.google.com/p/android/issues/detail?id=214633 Change-Id: I1d398d19a9bce1ecb3fdc4aabc31aa98c82c3f93 Test: Relevant adb_tests pass on Linux and Windows 10.
2016-08-01Fix clang-tidy performance warnings in syste/core.Chih-Hung Hsieh
* Use const reference type for parameters to avoid unnecessary copy. * Suppress warning of not using faster overloaded string find function. Bug: 30407689 Bug: 30411878 Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee Test: build with WITH_TIDY=1 Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
2016-07-28adb: extract Windows bits out of directory_exists test.Josh Gao
Bug: http://b/30481559 Bug: https://code.google.com/p/android/issues/detail?id=214633 Change-Id: I8f20b3cd5aef6a77c2b4f194b914b4295397d73f
2016-05-09adb: support forwarding TCP port 0.David Pursell
This CL adds support to forward or reverse TCP port 0 to allow the system to automatically select an open port. The resolved port number will be printed to stdout: $ adb forward tcp:0 tcp:8000 12345 $ adb reverse tcp:0 tcp:9000 23456 This allows testing to be more robust by not hardcoding TCP ports which may already be in use. Forwarding port 0 is a host-only change and will work with any device, but reversing port 0 requires the device to be updated with a new adbd binary. This CL also does a little bit of cleanup such as moving the alistener class out of adb.h, and adds some error checking and additional tests. Bug: 28051746 Test: python -m unittest discover Test: adb_test Test: `adb forward` and `adb reverse` with tcp:0 Change-Id: Icaa87346685b403ab5da7f0e6aa186aa091da572
2016-02-10adb: mkdirs fixesSpencer Low
Fix pathological case where the directory to be created can't be created because there is already a file there. This was previously returning success because the wrong var was passed to directory_exists(). Fix test to exercise this situation. Also clarify tests. Change-Id: I0dc0f14084e0eda4e1498874d4ab2a6445d322ac Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2016-02-08adb: fix mkdirs test.Josh Gao
The behavior of mkdirs was changed a while ago, without updating the test. Change-Id: I2aaa73818933b281e911c42a14e3c843d8bd972a
2016-01-21base: add network address parsing function from adb.David Pursell
This CL moves the network address parsing function from adb to libbase so that it can be used by fastboot as well as adb. libbase seemed like the right choice because: 1. It already has some parsing functions (parseint) 2. The net address parsing function uses the libbase string functions so we have a libbase dependency anyway. The parsing function has been modified slightly to make the canonical address optional, and debug logging on success has been removed. For adb the only functional difference is that parsing a network address will no longer print the result to the debug log, which seemed unnecessary. Bug: http://b/26236380 Change-Id: Ife6df02937225fc66de87884d3572d79c092c522
2015-12-04Track rename of base/ to android-base/.Elliott Hughes
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-11-04adb: make adb_basename match the POSIX behavior.Josh Gao
Previously, adb_basename was behaving according to the GNU, POSIX-incompatible basename, despite POSIX adb_dirname existing alongside it. This patch changes adb_basename to pass through to the POSIX basename. Bug: http://b/25456821 Change-Id: I62a4865cccf3b9cdbc112e3e53ff475aa4a23bd9
2015-10-06adb: keep file flags in fdevent_install.Yabin Cui
Bug: 24615098 Change-Id: Ia791ecbe612f09aca3bbd5787513f121fae54da5
2015-08-06win32: adb_test/libbase_test fixesSpencer Low
- My recent change with -DUNICODE=1 required changing GetProfilesDirectory() to GetProfilesDirectoryA() for the ANSI version of the API. - enh's edit to my previous change deleted a test that used /proc/version, but I think another test was missed. Merge that test into another. Change-Id: Ic748549848e7be922bcbf218d5b0c3fca2a90704 Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-03adb: fix mkdirs / adb pull with relative paths, fix win32 issuesSpencer Low
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-03adb_test/libbase_test: win32: get some tests workingSpencer Low
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-07-30More adb cleanup.Elliott Hughes
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-30Write mkdirs in more idiomatic C++ style.Alex Vallée
~ 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-21Recognize IPv6 addresses for "adb connect".Elliott Hughes
Bug: http://b/22559299 Change-Id: I32891d706b5010c38db84a056e76dd279b780f75
2015-05-15Fix ' escaping in adb.Elliott Hughes
You can't just use \' inside a single-quoted string. Bug: http://b/20323053 Bug: http://b/3090932 Change-Id: I73754b097671d02dc11c35052f0534b6dd789e4f
2015-04-17Use ' quoting to escape arguments.Elliott Hughes
The specific motivating case is "text;ls;1.apk", but rather than continue adding individual characters to the list of characters to be escaped, let's just switch to quote all arguments with ', which only leaves ' itself to be escaped. Bug: 20323053 Bug: 19734868 Change-Id: I8bd71db9373bc2d1169fc11e46c889da6638550a
2015-04-17Fix more buffer overruns.Elliott Hughes
Also add some tests. Bug: 20323050 Change-Id: I9eaf3dc04efd85206663c4cca4f8c1208620a89a