Re: Why use net_if_get_first_by_type(...) instead of net_if_get_default in dhcp4 test case from v.2.6.0. #net #test

Jukka Rissanen


the unit test programs are self contained i.e., they do not need any external network connections to verify functionality. If the unit test is run in a board that has for example Ethernet support, there could be multiple network interfaces created (Ethernet and Dummy). If the unit test would use net_if_get_default(), then we might get incorrect network interface returned. So to avoid this possible issue, the unit tests use the proper network interface in order to allow the test pass.


On Mon, 2021-12-20 at 18:55 -0800, yunkai@... wrote:

In my opinion, is using net_if_get_default more appropriate than using net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)) in tests/net/dhcpv4/src/main.c:434?

If using the net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)), the test program can only be tested through a fake network interface(GUMMY), it means that it won't test the communicate between device and DHCP server on the real network.
But if using net_if_get_default, users can use Kconfig to select the default network interface, and if the developer has ported the driver for physical network interface, users can test the communication between the device and DHCP server.

Maybe it’s because I don’t know enough about the program architecture
Please forgive me if the concept is not correct.


Join to automatically receive all group messages.