Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62d0d2d6 authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

liblog: add logprint to host build

- cleanup of some style issues
- resolve a few minor bugs
- add -lrt for host so that clock_gettime can be issued
- enable write-only logging, logprint and event list
  handling tests for host consumption.

NB: CtsLiblogTestCases_list is only outlet for host testing of
    the interfaces, but it is not part of any automated testing

Test: gTest liblog-unit-tests, liblog-benchmarks and
      CtsLiblogTestCases_list && build mmma system/core/liblog
Bug: 27405083
Change-Id: I13db1f45f67569407587a5a909248de33809b8cf
parent 8f2492f5
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -15,13 +15,14 @@
//
//


liblog_sources = [
liblog_sources = [
    "config_write.c",
    "log_event_list.c",
    "log_event_list.c",
    "log_event_write.c",
    "log_event_write.c",
    "logger_write.c",
    "config_write.c",
    "logger_name.c",
    "logger_lock.c",
    "log_ratelimit.cpp",
    "log_ratelimit.cpp",
    "logger_lock.c",
    "logger_name.c",
    "logger_write.c",
    "logprint.c",
]
]
liblog_host_sources = [
liblog_host_sources = [
    "fake_log_device.c",
    "fake_log_device.c",
@@ -32,7 +33,6 @@ liblog_target_sources = [
    "config_read.c",
    "config_read.c",
    "log_time.cpp",
    "log_time.cpp",
    "properties.c",
    "properties.c",
    "logprint.c",
    "pmsg_reader.c",
    "pmsg_reader.c",
    "pmsg_writer.c",
    "pmsg_writer.c",
    "logd_reader.c",
    "logd_reader.c",
+6 −1
Original line number Original line Diff line number Diff line
@@ -612,7 +612,12 @@ static ssize_t logWritev(int fd, const struct iovec* vector, int count)


bail:
bail:
    unlock();
    unlock();
    return vector[0].iov_len + vector[1].iov_len + vector[2].iov_len;
    int len = 0;
    for (i = 0; i < count; ++i) {
       len += vector[i].iov_len;
    }
    return len;

error:
error:
    unlock();
    unlock();
    return -1;
    return -1;
+25 −3
Original line number Original line Diff line number Diff line
@@ -46,9 +46,19 @@ static int fakeOpen() {
    int i;
    int i;


    for (i = 0; i < LOG_ID_MAX; i++) {
    for (i = 0; i < LOG_ID_MAX; i++) {
        char buf[sizeof("/dev/log_security")];
        /*
         * Known maximum size string, plus an 8 character margin to deal with
         * possible independent changes to android_log_id_to_name().
         */
        char buf[sizeof("/dev/log_security") + 8];
        if (logFds[i] >= 0) {
            continue;
        }
        snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i));
        snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i));
        logFds[i] = fakeLogOpen(buf, O_WRONLY);
        logFds[i] = fakeLogOpen(buf, O_WRONLY);
        if (logFds[i] < 0) {
            fprintf(stderr, "fakeLogOpen(%s, O_WRONLY) failed\n", buf);
        }
    }
    }
    return 0;
    return 0;
}
}
@@ -66,16 +76,28 @@ static int fakeWrite(log_id_t log_id, struct timespec *ts __unused,
                      struct iovec *vec, size_t nr)
                      struct iovec *vec, size_t nr)
{
{
    ssize_t ret;
    ssize_t ret;
    int logFd;
    size_t i;
    int logFd, len;


    if (/*(int)log_id >= 0 &&*/ (int)log_id >= (int)LOG_ID_MAX) {
    if (/*(int)log_id >= 0 &&*/ (int)log_id >= (int)LOG_ID_MAX) {
        return -EBADF;
        return -EINVAL;
    }

    len = 0;
    for (i = 0; i < nr; ++i) {
        len += vec[i].iov_len;
    }

    if (len > LOGGER_ENTRY_MAX_PAYLOAD) {
        len = LOGGER_ENTRY_MAX_PAYLOAD;
    }
    }


    logFd = logFds[(int)log_id];
    logFd = logFds[(int)log_id];
    ret = TEMP_FAILURE_RETRY(fakeLogWritev(logFd, vec, nr));
    ret = TEMP_FAILURE_RETRY(fakeLogWritev(logFd, vec, nr));
    if (ret < 0) {
    if (ret < 0) {
        ret = -errno;
        ret = -errno;
    } else if (ret > len) {
        ret = len;
    }
    }


    return ret;
    return ret;
+4 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,10 @@


/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */


#ifndef __predict_false
#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
#endif

/*
/*
 * Simplified macro to send a verbose radio log message using current LOG_TAG.
 * Simplified macro to send a verbose radio log message using current LOG_TAG.
 */
 */
+4 −0
Original line number Original line Diff line number Diff line
@@ -251,7 +251,11 @@ int android_logger_set_prune_list(struct logger_list* logger_list,
#define ANDROID_LOG_WRONLY   O_WRONLY
#define ANDROID_LOG_WRONLY   O_WRONLY
#define ANDROID_LOG_RDWR     O_RDWR
#define ANDROID_LOG_RDWR     O_RDWR
#define ANDROID_LOG_ACCMODE  O_ACCMODE
#define ANDROID_LOG_ACCMODE  O_ACCMODE
#ifndef O_NONBLOCK
#define ANDROID_LOG_NONBLOCK 0x00000800
#else
#define ANDROID_LOG_NONBLOCK O_NONBLOCK
#define ANDROID_LOG_NONBLOCK O_NONBLOCK
#endif
#if __ANDROID_USE_LIBLOG_READER_INTERFACE > 2
#if __ANDROID_USE_LIBLOG_READER_INTERFACE > 2
#define ANDROID_LOG_WRAP     0x40000000 /* Block until buffer about to wrap */
#define ANDROID_LOG_WRAP     0x40000000 /* Block until buffer about to wrap */
#define ANDROID_LOG_WRAP_DEFAULT_TIMEOUT 7200 /* 2 hour default */
#define ANDROID_LOG_WRAP_DEFAULT_TIMEOUT 7200 /* 2 hour default */
Loading