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

Commit b398a7c8 authored by Tom Cherry's avatar Tom Cherry
Browse files

logd: add tests for log deduplication

Fix a subtle bug that liblog event messages have a payload of int32_t,
not uint32_t, so they should only be summed to int32_t max.

Make a bunch of test improvements as well to support these.

Test: these tests
Change-Id: I4069cc546240bfffec5b19f34ebec913799674e8
parent 0e95c210
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -125,10 +125,7 @@ cc_defaults {
        "-Wextra",
        "-Werror",
        "-fno-builtin",

        "-DAUDITD_LOG_TAG=1003",
        "-DCHATTY_LOG_TAG=1004",
    ],
    ] + event_flag,

    srcs: [
        "logd_test.cpp",
+2 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <time.h>
#include <unistd.h>

#include <limits>
#include <unordered_map>
#include <utility>

@@ -286,7 +287,7 @@ int ChattyLogBuffer::Log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pi
                    lastLoggedElements[LOG_ID_EVENTS] = elem;
                    total += htole32(swab);
                    // check for overflow
                    if (total >= UINT32_MAX) {
                    if (total >= std::numeric_limits<int32_t>::max()) {
                        log(currentLast);
                        unlock();
                        return len;
+334 −101

File changed.

Preview size limit exceeded, changes collapsed.