def bpftool_json(args):
res = _bpftool(args) return json.loads(res)
def get_default_iface(): for iface in socket.if_nameindex(): if iface[1] != "lo": return iface[1] raise IfaceNotFoundError("Could not find any network interface to probe")
class TestBpftool(unittest.TestCase):
@classmethod def setUpClass(cls): if os.getuid() != 0: raise UnprivilegedUserError( "This test suite needs root privileges")
res = bpftool_json(["feature", "probe", "dev", iface]) # Check if the result has all expected keys.
self.assertCountEqual(res.keys(), expected_keys) # Check if unexpected helpers are not included in helpers probes # result. for helpers in res["helpers"].values(): for unexpected_helper in unexpected_helpers:
self.assertNotIn(unexpected_helper, helpers)
for tc in test_cases: # Check if the result has all expected keys.
self.assertCountEqual(tc.keys(), expected_keys) # Check if unexpected helpers are not included in helpers probes # result. for helpers in tc["helpers"].values(): for unexpected_helper in unexpected_helpers:
self.assertNotIn(unexpected_helper, helpers)
for tc in test_cases: # Check if expected helpers are included at least once in any # helpers list for any program type. Unfortunately we cannot assume # that they will be included in all program types or a specific # subset of programs. It depends on the kernel version and # configuration.
found_helpers = False
for helpers in tc["helpers"].values(): if all(expected_helper in helpers for expected_helper in expected_helpers):
found_helpers = True break
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.