summaryrefslogtreecommitdiff
path: root/base/file_test.cpp
AgeCommit message (Collapse)Author
2020-05-19Migrate system/core/base to system/libbaseBaligh Uddin
BUG: 148941208 test: TH Change-Id: I1134f1e9e968b9273748e2483bea8d25e5c9e994
2019-10-02Addressing comments in 1130236.Alex Buynytskyy
Use Unicode versions of mktemp function. Correctly handle unset TMP variable in tests. Test: atest libbase_test Change-Id: I5009962d33b224c4d5f39102e03daeb0837f1525
2019-10-02Using WideChar->UTF8 versions of Windows API to obtain temp folder.Alex Buynytskyy
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
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-12libbase: return different result depend on the errnoliwugang
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>
2017-03-21Keep the ReadFileToString/ReadFdToString overhead down.Elliott Hughes
Bug: https://code.google.com/p/android/issues/detail?id=258500 Bug: http://b/36046324 Test: ran tests Change-Id: I40e76a6dd164ea9a5e8e18159f543e1bb221dcba
2017-03-15Add android::base::Realpath.Dimitry Ivanov
Bug: http://b/31396973 Test: libbase_test on host and device Change-Id: I1e5f15c76227ec1c2128baa38eb454d347987703
2017-02-28Add GetExecutableDirectory to libbaseColin Cross
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
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
2017-01-11Fix libbase file.Readlink test on marlin/sailfish.Elliott Hughes
Bug: http://b/33306057 Test: ran tests Change-Id: Ie6797e71d3507572da66d6b6966f8ee9373124a4
2016-09-14base: add parameter that controls O_NOFOLLOW in file functions.Josh Gao
Bug: http://b/31491920 Change-Id: I19cb06941d87c0180ccab8bb2d85e57338811624 Test: m
2016-09-01Add android::base::GetExecutablePath, switch adb and fastboot over.Elliott Hughes
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
2016-08-31Add android::base::Readlink.Elliott Hughes
Bug: http://b/30988271 Change-Id: Ib844d7c9e33465dabf7aee5e24dc3d1d8d799abd
2016-01-29base: add API to remove file if it exists.Yabin Cui
It is a function needed in different places like uncrypt, simpleperf. Bug: 26883096 Change-Id: I26f4f30e8367867a88272625f00858569fc8e950
2015-12-04Track rename of base/ to android-base/.Elliott Hughes
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
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_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-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-04-30Fix comparison between signed and unsigned error on darwinColin Cross
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
2015-04-29Get libbase tests working on Windows.Dan Albert
Tests using files from /proc still fail on Windows (obviously), but all tests are passing when run in Wine. Change-Id: Ie4c3ba65b642202f8fcaec73332a53bee6115fba
2015-04-29Print strerror instead of errno in tests.Dan Albert
Change-Id: Ibfab1b7cd439fdb5ae19855cc700613c00d4aff8
2015-04-24Add ReadFully and WriteFully to libbase.Elliott Hughes
Change-Id: I6b7aa2a93398e7acdd1d74c71d9abed08a72b3c4
2015-03-20Add google3 style logging to libbase.Dan Albert
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
2015-03-16Revert "Revert "Create libbase.""Dan Albert
This reverts commit a7870d88167f619e758b5bcd15b410d16da7c16b.
2015-03-16Revert "Create libbase."Nicolas Geoffray
Breaks internal master. This reverts commit 98ff77204cef9bb8f0f27420833233622060a09e. Change-Id: I18dc6021cb43efff8aa88486c2d980dc2b8eedba
2015-03-14Create libbase.Dan Albert
Move StringPrintf and the string based file I/O from libutils to libbase. Change-Id: I0297a6063874b9d92100e0dd5123fddfbda932fe