Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
c6aaaed1
Commit
c6aaaed1
authored
Feb 01, 2017
by
Sasha Goldshtein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Add test for TP_DATA_LOC_READ_CONST
parent
b9545a5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
tests/python/test_tracepoint.py
tests/python/test_tracepoint.py
+27
-0
No files found.
tests/python/test_tracepoint.py
View file @
c6aaaed1
...
...
@@ -7,6 +7,7 @@ import unittest
from
time
import
sleep
import
distutils.version
import
os
import
subprocess
def
kernel_version_ge
(
major
,
minor
):
# True if running kernel is >= X.Y
...
...
@@ -39,5 +40,31 @@ class TestTracepoint(unittest.TestCase):
total_switches
+=
v
.
value
self
.
assertNotEqual
(
0
,
total_switches
)
@
unittest
.
skipUnless
(
kernel_version_ge
(
4
,
7
),
"requires kernel >= 4.7"
)
class
TestTracepointDataLoc
(
unittest
.
TestCase
):
def
test_tracepoint_data_loc
(
self
):
text
=
"""
struct value_t {
char filename[64];
};
BPF_HASH(execs, u32, struct value_t);
TRACEPOINT_PROBE(sched, sched_process_exec) {
struct value_t val = {0};
char fn[64];
u32 pid = args->pid;
struct value_t *existing = execs.lookup_or_init(&pid, &val);
TP_DATA_LOC_READ_CONST(fn, filename, 64);
__builtin_memcpy(existing->filename, fn, 64);
return 0;
}
"""
b
=
bcc
.
BPF
(
text
=
text
)
subprocess
.
check_output
([
"/bin/ls"
])
sleep
(
1
)
found
=
False
for
k
,
v
in
b
[
"execs"
].
items
():
found
=
"ls"
in
v
.
filename
self
.
assertTrue
(
found
,
"'ls' was not found in map"
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment