Tests should tolerate cpusets. (#1853)

Motivation:

Our current CPU pinning tests do not expect to be pinned to cores that
do not include core 0. That's unnecessary.

Modifications:

- Expect to pin to the first core in our cpuset.

Result:

Tests run inside cpusets.
This commit is contained in:
Cory Benfield 2021-05-07 11:28:18 +01:00 committed by GitHub
parent 06195d2f46
commit d161bf6587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -552,8 +552,9 @@ public final class EventLoopTest : XCTestCase {
public func testEventLoopPinned() throws {
#if os(Linux) || os(Android)
let target = NIOThread.current.affinity.cpuIds.first!
let body: ThreadInitializer = { t in
let set = LinuxCPUSet(0)
let set = LinuxCPUSet(target)
t.affinity = set
XCTAssertEqual(set, t.affinity)
}
@ -567,13 +568,14 @@ public final class EventLoopTest : XCTestCase {
public func testEventLoopPinnedCPUIdsConstructor() throws {
#if os(Linux) || os(Android)
let group = MultiThreadedEventLoopGroup(pinnedCPUIds: [0])
let target = NIOThread.current.affinity.cpuIds.first!
let group = MultiThreadedEventLoopGroup(pinnedCPUIds: [target])
let eventLoop = group.next()
let set = try eventLoop.submit {
NIOThread.current.affinity
}.wait()
XCTAssertEqual(LinuxCPUSet(0), set)
XCTAssertEqual(LinuxCPUSet(target), set)
XCTAssertNoThrow(try group.syncShutdownGracefully())
#endif
}