Skip to content

Commit

Permalink
Tests should tolerate cpusets. (#1853)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Lukasa authored May 7, 2021
1 parent 06195d2 commit d161bf6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Tests/NIOTests/EventLoopTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}
Expand Down

0 comments on commit d161bf6

Please sign in to comment.