summaryrefslogtreecommitdiff
path: root/liblog/tests
Commit message (Collapse)AuthorAgeFilesLines
* Remove liblog, logcat, logd, logwrapperBaligh Uddin2020-10-0816-5349/+0
| | | | | | | | These subdirectories have moved to platform/system/logging. BUG: 168791309 Test: Local build + TH Change-Id: Iaee2ff59d4450f3e59dc9ea8b0e257b2de53e478
* Remove vts10 related configsDan Shi2020-10-061-1/+0
| | | | | | Bug: 169582597 Test: build Change-Id: I38e1e0f8e32b86ab14b905d040c1c62245a1a9e3
* Remove android_lookupEventTagNum() and related codeTom Cherry2020-08-172-41/+0
| | | | | | | | This was introduced years ago but never gained any users. Test: build Merged-In: Id2deb6de1839f995970c6350a1970a872f0b51cf Change-Id: Id2deb6de1839f995970c6350a1970a872f0b51cf
* liblog: use unique log tags for is_loggable testsTom Cherry2020-08-031-55/+63
| | | | | | | | | | | | Apparently these tests are run in parallel, which causes errors since they use the same log tag. Use unique log tags based on pid to fix this. Also re-enable the previously disabled tests. Bug: 162669552 Test: run these tests 100x+ and see that they no longer fail Change-Id: Ib20d638e5e559bca23adec479a5dcf64075e376e
* liblog: disable property tag testsTom Cherry2020-08-031-0/+2
| | | | | | | | | | | Disable: liblog_global_state.is_loggable_both_set liblog_global_state.is_loggable_tag_log_priority_only Bug: 162633089 Bug: 162669552 Test: these tests don't run Change-Id: I82b8e6685a321ae03374e86ffbe845608aec93b5
* Run liblog and logd CTS tests in presubmitTom Cherry2020-07-291-0/+1
| | | | | | | And sort the rest of the CTS tests. Test: these tests run Change-Id: I8eeb7b8acac2ed658b36da8463112fe1da8437a9
* logd: remove users of __android_logger_property_get_bool()Tom Cherry2020-07-281-20/+18
| | | | | | | | | | | | | | | | | | __android_logger_property_get_bool() has a clunky API and doesn't belong in liblog, since a vast majority of liblog users will never query this property. Specifically 1) Replace with GetBoolProperty() when completely equivalent. 2) Remove checking if property values are 'eng' or 'svelte', since there's no evidence that those values were ever used. 3) Remove checking 'persist.logd.statistics' and 'ro.logd.statistics', since there's no evidence that those values were ever used. 4) Set ro.logd.kernel explicitly, so other processes don't need to replicate the defaults that logd uses. Test: build Change-Id: I7c37af64ba7754e839185f46da66bf077f09d9c3
* liblog: remove unused log_time functions, inline the othersTom Cherry2020-05-182-7/+7
| | | | | | | | | | | One of the reasons that logcat and logd statically include liblog is to access the symbols in log_time.cpp, which we do not expose otherwise. Except for strptime(), which will be handled in a separate CL, these symbols are either small enough to inline in the header or unused and can be removed. Test: logging unit tests Change-Id: I1f8cfbb779aef79fc7d5b6d0050438fe5f0e0e2c
* Remove the monotonic option for loggingTom Cherry2020-05-062-18/+5
| | | | | | | | | | This has been around for ~5 years but there has been roughly no adoption, so remove this as we clean up the logging code. Future efforts may track the monotonic timestamp in all cases. Test: logging unit tests Change-Id: I55ed565669f923988e741f6b384141bba893630d
* liblog: mark tests as require_root: trueTom Cherry2020-04-301-0/+1
| | | | | | | | Some tests require root to be run, so we require_root to run all of them. Test: tests pass as root Change-Id: I5b3ca4f08e41f16e81c5d5995043ab55d379a882
* liblog: require root for multi_connect_dgram_socket testTom Cherry2020-04-301-0/+4
| | | | | | | Bug: 65062446 Test: multi_connect_dgram_socket is skipped for non-root Test: multi_connect_dgram_socket passes for root Change-Id: I610bed5987580e0c5a01952efc2e32e7d8cdf9b4
* liblog: remove Rwlocks for logd_socket and pmsg_fdTom Cherry2020-04-273-93/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These historically used atomics to manage their lifetime. They were unfortunately unsafe and later replace with a RwLock. A lock is also problematic as it is too heavy weight for the typical use case and implies that logging is neither async nor fork safe. This change returns us to using atomics with two key changes: 1) compare_exchange_strong() is used instead of atomic_exchange(). The latter has a race condition where a separate thread could have read the atomic value into a register, while the thread performing the atomic_exchange closes that FD. The new code only changes the FD in the atomic if it is uninitialized. 2) Using the fact that DGRAM sockets can have connect() called on them multiple times, it uses a single logd_socket for the duration of the program. These sockets are thread/async/fork safely created and accessed. The one caveat is __android_log_close(), which is intended only to be used by zygote when it is single threaded and is therefore not thread safe. It will close this socket and reset the underlying variable, such that the next log message will go through the above initialization. Bug: 65062446 Test: logging works, logging unit tests Test: new unit test Change-Id: Ia4dbf7479dbe50683d124558ab2f83bff53b8f5f
* Don't include log/log_read.h in log/log.hTom Cherry2020-04-172-0/+2
| | | | | | | | | log/log.h primarily concerns itself with writing logs. The few users who read logs should directly include log/log_read.h. Bug: 78370064 Test: build Change-Id: Ie95c55ea2ffc76fc95768323d445ada6ad4f2520
* liblog: cleanup TODOs in testsTom Cherry2020-04-101-10/+3
| | | | | | | | | | | | | | | 1) log_msg.msg() will never be nullptr, unless logd sends an invalid response, so it's the right idea to ASSERT() that this is true instead of just checking and continuing. 2) Even though liblog.too_big_payload is tautological, there's no reason not to test it, in case the assumptions that make it tautological change. 3) We're not too worried about the return value of logging functions or that liblog prevents them from being written (anyone can write their own values to logd after all). Test: liblog-unit-tests Change-Id: I144cc7cf45c164ea5f04e0786ff0e298fd626f07
* liblog: support extended logger_entry headersTom Cherry2020-04-091-0/+66
| | | | | | | | | | | | | | | logger_entry has a hdr_size field meant for backwards compatibility, however there are a few checks that expect it to be a specific size. More problematically, it has a variable length array element, msg[0] at the end, that would be incorrect if the header size was not kept static. This change fixes up those issues to facilitate future additions. Bug: 119867234 Test: logging works with extended size headers, logging unit tests Test: newly added unit tests with extended size header Change-Id: I14b2b0855d219d11f374b53a5aa8e05cd6a65eef
* Remove vts10 tests from vts suiteDan Shi2020-03-271-1/+0
| | | | | | | | | | | The tests are only needed in vts10 suite. Bug: 151896491 Test: local build Exempt-From-Owner-Approval: This CL removes vts10 tests from vts suite. It won't change test logic or behavior. Change-Id: I4d468be075b54213b56c7e1aa94af94f2bdce9ff
* liblog: correct new APIs per the API reviewTom Cherry2020-03-251-18/+16
| | | | | | | | | | | | | | | | 1) Rename __android_logger_data to __android_log_message and rename __android_log_write_logger_data to __android_log_write_log_message. Move the const char* message argument into __android_log_message. 2) Add @param, @return, and "Available since API level 30." to the documentation of new functions. 3) Document that the user defined aborter should but may not abort. 4) Document the line separation is the responsibility of the log function provided to __android_log_set_logger(). Bug: 150898477 Test: build, liblog and libbase unit tests Change-Id: I07c41011ef25b3e7cc4943f3f1e240a2f6aa2802
* Merge "Add vts10 suite to existing vts tests"Treehugger Robot2020-03-241-0/+1
|\
| * Add vts10 suite to existing vts testsDan Shi2020-03-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This is to prepare renaming vts to vts10. Bug: 151896491 Test: local build Exempt-From-Owner-Approval: This CL adds all tests in vts to a new suite vts10. vts10 will be the new name of existing vts suite. This CL won't change test logic or behavior. Change-Id: I3c7ccef142de30f02a59046cecba121480f6e436
* | Merge "Remove ANDROID_LOG_RDONLY, etc"Tom Cherry2020-03-244-27/+18
|\ \
| * | Remove ANDROID_LOG_RDONLY, etcTom Cherry2020-03-234-27/+18
| |/ | | | | | | | | | | | | These macros haven't been meaningful in years. Test: logging unit tests Change-Id: I796ec6d9b450f8a84bc85c3f15ddd988724c5e08
* / Skip pmsg related tests if /dev/pmsg0 is not foundTom Cherry2020-03-232-14/+18
|/ | | | | | | | | | | | | | | | | These test use fopen() with append which includes O_CREAT. If these tests are run in the 'su' SELinux domain (aka through `adb root`) then they'll create a blank text file when opening /dev/pmsg0 if it does not exist. Other tests and processes will attempt to write to this file, either succeeding (for 'su' domain processes) and wasting memory, or failing due to SELinux and generating audits (for typical processes). This isn't a problem for user builds, since without `adb root`, the tests simply fail when pmsg0 does not exist. Test: no excess denials or /dev/pmsg0 creation when running liblog-unit-tests as root Change-Id: I06e0f308c72db5a53c5f9e4a29bd23f56352c7e2
* liblog: add benchmark tests for not-printed messageTom Cherry2020-02-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | Add a BM_log_verbose_overhead test that measure the overhead of writing a log message that will not be printed due to verbosity levels. This was optimized in R to not format the log messages before checking if they will be logged. Results with R: BM_log_verbose_overhead_null_mean 159 ns 159 ns 100 BM_log_verbose_overhead_null_median 159 ns 159 ns 100 BM_log_verbose_overhead_null_stddev 0.568 ns 0.464 ns 100 Results with Q: M_log_verbose_overhead_null_mean 601 ns 600 ns 100 BM_log_verbose_overhead_null_median 601 ns 600 ns 100 BM_log_verbose_overhead_null_stddev 2.40 ns 2.23 ns 100 This benchmark shows liblog's overhead when not printing a log message to be nearly ~4x faster than with Q. Test: run this benchmark Change-Id: I09a60e61bf064330bf15a9d0a946acf16e777a6d
* Rename ro.device_owner system propertyRubin Xu2020-02-191-2/+2
| | | | | | | | | | | | | This is renamed to ro.organization_owned to cover the extended usage now that there is a new management mode for fully-managed organization owned devices: organization-owned managed profile. A device is considered fully-managed if there is a device owner or an organization-owned managed profile. Test: atest liblog-unit-tests Test: atest propertyinfoserializer_tests Bug: 148437300 Change-Id: Iaa8ea246c973732526abc1da5b307af8bce1a0af
* liblog: fix host testsTom Cherry2020-01-284-109/+110
| | | | | | | | | 1) Fix up the host tests for new logging format 2) Add recently added tests to the host test 3) Ensure that properties are cleaned up by liblog-unit-tests Test: unit tests Change-Id: I303549aecc26d11ec87e59d48758ced4c198b72c
* liblog: use default tag for loggability checks if no tag is providedTom Cherry2020-01-271-0/+44
| | | | | | | Bug: 116329414 Bug: 119867234 Test: new unit tests Change-Id: I92a3f4f95e5f482f6fe20f17ed83c8ed367b06dc
* Move default tag from libbase to liblogTom Cherry2020-01-232-0/+100
| | | | | | Bug: 119867234 Test: log tags look right, libbase/liblog unit tests Change-Id: I3670c3fdce3d0238a23a53bba2877ffed1291f9c
* Move minimum log priority from libbase to liblogTom Cherry2020-01-212-8/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See the previous commit moving SetLogger and SetAborter to liblog for motivation. This creates more harmony between the two mechanisms in libbase and liblog for checking loggability. Currently: 1) libbase filters all messages based on its minimum log priority. For example, if minimum log priority in libbase remained at its default, but a tag was specifically opted into DEBUG logs via log.tag.<tag>, libbase would not print this log. 2) liblog ignores libbase's minimum log priority. For example if a process called SetMinimumLogPriority(WARNING) but used a library that logged via liblog's ALOGI macro, that log would still be printed even though the process intends on filtering out those INFO messages. With this change: 1) If both a minimum log priority and a priority through log.tag.<tag> are set, then the lower of the two values is used. 2) If only one or the other is set, then that value is used. This fixes the two issues described above. 3) If neither of these values are set, then the default of using INFO is unchanged. Bug: 116329414 Bug: 119867234 Test: libbase and liblog minimum log priority tests Change-Id: Icb49b30b9d93bf797470e23730ae9e537931bb6c
* Move SetLogger and SetAborter from libbase to liblogTom Cherry2020-01-213-1/+156
| | | | | | | | | | | | | | | | | | | | | | | | libbase is copied into each APEX module which requires it, meaning that there may be multiple instances of libbase running within a single process with their own copy of libbase's globals. This means that SetLogger() and SetAborter() will only impact logs from the instance of libbase that calls it. This change moves this state to liblog, since it will only ever have one instance in a single process. One major side-effect here is that now both ALOGE style and LOG(...) style logs will be handled through the same logger function. For example, a logger specified through libbase's SetLogger() will now see logs sent to liblog through ALOGE(). This is intended behavior. A second side-effect is that libbase's stderr logger is used for all host logging now. It's simply a better logging default than the fake_log_device logger in liblog currently and makes ALOGE and LOG(...) logs on host follow the same format. Bug: 119867234 Test: libbase and liblog unit tests; logging works Change-Id: Ib52cbfb4e43749e50910ed19a993dffae19ace86
* CtsLiblogTestCases secondary_userBookatz2020-01-061-0/+1
| | | | | | | | | | | | | | | Marks this CTS test module as supporting secondary_user, meaning that the tests are eligible to be run from a regular Android user other than the system user (i.e. other than user 0). Note that 'user' here refers to the concept of users in Android Multiuser; it is NOT the same as a uid. Bug: 141773058 Test: module passed with secondary_user params (--enable-optional-parameterization --module-parameter secondary_user) Change-Id: Iaff9fb5d21473129ce3a802d179db474f7c763bc
* liblog: use a rwlock for writer initializationTom Cherry2019-12-122-0/+92
| | | | | | | | | | | | | | | | | | | | The current system of using atomics isn't thread safe and may result in doubly closing FDs or closing actively used FDs. The safest way to do this is to use a rwlock, which should not have a much higher overhead than the atomics do, as a vast majority of the time, there will not be writers. This moves us further away from using the transport interface, which will be removed. Each writer should be self contained, without a separate open or available function. Also, keep the pmsg fd open if it is opened by __android_log_pmsg_file_write(). This fd was closed due to issues with zygote, but it looks like it is only called by recovery now, so there is no reason to close this fd at the end of that function. Test: logging works, liblog-unit-tests Change-Id: I345c9a5d18c55b11a280c8362df854784abf46fd
* liblog: add a test for liblog on hostTom Cherry2019-12-102-0/+203
| | | | | Test: this test Change-Id: I60fa8b82dbc010395762eba70502b89b295e29f5
* liblog: simplify logd 'command' functions and struct loggerTom Cherry2019-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a set of functions, such as android_logger_get_log_size() and android_logger_get_prune_list() that talk to the logd command socket to perform their activities. There's a transport abstraction layer that handles these symbols to optionally route them to other transports, originally designed for pstore or local logger; however these functions fundamentally only make sense for logd. Ideally, these functions would be removed and new functions would be added that do not depend on struct logger_list or struct logger and more clearly indicate that they only work with logd. For example: android_logger_get_size(struct logger*) could be logd_get_buffer_size(log_id_t log_id). We would remove the need to 'open' the struct logger and make it clear that it only operates on logd. Since liblog is an llndk library however, we cannot change or remove these symbols. Since these symbols are not frequently used, it seems acceptable to keep them as is and not introduce improved versions. We, however, do want to simplify the code that handles them and this change removes the transport abstraction layer that handles them. They retain the behavior that unless the struct logger_list was opened for logd, that the functions return -EINVAL. The one exception to this is android_logger_clear(). If the struct logger provided to this function was opened from a struct logger_list that used pstore for its mode argument, this function will clear the entire pstore log. This function does not respect the 'logId' parameter of the struct logger, since that would not be possible. This change removes this android_logger_clear() behavior and makes it strictly for logd, for symmetry with the rest of the functions and due to the lack of clarity regarding the 'logId' parameter of its input. The only caller of this function, logcat, will clear pstore directly. struct logger was built to encapsulate the information needed to connect to a logger device from the old kernel logger. Now that we only support reading from pstore and from logd, there is much less information needed to be captured. Specifically, we only need to know the log_id and whether or not it was opened as part of a pstore or logd 'list'. Test: liblog-unit-test Test: logcat -c/-g/-G/-p/-P/-S work Test: logcat -c works with -L Test: logcat -g/-G/-p/-P/-S continue to fail with -L Change-Id: I2c549b6f8539de94510e223949ab209ecc40e2d0
* Remove old logger_entry_v* formatsTom Cherry2019-10-241-7/+5
| | | | | | | | | | | | | logger_entry and logger_entry_v2 were used for the kernel logger, which we have long since deprecated. logger_entry_v3 is the same as logger_entry_v4 without a uid field, so it is trivially removable, especially since we're now always providing uids in log messages. liblog and logd already get updated in sync with each other, so we have no reason for backwards compatibility with their format. Test: build, unit tests Change-Id: I27c90609f28c8d826e5614fdb3fe59bde22b5042
* Merge "liblog: remove unneeded checks and includes from headers"Tom Cherry2019-10-161-0/+1
|\
| * liblog: remove unneeded checks and includes from headersTom Cherry2019-10-141-0/+1
| | | | | | | | | | Test: build Change-Id: Ifa3cffe60120fcc30a37239ceb2db46202a03471
* | liblog: enable more testsTom Cherry2019-10-151-38/+50
| | | | | | | | | | | | | | | | | | | | | | Enable more of the disabled tests. These should not be flaky and have value. The dual_reader test is rewritten in the style of RunLogTests() as well. Test: 100 iterations of these tests on CF without failure Change-Id: I15de9e21b066aa22635cc0bd71b51e2648198823
* | liblog: use RunLogTests() for more testsTom Cherry2019-10-142-165/+94
|/ | | | | | | | | | Continuing the speed up / clean up from the last change. Enable a subtest that was previously disabled as well. It passes 100s of cycles now on CF. Test: liblog-unit-tests Change-Id: Ifff6f400c3736a1a857a3fdaf22d7ef1794abf9b
* liblog: don't sleep in the middle of testsTom Cherry2019-10-111-333/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | A lot of liblog tests follow this pattern: 1) Write a log message 2) Sleep ~1 second 3) Use the non_blocking log reader to dump all log messages 4) Test those log messages This causes running back to back tests to be very slow and still allows for some amount of flakiness if the system is very loaded. This change replaces that pattern with the following: 1) Write a log message 2) Set an alarm for 2 seconds as a test timeout 3) Read logs with the blocking reader until finding the expected log messages 4) Test those log messages 5) Use the non_blocking reader to dump all log messages 6) Re-test those log messages, to ensure no duplicates, etc, which isn't done in step 3). Despite dumping the logs twice, the tests are orders of magnitude faster in the good case, and should be less prone to flakes. Test: liblog-unit-tests Change-Id: Iedf473316576b8007746fe3560815bde1813787a
* liblog: use packed structs instead of raw unaligned readsTom Cherry2019-10-091-51/+42
| | | | | | | | | | | | Per jmgao@, we still need to worry about unaligned integer accesses. In any case, we already have the packed structs for all of the unaligned data that we're reading, so this change favors using those packed structs. Bug: 142256213 Test: x86,arm32,arm64 liblog-unit-tests Change-Id: I21fc629eac49895d03b5b31daa4cc494b0c4c230
* liblog: remove alarm in logd_reader.cppTom Cherry2019-10-081-44/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | There is an alarm() call that provides a 30 second timeout in case logd is unavailable. The main reason for this is in the case that logd is crashing, debuggerd is ptrace'ing logd, and tombstoned is attempting to dump log messages. In this case, with no other checks and without this alarm, tombstoned will deadlock when dumping log messages. However, tombstoned already has two mechanisms to prevent the above situation from happening: 1) It checks that the thread name that is is dumping is either logd or starts with "logd." and skips dumping logs in this case. 2) It does not dump logs if it is running in process for any process. Calling alarm() or modifying signal handlers from general purpose libraries is not recommended either, so without a strong reason to keep this, this change removes it. This also shortens the liblog.wrap_mode_blocks test time, since the 30 second issue that it ensures does not happen has been fundamentally removed. Test: `kill -8 `pidof logd`` succeeds without delay Test: liblog, logd unit tests Change-Id: Id8a40544645d220e49f7ba299201af80a0c44de9
* liblog: run in isolated mode, disable flaky testsTom Cherry2019-10-042-5/+32
| | | | | | | | | | | | | | | | | | We disabled then re-enabled a set of tests believing that they were stable; they were not, so we disable them again while we investigate their stability. A majority of tests filter the logs from logd based on pid, so running in isolation helps them not see unexpected information from other test runs. Bug: 138876729 Bug: 142041379 Test: run via gtest with gtest_repeat=10 without failure Test: run via atest 5x times without failure Test: observe that isolated applies to both gtest and atest Change-Id: I757d52dd3233323be9519625868b2fd2aaa41aeb
* liblog: use EXPECTED_STREQ for stringsTom Cherry2019-10-031-3/+2
| | | | | | | | | These tests are flaky, but we're not seeing what the failure strings are. Bug: 142041379 Test: force a failure and see the right error message Change-Id: Icd7777e5c309cac3b98ce65925980965a3cc3753
* liblog: remove log/log_transport.hTom Cherry2019-10-012-35/+0
| | | | | | | | There are no users; future versions will need to be more generic to support the libbase style Logger/Aborter options. Test: build, liblog-unit-tests Change-Id: Ia4571cd39d3e499f18306920ecbf40ea8878fb81
* liblog: remove endianness functionsTom Cherry2019-09-302-30/+19
| | | | | | | Android is little endian. Test: liblog unit tests Change-Id: Ieea7af39013a97f9f0d138a6d1ada3524d94e710
* liblog: remove unused test #defines and transport codeTom Cherry2019-09-301-254/+48
| | | | | | | | We only ever have the default logger now, so we can remove this code. Test: liblog unit tests Change-Id: Ic3755d1c807c53192c614860a3cbe985748a3fe8
* liblog: remove stderr loggerTom Cherry2019-09-304-18/+7
| | | | | | | | | There are no users of the liblog stderr logger, but 66 users of android::base::StderrLogger. We'll prefer that format and work to merge it into liblog. Test: liblog-unit-tests Change-Id: Ifad24b27ac0f51379b925f6644caa1f6f3d9ad81
* liblog: run liblog#enoent only as rootTom Cherry2019-09-041-28/+10
| | | | | | | | | | | | Previously this test would rely on ro.debuggable being true, but there are now some circumstances where ro.debuggable is true, yet `su` does not exist. Therefore we only run this test when it is root. Also simplify some of the test macros. Bug: 140446213 Test: passes as root, skips as non-root Change-Id: I0651963d5c7d4f5308989ab6b04aab1042094e5a
* liblog: only allow one transport for readingTom Cherry2019-08-261-0/+4
| | | | | | | | | liblog has left over code from local_logger that allows for reading from multiple sources and merging the contents. Since we've already removed local_logger, this change removes the rest of this code. Test: liblog-unit-tests Change-Id: I5685ad6c1e7cbcaa0a660ed10f47714784a40791
* liblog: enable tests accidentally disabledTom Cherry2019-08-232-15/+1
| | | | | | | | | | | | | | Some tests were meant to be run with logd only and were ifdef'ed based on USING_LOGGER_DEFAULT. Unfortunately a previous change removed the appropriate #define, so these tests weren't being run at all. They passed multiple times on CF, so they should still be stable. Except for one test for __android_log_event_list. We removed that struct, so this change removes the test as well. Test: liblog-unit-tests on CF (5 runs) Change-Id: Ifaf3dbfdc5c714aead3f26c333e9cf19a1ed86c6