-
Notifications
You must be signed in to change notification settings - Fork 366
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
Add unit test for ListIPForwardRows #6673
base: main
Are you sure you want to change the base?
Conversation
a30bd29
to
b2e1f7a
Compare
syscallN := func(trap uintptr, args ...uintptr) (r1, r2 uintptr, err syscall.Errno) { | ||
// This mocks the 1st call to syscallN made by getIPForwardTable. It makes args[1] point to the table. | ||
if len(args) > 1 { | ||
ptr := unsafe.Pointer(args[1]) |
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.
Somehow checkptr
thinks "pointer arithmetic result points to invalid allocation".
There is no problem when -race
is not used. Need more investigation.
fd4d9c8
to
7ed92a0
Compare
Signed-off-by: Quan Tian <[email protected]>
7ed92a0
to
10983b1
Compare
@@ -307,11 +307,14 @@ type NetIOInterface interface { | |||
} | |||
|
|||
type netIO struct { | |||
syscallN func(trap uintptr, args ...uintptr) (r1, r2 uintptr, err syscall.Errno) | |||
syscallN func(trap uintptr, args ...uintptr) (r1, r2 uintptr, err syscall.Errno) | |||
getIPForwardTableFn func(family uint16, ipForwardTable **MibIPForwardTable) (errcode error) |
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.
couldn't we just fake syscallN
in tests, instead of faking individual functions like getIPForwardTable
? It seems that getIPForwardTable
is just a thin wrapper around a syscallN
call.
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.
That's what I did in an earlier version: b2e1f7a. However, checkptr failed when --race
is enabled, as I commented in #6673 (comment). The error can be found here: https://github.com/antrea-io/antrea/actions/runs/10863106542/job/30146883490.
I suspect the compiler doesn't recognize the fake syscall and mistakenly raise the error. But even the latest version failed due to another checkptr error in code (as opposed the previous error in test code), and this error seems valid: the code shouldn't assign uintptr to a variable.
No description provided.