Skip to content

[4.2] [test] Tweak class_getImageName to correctly handle 2018 OS betas #18091

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions test/Interpreter/SDK/class_getImageName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ func check(_ cls: AnyClass, in library: String) {
"wrong library for \(cls)")
}

var cannotUseObjCRuntimeHook = false
#if targetEnvironment(device) && !os(macOS)
if #available(iOS 12, tvOS 12, watchOS 5, *) {
var newOSButCannotUseObjCRuntimeHook = false
if #available(macOS 10.14, iOS 12, tvOS 12, watchOS 5, *) {
// The only place these tests will fail is on early versions of the 2018 OSs.
// The final versions will have 'objc_setHook_getImageName'; anything earlier
// will be handled by manually overwriting the original implementation of
// 'class_getImageName'.
cannotUseObjCRuntimeHook =
newOSButCannotUseObjCRuntimeHook =
(nil == dlsym(UnsafeMutableRawPointer(bitPattern: -2),
"objc_setHook_getImageName"))
}
#endif // targetEnvironment(device) && !os(macOS)

var testSuite = TestSuite("class_getImageName")

Expand All @@ -43,7 +41,7 @@ testSuite.test("Simple") {
}

testSuite.test("Generic")
.xfail(.custom({ cannotUseObjCRuntimeHook },
.skip(.custom({ newOSButCannotUseObjCRuntimeHook },
reason: "hook for class_getImageName not present"))
.code {
check(GenericSwiftObject<Int>.self, in: "libGetImageNameHelper.dylib")
Expand All @@ -54,7 +52,7 @@ testSuite.test("Generic")
}

testSuite.test("GenericAncestry")
.xfail(.custom({ cannotUseObjCRuntimeHook },
.skip(.custom({ newOSButCannotUseObjCRuntimeHook },
reason: "hook for class_getImageName not present"))
.code {
check(GenericAncestrySwiftObject.self, in: "libGetImageNameHelper.dylib")
Expand Down