diff --git a/scripts/build/build/target.py b/scripts/build/build/target.py index 8411ff9432c2c7..7f1716170178a8 100644 --- a/scripts/build/build/target.py +++ b/scripts/build/build/target.py @@ -406,7 +406,7 @@ def Create(self, name: str, runner, repository_path: str, output_prefix: str, builder.target = self builder.identifier = name builder.output_dir = os.path.join(output_prefix, name) - builder.chip_dir = repository_path + builder.chip_dir = os.path.abspath(repository_path) builder.options = builder_options return builder diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 3f5fc57a616901..9eb2ebfb704e23 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -177,7 +177,7 @@ def BuildHostTarget(): target.AppendModifier("ossfuzz", fuzzing_type=HostFuzzingType.OSS_FUZZ).OnlyIfRe( "-clang").ExceptIfRe('-libfuzzer') target.AppendModifier('coverage', use_coverage=True).OnlyIfRe( - '-(chip-tool|all-clusters)') + '-(chip-tool|all-clusters|tests)') target.AppendModifier('dmalloc', use_dmalloc=True) target.AppendModifier('clang', use_clang=True) target.AppendModifier('test', extra_tests=True) diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index fcb609c70e941f..c1c81dbdc30f9c 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -512,19 +512,21 @@ def generate(self): def PreBuildCommand(self): if self.app == HostApp.TESTS and self.use_coverage: self._Execute(['ninja', '-C', self.output_dir, 'default'], title="Build-only") - self._Execute(['find', os.path.join(self.output_dir, 'obj/src/'), '-depth', - '-name', 'tests', '-exec', 'rm -rf {} \\;'], title="Cleanup unit tests") self._Execute(['lcov', '--initial', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), + '--exclude', os.path.join(self.chip_dir, '**/tests/*'), '--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'), '--exclude', os.path.join(self.chip_dir, 'third_party/*'), + '--exclude', os.path.join(self.chip_dir, 'out/*'), '--exclude', '/usr/include/*', '--output-file', os.path.join(self.coverage_dir, 'lcov_base.info')], title="Initial coverage baseline") def PostBuildCommand(self): if self.app == HostApp.TESTS and self.use_coverage: self._Execute(['lcov', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), + '--exclude', os.path.join(self.chip_dir, '**/tests/*'), '--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'), '--exclude', os.path.join(self.chip_dir, 'third_party/*'), + '--exclude', os.path.join(self.chip_dir, 'out/*'), '--exclude', '/usr/include/*', '--output-file', os.path.join(self.coverage_dir, 'lcov_test.info')], title="Update coverage") self._Execute(['lcov', '--add-tracefile', os.path.join(self.coverage_dir, 'lcov_base.info'), diff --git a/src/access/tests/TestAccessControl.cpp b/src/access/tests/TestAccessControl.cpp index 2d25a7c3d33ee4..16f30284fbc4d1 100644 --- a/src/access/tests/TestAccessControl.cpp +++ b/src/access/tests/TestAccessControl.cpp @@ -23,7 +23,8 @@ #include -namespace { +namespace chip { +namespace Access { using namespace chip; using namespace chip::Access; @@ -2189,4 +2190,5 @@ TEST_F(TestAccessControl, TestUpdateEntry) } } -} // namespace +} // namespace Access +} // namespace chip diff --git a/src/lib/core/tests/TestTLV.cpp b/src/lib/core/tests/TestTLV.cpp index 4b391c4983f701..19b4c77ac35280 100644 --- a/src/lib/core/tests/TestTLV.cpp +++ b/src/lib/core/tests/TestTLV.cpp @@ -859,8 +859,7 @@ void WriteEncoding3(TLVWriter & writer) TLVWriter writer1; err = writer.OpenContainer(ProfileTag(TestProfile_1, 1), kTLVType_Structure, writer1); - if (err != CHIP_NO_ERROR) - EXPECT_EQ(err, CHIP_NO_ERROR); + EXPECT_EQ(err, CHIP_NO_ERROR); err = writer1.PutBoolean(ProfileTag(TestProfile_2, 2), false); EXPECT_EQ(err, CHIP_NO_ERROR); diff --git a/src/platform/tests/BUILD.gn b/src/platform/tests/BUILD.gn index 11e8bd5c746029..bf4c2ee6ff90f4 100644 --- a/src/platform/tests/BUILD.gn +++ b/src/platform/tests/BUILD.gn @@ -78,7 +78,6 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") { # sources = [ "TestCHIPoBLEStackMgr.cpp", - "TestCHIPoBLEStackMgr.h", "TestCHIPoBLEStackMgrDriver.cpp", ] tests = [ "TestCHIPoBLEStackMgr" ] diff --git a/src/platform/tests/TestCHIPoBLEStackMgr.h b/src/platform/tests/TestCHIPoBLEStackMgr.h deleted file mode 100644 index b0f4f59516f2b1..00000000000000 --- a/src/platform/tests/TestCHIPoBLEStackMgr.h +++ /dev/null @@ -1,30 +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. - */ - -/** - * @file - * This file declares test entry point for CHIP over BLE code unit tests in Linux - * - */ - -#pragma once - -#include - -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE -int TestCHIPoBLEStackManager(); -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/tests/TestCHIPoBLEStackMgrDriver.cpp b/src/platform/tests/TestCHIPoBLEStackMgrDriver.cpp index 2635ebe81eb273..38e3f23a10b59c 100644 --- a/src/platform/tests/TestCHIPoBLEStackMgrDriver.cpp +++ b/src/platform/tests/TestCHIPoBLEStackMgrDriver.cpp @@ -15,19 +15,16 @@ * limitations under the License. */ -#include "TestCHIPoBLEStackMgr.h" #include #include #include int main(int argc, char * argv[]) { -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE + testing::InitGoogleTest(&argc, argv); if (argc == 2 && atoi(argv[1]) == 1) { - testing::InitGoogleTest(nullptr, nullptr); return RUN_ALL_TESTS(); } return 0; -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE } diff --git a/src/system/SystemPacketBuffer.h b/src/system/SystemPacketBuffer.h index 513f0b4fbc0cdb..928743762e3de7 100644 --- a/src/system/SystemPacketBuffer.h +++ b/src/system/SystemPacketBuffer.h @@ -657,6 +657,8 @@ class DLL_EXPORT PacketBufferHandle #endif } + bool operator==(const PacketBufferHandle & aOther) const { return mBuffer == aOther.mBuffer; } + protected: #if CHIP_SYSTEM_CONFIG_USE_LWIP // For use via LwIPPacketBufferView only. @@ -684,8 +686,7 @@ class DLL_EXPORT PacketBufferHandle } PacketBuffer * Get() const { return mBuffer; } - - bool operator==(const PacketBufferHandle & aOther) const { return mBuffer == aOther.mBuffer; } + PacketBuffer * GetNext() const { return static_cast(mBuffer->next); } #if CHIP_SYSTEM_PACKETBUFFER_HAS_RIGHTSIZE void InternalRightSize(); diff --git a/src/system/tests/TestSystemPacketBuffer.cpp b/src/system/tests/TestSystemPacketBuffer.cpp index 5b3f709a5bee67..5ee708fcd476ed 100644 --- a/src/system/tests/TestSystemPacketBuffer.cpp +++ b/src/system/tests/TestSystemPacketBuffer.cpp @@ -469,13 +469,13 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckSetDataLength) { EXPECT_EQ(config_2.handle->len, (config_2.end_buffer - config_2.payload_ptr)); EXPECT_EQ(config_2.handle->tot_len, (config_2.end_buffer - config_2.payload_ptr)); - EXPECT_EQ(config_2.handle->next, nullptr); + EXPECT_EQ(config_2.handle.GetNext(), nullptr); } else { EXPECT_EQ(config_2.handle->len, length); EXPECT_EQ(config_2.handle->tot_len, length); - EXPECT_EQ(config_2.handle->next, nullptr); + EXPECT_EQ(config_2.handle.GetNext(), nullptr); } } else @@ -487,7 +487,7 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckSetDataLength) { EXPECT_EQ(config_2.handle->len, (config_2.end_buffer - config_2.payload_ptr)); EXPECT_EQ(config_2.handle->tot_len, (config_2.end_buffer - config_2.payload_ptr)); - EXPECT_EQ(config_2.handle->next, nullptr); + EXPECT_EQ(config_2.handle.GetNext(), nullptr); EXPECT_EQ(config_1.handle->tot_len, (config_1.init_len + static_cast(config_2.end_buffer - config_2.payload_ptr) - @@ -497,7 +497,7 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckSetDataLength) { EXPECT_EQ(config_2.handle->len, length); EXPECT_EQ(config_2.handle->tot_len, length); - EXPECT_EQ(config_2.handle->next, nullptr); + EXPECT_EQ(config_2.handle.GetNext(), nullptr); EXPECT_EQ(config_1.handle->tot_len, (config_1.init_len + static_cast(length) - static_cast(config_2.init_len))); @@ -632,9 +632,9 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckAddToEnd) EXPECT_EQ(config_3.handle->ref, 1); // config_3.handle EXPECT_EQ(config_1.handle->tot_len, (config_1.init_len + config_2.init_len)); - EXPECT_EQ(config_1.handle->next, config_2.handle.Get()); - EXPECT_EQ(config_2.handle->next, nullptr); - EXPECT_EQ(config_3.handle->next, nullptr); + EXPECT_EQ(config_1.handle.GetNext(), config_2.handle.Get()); + EXPECT_EQ(config_2.handle.GetNext(), nullptr); + EXPECT_EQ(config_3.handle.GetNext(), nullptr); config_1.handle->AddToEnd(config_3.handle.Retain()); EXPECT_EQ(config_1.handle->ref, 1); // config_1.handle @@ -642,9 +642,9 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckAddToEnd) EXPECT_EQ(config_3.handle->ref, 2); // config_3.handle and config_2.handle->next EXPECT_EQ(config_1.handle->tot_len, (config_1.init_len + config_2.init_len + config_3.init_len)); - EXPECT_EQ(config_1.handle->next, config_2.handle.Get()); - EXPECT_EQ(config_2.handle->next, config_3.handle.Get()); - EXPECT_EQ(config_3.handle->next, nullptr); + EXPECT_EQ(config_1.handle.GetNext(), config_2.handle.Get()); + EXPECT_EQ(config_2.handle.GetNext(), config_3.handle.Get()); + EXPECT_EQ(config_3.handle.GetNext(), nullptr); config_1.handle = nullptr; config_2.handle = nullptr; @@ -703,7 +703,7 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckPopHead) const PacketBufferHandle popped = config_1.handle.PopHead(); EXPECT_EQ(config_1.handle, config_2.handle); - EXPECT_EQ(config_1.handle->next, nullptr); + EXPECT_EQ(config_1.handle.GetNext(), nullptr); EXPECT_EQ(config_1.handle->tot_len, config_1.init_len); } } @@ -786,7 +786,7 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckCompactHead) { EXPECT_EQ(config_1.handle->len, config_1.handle->MaxDataLength()); EXPECT_EQ(buffer_2->len, config_1.handle->tot_len - config_1.handle->MaxDataLength()); - EXPECT_EQ(config_1.handle->next, buffer_2); + EXPECT_EQ(config_1.handle.GetNext(), buffer_2); EXPECT_EQ(config_1.handle->ref, 2); EXPECT_EQ(buffer_2->ref, 1); } @@ -796,13 +796,13 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckCompactHead) if (data_length_1 >= config_1.handle->MaxDataLength() && data_length_2 == 0) { /* make sure the second buffer is not freed */ - EXPECT_EQ(config_1.handle->next, buffer_2); + EXPECT_EQ(config_1.handle.GetNext(), buffer_2); EXPECT_EQ(buffer_2->ref, 1); } else { /* make sure the second buffer is freed */ - EXPECT_EQ(config_1.handle->next, nullptr); + EXPECT_EQ(config_1.handle.GetNext(), nullptr); buffer_2 = nullptr; } } @@ -1263,7 +1263,7 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckFree) // Verify that head ref count is decremented. EXPECT_EQ(config_1.handle->ref, initial_refs_1 - 1); // Verify that chain is maintained. - EXPECT_EQ(config_1.handle->next, config_2.handle.Get()); + EXPECT_EQ(config_1.handle.GetNext(), config_2.handle.Get()); // Verify that chained buffer ref count has not changed. EXPECT_EQ(config_2.handle->ref, initial_refs_2); }