Commit graph

162 commits

Author SHA1 Message Date
Keun-young Park
22a64b3a8a Merge "add base::WaitForPropertyCreation" 2017-02-28 22:39:41 +00:00
Keun-young Park
e2d986daa6 add base::WaitForPropertyCreation
- unlike base::WaitForProperty, which waits for specific value to
  be set, this one only waits until the property is created.

bug: 35178781
Test: added unit test
Change-Id: Idbf98c2152fe768357302f6b69310c55305f5d54
2017-02-28 12:08:54 -08:00
Colin Cross
bb3a515f46 Add GetExecutableDirectory to libbase
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-28 16:34:04 +00:00
Colin Cross
58021d15c9 Move adb_dirname and adb_basename to libbase
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-02-27 18:18:31 -08:00
Elliott Hughes
8a16081fa1 Merge "Add cross-platform <android-base/endian.h>." 2017-02-25 02:07:05 +00:00
Elliott Hughes
1dbd976200 Add cross-platform <android-base/endian.h>.
Bionic has <sys/endian.h>, glibc <endian.h>, and macOS and Windows have
nothing. This has often been annoying.

Bug: N/A
Test: new tests
Change-Id: I2a40c570df6a9bb30607ace1af653265938cc4b8
2017-02-24 14:03:36 -08:00
Elliott Hughes
9f4c8f753b Add some basic docs for <android-base/logging.h>
Bug: http://b/35360600
Test: N/A
Change-Id: I3de6bbe4afc7ca6adbfb0c9b01a5a3d4c2c35cfc
2017-02-22 18:02:46 -08:00
Elliott Hughes
03edc9f764 Add timeout support to android::base::WaitForProperty.
Bug: http://b/35201172
Test: ran tests
Change-Id: I025aa0217dc94fabf0eb076b285a84866b00e741
2017-02-21 14:57:15 -08:00
Elliott Hughes
ec46f4ed28 Only sanitize Android.
Bug: N/A
Test: didn't
Change-Id: I9b9bc04112501eaa9f9ccf23152fc5d118b03000
2017-02-14 15:46:33 -08:00
James Hawkins
91cf0bd5c0 Merge "Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."" 2017-02-14 19:24:36 +00:00
James Hawkins
c8ac067773 Revert "bootstat: Refactor init/utils/boot_clock into base/chrono_utils."
This reverts commit 7c92e48450.

Mac sdk still broken (despite testing locally).

Change-Id: I7d9206e15997cd0efe081bd3fa17d53d2b20ec32
2017-02-14 19:20:20 +00:00
Treehugger Robot
aa9548dbb4 Merge "Fix ubsan failure in android::base::Split." 2017-02-14 18:43:17 +00:00
Treehugger Robot
e968b73e19 Merge "bootstat: Refactor init/utils/boot_clock into base/chrono_utils." 2017-02-14 18:35:54 +00:00
Treehugger Robot
01003d40fc Merge "Implement android::base::WaitForProperty." 2017-02-14 03:48:26 +00:00
Yabin Cui
b13d4a31a3 Merge "libbase: fix the way to find temp dir." 2017-02-14 00:29:40 +00: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
James Hawkins
7c92e48450 bootstat: Refactor init/utils/boot_clock into base/chrono_utils.
Use this for bootstat and init. This replaces the custom uptime parser in
bootstat.

This is a reland of aosp/332854 with a fix for Darwin.

Bug: 34352037
Test: chrono_utils_test
Change-Id: Ib2567d8df0e460ab59753ac1c053dd7f9f1008a7
2017-02-13 15:47:21 -08:00
Elliott Hughes
bf0dd7cb03 Fix ubsan failure in android::base::Split.
ubsan doesn't like us incrementing std::string::npos, even if we won't use
the result.

Bug: http://b/28729303
Test: ran tests
Change-Id: I8227eca57dc6f3e49626c7025514caa04ef18f0a
2017-02-13 14:13:24 -08:00
Elliott Hughes
b30769a87a Implement android::base::WaitForProperty.
Also adapt libcutils to the bionic change that was necessary for this.

Bug: http://b/35201172
Test: ran tests
Change-Id: I72a98b70b03d23e958b46778b505fbd5c86c32ae
2017-02-13 11:29:02 -08:00
James Hawkins
0e3167e203 Revert "bootstat: Remove custom uptime parser in favor of elapsedRealtime."
This reverts commit 26f40c04c3.

This change broke the Darwin SDK target.

Test: none
Change-Id: Ia54fe2c31da8d8fa2825e023b035fb8321dcd457
2017-02-08 14:16:51 -08:00
James Hawkins
26f40c04c3 bootstat: Remove custom uptime parser in favor of elapsedRealtime.
Refactored init/utils/boot_clock into base/chrono_utils.

Bug: 34352037
Test: none
Change-Id: Ied0c00867336b85922369d7ff37520e3d28fc61e
2017-02-07 15:43:32 -08:00
Yabin Cui
0c68953778 base: support logging before enter main function.
Bug: http://b/30974760
Test: run libbase_test.

Change-Id: I3f45fc21e8fe6301b5fef027728ea91f2188911d
2017-01-25 15:50:47 -08:00
Elliott Hughes
2140782d24 bootable/recovery wants EqualsIgnoreCase.
Bug: N/A
Test: ran tests
Change-Id: I4a6ee9eba0514b8bb8fb0489f4d370964ce9c1c2
2017-01-13 18:51:32 -08:00
Elliott Hughes
a6c65704d6 Fix libbase file.Readlink test on marlin/sailfish.
Bug: http://b/33306057
Test: ran tests
Change-Id: Ie6797e71d3507572da66d6b6966f8ee9373124a4
2017-01-11 17:34:40 -08:00
Charles He
40feda6ae9 [nit] Fix typo in properties.h
Test: none
Change-Id: I6fe25bc9404c18bedc5802b3d830ede8a1bc28df
2016-12-15 10:47:32 +00:00
Stephen Hines
b0775ca517 Switch to memcpy for accessing misaligned data.
Bug: http://b/31532493

Using misaligned pointers forces us to potentially take the address of
members in a packed structure (which is now a warning/error in the
latest Clang). Using memcpy() is the proper way to handle this kind of
problem, as the compiler can insert the proper instructions (and usually
elide the memcpy() entirely).

Test: Built correctly with updated compilers.
Change-Id: Ia1f6eb62cf19404ff76b71d3c6c7ffffa1403120
2016-12-07 03:46:55 -08:00
Dan Willemsen
ab34b47b35 Enable libbase/libutils/libziparchive on host bionic
Bug: 31559095
Test: Test linux_bionic compile
Change-Id: Ib42c063532c1cbeb3e1418ab16a1fb54d5902aab
2016-11-29 13:38:53 -08:00
Elliott Hughes
42937492c8 Add StartsWithIgnoreCase/EndsWithIgnoreCase.
This has come up a couple of times now.

Bug: wanted as part of http://b/32094640
Test: ran tests
Change-Id: I51b67074b7ddeedd771d7be9651ba33e05491b33
2016-10-25 14:56:04 -07: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
Mark Salyzyn
27d2d49f48 Merge "system/core: preparation to pull back interfaces from android/log.h" 2016-10-20 17:53:45 +00:00
Yabin Cui
d55705796e Merge "libbase: add parsedouble.h." 2016-10-20 17:18:36 +00:00
Mark Salyzyn
cfd5b080af system/core: preparation to pull back interfaces from android/log.h
Point to log/log.h where necessary, define LOG_TAG where necessary.
Accept that private/android_logger.h is suitable replacement for
log/logger.h and android/log.h.

Correct liblog/README

Effectively a cleanup and controlled select revert of
'system/core: drop or replace log/logger.h' and
'system/core: Replace log/log.h with android/log.h'.

Test: compile
Bug: 30465923
Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
2016-10-20 08:11:39 -07:00
Yabin Cui
997cba4271 libbase: add parsedouble.h.
Bug: http://b/24905115
Test: run libbase_test --gtest_filter=parsedouble.smoke.
Change-Id: I604424772f2082b420935e6647da03981c0b8929
2016-10-19 11:19:42 -07:00
Elliott Hughes
da46b392f1 Move off std::sto* function which abort on failure.
Bug: http://b/31403370
Test: builds, boots, libbase tests pass
Change-Id: I89cd7ca3d8f1c8a1bad0ddf3043439449d19a293
2016-10-13 15:34:05 -07:00
Treehugger Robot
392a2c8f0f Merge "Add 0X as a valid hex prefix for parseint" 2016-10-08 10:36:02 +00:00
Yifan Hong
89fbd6349f Add 0X as a valid hex prefix for parseint
Bug: 31983995

Test: make android.hardware.tests.expression@1.0
Change-Id: I526d73f96c519f84dec93befa442b1d2fff7979b
2016-10-07 16:50:16 -07:00
Andreas Gampe
b4e32f3b33 Base: Hand complete log message to aborter
Undo zero-termination-substitution for linebreaks when logging.
This results in handing the complete log message to the aborter.
Add a test.

Bug: 31893081
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I2ef6c6351db2fd494a02985f634f439104136227
2016-10-04 19:19:59 -07:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
Treehugger Robot
aa00f5852f Merge "Base: Remove LOG_S variants." 2016-09-26 00:37:13 +00:00
Andreas Gampe
1f5fb43047 Base: Remove LOG_S variants.
Partially reverts commit 436f5a031f.

Remove the variants taking a fully qualified LogSeverity. Instead
use a lambda with "using" statements to translate both qualified
and unqualified names into valid expressions.

Compile-time regression was measured as 0.1s for a thousand LOG
statements on a z840.

Update tests.

Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I36fdf30a9d535b19543307b85d1b3c19a97f20dd
2016-09-24 10:18:38 -07:00
Treehugger Robot
3f049c3f19 Merge "Add std::string system property functions." 2016-09-24 04:52:59 +00:00
Elliott Hughes
1e88c8c0ac Add std::string system property functions.
Makes it easier to write correct code in a world where the maximum
property key/value lengths change.

Bug: http://b/23102347
Test: libbase_test64
Change-Id: I100f00904221bbcef9e8786a4e6e30428039bb49
2016-09-23 15:30:22 -07:00
Andreas Gampe
19ff8f1e57 Base: Check severity in destructor
Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: Ic077822bcfd591bd11f4fa9d4b6e440b461c70c1
2016-09-23 13:31:52 -07:00
Andreas Gampe
436f5a031f Base: Add more log macros
Add WOULD_LOG to determine whether a given severity would be logged.

Add LOG_STREAM to have direct access to a logging stream.

Add LOG_S variants that take a fully qualified severity. This allows
complex expressions as parameters, e.g., ternaries for conditional
severity levels.

Add tests.

Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I242b960594e68caff6db9cd8aaa4ce8aaf90474c
2016-09-22 12:47:40 -07:00
Josh Gao
5d1b1a8b91 base: rename unique_fd::clear() to unique_fd::reset().
unique_fd is modeled on unique_ptr, so make this consistent.

Test: m checkbuild
Change-Id: Ia6a77095dc18746fbb432e96bb8dccfc049c57f6
2016-09-19 11:24:58 -07:00
Pirama Arumuga Nainar
70f281ae36 Remove mutex.h and its uses.
mutex.h is now available as a part of MinGW itself.

Test: Successful build
Change-Id: I036ee37600a39130d6fbf293398585cfc58209ca
2016-09-16 15:58:00 -07:00
Josh Gao
ffabc9651f base: add parameter that controls O_NOFOLLOW in file functions.
Bug: http://b/31491920
Change-Id: I19cb06941d87c0180ccab8bb2d85e57338811624
Test: m
2016-09-14 17:08:22 -07:00
Josh Gao
c95afaa20b Fix darwin build break.
Bug: http://b/31468413
Change-Id: I12fdf0977213eefc7043939964070025a672881a
2016-09-14 13:54:45 -07:00
Treehugger Robot
c9c555b8dd Merge changes Ie15fcb8f,I0a895911
* changes:
  base: add quick_exit emulation.
  base: extract mutex.h from logging.cpp.
2016-09-14 20:14:53 +00:00
Josh Gao
0c44256ae4 base: add quick_exit emulation.
Bug: http://b/31468413
Change-Id: Ie15fcb8ff0613d01a0eb7437a2cb37283aa52bab
Test: mma, libbase_test on Linux/Windows
2016-09-13 17:54:50 -07:00