-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Objc] add ios libuv timer test #28570
Conversation
thanks Hannah, it is great to see that we can now import and reuse libuv test suite ; ) Can you update the PR description with a few summary of
|
third_party/libuv_test.patch
Outdated
static int connect_port = -1; | ||
|
||
-static int getsocknamecount = 0; | ||
+static int getsocknamecount_tcp = 0; |
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.
I wonder why we need to separate the callback counting here (thus this patch), is there a difference on iOS test context that makes the vanilla libuv test invalid here ?
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 static variable was used by multi test cases, it was OK since other languages use fork and count separately. But in iOS test, we have to run all tests in the same process, so we need separate variables to count separately.
@implementation LibuvTimerTests | ||
|
||
- (void)testTimerAll { | ||
for (task_entry_t* task = TASKS; task->main; task++) { |
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.
we will need a way to obtain the test result signals from these test by calling into XCTest's assertion methods (https://developer.apple.com/documentation/xctest?language=objc). Currently if we just run these it will always be reported as success (unless it crashed), thanks !
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 ASSERT works. If a test case fails at any assert, the whole test will crash. It'll be reported as success, only when all assert in all test cases passed.
eeb2c34
to
88a16f5
Compare
added |
88a16f5
to
95e12df
Compare
95e12df
to
1154ee3
Compare
594599e
to
09f7d81
Compare
thanks for the update, all test looks good |
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.
Sorry I didn't see this sooner. I'm glad to see you found a way to run libuv tests on iOS!
third_party/libuv_test.patch
Outdated
@@ -0,0 +1,56 @@ | |||
diff --git a/test/test-timer.c b/test/test-timer.c |
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 looks like a general change to the libuv test code, nothing gRPC-specific. I don't see why we'd want to maintain patches for general improvements that they'd likely accept and maintain upstream. Patches are a maintenance burden best avoided, if possible. For example, if it does not apply cleanly onto the next libuv version, upgrading the libuv dependency now means we'd have to port a patch before we could do the upgrade.
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.
Will send a PR to libuv after we finished adding other tests and collected all the patches needed.
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. Please collect the patches separately, and remove them from this PR. If it was a patch for something that we absolutely need for libuv to function on iOS, the extra burden is justifiable. But this is not essential, and again, every patch we have to maintain adds a real maintenance burden for library upgrades.
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.
Chatted w/ Hannah offline, we have a solution to run iOS test without patching libuv via ios_ui_test. This allows us to re-launch the app per test case via XCUIApplication.launch if needed in order to simulate the same fork run behavior as other platform.
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.
unfortunately, re-launch ios ui app didn't work, it might because that it only restarts the ios ui toolkit part, not the entire process.
PS: ios ui test also runs super slow due to boot up the simulator.
If we cannot add patch in our build system, could we try upstream it to libuv and wait for them to merge first?
Another alternative maybe split LibuvTest target into smaller ones, though it'll make the project a bit messy.
Error log with ios ui test:
Assertion failed in external/com_github_libuv_libuv/test/test-timer.c on line 152: once_cb_called == 1
...
Failing tests:
Runner:
-[LibuvTimerTests testTimerStartTwice]
** TEST EXECUTE FAILED **
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.
discussed offline, we will add back timer_start_twice test in a follow up PR pending the process relaunch fix
third_party/libuv_test.patch
Outdated
ASSERT(r == 0); | ||
|
||
- ASSERT(once_cb_called == 1); | ||
+ ASSERT(twice_cb_called == 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.
This change could be a bit misleading. The purpose of this test is that once_cb
is called exactly once, even when started twice. Calling it twice_cb
maybe implies that it's somehow different from once_cb
, which it should not be.
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.
It’s for test case timer_start_twice
, which is the named similar to other xx_cb variables. Can we keep it for now and let the libuv team decide when I send them the PR?
deps = [ | ||
":libuv" | ||
], | ||
linkopts = select({ |
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 same copts
would be needed here as well, I think
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.
comment addressed
"//conditions:default": [], | ||
}), | ||
visibility = [ | ||
"//visibility:public", |
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.
Does this need to be publicly visible?
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.
Tried with "//src/objective-c/tests/ThirdPartyTests/Libuv:LibuvTestsLib” but didn’t work, any suggestions?
09f7d81
to
ecebdc3
Compare
Thanks for the update @HannahShiSFB . Let's remove libuv patch and split the PR with bazel only changes here. We can add iOS test setup in a follow up. Cheers |
ecebdc3
to
861e18d
Compare
libuv patch removed. |
* use libuv in third party * add ios libuv timer test * name changed correspondingly * format code * address comment * remove libuv patch
libuv test source is build as
libuv_test
library and selected test cases will be ran from objective C code.Currently tests are manually selected and put into objective C tests, in long term we may consider add some script to extract the libuv test cases and report if libuv added or removed test cases.
use the following command to run test:
./tools/bazel run //src/objective-c/tests/ThirdPartyTests/Libuv:LibuvTest
@drfloob
@dennycd