[llvm] d7aee33 - [llvm][Windows] Don't run socket tests on old versions of Windows

Michael Spencer via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 17:33:23 PST 2023


Author: Michael Spencer
Date: 2023-12-13T17:33:04-08:00
New Revision: d7aee33029f2d029c16098bd0630831638c7038e

URL: https://github.com/llvm/llvm-project/commit/d7aee33029f2d029c16098bd0630831638c7038e
DIFF: https://github.com/llvm/llvm-project/commit/d7aee33029f2d029c16098bd0630831638c7038e.diff

LOG: [llvm][Windows] Don't run socket tests on old versions of Windows

AF_UNIX sockets were added to Windows 10 build 17063 in 2017, older
versions of Windows will fail this test.

Also add a lit config so lit tests using sockets can do:
// REQUIRES: unix-sockets
(It would be cool if unit tests could use lit available_features)

Also fix llvm-config test that didn't fail when new libs are added.

Added: 
    

Modified: 
    llvm/test/lit.cfg.py
    llvm/test/tools/llvm-config/system-libs.windows.test
    llvm/unittests/Support/raw_socket_stream_test.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index 8319093408020f..c6f9ee82e08cc1 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -572,6 +572,9 @@ def have_ld64_plugin_support():
         if "hw.optional.fma: 1" in result:
             config.available_features.add("fma3")
 
+if not hasattr(sys, "getwindowsversion") or sys.getwindowsversion().build >= 17063:
+    config.available_features.add("unix-sockets")
+
 # .debug_frame is not emitted for targeting Windows x64, aarch64/arm64, AIX, or Apple Silicon Mac.
 if not re.match(
     r"^(x86_64|aarch64|arm64|powerpc|powerpc64).*-(windows-gnu|windows-msvc|aix)",

diff  --git a/llvm/test/tools/llvm-config/system-libs.windows.test b/llvm/test/tools/llvm-config/system-libs.windows.test
index d1d91a9a0b9e2f..007be5cb866a49 100644
--- a/llvm/test/tools/llvm-config/system-libs.windows.test
+++ b/llvm/test/tools/llvm-config/system-libs.windows.test
@@ -2,6 +2,6 @@ RUN: llvm-config --link-static --system-libs Support 2>&1 | FileCheck %s
 REQUIRES: static-libs
 REQUIRES: host={{.*-windows-msvc}}
 CHECK-NOT: -l
-CHECK: psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib
+CHECK: psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib Ws2_32.lib{{$}}
 CHECK-NOT: error
 CHECK-NOT: warning

diff  --git a/llvm/unittests/Support/raw_socket_stream_test.cpp b/llvm/unittests/Support/raw_socket_stream_test.cpp
index 53eb86ae45d29d..0a2a8b5a2c653e 100644
--- a/llvm/unittests/Support/raw_socket_stream_test.cpp
+++ b/llvm/unittests/Support/raw_socket_stream_test.cpp
@@ -10,11 +10,27 @@
 #include <iostream>
 #include <stdlib.h>
 
+#ifdef _WIN32
+#include "llvm/Support/Windows/WindowsSupport.h"
+#endif
+
 using namespace llvm;
 
 namespace {
 
+bool hasUnixSocketSupport() {
+#ifdef _WIN32
+  VersionTuple Ver = GetWindowsOSVersion();
+  if (Ver < VersionTuple(10, 0, 0, 17063))
+    return false;
+#endif
+  return true;
+}
+
 TEST(raw_socket_streamTest, CLIENT_TO_SERVER_AND_SERVER_TO_CLIENT) {
+  if (!hasUnixSocketSupport())
+    GTEST_SKIP();
+
   SmallString<100> SocketPath;
   llvm::sys::fs::createUniquePath("test_raw_socket_stream.sock", SocketPath,
                                   true);


        


More information about the llvm-commits mailing list