--- /dev/null
+# Copyright (c) PLUMgrid, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License")
+
+add_test(NAME py_test_dump_func WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND ${TEST_WRAPPER} py_dump_func simple ${CMAKE_CURRENT_SOURCE_DIR}/test_dump_func.py)
--- /dev/null
+#!/usr/bin/env python
+# Copyright (c) PLUMgrid, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License")
+
+# test program for the 'dump_func' method
+
+from bcc import BPF
+from unittest import main, TestCase
+
+class TestDumpFunc(TestCase):
+ def test_return(self):
+ b = BPF(text="""
+ int entry(void)
+ {
+ return 1;
+ }""")
+
+ self.assertEquals(
+ "\xb7\x00\x00\x00\x01\x00\x00\x00" +
+ "\x95\x00\x00\x00\x00\x00\x00\x00",
+ b.dump_func("entry"))
+
+if __name__ == "__main__":
+ main()
sudo bash -c "PYTHONPATH=$PYTHONPATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH $cmd $1 $2"
return $?
}
+function simple_run() {
+ PYTHONPATH=$PYTHONPATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH $cmd $1 $2
+ return $?
+}
case $kind in
namespace)
sudo)
sudo_run $@
;;
+ simple)
+ simple_run $@
+ ;;
*)
echo "Invalid kind $kind"
exit 1