MCPcopy Create free account
hub / github.com/iovisor/bcc / test_queue

Method test_queue

tests/python/test_queuestack.py:49–80  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

47 b.cleanup()
48
49 def test_queue(self):
50 text = b"""
51 BPF_QUEUE(queue, u64, 10);
52 """
53 b = BPF(text=text)
54 queue = b[b'queue']
55
56 for i in range(10):
57 queue.push(ct.c_uint64(i))
58
59 with self.assertRaises(Exception):
60 queue.push(ct.c_uint(10))
61
62 assert queue.peek().value == 0
63
64 for i in range(10):
65 assert queue.pop().value == i
66
67 with self.assertRaises(KeyError):
68 queue.peek()
69
70 with self.assertRaises(KeyError):
71 queue.pop()
72
73 for i in range(10):
74 queue.push(ct.c_uint64(i))
75
76 # testing itervalues()
77 for i,v in enumerate(queue.values()):
78 assert v.value == i
79
80 b.cleanup()
81
82
83if __name__ == "__main__":

Callers

nothing calls this directly

Calls 6

cleanupMethod · 0.95
BPFClass · 0.90
pushMethod · 0.45
peekMethod · 0.45
popMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected