From f7918a80f16cecc06d9980f65019300fdeb59e77 Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Thu, 15 Apr 2021 11:30:26 +0100 Subject: [PATCH] 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. --- Tests/NIOTests/SystemTest.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Tests/NIOTests/SystemTest.swift b/Tests/NIOTests/SystemTest.swift index 3c5a46c07..176ca208a 100644 --- a/Tests/NIOTests/SystemTest.swift +++ b/Tests/NIOTests/SystemTest.swift @@ -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)") }