Skip to content

Commit 80b2f61

Browse files
jlatusekrestyled-commitsbzbarsky-apple
authored
Replace nl-unit-test with pigweed for platform (#33030)
* Pigweed tests for platform * Fix tests * Restyled by clang-format * Update src/platform/tests/TestPlatformMgr.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Fix review * CI fixes --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent c3c3b3c commit 80b2f61

12 files changed

+351
-584
lines changed

src/platform/tests/BUILD.gn

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
17-
import("//build_overrides/nlunit_test.gni")
1817

1918
import("${chip_root}/src/platform/device.gni")
2019

@@ -27,7 +26,7 @@ declare_args() {
2726
if (chip_device_platform != "none" && chip_device_platform != "fake") {
2827
import("${chip_root}/build/chip/chip_test_suite.gni")
2928

30-
chip_test_suite_using_nltest("tests") {
29+
chip_test_suite("tests") {
3130
output_name = "libPlatformTests"
3231

3332
test_sources = []
@@ -41,10 +40,8 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") {
4140
public_deps = [
4241
"${chip_root}/src/lib/support",
4342
"${chip_root}/src/lib/support:test_utils",
44-
"${chip_root}/src/lib/support:testing_nlunit",
4543
"${chip_root}/src/platform",
4644
"${chip_root}/src/system",
47-
"${nlunit_test_root}:nlunit-test",
4845
]
4946

5047
if (chip_mdns != "none" && chip_enable_dnssd_tests &&
@@ -67,6 +64,7 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") {
6764
if (chip_enable_openthread) {
6865
# FIXME: TestThreadStackMgr requires ot-br-posix daemon to be running
6966
# test_sources += [ "TestThreadStackMgr.cpp" ]
67+
# configs = [ "//${chip_root}/third_party/ot-br-posix:dbus_config" ]
7068
}
7169

7270
if (chip_enable_ble &&

src/platform/tests/TestCHIPoBLEStackMgr.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,23 @@
1717

1818
#include "platform/internal/CHIPDeviceLayerInternal.h"
1919
#include <assert.h>
20+
#include <gtest/gtest.h>
2021
#include <lib/support/CHIPMem.h>
2122
#include <lib/support/CodeUtils.h>
22-
#include <lib/support/UnitTestRegistration.h>
2323
#include <memory>
2424

2525
#include "platform/PlatformManager.h"
2626
#include "platform/internal/BLEManager.h"
2727

28-
void EventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg)
28+
void EventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t)
2929
{
30-
(void) arg;
3130
if (event->Type == chip::DeviceLayer::DeviceEventType::kCHIPoBLEConnectionEstablished)
3231
{
3332
ChipLogProgress(DeviceLayer, "Receive kCHIPoBLEConnectionEstablished");
34-
// exit(0);
3533
}
3634
}
3735

38-
int TestCHIPoBLEStackManager()
36+
TEST(TestCHIPoBLEStackManager, TestCHIPoBLEStackManager)
3937
{
4038
chip::Platform::MemoryInit();
4139

@@ -54,7 +52,4 @@ int TestCHIPoBLEStackManager()
5452
chip::DeviceLayer::PlatformMgrImpl().RunEventLoop();
5553
ChipLogProgress(DeviceLayer, "RunEventLoop completed");
5654
chip::Platform::MemoryShutdown();
57-
return 0;
5855
}
59-
60-
CHIP_REGISTER_TEST_SUITE(TestCHIPoBLEStackManager);

src/platform/tests/TestCHIPoBLEStackMgrDriver.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include "TestCHIPoBLEStackMgr.h"
19+
#include <gtest/gtest.h>
1920
#include <platform/CHIPDeviceConfig.h>
2021
#include <stdlib.h>
2122

@@ -24,7 +25,8 @@ int main(int argc, char * argv[])
2425
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
2526
if (argc == 2 && atoi(argv[1]) == 1)
2627
{
27-
return TestCHIPoBLEStackManager();
28+
testing::InitGoogleTest(nullptr, nullptr);
29+
return RUN_ALL_TESTS();
2830
}
2931
return 0;
3032
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

0 commit comments

Comments
 (0)