Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/setup-no…
Browse files Browse the repository at this point in the history
…de-4
  • Loading branch information
kripton authored Feb 28, 2024
2 parents df02c7b + 4ca3ab8 commit b86ee69
Show file tree
Hide file tree
Showing 36 changed files with 486 additions and 56 deletions.
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
x/y/2023 ola-0.10.10
x/y/2024 ola-0.10.10
Features:
*

Expand Down
8 changes: 8 additions & 0 deletions common/messaging/DescriptorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using ola::messaging::BoolFieldDescriptor;
using ola::messaging::FieldDescriptor;
using ola::messaging::FieldDescriptorGroup;
using ola::messaging::IPV4FieldDescriptor;
using ola::messaging::IPV6FieldDescriptor;
using ola::messaging::MACFieldDescriptor;
using ola::messaging::StringFieldDescriptor;
using ola::messaging::UIDFieldDescriptor;
Expand Down Expand Up @@ -77,6 +78,13 @@ void DescriptorTest::testFieldDescriptors() {
OLA_ASSERT_TRUE(ipv4_descriptor.LimitedSize());
OLA_ASSERT_EQ(4u, ipv4_descriptor.MaxSize());

// IPv6 address
IPV6FieldDescriptor ipv6_descriptor("ipv6");
OLA_ASSERT_EQ(string("ipv6"), ipv6_descriptor.Name());
OLA_ASSERT_TRUE(ipv6_descriptor.FixedSize());
OLA_ASSERT_TRUE(ipv6_descriptor.LimitedSize());
OLA_ASSERT_EQ(16u, ipv6_descriptor.MaxSize());

// MAC address
MACFieldDescriptor mac_descriptor("mac");
OLA_ASSERT_EQ(string("mac"), mac_descriptor.Name());
Expand Down
44 changes: 26 additions & 18 deletions common/messaging/MessagePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,44 @@ string MessagePrinter::AsString(const Message *message) {


void GenericMessagePrinter::Visit(const BoolMessageField *message) {
Stream() << string(m_indent, ' ') <<
TransformLabel(message->GetDescriptor()->Name()) << ": "
<< (message->Value() ? "true" : "false") << endl;
Stream() << string(m_indent, ' ')
<< TransformLabel(message->GetDescriptor()->Name()) << ": "
<< (message->Value() ? "true" : "false") << endl;
}


void GenericMessagePrinter::Visit(const IPV4MessageField *message) {
Stream() << string(m_indent, ' ') <<
TransformLabel(message->GetDescriptor()->Name()) << ": "
<< message->Value() << endl;
Stream() << string(m_indent, ' ')
<< TransformLabel(message->GetDescriptor()->Name()) << ": "
<< message->Value() << endl;
}


void GenericMessagePrinter::Visit(const IPV6MessageField *message) {
Stream() << string(m_indent, ' ')
<< TransformLabel(message->GetDescriptor()->Name()) << ": "
<< message->Value() << endl;
}


void GenericMessagePrinter::Visit(const MACMessageField *message) {
Stream() << string(m_indent, ' ') <<
TransformLabel(message->GetDescriptor()->Name()) << ": "
<< message->Value().ToString() << endl;
Stream() << string(m_indent, ' ')
<< TransformLabel(message->GetDescriptor()->Name()) << ": "
<< message->Value().ToString() << endl;
}


void GenericMessagePrinter::Visit(const UIDMessageField *message) {
Stream() << string(m_indent, ' ') <<
TransformLabel(message->GetDescriptor()->Name()) << ": "
<< message->Value().ToString() << endl;
Stream() << string(m_indent, ' ')
<< TransformLabel(message->GetDescriptor()->Name()) << ": "
<< message->Value().ToString() << endl;
}


void GenericMessagePrinter::Visit(const StringMessageField *message) {
Stream() << string(m_indent, ' ') <<
TransformLabel(message->GetDescriptor()->Name()) << ": "
<< EncodeString(message->Value()) << endl;
Stream() << string(m_indent, ' ')
<< TransformLabel(message->GetDescriptor()->Name()) << ": "
<< EncodeString(message->Value()) << endl;
}


Expand Down Expand Up @@ -134,8 +141,8 @@ void GenericMessagePrinter::Visit(const BasicMessageField<int32_t> *message) {


void GenericMessagePrinter::Visit(const GroupMessageField *message) {
Stream() << string(m_indent, ' ') <<
TransformLabel(message->GetDescriptor()->Name()) << " {" << endl;
Stream() << string(m_indent, ' ')
<< TransformLabel(message->GetDescriptor()->Name()) << " {" << endl;
m_indent += m_indent_size;
}

Expand Down Expand Up @@ -178,8 +185,9 @@ void GenericMessagePrinter::AppendInt(const string &name,


void GenericMessagePrinter::AppendMultiplier(int8_t multiplier) {
if (multiplier)
if (multiplier) {
Stream() << " x 10 ^ " << static_cast<int>(multiplier);
}
}
} // namespace messaging
} // namespace ola
23 changes: 15 additions & 8 deletions common/messaging/MessagePrinterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@

using std::string;
using std::vector;
using ola::rdm::UID;
using ola::network::IPV6Address;
using ola::network::MACAddress;
using ola::rdm::UID;


using ola::messaging::BoolFieldDescriptor;
Expand All @@ -42,14 +43,16 @@ using ola::messaging::FieldDescriptor;
using ola::messaging::FieldDescriptorGroup;
using ola::messaging::GenericMessagePrinter;
using ola::messaging::GroupMessageField;
using ola::messaging::Int16FieldDescriptor;
using ola::messaging::Int16MessageField;
using ola::messaging::Int8FieldDescriptor;
using ola::messaging::Int8MessageField;
using ola::messaging::IPV4FieldDescriptor;
using ola::messaging::IPV4MessageField;
using ola::messaging::IPV6FieldDescriptor;
using ola::messaging::IPV6MessageField;
using ola::messaging::MACFieldDescriptor;
using ola::messaging::MACMessageField;
using ola::messaging::Int16FieldDescriptor;
using ola::messaging::Int16MessageField;
using ola::messaging::Int8FieldDescriptor;
using ola::messaging::Int8MessageField;
using ola::messaging::Message;
using ola::messaging::MessageFieldInterface;
using ola::messaging::StringFieldDescriptor;
Expand Down Expand Up @@ -90,6 +93,7 @@ void GenericMessagePrinterTest::testSimplePrinter() {
// setup some fields
BoolFieldDescriptor bool_descriptor("On/Off");
IPV4FieldDescriptor ipv4_descriptor("ip");
IPV6FieldDescriptor ipv6_descriptor("ipv6");
MACFieldDescriptor mac_descriptor("mac");
UIDFieldDescriptor uid_descriptor("uid");
StringFieldDescriptor string_descriptor("Name", 0, 32);
Expand All @@ -104,6 +108,9 @@ void GenericMessagePrinterTest::testSimplePrinter() {
fields.push_back(
new IPV4MessageField(&ipv4_descriptor,
ola::network::HostToNetwork(0x0a000001)));
fields.push_back(
new IPV6MessageField(&ipv6_descriptor,
IPV6Address::FromStringOrDie("::ffff:192.168.0.1")));
fields.push_back(
new MACMessageField(&mac_descriptor,
MACAddress::FromStringOrDie("01:23:45:67:89:ab")));
Expand All @@ -116,9 +123,9 @@ void GenericMessagePrinterTest::testSimplePrinter() {

Message message(fields);
string expected = (
"On/Off: false\nip: 10.0.0.1\nmac: 01:23:45:67:89:ab\n"
"uid: 7a70:00000001\nName: foobar\nId: 42\nCount: 4 x 10 ^ -3\n"
"Delta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n");
"On/Off: false\nip: 10.0.0.1\nipv6: ::ffff:192.168.0.1\n"
"mac: 01:23:45:67:89:ab\nuid: 7a70:00000001\nName: foobar\nId: 42\n"
"Count: 4 x 10 ^ -3\nDelta: 10 x 10 ^ 1\nRate: 10 x 10 ^ -1\n");
OLA_ASSERT_EQ(expected, m_printer.AsString(&message));
}

Expand Down
6 changes: 6 additions & 0 deletions common/messaging/SchemaPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ void SchemaPrinter::Visit(const IPV4FieldDescriptor *descriptor) {
}


void SchemaPrinter::Visit(const IPV6FieldDescriptor *descriptor) {
m_str << string(m_indent, ' ') << descriptor->Name() << ": IPv6 address"
<< endl;
}


void SchemaPrinter::Visit(const MACFieldDescriptor *descriptor) {
m_str << string(m_indent, ' ') << descriptor->Name() << ": MAC" << endl;
}
Expand Down
7 changes: 6 additions & 1 deletion common/messaging/SchemaPrinterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using std::vector;

using ola::messaging::BoolFieldDescriptor;
using ola::messaging::IPV4FieldDescriptor;
using ola::messaging::IPV6FieldDescriptor;
using ola::messaging::MACFieldDescriptor;
using ola::messaging::Descriptor;
using ola::messaging::FieldDescriptor;
Expand Down Expand Up @@ -85,6 +86,8 @@ void SchemaPrinterTest::testPrinter() {
"Count", false, 10);
IPV4FieldDescriptor *ipv4_descriptor = new IPV4FieldDescriptor(
"Address");
IPV6FieldDescriptor *ipv6_descriptor = new IPV6FieldDescriptor(
"v6 Address");
MACFieldDescriptor *mac_descriptor = new MACFieldDescriptor(
"MAC Address");
UIDFieldDescriptor *uid_descriptor = new UIDFieldDescriptor("Device");
Expand All @@ -95,6 +98,7 @@ void SchemaPrinterTest::testPrinter() {
fields.push_back(string_descriptor);
fields.push_back(uint8_descriptor);
fields.push_back(ipv4_descriptor);
fields.push_back(ipv6_descriptor);
fields.push_back(mac_descriptor);
fields.push_back(uid_descriptor);

Expand All @@ -104,7 +108,8 @@ void SchemaPrinterTest::testPrinter() {

string expected = (
"On/Off: bool\nName: string [0, 32]\nCount: uint8\n"
"Address: IPv4 address\nMAC Address: MAC\nDevice: UID\n");
"Address: IPv4 address\nv6 Address: IPv6 address\nMAC Address: MAC\n"
"Device: UID\n");
OLA_ASSERT_EQ(expected, printer.AsString());
}

Expand Down
5 changes: 5 additions & 0 deletions common/rdm/DescriptorConsistencyChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ void DescriptorConsistencyChecker::Visit(
}


void DescriptorConsistencyChecker::Visit(
const ola::messaging::IPV6FieldDescriptor*) {
}


void DescriptorConsistencyChecker::Visit(
const ola::messaging::MACFieldDescriptor*) {
}
Expand Down
1 change: 1 addition & 0 deletions common/rdm/DescriptorConsistencyChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class DescriptorConsistencyChecker

void Visit(const ola::messaging::BoolFieldDescriptor*);
void Visit(const ola::messaging::IPV4FieldDescriptor*);
void Visit(const ola::messaging::IPV6FieldDescriptor*);
void Visit(const ola::messaging::MACFieldDescriptor*);
void Visit(const ola::messaging::UIDFieldDescriptor*);
void Visit(const ola::messaging::StringFieldDescriptor*);
Expand Down
12 changes: 12 additions & 0 deletions common/rdm/GroupSizeCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ void GroupSizeCalculator::Visit(
}


void GroupSizeCalculator::Visit(
const ola::messaging::IPV6FieldDescriptor *descriptor) {
m_non_groups.push_back(descriptor);
}


void GroupSizeCalculator::Visit(
const ola::messaging::MACFieldDescriptor *descriptor) {
m_non_groups.push_back(descriptor);
Expand Down Expand Up @@ -246,6 +252,12 @@ void StaticGroupTokenCalculator::Visit(
}


void StaticGroupTokenCalculator::Visit(
OLA_UNUSED const ola::messaging::IPV6FieldDescriptor *descriptor) {
m_token_count.top()++;
}


void StaticGroupTokenCalculator::Visit(
OLA_UNUSED const ola::messaging::MACFieldDescriptor *descriptor) {
m_token_count.top()++;
Expand Down
2 changes: 2 additions & 0 deletions common/rdm/GroupSizeCalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class StaticGroupTokenCalculator

void Visit(const ola::messaging::BoolFieldDescriptor*);
void Visit(const ola::messaging::IPV4FieldDescriptor*);
void Visit(const ola::messaging::IPV6FieldDescriptor*);
void Visit(const ola::messaging::MACFieldDescriptor*);
void Visit(const ola::messaging::UIDFieldDescriptor*);
void Visit(const ola::messaging::StringFieldDescriptor*);
Expand Down Expand Up @@ -98,6 +99,7 @@ class GroupSizeCalculator: public ola::messaging::FieldDescriptorVisitor {

void Visit(const ola::messaging::BoolFieldDescriptor*);
void Visit(const ola::messaging::IPV4FieldDescriptor*);
void Visit(const ola::messaging::IPV6FieldDescriptor*);
void Visit(const ola::messaging::MACFieldDescriptor*);
void Visit(const ola::messaging::UIDFieldDescriptor*);
void Visit(const ola::messaging::StringFieldDescriptor*);
Expand Down
12 changes: 7 additions & 5 deletions common/rdm/GroupSizeCalculatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using ola::messaging::Descriptor;
using ola::messaging::FieldDescriptor;
using ola::messaging::FieldDescriptorGroup;
using ola::messaging::IPV4FieldDescriptor;
using ola::messaging::IPV6FieldDescriptor;
using ola::messaging::Int16FieldDescriptor;
using ola::messaging::Int32FieldDescriptor;
using ola::messaging::Int8FieldDescriptor;
Expand Down Expand Up @@ -84,16 +85,17 @@ void GroupSizeCalculatorTest::testSimpleCases() {
fields.push_back(new Int8FieldDescriptor("int8"));
fields.push_back(new Int16FieldDescriptor("int16"));
fields.push_back(new Int32FieldDescriptor("int32"));
fields.push_back(new MACFieldDescriptor("mac"));
fields.push_back(new StringFieldDescriptor("string", 0, 32));
fields.push_back(new IPV4FieldDescriptor("address"));
fields.push_back(new IPV6FieldDescriptor("addressv6"));
fields.push_back(new MACFieldDescriptor("mac"));
fields.push_back(new UIDFieldDescriptor("uid"));
Descriptor descriptor("Test Descriptor", fields);

unsigned int token_count, group_repeat_count;
OLA_ASSERT_TRUE(
m_static_calculator.CalculateTokensRequired(&descriptor, &token_count));
OLA_ASSERT_EQ(11u, token_count); // Actual token count
OLA_ASSERT_EQ(12u, token_count); // Actual token count


OLA_ASSERT_EQ(
Expand All @@ -106,21 +108,21 @@ void GroupSizeCalculatorTest::testSimpleCases() {
OLA_ASSERT_EQ(
GroupSizeCalculator::INSUFFICIENT_TOKENS,
m_calculator.CalculateGroupSize(
10, // Actual token count - 1
11, // Actual token count - 1
&descriptor,
&group_repeat_count));

OLA_ASSERT_EQ(
GroupSizeCalculator::NO_VARIABLE_GROUPS,
m_calculator.CalculateGroupSize(
11, // Actual token count
12, // Actual token count
&descriptor,
&group_repeat_count));

OLA_ASSERT_EQ(
GroupSizeCalculator::EXTRA_TOKENS,
m_calculator.CalculateGroupSize(
12, // Actual token count + 1
13, // Actual token count + 1
&descriptor,
&group_repeat_count));
}
Expand Down
Loading

0 comments on commit b86ee69

Please sign in to comment.