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/tests/ to use PW instead of NL. #33249

Merged
merged 20 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4c95b7f
Refactored TestSecureSessionTable.cpp to use TestSecureSessionTable a…
feasel0 May 1, 2024
08fa55e
Updated test_components[_nl].txt to move TransportLayerTests
feasel0 May 1, 2024
db33f68
Fixed formatting
feasel0 May 4, 2024
345a29d
Merge branch 'master' into feature/unittest--transport-tests
feasel0 May 4, 2024
2168c2e
Merge branch 'master' of https://github.com/feasel0/connectedhomeip i…
feasel0 May 4, 2024
8c55586
Fixing merge conflict in test components nl
feasel0 May 4, 2024
c036138
Fixing merge conflict
feasel0 May 4, 2024
e3afaa9
Merge branch 'feature/unittest--transport-tests' of https://github.co…
feasel0 May 4, 2024
3674380
Merge branch 'master' into feature/unittest--transport-tests
feasel0 May 6, 2024
10b7a72
Merge branch 'master' into feature/unittest--transport-tests
feasel0 May 6, 2024
6557d46
Merge branch 'master' of https://github.com/feasel0/connectedhomeip i…
feasel0 May 6, 2024
537c360
Updated TestSessionManagerDispatch to use staticly allocated context …
feasel0 May 6, 2024
87abd19
Merge branch 'feature/unittest--transport-tests' of https://github.co…
feasel0 May 6, 2024
6bcbcb5
Merge branch 'master' into feature/unittest--transport-tests
feasel0 May 6, 2024
38806bd
Made context a non-pointer which is created/destroyed implicitly when…
feasel0 May 6, 2024
4a153e9
Merge branch 'master' into feature/unittest--transport-tests
feasel0 May 6, 2024
570ed23
Reordered includes to be consistent with the standard.
feasel0 May 6, 2024
cbb528e
Merge branch 'feature/unittest--transport-tests' of https://github.co…
feasel0 May 6, 2024
2456239
Merge branch 'master' into feature/unittest--transport-tests
feasel0 May 7, 2024
827022b
Merge branch 'master' into feature/unittest--transport-tests
andy31415 May 7, 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
3 changes: 1 addition & 2 deletions src/test_driver/openiotsdk/unit-tests/test_components.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ SetupPayloadTests
SupportTests
UserDirectedCommissioningTests
SecureChannelTests
ICDServerTests
InetLayerTests
ICDServerTests
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ AppTests
DataModelTests
MessagingLayerTests
SecureChannelTestsNL
TransportLayerTests
6 changes: 2 additions & 4 deletions src/transport/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

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")

Expand All @@ -31,7 +31,7 @@ source_set("helpers") {
]
}

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

test_sources = [
Expand Down Expand Up @@ -59,10 +59,8 @@ chip_test_suite_using_nltest("tests") {
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support:testing",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/protocols",
"${chip_root}/src/transport",
"${chip_root}/src/transport/tests:helpers",
"${nlunit_test_root}:nlunit-test",
]
}
56 changes: 12 additions & 44 deletions src/transport/tests/TestCryptoContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
*/

#include <inttypes.h>
#include <nlunit-test.h>

#include <gtest/gtest.h>

#include <crypto/CHIPCryptoPAL.h>
#include <lib/core/CHIPCore.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/UnitTestRegistration.h>

#include <transport/CryptoContext.h>

using namespace chip;
Expand All @@ -48,7 +47,14 @@ struct PrivacyNonceTestEntry thePrivacyNonceTestVector[] = {
},
};

void TestBuildPrivacyNonce(nlTestSuite * apSuite, void * apContext)
class TestGroupCryptoContext : public ::testing::Test
{
public:
static void SetUpTestSuite() { ASSERT_EQ(chip::Platform::MemoryInit(), CHIP_NO_ERROR); }
static void TearDownTestSuite() { chip::Platform::MemoryShutdown(); }
};

TEST_F(TestGroupCryptoContext, TestBuildPrivacyNonce)
{
for (const auto & testVector : thePrivacyNonceTestVector)
{
Expand All @@ -60,47 +66,9 @@ void TestBuildPrivacyNonce(nlTestSuite * apSuite, void * apContext)

mic.SetTag(nullptr, testVector.mic, MIC_LENGTH);

NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == chip::CryptoContext::BuildPrivacyNonce(privacyNonce, sessionId, mic));
NL_TEST_ASSERT(apSuite, 0 == memcmp(privacyNonceView.data(), expectedPrivacyNonce.data(), NONCE_LENGTH));
EXPECT_EQ(CHIP_NO_ERROR, chip::CryptoContext::BuildPrivacyNonce(privacyNonce, sessionId, mic));
EXPECT_EQ(0, memcmp(privacyNonceView.data(), expectedPrivacyNonce.data(), NONCE_LENGTH));
}
}

/**
* Test Suite. It lists all the test functions.
*/
const nlTest sTests[] = { NL_TEST_DEF("TestBuildPrivacyNonce", TestBuildPrivacyNonce), NL_TEST_SENTINEL() };

/**
* Set up the test suite.
*/
int Test_Setup(void * inContext)
{
CHIP_ERROR error = chip::Platform::MemoryInit();
VerifyOrReturnError(error == CHIP_NO_ERROR, FAILURE);
return SUCCESS;
}

/**
* Tear down the test suite.
*/
int Test_Teardown(void * inContext)
{
chip::Platform::MemoryShutdown();
return SUCCESS;
}

} // namespace

/**
* Main
*/
int TestGroupCryptoContext()
{
nlTestSuite theSuite = { "TestGroupCryptoContext", &sTests[0], Test_Setup, Test_Teardown };

// Run test suite againt one context.
nlTestRunner(&theSuite, nullptr);
return nlTestRunnerStats(&theSuite);
}

CHIP_REGISTER_TEST_SUITE(TestGroupCryptoContext)
Loading
Loading