-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
copying argprinters funcs under libbpfgo #493
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mtcherni95 . you should move the tests as well
Since this is exported API we should use this opportunity to think about our naming conventions. All these functions start with 'Print' but none of them do any printing, they return strings. I would rather rename them to things like:
Also the package name What do you think @mtcherni95 @itaysk ? |
good point. wdyt of I don't think all of the helpers should live in the same package as libbpfgo, I'm fine with renaming the package. @yanivagman wdyt? |
ParseXXX sounds good to me. And different package but with different name is also good by me. |
Funny @grantseltzer that the names that you suggest where the ones used in the original tracee python version (e.g. open_flags_to_str) :-) |
I don't see the problem with Parse ( |
@mtcherni95 Could you rename all the functions to |
hi @mtcherni95 are you still working on this? |
Hi @mtcherni95 do you still want to work on this? If not is it cool with you if I pick it up to close this out? |
ff57fcf
to
8d9258a
Compare
After talking with @mtcherni95 I went ahead and pushed the requested changes to this, I will follow up with the second PR described in Michael's original comment right after this merges. |
@simar7 Can you please take a look at this? |
libbpfgo/helpers/argParsers_test.go
Outdated
"os" | ||
) | ||
|
||
func ExampleTracePipeListen_usage() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is named as argParsers_test.go
but none of the functions are actually test functions themselves. If it's more of an example/toy program to demonstrate usage of TracePipe()
, I would suggest renaming the file.
Otherwise we should make TracePipeListen()
injectable with a param, something like: TracePipeListen(path string)
, path being something we can inject during a test. We can further use "/sys/kernel/debug/tracing/trace_pipe"
as the default if no args are specified (the real world usage) to alleviate the need for passing in the path for the library user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea on making that function testable, I'd like to go through a lot of these helpers and write tests, will do I that in a follow up PR (I swear, I will!)
I've gone ahead and renamed this file to example_tracelisten_test.go
. The _test
suffix is necessary for the example to show up in godoc, but it seems an example_
prefix is idiomatic in the standard library (for example: code and docs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tests in tracee-ebpf/tracee/tracee_test.go
are mostly testing these argprinters. I think we can move them here (argparsers_test.go)
also, TracePipeListen
doesn't feel like it belongs in the argParsers file, can we move it into another helpers
file? if we do that, I think it's ok to rename example_tracelisten_test.go
to helpers_test.go
(it's common in go to put examples with test right?). wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itaysk I don't follow, the only test I see in tracee_test.go
is for readArgFromBuff()
.
I am all for separating out TracePipeListen to its own file and renaming the test file though. I'm about to open a PR with helpers for CO:RE stuff, I'll do that change as part of that PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just left a clarification comment but otherwise 🚢 it!
045960e
to
8bf51a2
Compare
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
8bf51a2
to
8934c28
Compare
Please note, after consulting with @itaysk , we decided that is better to close this issue with a two-phase commit.
In the first commit (this one) we will simply copy functions in libbpfgo so that tests will pass. In the second commit we will use libbpfgo funcs (under linuxhelpers package) and remove not relevant functions under tracee package (argprinters.go).