Skip to content

Commit

Permalink
Merge pull request iovisor#25 from plumgrid/bblanco_dev
Browse files Browse the repository at this point in the history
Rename files and a few functions
  • Loading branch information
4ast committed Jun 1, 2015
2 parents f197faf + f178be9 commit c3f57e6
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/bpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, bpf, map_fd, keytype, leaftype):
self.keytype = keytype
self.leaftype = leaftype

def get(self, key):
def lookup(self, key):
key_p = ct.pointer(key)
leaf = self.leaftype()
leaf_p = ct.pointer(leaf)
Expand All @@ -73,7 +73,7 @@ def get(self, key):
raise Exception("Could not lookup in table")
return leaf

def put(self, key, leaf, flags=0):
def update(self, key, leaf, flags=0):
key_p = ct.pointer(key)
leaf_p = ct.pointer(leaf)
res = lib.bpf_update_elem(self.map_fd,
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ configure_file(wrapper.sh.in "${CMAKE_CURRENT_BINARY_DIR}/wrapper.sh" @ONLY)

set(TEST_WRAPPER ${CMAKE_CURRENT_BINARY_DIR}/wrapper.sh)

add_subdirectory(jit)
add_subdirectory(cc)
16 changes: 16 additions & 0 deletions tests/cc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_test(NAME py_test_stat1_b WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_stat1_b namespace ${CMAKE_CURRENT_SOURCE_DIR}/test_stat1.py test_stat1.b proto.b)
add_test(NAME py_test_stat1_c WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_stat1_c namespace ${CMAKE_CURRENT_SOURCE_DIR}/test_stat1.py test_stat1.c)
add_test(NAME py_test_xlate1_b WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_xlate1_b namespace ${CMAKE_CURRENT_SOURCE_DIR}/test_xlate1.py test_xlate1.b proto.b)
add_test(NAME py_test_xlate1_c WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_xlate1_c namespace ${CMAKE_CURRENT_SOURCE_DIR}/test_xlate1.py test_xlate1.c)
add_test(NAME py_test_call1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_call1_c namespace ${CMAKE_CURRENT_SOURCE_DIR}/test_call1.py test_call1.c)
add_test(NAME py_test_trace1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_trace1 sudo ${CMAKE_CURRENT_SOURCE_DIR}/test_trace1.py test_trace1.b kprobe.b)
add_test(NAME py_test_trace2 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_trace2 sudo ${CMAKE_CURRENT_SOURCE_DIR}/test_trace2.py)
add_test(NAME py_test_trace3_c WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_trace3_c sudo ${CMAKE_CURRENT_SOURCE_DIR}/test_trace3.py test_trace3.c)
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions tests/jit/test3.py → tests/cc/test_call1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ def setUp(self):
eop_fn = b.load_func("eop", BPF.SCHED_CLS)
BPF.attach_classifier(ether_fn, "eth0")
self.jump = b.get_table("jump", c_int, c_int)
self.jump.put(c_int(S_ARP), c_int(arp_fn.fd))
self.jump.put(c_int(S_IP), c_int(ip_fn.fd))
self.jump.put(c_int(S_EOP), c_int(eop_fn.fd))
self.jump.update(c_int(S_ARP), c_int(arp_fn.fd))
self.jump.update(c_int(S_IP), c_int(ip_fn.fd))
self.jump.update(c_int(S_EOP), c_int(eop_fn.fd))
self.stats = b.get_table("stats", c_int, c_ulonglong)

def test_jumps(self):
udp = socket(AF_INET, SOCK_DGRAM)
udp.sendto(b"a" * 10, ("172.16.1.1", 5000))
self.assertGreater(self.stats.get(c_int(S_IP)).value, 0)
self.assertGreater(self.stats.get(c_int(S_ARP)).value, 0)
self.assertGreater(self.stats.get(c_int(S_EOP)).value, 1)
self.assertGreater(self.stats.lookup(c_int(S_IP)).value, 0)
self.assertGreater(self.stats.lookup(c_int(S_ARP)).value, 0)
self.assertGreater(self.stats.lookup(c_int(S_EOP)).value, 1)

if __name__ == "__main__":
main()
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/jit/test1.py → tests/cc/test_stat1.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def test_ping(self):
cmd = ["ping", "-f", "-c", "100", "172.16.1.1"]
check_call(cmd)
#for key in self.stats.iter():
# leaf = self.stats.get(key)
# leaf = self.stats.lookup(key)
# print(IPAddress(key.sip), "=>", IPAddress(key.dip),
# "rx", leaf.rx_pkts, "tx", leaf.tx_pkts)
key = Key(IPAddress("172.16.1.2").value, IPAddress("172.16.1.1").value)
leaf = self.stats.get(key)
leaf = self.stats.lookup(key)
self.assertEqual(leaf.rx_pkts, 100)
self.assertEqual(leaf.tx_pkts, 100)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/jit/trace1.py → tests/cc/test_trace1.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_trace1(self):
for i in range(0, 200):
os.read(f.fileno(), 1)
for key in self.stats.iter():
leaf = self.stats.get(key)
leaf = self.stats.lookup(key)
print("fd %x:" % key.fd, "stat1 %d" % leaf.stat1, "stat2 %d" % leaf.stat2)

if __name__ == "__main__":
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/jit/trace2.py → tests/cc/test_trace2.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_sched1(self):
for i in range(0, 100):
sleep(0.01)
for key in self.stats.iter():
leaf = self.stats.get(key)
leaf = self.stats.lookup(key)
print("ptr %x:" % key.ptr, "stat1 %x" % leaf.stat1)

if __name__ == "__main__":
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/jit/trace3.py → tests/cc/test_trace3.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_blk1(self):
subprocess.call(["sync"])
os.unlink("/opt/trace3.txt")
for key in self.latency.iter():
leaf = self.latency.get(key)
leaf = self.latency.lookup(key)
print("latency %u:" % key.value, "count %u" % leaf.value)
sys.stdout.flush()

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/jit/test2.py → tests/cc/test_xlate1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def setUp(self):
def test_xlate(self):
key = Key(IPAddress("172.16.1.1").value, IPAddress("172.16.1.2").value)
leaf = Leaf(IPAddress("192.168.1.1").value, IPAddress("192.168.1.2").value, 0)
self.xlate.put(key, leaf)
self.xlate.update(key, leaf)
udp = socket(AF_INET, SOCK_DGRAM)
udp.sendto(b"a" * 10, ("172.16.1.1", 5000))
leaf = self.xlate.get(key)
leaf = self.xlate.lookup(key)
self.assertGreater(leaf.xlated_pkts, 0)
udp.close()

Expand Down
16 changes: 0 additions & 16 deletions tests/jit/CMakeLists.txt

This file was deleted.

6 changes: 0 additions & 6 deletions tests/jit/loader.py

This file was deleted.

0 comments on commit c3f57e6

Please sign in to comment.