summaryrefslogtreecommitdiff
path: root/logd/SerializedLogChunkTest.cpp
diff options
context:
space:
mode:
authorJustin DeMartino <jjdemartino@google.com>2020-09-21 13:24:08 -0700
committerJustin DeMartino <jjdemartino@google.com>2020-09-21 13:24:08 -0700
commit338e91517f011da3056cdab4fe75198281cbc997 (patch)
treedaadd64a0a84b5836dda7d2ce15737d4d59abdae /logd/SerializedLogChunkTest.cpp
parent9a1114d8a44e4d93a719095ad81c119273d43ee4 (diff)
parent79c5fee02e1430bec2f75956297f5b631e70b407 (diff)
Merge SP1A.200921.001
Change-Id: I90b97c4e9fb10b1f45e74def404823eed5b1aaa8
Diffstat (limited to 'logd/SerializedLogChunkTest.cpp')
-rw-r--r--logd/SerializedLogChunkTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/logd/SerializedLogChunkTest.cpp b/logd/SerializedLogChunkTest.cpp
index f10b9c673..3b451252d 100644
--- a/logd/SerializedLogChunkTest.cpp
+++ b/logd/SerializedLogChunkTest.cpp
@@ -281,3 +281,27 @@ TEST_P(UidClearTest, save_beginning_and_end) {
}
INSTANTIATE_TEST_CASE_P(UidClearTests, UidClearTest, testing::Values(true, false));
+
+// b/166187079: ClearUidLogs() should not compress the log if writer_active_ is true
+TEST(SerializedLogChunk, ClearUidLogs_then_FinishWriting) {
+ static constexpr size_t kChunkSize = 10 * 4096;
+ static constexpr uid_t kUidToClear = 1000;
+ static constexpr uid_t kOtherUid = 1234;
+
+ SerializedLogChunk chunk{kChunkSize};
+ static const char msg1[] = "saved first message";
+ static const char msg2[] = "cleared interior message";
+ static const char msg3[] = "last message stays";
+ ASSERT_NE(nullptr, chunk.Log(1, log_time(), kOtherUid, 1, 2, msg1, sizeof(msg1)));
+ ASSERT_NE(nullptr, chunk.Log(2, log_time(), kUidToClear, 1, 2, msg2, sizeof(msg2)));
+ ASSERT_NE(nullptr, chunk.Log(3, log_time(), kOtherUid, 1, 2, msg3, sizeof(msg3)));
+
+ chunk.ClearUidLogs(kUidToClear, LOG_ID_MAIN, nullptr);
+
+ ASSERT_NE(nullptr, chunk.Log(4, log_time(), kOtherUid, 1, 2, msg3, sizeof(msg3)));
+
+ chunk.FinishWriting();
+ // The next line would violate a CHECK() during decompression with the faulty code.
+ chunk.IncReaderRefCount();
+ chunk.DecReaderRefCount();
+}