Skip to content

Commit

Permalink
Replace nl-unit-test with pigweed for platform (project-chip#33030)
Browse files Browse the repository at this point in the history
* Pigweed tests for platform

* Fix tests

* Restyled by clang-format

* Update src/platform/tests/TestPlatformMgr.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Fix review

* CI fixes

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
3 people authored Apr 19, 2024
1 parent c3c3b3c commit 80b2f61
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 584 deletions.
6 changes: 2 additions & 4 deletions src/platform/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

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

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

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

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

test_sources = []
Expand All @@ -41,10 +40,8 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") {
public_deps = [
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support:test_utils",
"${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/platform",
"${chip_root}/src/system",
"${nlunit_test_root}:nlunit-test",
]

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

if (chip_enable_ble &&
Expand Down
11 changes: 3 additions & 8 deletions src/platform/tests/TestCHIPoBLEStackMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,23 @@

#include "platform/internal/CHIPDeviceLayerInternal.h"
#include <assert.h>
#include <gtest/gtest.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/UnitTestRegistration.h>
#include <memory>

#include "platform/PlatformManager.h"
#include "platform/internal/BLEManager.h"

void EventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg)
void EventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t)
{
(void) arg;
if (event->Type == chip::DeviceLayer::DeviceEventType::kCHIPoBLEConnectionEstablished)
{
ChipLogProgress(DeviceLayer, "Receive kCHIPoBLEConnectionEstablished");
// exit(0);
}
}

int TestCHIPoBLEStackManager()
TEST(TestCHIPoBLEStackManager, TestCHIPoBLEStackManager)
{
chip::Platform::MemoryInit();

Expand All @@ -54,7 +52,4 @@ int TestCHIPoBLEStackManager()
chip::DeviceLayer::PlatformMgrImpl().RunEventLoop();
ChipLogProgress(DeviceLayer, "RunEventLoop completed");
chip::Platform::MemoryShutdown();
return 0;
}

CHIP_REGISTER_TEST_SUITE(TestCHIPoBLEStackManager);
4 changes: 3 additions & 1 deletion src/platform/tests/TestCHIPoBLEStackMgrDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "TestCHIPoBLEStackMgr.h"
#include <gtest/gtest.h>
#include <platform/CHIPDeviceConfig.h>
#include <stdlib.h>

Expand All @@ -24,7 +25,8 @@ int main(int argc, char * argv[])
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
if (argc == 2 && atoi(argv[1]) == 1)
{
return TestCHIPoBLEStackManager();
testing::InitGoogleTest(nullptr, nullptr);
return RUN_ALL_TESTS();
}
return 0;
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand Down
Loading

0 comments on commit 80b2f61

Please sign in to comment.