Skip to content

Commit

Permalink
Merge 95e644c into 28ddbeb
Browse files Browse the repository at this point in the history
  • Loading branch information
jlatusek authored Nov 22, 2023
2 parents 28ddbeb + 95e644c commit 2374323
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 93 deletions.
2 changes: 1 addition & 1 deletion build/chip/chip_test_group.gni
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ template("chip_test_group") {
deps += [ get_label_info(_test, "label_no_toolchain") + ".lib" ]
}

if (_build_monolithic_library && chip_build_test_static_libraries) {
if (_build_monolithic_library) {
complete_static_lib = true
}
}
Expand Down
14 changes: 2 additions & 12 deletions build/chip/chip_test_suite.gni
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ template("chip_test_suite") {
invoker.sources += invoker.test_sources
}

if (chip_build_test_static_libraries) {
_target_type = "static_library"
} else {
_target_type = "source_set"
}
target(_target_type, "${_suite_name}.lib") {
pw_source_set("${_suite_name}.lib") {
forward_variables_from(invoker, "*", [ "tests" ])

output_dir = "${root_out_dir}/lib"
Expand Down Expand Up @@ -178,12 +173,7 @@ template("chip_test_suite_using_nltest") {
invoker.sources += invoker.test_sources
}

if (chip_build_test_static_libraries) {
_target_type = "static_library"
} else {
_target_type = "source_set"
}
target(_target_type, "${_suite_name}.lib") {
target("source_set", "${_suite_name}.lib") {
forward_variables_from(invoker, "*", [ "tests" ])

output_dir = "${root_out_dir}/lib"
Expand Down
5 changes: 0 additions & 5 deletions build/chip/tests.gni
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ declare_args() {
chip_pw_run_tests = chip_link_tests && current_os != "tizen"
}

declare_args() {
# Use source_set instead of static_lib for tests.
chip_build_test_static_libraries = chip_device_platform != "efr32"
}

declare_args() {
# Enable use of nlfaultinjection.
chip_with_nlfaultinjection = chip_build_tests
Expand Down
1 change: 1 addition & 0 deletions src/inet/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ chip_test_suite_using_nltest("tests") {
chip_device_platform != "ameba") {
# TODO: This test does not seem executed
sources += [ "TestLwIPDNS.cpp" ]
tests = [ "TestLwIPDNS" ]
}

cflags = [ "-Wconversion" ]
Expand Down
74 changes: 1 addition & 73 deletions src/inet/tests/TestLwIPDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,11 @@ using namespace chip::Inet;

#define TOOL_NAME "TestLwIPDNS"

static bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[]);

// Globals

#if CHIP_SYSTEM_CONFIG_USE_LWIP
static uint8_t sNumIpAddrs = DNS_MAX_ADDRS_PER_NAME;
static ip_addr_t sIpAddrs[DNS_MAX_ADDRS_PER_NAME];
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

static const char * sHostname = nullptr;
static const char * sDNSServerAddr = nullptr;

// clang-format off
static ArgParser::HelpOptions gHelpOptions(TOOL_NAME,
"Usage: " TOOL_NAME " [<options...>] <hostname> <dns-server-address>\n",
CHIP_VERSION_STRING "\n" CHIP_TOOL_COPYRIGHT);

static ArgParser::OptionSet * gToolOptionSets[] =
{
&gNetworkOptions,
&gFaultInjectionOptions,
&gHelpOptions,
nullptr
};
// clang-format on

#if CHIP_SYSTEM_CONFIG_USE_LWIP
static void found_multi(const char * aName, ip_addr_t * aIpAddrs, uint8_t aNumIpAddrs, void * callback_arg)
{
Expand All @@ -96,7 +75,7 @@ static void found_multi(const char * aName, ip_addr_t * aIpAddrs, uint8_t aNumIp
Done = true;
}

static void TestLwIPDNS(void)
static void TestLwIPDNS(const char *sDNSServerAddr)
{
uint8_t numdns = 1;
ip_addr_t dnsserver[1];
Expand Down Expand Up @@ -207,54 +186,3 @@ static void TestLwIPDNS(void)
}
}
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

int main(int argc, char * argv[])
{
SetSIGUSR1Handler();

if (argc == 1)
{
gHelpOptions.PrintBriefUsage(stderr);
exit(EXIT_FAILURE);
}

if (!ParseArgs(TOOL_NAME, argc, argv, gToolOptionSets, HandleNonOptionArgs))
{
exit(EXIT_FAILURE);
}

InitSystemLayer();

InitNetwork();

#if CHIP_SYSTEM_CONFIG_USE_LWIP
TestLwIPDNS();
#else
fprintf(stderr, "Please assert CHIP_SYSTEM_CONFIG_USE_LWIP to use this test.\n");
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

ShutdownNetwork();

ShutdownSystemLayer();

return (EXIT_SUCCESS);
}

static bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[])
{
if (argc < 2)
{
printf("TestDNS: Missing %s argument\n", argc == 0 ? "<hostname>" : "<dns-server-address>");
return false;
}

if (argc > 2)
{
printf("Unexpected argument: %s\n", argv[1]);
}

sHostname = argv[0];
sDNSServerAddr = argv[1];

return true;
}
29 changes: 29 additions & 0 deletions src/inet/tests/TestLwIPDNS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2023 Samsung
* All rights reserved.
*
* 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 implements a process to effect a functional test for
* LwIP's Domain Name Service (DNS) interface.
*
*/

#if CHIP_SYSTEM_CONFIG_USE_LWIP
static void TestLwIPDNS(const char * sDNSServerAddr);
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
115 changes: 115 additions & 0 deletions src/inet/tests/TestLwIPDNSDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2013-2017 Nest Labs, Inc.
* All rights reserved.
*
* 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 implements a process to effect a functional test for
* LwIP's Domain Name Service (DNS) interface.
*
*/

#include <inet/InetConfig.h>
#include <lib/core/CHIPConfig.h>

#include <stdint.h>
#include <string.h>

#include <sys/time.h>

#include <CHIPVersion.h>

#include <inet/InetArgParser.h>

#include "TestInetCommon.h"
#include "TestInetCommonOptions.h"
#include "TestSetupFaultInjection.h"
#include "TestSetupSignalling.h"

using namespace chip;
using namespace chip::Inet;

#define TOOL_NAME "TestLwIPDNS"

static bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[]);

static const char * sDNSServerAddr = nullptr;

// clang-format off
static ArgParser::HelpOptions gHelpOptions(TOOL_NAME,
"Usage: " TOOL_NAME " [<options...>] <hostname> <dns-server-address>\n",
CHIP_VERSION_STRING "\n" CHIP_TOOL_COPYRIGHT);

static ArgParser::OptionSet * gToolOptionSets[] =
{
&gNetworkOptions,
&gFaultInjectionOptions,
&gHelpOptions,
nullptr
};
// clang-format on

int main(int argc, char * argv[])
{
SetSIGUSR1Handler();

if (argc == 1)
{
gHelpOptions.PrintBriefUsage(stderr);
exit(EXIT_FAILURE);
}

if (!ParseArgs(TOOL_NAME, argc, argv, gToolOptionSets, HandleNonOptionArgs))
{
exit(EXIT_FAILURE);
}

InitSystemLayer();

InitNetwork();

#if CHIP_SYSTEM_CONFIG_USE_LWIP
TestLwIPDNS(sDNSServerAddr);
#else
fprintf(stderr, "Please assert CHIP_SYSTEM_CONFIG_USE_LWIP to use this test.\n");
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

ShutdownNetwork();

ShutdownSystemLayer();

return (EXIT_SUCCESS);
}

static bool HandleNonOptionArgs(const char * progName, int argc, char * const argv[])
{
if (argc < 2)
{
printf("TestDNS: Missing %s argument\n", argc == 0 ? "<hostname>" : "<dns-server-address>");
return false;
}

if (argc > 2)
{
printf("Unexpected argument: %s\n", argv[1]);
}

sDNSServerAddr = argv[1];

return true;
}
5 changes: 3 additions & 2 deletions src/platform/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ if (chip_device_platform != "none" && chip_device_platform != "fake") {
sources = [
"TestCHIPoBLEStackMgr.cpp",
"TestCHIPoBLEStackMgr.h",
"TestCHIPoBLEStackMgrDriver.cpp",
]
tests = [ "TestCHIPoBLEStackMgr" ]
tests = [
"TestCHIPoBLEStackMgr",
]
}

if (current_os == "zephyr" || current_os == "android" ||
Expand Down

0 comments on commit 2374323

Please sign in to comment.