thom311 / libnl

Netlink Library Suite
GNU Lesser General Public License v2.1
419 stars 313 forks source link

test case can not be automatically executed after the make check is exceuted #299

Closed chengyechun closed 2 years ago

chengyechun commented 2 years ago

I've noticed that many test cases contain specific parameters that prevent them from being automatically executed by make check. Most of these parameters are local NIC names. If I need to test these functions, I need to manually change these parameters and then manually execute them while writing them, which is inconvenient. Is there a way to directly obtain the local network adapter name and then automatically transfer the name to these test cases through parameters? In this way, these cases can be self-adapted to facilitate execution. It can be a command line, for example, ifconfig -a|grep -B1 inet|grep -v inet6|grep -B1 inet|grep flags|grep -v lo |grep -v 127.0.0.1|awk '{print $1}'|sed's/^[\t]*//g '|sed's/[:]*$//g'; Of course, it may also be a function interface.

thom311 commented 2 years ago

see also: https://github.com/thom311/libnl/issues/270#issuecomment-1067394940

even if those test programs would be smarter about detecting the local system, one wouldn't want that running a test modifies your actual system.

What needs to be done, is to spawn a network namespace and run the tests in there. The tests themselves could do that. NetworkManager does that for its unit tests, for example here.

I agree we should improve tests! But that happens by somebody sending a patch :) Hence, I am going to close this issue. Thank you.