Commit dd3867d3 authored by Brenden Blanco's avatar Brenden Blanco Committed by GitHub

Merge pull request #1032 from goldshtn/tools-tests

Smoke tests for the tools
parents eea18dc8 5c41b39b
...@@ -64,3 +64,5 @@ add_test(NAME py_test_percpu WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ...@@ -64,3 +64,5 @@ add_test(NAME py_test_percpu WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_test_percpu sudo ${CMAKE_CURRENT_SOURCE_DIR}/test_percpu.py) COMMAND ${TEST_WRAPPER} py_test_percpu sudo ${CMAKE_CURRENT_SOURCE_DIR}/test_percpu.py)
add_test(NAME py_test_dump_func WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 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) COMMAND ${TEST_WRAPPER} py_dump_func simple ${CMAKE_CURRENT_SOURCE_DIR}/test_dump_func.py)
add_test(NAME py_test_tools_smoke WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${TEST_WRAPPER} py_test_tools_smoke sudo ${CMAKE_CURRENT_SOURCE_DIR}/test_tools_smoke.py)
This diff is collapsed.
...@@ -637,7 +637,7 @@ argdist -p 2780 -z 120 \\ ...@@ -637,7 +637,7 @@ argdist -p 2780 -z 120 \\
self.probes.append(Probe(self, "hist", histspecifier)) self.probes.append(Probe(self, "hist", histspecifier))
if len(self.probes) == 0: if len(self.probes) == 0:
print("at least one specifier is required") print("at least one specifier is required")
exit() exit(1)
def _generate_program(self): def _generate_program(self):
bpf_source = """ bpf_source = """
...@@ -695,10 +695,13 @@ struct __string_t { char s[%d]; }; ...@@ -695,10 +695,13 @@ struct __string_t { char s[%d]; };
self._attach() self._attach()
self._main_loop() self._main_loop()
except: except:
exc_info = sys.exc_info()
sys_exit = exc_info[0] is SystemExit
if self.args.verbose: if self.args.verbose:
traceback.print_exc() traceback.print_exc()
elif sys.exc_info()[0] is not SystemExit: elif not sys_exit:
print(sys.exc_info()[1]) print(exc_info[1])
exit(0 if sys_exit else 1)
if __name__ == "__main__": if __name__ == "__main__":
Tool().run() Tool().run()
...@@ -21,6 +21,7 @@ b = BPF(text=""" ...@@ -21,6 +21,7 @@ b = BPF(text="""
#include <uapi/linux/ptrace.h> #include <uapi/linux/ptrace.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/genhd.h> #include <linux/genhd.h>
#include <linux/bio.h>
struct data_t { struct data_t {
u64 pid; u64 pid;
......
File mode changed from 100644 to 100755
...@@ -691,10 +691,13 @@ trace 'p::SyS_nanosleep(struct timespec *ts) "sleep for %lld ns", ts->tv_nsec' ...@@ -691,10 +691,13 @@ trace 'p::SyS_nanosleep(struct timespec *ts) "sleep for %lld ns", ts->tv_nsec'
self._attach_probes() self._attach_probes()
self._main_loop() self._main_loop()
except: except:
exc_info = sys.exc_info()
sys_exit = exc_info[0] is SystemExit
if self.args.verbose: if self.args.verbose:
traceback.print_exc() traceback.print_exc()
elif sys.exc_info()[0] is not SystemExit: elif not sys_exit:
print(sys.exc_info()[1]) print(exc_info[1])
exit(0 if sys_exit else 1)
if __name__ == "__main__": if __name__ == "__main__":
Tool().run() Tool().run()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment