logd: fix bug in FlushTo when requesting exact sequence number
SimpleLogBuffer::FlushTo() attempts to find the iterator matching a
given sequence number, but the logic is wrong and will always skip one
element forward. This change fixes this and adds a test for the
situation.
This likely contributed to some test instability in the past, but was
identified because subsequent changes that track the start value
closer exacerbated this issue.
Test: existing and new unit tests
Change-Id: Iba2e654e94234693dba20d4747a60bc79d195673
diff --git a/logd/SimpleLogBuffer.cpp b/logd/SimpleLogBuffer.cpp
index 8a11b92..ceecc6d 100644
--- a/logd/SimpleLogBuffer.cpp
+++ b/logd/SimpleLogBuffer.cpp
@@ -126,7 +126,9 @@
for (it = logs_.end(); it != logs_.begin();
/* do nothing */) {
--it;
- if (it->getSequence() <= start) {
+ if (it->getSequence() == start) {
+ break;
+ } else if (it->getSequence() < start) {
it++;
break;
}