diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4a55b6c31032c6..613c3aeb6b4e47 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -119,10 +119,6 @@ jobs: --known-failure app/reporting/tests/MockReportScheduler.h \ --known-failure app/server/AppDelegate.h \ --known-failure app/TestEventTriggerDelegate.h \ - --known-failure app/tests/integration/common.h \ - --known-failure app/tests/integration/MockEvents.h \ - --known-failure app/tests/suites/credentials/TestHarnessDACProvider.h \ - --known-failure app/tests/TestOperationalDeviceProxy.cpp \ --known-failure app/util/af-enums.h \ --known-failure app/util/af.h \ --known-failure app/util/af-types.h \ @@ -156,15 +152,11 @@ jobs: --known-failure app/util/util.h \ --known-failure app/WriteClient.h \ --known-failure app/WriteHandler.h \ - --known-failure inet/tests/TestInetLayerCommon.hpp \ --known-failure lib/core/CHIPVendorIdentifiers.hpp \ - --known-failure lib/support/CHIPArgParser.hpp \ - --known-failure messaging/tests/echo/common.h \ --known-failure platform/DeviceSafeQueue.cpp \ --known-failure platform/DeviceSafeQueue.h \ --known-failure platform/GLibTypeDeleter.h \ --known-failure platform/SingletonConfigurationManager.cpp \ - --known-failure transport/retransmit/tests/TestCacheDriver.cpp \ " - name: Check for matter lint errors diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index 245e939fc39799..7d9a3fa9efe376 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -235,7 +235,10 @@ chip_test_suite_using_nltest("tests") { if (chip_config_network_layer_ble && (chip_device_platform == "linux" || chip_device_platform == "darwin")) { test_sources += [ "TestCommissionManager.cpp" ] - public_deps += [ "${chip_root}/src/app/server" ] + public_deps += [ + "${chip_root}/src/app/server", + "${chip_root}/src/messaging/tests/echo:common", + ] } if (chip_persist_subscriptions) { diff --git a/src/app/tests/TestOperationalDeviceProxy.cpp b/src/app/tests/TestOperationalDeviceProxy.cpp deleted file mode 100644 index 3b8252323f920a..00000000000000 --- a/src/app/tests/TestOperationalDeviceProxy.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::Transport; -using namespace chip::Messaging; -using namespace chip::Credentials; - -#if INET_CONFIG_ENABLE_IPV4 -namespace { - -using TestTransportMgr = TransportMgr; - -void TestOperationalDeviceProxy_EstablishSessionDirectly(nlTestSuite * inSuite, void * inContext) -{ - // TODO: This test appears not to be workable since it does not init the fabric table!!! - Platform::MemoryInit(); - TestTransportMgr transportMgr; - SessionManager sessionManager; - SimpleSessionResumptionStorage sessionResumptionStorage; - ExchangeManager exchangeMgr; - Inet::UDPEndPointManagerImpl udpEndPointManager; - System::LayerImpl systemLayer; - // Heap-allocate the fairly large FabricTable so we don't end up with a huge - // stack. - FabricTable * fabrics = Platform::New(); - const FabricInfo * fabric = fabrics->FindFabricWithIndex(1); - VerifyOrDie(fabric != nullptr); - secure_channel::MessageCounterManager messageCounterManager; - chip::TestPersistentStorageDelegate deviceStorage; - GroupDataProviderImpl groupDataProvider; - - systemLayer.Init(); - udpEndPointManager.Init(systemLayer); - transportMgr.Init(UdpListenParameters(udpEndPointManager).SetAddressType(Inet::IPAddressType::kIPv4).SetListenPort(CHIP_PORT)); - sessionManager.Init(&systemLayer, &transportMgr, &messageCounterManager, &deviceStorage); - sessionResumptionStorage.Init(&deviceStorage); - exchangeMgr.Init(&sessionManager); - messageCounterManager.Init(&exchangeMgr); - groupDataProvider.SetPersistentStorage(&deviceStorage); - VerifyOrDie(groupDataProvider.Init() == CHIP_NO_ERROR); - // TODO: Set IPK in groupDataProvider - - CASEClientInitParams params = { - .sessionManager = &sessionManager, - .sessionResumptionStorage = &sessionResumptionStorage, - .exchangeMgr = &exchangeMgr, - .fabricInfo = fabric, - .groupDataProvider = &groupDataProvider, - }; - NodeId mockNodeId = 1; - OperationalDeviceProxy device(params, PeerId().SetNodeId(mockNodeId)); - Inet::IPAddress mockAddr; - Inet::IPAddress::FromString("127.0.0.1", mockAddr); - PeerAddress addr = PeerAddress::UDP(mockAddr, CHIP_PORT); - device.UpdateAddress(addr); - - NL_TEST_ASSERT(inSuite, device.Connect(nullptr, nullptr) == CHIP_NO_ERROR); - - device.Clear(); - messageCounterManager.Shutdown(); - exchangeMgr.Shutdown(); - sessionManager.Shutdown(); - Platform::Delete(fabrics); - transportMgr.Close(); - udpEndPointManager.Shutdown(); - systemLayer.Shutdown(); - Platform::MemoryShutdown(); -} - -// clang-format off -const nlTest sTests[] = -{ - NL_TEST_DEF("TestOperationalDeviceProxy_EstablishSessionDirectly", TestOperationalDeviceProxy_EstablishSessionDirectly), - NL_TEST_SENTINEL() -}; -// clang-format on - -} // namespace - -int TestOperationalDeviceProxy() -{ - nlTestSuite theSuite = { "OperationalDeviceProxy", &sTests[0], NULL, NULL }; - nlTestRunner(&theSuite, nullptr); - return nlTestRunnerStats(&theSuite); -} - -CHIP_REGISTER_TEST_SUITE(TestOperationalDeviceProxy) - -#endif // INET_CONFIG_ENABLE_IPV4 diff --git a/src/app/tests/integration/BUILD.gn b/src/app/tests/integration/BUILD.gn index 0381691b43ffbd..da0db88682f180 100644 --- a/src/app/tests/integration/BUILD.gn +++ b/src/app/tests/integration/BUILD.gn @@ -19,15 +19,31 @@ import("${chip_root}/build/chip/tools.gni") assert(chip_build_tools) +source_set("common") { + sources = [ + "common.cpp", + "common.h", + ] + + deps = [ + "${chip_root}/src/credentials", + "${chip_root}/src/crypto", + "${chip_root}/src/lib/support:testing", + "${chip_root}/src/messaging", + "${chip_root}/src/protocols", + "${chip_root}/src/transport", + ] +} + executable("chip-im-initiator") { sources = [ "${chip_root}/src/app/reporting/tests/MockReportScheduler.cpp", "RequiredPrivilegeStubs.cpp", "chip_im_initiator.cpp", - "common.cpp", ] deps = [ + ":common", "${chip_root}/src/app", "${chip_root}/src/app/util/mock:mock_ember", "${chip_root}/src/lib/core", @@ -44,16 +60,18 @@ executable("chip-im-responder") { sources = [ "${chip_root}/src/app/reporting/tests/MockReportScheduler.cpp", "MockEvents.cpp", + "MockEvents.h", "RequiredPrivilegeStubs.cpp", "chip_im_responder.cpp", - "common.cpp", ] deps = [ + ":common", "${chip_root}/src/app", "${chip_root}/src/app/util/mock:mock_ember", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", + "${chip_root}/src/messaging", "${chip_root}/src/platform", "${chip_root}/src/protocols", "${chip_root}/src/system", diff --git a/src/app/tests/suites/credentials/BUILD.gn b/src/app/tests/suites/credentials/BUILD.gn index 31b96297af3c8a..d7a49f58ab590a 100644 --- a/src/app/tests/suites/credentials/BUILD.gn +++ b/src/app/tests/suites/credentials/BUILD.gn @@ -21,7 +21,10 @@ config("default_config") { } source_set("dac_provider") { - sources = [ "TestHarnessDACProvider.cpp" ] + sources = [ + "TestHarnessDACProvider.cpp", + "TestHarnessDACProvider.h", + ] deps = [ "${chip_root}/src/credentials", diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn index b5e916a5f9e0cd..0eeec8408d59af 100644 --- a/src/inet/tests/BUILD.gn +++ b/src/inet/tests/BUILD.gn @@ -34,6 +34,7 @@ static_library("helpers") { "TestInetCommonOptions.h", "TestInetCommonPosix.cpp", "TestInetLayerCommon.cpp", + "TestInetLayerCommon.hpp", "TestSetupSignalling.h", "TestSetupSignallingPosix.cpp", ] diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 3e426746ad3d2b..e1e87aeb2b2192 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -188,6 +188,7 @@ static_library("support") { "BytesToHex.cpp", "BytesToHex.h", "CHIPArgParser.cpp", + "CHIPArgParser.hpp", "CHIPCounter.h", "CHIPMemString.h", "CommonIterator.h", diff --git a/src/messaging/tests/echo/BUILD.gn b/src/messaging/tests/echo/BUILD.gn index a95ad6b105aa26..666629562dc5cc 100644 --- a/src/messaging/tests/echo/BUILD.gn +++ b/src/messaging/tests/echo/BUILD.gn @@ -17,15 +17,29 @@ import("//build_overrides/chip.gni") import("${chip_root}/build/chip/tools.gni") -assert(chip_build_tools) - -executable("chip-echo-requester") { +source_set("common") { sources = [ "common.cpp", - "echo_requester.cpp", + "common.h", ] public_deps = [ + "${chip_root}/src/crypto", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:testing", + "${chip_root}/src/messaging", + "${chip_root}/src/platform", + "${chip_root}/src/protocols", + "${chip_root}/src/transport", + ] +} + +executable("chip-echo-requester") { + sources = [ "echo_requester.cpp" ] + + public_deps = [ + ":common", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/platform", @@ -37,12 +51,10 @@ executable("chip-echo-requester") { } executable("chip-echo-responder") { - sources = [ - "common.cpp", - "echo_responder.cpp", - ] + sources = [ "echo_responder.cpp" ] public_deps = [ + ":common", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/platform", diff --git a/src/transport/retransmit/tests/BUILD.gn b/src/transport/retransmit/tests/BUILD.gn index fb08fa08f48a1d..a3e2333b4d6b7d 100644 --- a/src/transport/retransmit/tests/BUILD.gn +++ b/src/transport/retransmit/tests/BUILD.gn @@ -23,16 +23,11 @@ chip_test_suite_using_nltest("tests") { cflags = [ "-Wconversion" ] - sources = [ - "TestCache.cpp", - "TestRetransmit.h", - ] + test_sources = [ "TestCache.cpp" ] public_deps = [ "${chip_root}/src/lib/support:testing_nlunit", "${chip_root}/src/transport/retransmit", "${nlunit_test_root}:nlunit-test", ] - - tests = [ "TestCache" ] } diff --git a/src/transport/retransmit/tests/TestCache.cpp b/src/transport/retransmit/tests/TestCache.cpp index 8a619e9d1271cc..fefdbca67250ec 100644 --- a/src/transport/retransmit/tests/TestCache.cpp +++ b/src/transport/retransmit/tests/TestCache.cpp @@ -14,9 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "TestRetransmit.h" - #include #include @@ -271,7 +268,7 @@ static const nlTest sTests[] = }; // clang-format on -int TestCache(void) +int TestCache() { nlTestSuite theSuite = { "Retransmit-Cache", &sTests[0], nullptr, nullptr }; gPayloadTracker.Init(&theSuite); diff --git a/src/transport/retransmit/tests/TestCacheDriver.cpp b/src/transport/retransmit/tests/TestCacheDriver.cpp deleted file mode 100644 index 2e4da038a258fe..00000000000000 --- a/src/transport/retransmit/tests/TestCacheDriver.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "TestRetransmit.h" -#include - -int main() -{ - nlTestSetOutputStyle(OUTPUT_CSV); - return (TestCache()); -} diff --git a/src/transport/retransmit/tests/TestRetransmit.h b/src/transport/retransmit/tests/TestRetransmit.h deleted file mode 100644 index 95a71e36fb03e8..00000000000000 --- a/src/transport/retransmit/tests/TestRetransmit.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -int TestCache(void); - -#ifdef __cplusplus -} -#endif