* Reinhard Tartler <siret...@tauware.de> [2024-07-24 09:36]:
Looking closer at the tests, it appears that they are iterating over all installed network interfaces, and try to query them for statistics. In that 'unshare -nr' context, they still find a loopback interface, but commands to query fail with "operation not supported".Clearly, those tests don't make sense in such an environment.Jochen, what's the best way to detect this situation in a test, so that it can decide to do a "t.Skip(...)" instead of failing? I'm looking for a way to avoid having to disable the tests altogether to not loose test coverage on machines that don't run in unshare mode.
Looking at: https://sources.debian.org/src/golang-github-safchain-ethtool/0.4.1-1/ethtool_test.go/#L45The skip condition could depend on the return value of net.Interfaces() but I guess it would be basically the same as the fail condition. I think the correct way would be to mock the net.Interfaces() return value such that the same test data is used, independent of the host system.
on a side note, I'd like to express concerns with having the buildds enable unshare mode becaues it evidently reduces test coverage, as shown in this context.
I disagree with this as unit tests can (and should) always mock the system state.
Cheers Jochen
signature.asc
Description: PGP signature