This will correctly handle non-ascii chars in paths.
+Windows specific tests for non-unicode chars and root of disk as a temp
folder.
Test: atest libbase_test
Change-Id: Ief3ee26df93e122250441bfe41f0440fe62bfadc
In the RemoveFileIfExists it always return true even if error appeared
when using stat function.
It should distinguish different error. Such as ENOENT and ENOTDIR
we exactly know the file does not exist. But EACCES(current user has not
all search permission in the file path) and other errors appeared
we can't know whether file exits. So we should return false indicate
there are some error appeared.
Test: ran unit tests
Change-Id: I75788bf0621040812413d52596b5effb628fd0b1
Signed-off-by: liwugang <liwugang@xiaomi.com>
Tests will often want to get the executable directory in order to
find test data.
Test: out/host/linux-x86/nativetest64/libbase_tests/libbase_tests
Change-Id: Ica9d211bcd039fcf83a22fd494816abd01b97aa3
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
We'd long had two copies of this stuff, so rather than rewrite both
Linux versions to use android::base::Readlink, let's kill the duplication
too...
Bug: http://b/30988271
Change-Id: I4de58a94a22a4b1faf969a6fc70ca1560a4d5121
- 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>
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>
~ 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
mode_t is a uint16_t on darwin, which causes
sb.st_mode & ~S_IFMT
to produce an int when the uint16_t is promoted for the operator.
Cast to unsigned int before comparing against 0660U.
Change-Id: Ib1439c08d9e2b297eeeba701891508d269c19a3d
Tests using files from /proc still fail on Windows (obviously), but
all tests are passing when run in Wine.
Change-Id: Ie4c3ba65b642202f8fcaec73332a53bee6115fba
ART already had a flavor of this, but it was specialized for their use
case a bit.
Note that the logging.* tests are currently disabled for the device
because there is no good way to capture the output of liblog. We can
make something that will execute logcat and then then scan the output,
but that's messy. Since we know it at least works on the host, we can
add better device tests later.
Change-Id: I47acd87a3312c0a5285b03f9c8dadef0c669f06a