Commit graph

141 commits

Author SHA1 Message Date
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
Josh Gao
63bdcb57aa base: extract mutex.h from logging.cpp.
Extract the Windows-specific mutex implementation from logging.cpp.

Bug: http://b/31468413
Change-Id: I0a895911ec6d815b8011b09d55209b64bbf9a70e
Test: mma
2016-09-13 15:59:46 -07:00
Andreas Gampe
d8f26e2ac9 Base: Fix dangling-else in CHECK_STROP
Follow-up to commit 2527628eda.

Bug: 26962895
Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: Ifd71314e146ebf3957cc053ee95ef85002c909b4
2016-09-13 14:16:37 -07:00
Andreas Gampe
2691e335fe Base: Add AbortFunction for logging
Add a hook to modify FATAL behavior. Add a test.

Bug: 31338270
Test: m
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I966da319cda613738b3f2ccdac8c21900d6a5c72
2016-09-08 15:33:27 -07:00
Andreas Gampe
550829d84b Base: Add INTERNAL_FATAL to logging severity
Add the INTERNAL_FATAL level. It will print 'F' like FATAL, but
does not abort after logging.

Add a test to logging_test.

Bug: 31338270
Test: m
Test: mmma system/core/base && adb sync && adb shell /data/nativetest/libbase_test/libbase_test32
Change-Id: Idf74c08e8516881efccaefc58fa3f41d57e56396
2016-09-07 18:19:42 -07:00
Elliott Hughes
13d78e440a Clean up the libbase logging test.
Use ECMAscript regex syntax (the default!) for a simpler regex.

Also test the cartesian product of logging options, with less copy & paste
than the previous test of a subset.

Change-Id: I7aae91d276dbbb8de6173d18b5c1ceb01c1dff73
2016-09-07 16:22:40 -07:00
Andreas Gampe
7c1cdd7700 Base: Fix logging_test
Update the expected logging pattern.

Bug: 31338270
Test: mmma system/core/base && adb sync && adb shell /data/nativetest/libbase_test/libbase_test32
Change-Id: I299620669126bc0258cad6e30d5b40bff5ea92ad
2016-09-07 11:39:59 -07:00
Treehugger Robot
43824e72c7 Merge "Base: assume and use C++11 in libbase" 2016-09-01 22:32:42 +00:00
Andreas Gampe
22847131da Base: assume and use C++11 in libbase
Assume C++11 support. logging.h already used constexpr before,
macros.h now also does no longer check the language level.

Use constexpr for the logging evaluator. This allows the usage
of CHECK and co in other constexpr expressions in C++14.

Test: m checkbuild (N9)
Change-Id: Ifdffa074271fff1f9949c48829a185800ec5e524
2016-09-01 13:38:12 -07:00
Josh Gao
7307f09457 base: use _NSGetExecutablePath in GetExecutablePath
Bug: http://b/31240820
Change-Id: I0dbf95d3667c7ce7b474ddbb3f8e3ed69476d13e
Test: mma && adb kill-server && adb devices
2016-09-01 12:32:35 -07:00
Josh Gao
945d1aaa32 Merge "Add android::base::GetExecutablePath, switch adb and fastboot over." 2016-09-01 18:38:12 +00:00
Elliott Hughes
82ff315bb0 Add android::base::GetExecutablePath, switch adb and fastboot over.
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-09-01 09:24:24 -07:00
Treehugger Robot
3f3ea50828 Merge "Base: add more thread annotations" 2016-08-31 22:23:00 +00:00
Josh Gao
ca82aa7d1e Merge "base: disallow close() on unique_fd." 2016-08-31 20:47:13 +00:00
Andreas Gampe
bc5a32e2ad Base: add more thread annotations
These are taken from ART and wrap more attributes.

Test: m
Change-Id: I545fc9ab88cf9d2db4de2cb8893e2a35f6365f51
2016-08-31 13:29:07 -07:00
Treehugger Robot
a7c4424ebc Merge "Add android::base::Readlink." 2016-08-31 17:56:40 +00:00
Elliott Hughes
d3ff6e5231 Add android::base::Readlink.
Bug: http://b/30988271
Change-Id: Ib844d7c9e33465dabf7aee5e24dc3d1d8d799abd
2016-08-31 09:35:44 -07:00
Josh Gao
6496c4bf6f base: disallow close() on unique_fd.
unique_fd's implicit conversion to int allows it to be passed to
close(2), which is dangerous because unique_fd will think that it still
has ownership of the now-closed fd. Disallow this by providing an
overload for close that's tagged with an attribute that gives a
compile-time error.

Test: m
Change-Id: I514591335b337f2f57c1df371cf3979304aea17c
2016-08-29 14:37:49 -07:00
Andreas Gampe
247924a36f Libbase: add C++11 support to DISALLOW_IMPLICIT_CONSTRUCTORS
Use delete when possible.

Test: m
Test: m test-art-host
Change-Id: Ib741564c7a31348b2f706fe55eb23d9886f865e3
2016-08-29 09:36:31 -07:00
Elliott Hughes
7bc87a5a78 Move init's kernel logging into libbase.
This will let other stuff (such as adbd and recovery) use it too.

Bug: http://b/28467098
Change-Id: Idab51f438ed3edd6fe65a56c4b396eaff5f3833e
2016-08-04 16:09:39 -07:00
Elliott Hughes
e5dd71a290 libbase should use its own logging!
Not doing so led to us using a bogus log tag.

Bug: http://b/30281203
Change-Id: I3ac91758a1a043146c65f2ae0f36fcfbe372c30f
2016-07-28 15:15:28 -07:00
Colin Cross
fc06bd0ca3 Convert libbase Android.mk to Android.bp
Change-Id: I429d0a06c5138c3e54c9d25f15adb3e2647496e1
2016-07-11 14:23:32 -07:00