Skip to content
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

Introduce TestWebKitAPI mechanism for directly testing IPC serialization #19579

Conversation

beidson
Copy link
Contributor

@beidson beidson commented Oct 26, 2023

d9fd3e0

Introduce TestWebKitAPI mechanism for directly testing IPC serialization
https://bugs.webkit.org/show_bug.cgi?id=263703
rdar://117511848

Reviewed by Alex Christensen.

This patch introduces a framework to directly test serialization of object types that we know
we need to support coding for IPC, but might not have any indirect way to test.

The testing leverages IPC's support for MessageSenders to work without an IPC::Connection.
That support was originally added to support generated messages and encoding to our daemons,
but reusing it here fits nicely.

By using a test-specific MessageSender and sendWithAsyncReplyWithoutUsingIPCConnection, we coax
CoreIPC into encoding a message and decoding a reply the same way it does for actual IPC messaging.

The prime use-case for this technique is testing our Objective-C types as found in ArgumentCodersCocoa.mm
The CoreFoundation types in ArgumentCodersCF.mm are also a nice fit.

For the sake of introducing the mechanism at a high level, this patch only tests serialization of NSString.
With this framework introduced, testing other types will be trivial.

* Source/WebKit/Shared/Cocoa/CoreIPCData.serialization.in:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig:
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCSerialization.mm: Added.
(ObjCSerializationTester::performSendWithAsyncReplyWithoutUsingIPCConnection const):
(ObjCHolderForTesting::encode const):
(ObjCHolderForTesting::decode):
(operator==):
(BasicPingBackMessage::name):
(BasicPingBackMessage::asyncMessageReplyName):
(BasicPingBackMessage::BasicPingBackMessage):
(BasicPingBackMessage::arguments):
(TEST):

Canonical link: https://commits.webkit.org/269802@main

32563fb

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
  πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@beidson beidson self-assigned this Oct 26, 2023
@beidson beidson added the WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore). label Oct 26, 2023
@beidson beidson added the merge-queue Applied to send a pull request to merge-queue label Oct 26, 2023
https://bugs.webkit.org/show_bug.cgi?id=263703
rdar://117511848

Reviewed by Alex Christensen.

This patch introduces a framework to directly test serialization of object types that we know
we need to support coding for IPC, but might not have any indirect way to test.

The testing leverages IPC's support for MessageSenders to work without an IPC::Connection.
That support was originally added to support generated messages and encoding to our daemons,
but reusing it here fits nicely.

By using a test-specific MessageSender and sendWithAsyncReplyWithoutUsingIPCConnection, we coax
CoreIPC into encoding a message and decoding a reply the same way it does for actual IPC messaging.

The prime use-case for this technique is testing our Objective-C types as found in ArgumentCodersCocoa.mm
The CoreFoundation types in ArgumentCodersCF.mm are also a nice fit.

For the sake of introducing the mechanism at a high level, this patch only tests serialization of NSString.
With this framework introduced, testing other types will be trivial.

* Source/WebKit/Shared/Cocoa/CoreIPCData.serialization.in:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig:
* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCSerialization.mm: Added.
(ObjCSerializationTester::performSendWithAsyncReplyWithoutUsingIPCConnection const):
(ObjCHolderForTesting::encode const):
(ObjCHolderForTesting::decode):
(operator==):
(BasicPingBackMessage::name):
(BasicPingBackMessage::asyncMessageReplyName):
(BasicPingBackMessage::BasicPingBackMessage):
(BasicPingBackMessage::arguments):
(TEST):

Canonical link: https://commits.webkit.org/269802@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Introduce-TestWebKitAPI-mechanism-for-directly-testing-IPC-serialization branch from 32563fb to d9fd3e0 Compare October 26, 2023 05:46
@webkit-commit-queue
Copy link
Collaborator

Committed 269802@main (d9fd3e0): https://commits.webkit.org/269802@main

Reviewed commits have been landed. Closing PR #19579 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit d9fd3e0 into WebKit:main Oct 26, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore).
Projects
None yet
4 participants