Commit graph

15 commits

Author SHA1 Message Date
Mark Salyzyn
0790b2465a base: move TemporaryFile and TemporaryDir to android-base/file.h
Allow a wider legitimate audience to use TemporaryFile and
TemporaryDir by moving them from android-base/test_utils.h to
android-base/file.h.

Test: compile
Bug: 119313545
Change-Id: Ie558c5873ce5b3937914918b6bfb427e5b61d0da
2018-11-13 12:44:21 -08:00
Christopher Ferris
eea85c9aab Add Start/Stop/Reset to CapturedStdFd.
Move the fd() function to be private since it should not have been
exposed in the first place.

Fix the way logging_test uses CapturedXXX.

Adding this because the new isolated testing doesn't print errors to
stderr so the ASSERT_ EXPECT_ messages can get swallowed. Also, it's easier
to reuse a CapturedXXX object in a test with these functions.

Test: New unit tests pass.
Change-Id: I38b113fc184146ce434802f80a9b7997fa83e78a
2018-09-04 14:29:23 -07:00
Elliott Hughes
1be0d1481b Add StdioLogger for command-line tools.
Bug: N/A
Test: ran tests
Change-Id: If366a4ea25aea1becdd3e443eba225e9bd52ebba
2018-05-23 10:06:20 -07:00
Yabin Cui
ef58cef982 base: Add TemporaryFile::DoNotRemove().
Bug: http://b/73127105
Test: none.
Change-Id: I563c12bfb629ddd630568dda4817fb10cc9940a8
2018-03-08 17:59:36 -08:00
Yabin Cui
464ea61143 base: allow creating tempfile in a custom temporary dir.
Bug: http://b/70232908
Test: none.
Change-Id: I24b894793f6725186b3582a91db083427e51aa5a
2017-12-06 14:20:07 -08:00
Tianjie Xu
f9bc1b0571 Add the Release function for TemporaryFiles
Some tests may create a File* by calling fdopen() on the temp file's
fd. We should release the ownership of fd in this case to avoid the
double close.

Bug: 65430057
Test: libbase unit tests pass
Change-Id: I54fcce2029f9a574f53afdbdda737ee58620c73a
2017-09-11 14:08:32 -07:00
Yabin Cui
57e9cea099 libbase: fix the way to find temp dir.
Tests running in app context can't access /data/local/tmp,
so try current directory if /data/local/tmp is not accessible.

Bug: http://b/18790309
Test: run unit test in app context and shell context.
Change-Id: If66fe8f0ac3edb3a32a2a2a50a524364f818a58b
2017-02-13 15:50:56 -08:00
Wei Wang
8c176302e6 Move CapturedStderr to test_util library
Bug: 32181382
Test: run /data/nativetest(64)/binderTextOutputTest
Change-Id: Ifb2e1f6af2c3f57b5cbed7dde65efb31253c52a2
2016-10-22 10:35:21 -07:00
Elliott Hughes
38e2b63db8 Remove libbase's libutils dependency.
Yuck.

Change-Id: If84758f25bc15d5b1a732eaccc226385f51cac13
2016-02-17 11:53:54 -08:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Spencer Low
2fbeb0cc71 adb/base win32 tests: fix comment and open() flags
Match base's use of O_BINARY.

Change-Id: I930b5c8fddde20966580069f2e681b99cb26f1a3
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-09-01 14:57:58 -07:00
Spencer Low
40d0c7aead libbase_test: win32: get some tests working
* 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.

Change-Id: Ia01f94e8258503381a1df6d3da6e40de59e57125
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-08-03 10:54:17 -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
0c4b3a319d Get libbase tests working on Windows.
Tests using files from /proc still fail on Windows (obviously), but
all tests are passing when run in Wine.

Change-Id: Ie4c3ba65b642202f8fcaec73332a53bee6115fba
2015-04-29 17:11:28 -07:00
Dan Albert
58310b49fc Add google3 style logging to libbase.
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-20 14:04:35 -07:00