Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated unit tests in src/transport/raw/tests/ to use PW instead of NL. #33099

Merged
merged 27 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4645416
Updated unit tests in src/transport/tests/ to use PW instead of NL.
feasel0 Apr 22, 2024
69131f3
Updated unit tests in src/protocols/bdx/tests/ to use PW instead of NL
feasel0 Apr 22, 2024
da92b89
Updated unit tests in src/transport/raw/tests/ to use PW instead of NL.
feasel0 Apr 23, 2024
b9b1b96
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 23, 2024
57b133c
Undid the accidental reformatting of the comments at the top.
feasel0 Apr 23, 2024
df65f8c
Update src/transport/raw/tests/TestTCP.cpp
feasel0 Apr 24, 2024
234d705
Update src/transport/raw/tests/TestUDP.cpp
feasel0 Apr 24, 2024
d175d3b
Changed some EXPECT_ to ASSERT_. Changed C-casts to unsigned literal…
feasel0 Apr 24, 2024
916faff
Merge branch 'feature/unittest-transport-raw-tests' of https://github…
feasel0 Apr 24, 2024
3a3ecc5
Resolved merge conflicts in test_components[_nl].txt
feasel0 Apr 24, 2024
d5090be
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 24, 2024
cd84aa5
Added a destructor to TestUDP to delete the TestContext.
feasel0 Apr 25, 2024
130e766
Merge branch 'feature/unittest-transport-raw-tests' of https://github…
feasel0 Apr 25, 2024
400d0e5
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 25, 2024
efd7808
Added destructor to TestTCP to delete the TestContext.
feasel0 Apr 25, 2024
27ac393
Merge branch 'feature/unittest-transport-raw-tests' of https://github…
feasel0 Apr 25, 2024
3490e83
Added destructor to TestTCP to delete TestContext.
feasel0 Apr 25, 2024
95bc984
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 25, 2024
20408ba
Fixed issue with SystemLayerTests being listed multiple times.
feasel0 Apr 25, 2024
544888f
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 25, 2024
603573a
Changed MemoryInit line to ASSERT instead of EXPECT. Added correspon…
feasel0 Apr 25, 2024
81f52e5
Merge branch 'feature/unittest-transport-raw-tests' of https://github…
feasel0 Apr 25, 2024
6b7af17
Inherited TCP test from IOContext so we don't have to create a new co…
feasel0 Apr 26, 2024
811f3b0
Moved ChckSimpleInitTest and CheckMessageTest into the test context c…
feasel0 Apr 29, 2024
11cc04c
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 29, 2024
4681a06
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 29, 2024
c13b7aa
Merge branch 'master' into feature/unittest-transport-raw-tests
feasel0 Apr 29, 2024
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
1 change: 1 addition & 0 deletions src/test_driver/openiotsdk/unit-tests/test_components.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CoreTests
MdnsTests
CredentialsTest
PlatformTests
RawTransportTests
feasel0 marked this conversation as resolved.
Show resolved Hide resolved
RetransmitTests
TestShell
SetupPayloadTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ AppTests
DataModelTests
InetLayerTests
MessagingLayerTests
RawTransportTests
SecureChannelTestsNL
SupportTestsNL
TransportLayerTests
7 changes: 2 additions & 5 deletions src/transport/raw/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/nlunit_test.gni")
import("//build_overrides/pigweed.gni")

import("${chip_root}/build/chip/chip_test_suite.gni")

static_library("helpers") {
output_name = "libNetworkTestHelpers"
output_dir = "${root_out_dir}/lib"
Expand All @@ -35,7 +34,7 @@ static_library("helpers") {
]
}

chip_test_suite_using_nltest("tests") {
chip_test_suite("tests") {
output_name = "libRawTransportTests"

test_sources = [
Expand All @@ -51,10 +50,8 @@ chip_test_suite_using_nltest("tests") {
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support:test_utils",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/transport",
"${chip_root}/src/transport/raw",
"${nlunit_test_root}:nlunit-test",
]

cflags = [ "-Wconversion" ]
Expand Down
300 changes: 138 additions & 162 deletions src/transport/raw/tests/TestMessageHeader.cpp

Large diffs are not rendered by default.

60 changes: 13 additions & 47 deletions src/transport/raw/tests/TestPeerAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
#include <inet/IPAddress.h>
#include <lib/core/DataModelTypes.h>
#include <lib/core/PeerId.h>
#include <lib/support/UnitTestRegistration.h>
#include <transport/raw/PeerAddress.h>

#include <nlunit-test.h>
#include <gtest/gtest.h>

namespace {

Expand All @@ -39,47 +38,47 @@ using chip::Transport::PeerAddress;
/**
* Test correct identification of IPv6 multicast addresses.
*/
void TestPeerAddressMulticast(nlTestSuite * inSuite, void * inContext)
TEST(TestPeerAddress, TestPeerAddressMulticast)
{
constexpr chip::FabricId fabric = 0xa1a2a4a8b1b2b4b8;
constexpr chip::GroupId group = 0xe10f;
PeerAddress addr = PeerAddress::Multicast(fabric, group);
NL_TEST_ASSERT(inSuite, chip::Transport::Type::kUdp == addr.GetTransportType());
NL_TEST_ASSERT(inSuite, addr.IsMulticast());
EXPECT_EQ(chip::Transport::Type::kUdp, addr.GetTransportType());
EXPECT_TRUE(addr.IsMulticast());

const Inet::IPAddress & ip = addr.GetIPAddress();
NL_TEST_ASSERT(inSuite, ip.IsIPv6Multicast());
NL_TEST_ASSERT(inSuite, chip::Inet::IPAddressType::kIPv6 == ip.Type());
EXPECT_TRUE(ip.IsIPv6Multicast());
EXPECT_EQ(chip::Inet::IPAddressType::kIPv6, ip.Type());

constexpr uint8_t expected[NL_INET_IPV6_ADDR_LEN_IN_BYTES] = { 0xff, 0x35, 0x00, 0x40, 0xfd, 0xa1, 0xa2, 0xa4,
0xa8, 0xb1, 0xb2, 0xb4, 0xb8, 0x00, 0xe1, 0x0f };
uint8_t result[NL_INET_IPV6_ADDR_LEN_IN_BYTES];
uint8_t * p = result;
ip.WriteAddress(p);
NL_TEST_ASSERT(inSuite, !memcmp(expected, result, NL_INET_IPV6_ADDR_LEN_IN_BYTES));
EXPECT_EQ(0, memcmp(expected, result, NL_INET_IPV6_ADDR_LEN_IN_BYTES));
}

void TestToString(nlTestSuite * inSuite, void * inContext)
TEST(TestPeerAddress, TestToString)
{
char buff[PeerAddress::kMaxToStringSize];
IPAddress ip;
{
IPAddress::FromString("::1", ip);
PeerAddress::UDP(ip, 1122).ToString(buff);

NL_TEST_ASSERT(inSuite, !strcmp(buff, "UDP:[::1]:1122"));
EXPECT_STREQ(buff, "UDP:[::1]:1122");
}

{
IPAddress::FromString("::1", ip);
PeerAddress::TCP(ip, 1122).ToString(buff);

NL_TEST_ASSERT(inSuite, !strcmp(buff, "TCP:[::1]:1122"));
EXPECT_STREQ(buff, "TCP:[::1]:1122");
}

{
PeerAddress::BLE().ToString(buff);
NL_TEST_ASSERT(inSuite, !strcmp(buff, "BLE"));
EXPECT_STREQ(buff, "BLE");
}

{
Expand All @@ -89,49 +88,16 @@ void TestToString(nlTestSuite * inSuite, void * inContext)
int res1 = strcmp(buff, "UDP:[1223::3456:789a]:8080");
int res2 = strcmp(buff, "UDP:[1223::3456:789A]:8080");

NL_TEST_ASSERT(inSuite, (!res1 || !res2));
EXPECT_TRUE(!res1 || !res2);
}

{

PeerAddress udp = PeerAddress(Transport::Type::kUdp);
udp.SetPort(5840);
udp.ToString(buff);
NL_TEST_ASSERT(inSuite, !strcmp(buff, "UDP:[::]:5840"));
EXPECT_STREQ(buff, "UDP:[::]:5840");
}
}

/**
* Test Suite. It lists all the test functions.
*/

// clang-format off
const nlTest sTests[] =
{
NL_TEST_DEF("PeerAddress Multicast", TestPeerAddressMulticast),
NL_TEST_DEF("ToString", TestToString),
NL_TEST_SENTINEL()
};
// clang-format on

} // namespace

int TestPeerAddress()
{
// clang-format off
nlTestSuite theSuite =
{
"PeerAddress",
&sTests[0],
nullptr,
nullptr
};
// clang-format on

// Run test suite against one context.
nlTestRunner(&theSuite, nullptr);

return (nlTestRunnerStats(&theSuite));
}

CHIP_REGISTER_TEST_SUITE(TestPeerAddress)
Loading
Loading