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

Tests: adjust synchronization tests for Windows #615

Merged
merged 2 commits into from
Jun 7, 2023

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Jun 7, 2023

Windows does not support pthreads. Adjust the tests to use the Windows APIs for locking where the primitive being used is the SRWLOCK.

@compnerd
Copy link
Member Author

compnerd commented Jun 7, 2023

@swift-ci please test

Copy link
Contributor

@Kyle-Ye Kyle-Ye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a helper function to this?

private func XXhelper(_ synced: Synchronized) {
    #if os(macOS) || os(iOS)
    XCTAssertTrue(os_unfair_lock_trylock(synced.lock))
    #elseif os(Windows)
    XCTAssertNotEqual(TryAcquireSRWLockExclusive(synced.lock), 0)
    #elseif os(Linux)
    XCTAssertEqual(pthread_mutex_trylock(synced.lock),0)
    #endif
}

compnerd and others added 2 commits June 7, 2023 13:13
Windows does not support pthreads.  Adjust the tests to use the Windows
APIs for locking where the primitive being used is the `SRWLOCK`.
Address feedback from @Kyle-Ye in swiftlang#615.  This avoids replicating the
logic for checking the lock state which is already subtle due to the
checking of the return value.
@compnerd
Copy link
Member Author

compnerd commented Jun 7, 2023

@swift-ci please test

@compnerd compnerd merged commit 4b92390 into swiftlang:main Jun 7, 2023
@compnerd compnerd deleted the synchronized branch June 7, 2023 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants