support qemu: qemu returns ENOPROTOOPT for unknown socket opts (#1806)

Motivation:

When running SwiftNIO under Qemu, then one test case fails because it
expects `ENOTSOCK` but Qemu returns `ENOPROTOOPT`. This is a Qemu bug.

Modification:

Accept `ENOTSOCK` or `ENOPROTOOPT`.

Result:

Test suite works under Qemu.
This commit is contained in:
Johannes Weiss authored and GitHub committed 2021-04-15 11:30:26 +01:00
1 parent 5b6b7f02d7
commit f7918a80f1
1 file changed
+2 -3
+2 -3
View File
@@ -36,10 +36,9 @@ class SystemTest: XCTestCase {
}
XCTFail("success even though the call was invalid")
} catch let e as IOError {
XCTAssertEqual(ENOTSOCK, e.errnoCode)
XCTAssert([ENOTSOCK /* almost everything */, ENOPROTOOPT /* in Qemu */].contains(e.errnoCode))
XCTAssert(e.description.contains("setsockopt"))
XCTAssert(e.description.contains("\(ENOTSOCK)"))
XCTAssert(e.localizedDescription.contains("\(ENOTSOCK)"), "\(e.localizedDescription)")
XCTAssert(e.description.contains("\(ENOTSOCK)") || e.description.contains("\(ENOPROTOOPT)"))
} catch let e {
XCTFail("wrong error thrown: \(e)")
}