Skip to content

Commit b1fbced

Browse files
Fix completion check for TimestampPacketStorage
Change-Id: If15d2bbc49a1dc2dfb29e3b6cdc3ad1523997cd5 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
1 parent 8784491 commit b1fbced

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

runtime/helpers/timestamp_packet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct TimestampPacketStorage {
4848

4949
bool isCompleted() const {
5050
for (uint32_t i = 0; i < packetsUsed; i++) {
51-
if ((packets[0].contextEnd & 1) || (packets[0].globalEnd & 1)) {
51+
if ((packets[i].contextEnd & 1) || (packets[i].globalEnd & 1)) {
5252
return false;
5353
}
5454
}

unit_tests/helpers/timestamp_packet_tests.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,25 @@ TEST_F(TimestampPacketSimpleTests, whenIsCompletedIsCalledThenItReturnsProperTim
214214
EXPECT_TRUE(timestampPacketStorage.isCompleted());
215215
}
216216

217+
TEST_F(TimestampPacketSimpleTests, givenMultiplePacketsInUseWhenCompletionIsCheckedTheVerifyAllUsedNodes) {
218+
TimestampPacketStorage timestampPacketStorage;
219+
auto &packets = timestampPacketStorage.packets;
220+
221+
timestampPacketStorage.packetsUsed = TimestampPacketSizeControl::preferredPacketCount - 1;
222+
223+
for (uint32_t i = 0; i < timestampPacketStorage.packetsUsed - 1; i++) {
224+
packets[i].contextEnd = 0;
225+
packets[i].globalEnd = 0;
226+
EXPECT_FALSE(timestampPacketStorage.isCompleted());
227+
}
228+
229+
packets[timestampPacketStorage.packetsUsed - 1].contextEnd = 0;
230+
EXPECT_FALSE(timestampPacketStorage.isCompleted());
231+
232+
packets[timestampPacketStorage.packetsUsed - 1].globalEnd = 0;
233+
EXPECT_TRUE(timestampPacketStorage.isCompleted());
234+
}
235+
217236
TEST_F(TimestampPacketSimpleTests, givenImplicitDependencyWhenEndTagIsWrittenThenCantBeReleased) {
218237
TimestampPacketStorage timestampPacketStorage;
219238

0 commit comments

Comments
 (0)