Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sbe-tool/src/main/cpp/otf/IrDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class IrDecoder
return m_id;
}

int schemaVersion() const {
return m_version;
}

protected:
// OS specifics
static long long getFileSize(const char *filename)
Expand Down Expand Up @@ -188,6 +192,7 @@ class IrDecoder
std::unique_ptr<char[]> m_buffer;
std::uint64_t m_length = 0;
int m_id = 0;
int m_version = 0;

int decodeIr()
{
Expand Down Expand Up @@ -221,6 +226,7 @@ class IrDecoder
std::uint64_t headerLength = readHeader(offset);

m_id = frame.irId();
m_version = frame.schemaVersion();

offset += headerLength;

Expand Down
10 changes: 10 additions & 0 deletions sbe-tool/src/test/cpp/VersionedMessageTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <gtest/gtest.h>

#include "otf/IrDecoder.h"
#include "versmsg/VersionedMessageV1.h"
#include "versmsg/VersionedMessageV2.h"

Expand Down Expand Up @@ -55,3 +56,12 @@ TEST_F(VersionedMessageTest, shouldV1DecodeV2Message)

EXPECT_EQ(m_versionedMessageV1Decoder.decodeLength(), (uint64_t)26);
}

TEST_F(VersionedMessageTest, shouldExposeSchemaVersionFromIr)
{
IrDecoder irDecoder = {};

ASSERT_GE(irDecoder.decode("versioned-message-v2.sbeir"), 0);
EXPECT_EQ(irDecoder.schemaId(), 1);
EXPECT_EQ(irDecoder.schemaVersion(), 2);
}