1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
from socket import AF_UNIX
from pr2test.marks import require_root
from pyroute2 import DiagSocket
pytestmark = [require_root()]
def test_basic():
sstats_set = set()
pstats_set = set()
sstats = None
fd = None
with DiagSocket() as ds:
ds.bind()
sstats = ds.get_sock_stats(family=AF_UNIX)
for s in sstats:
sstats_set.add(s['udiag_ino'])
with open('/proc/net/unix') as fd:
for line in fd.readlines():
line = line.split()
try:
pstats_set.add(int(line[6]))
except ValueError:
pass
assert sstats_set == pstats_set
|