[llvm] [test] Align behavior of interrupts.test on different platforms (PR #68556)

Serge Pavlov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 06:53:31 PDT 2023


https://github.com/spavloff updated https://github.com/llvm/llvm-project/pull/68556

>From ddf29970e62362a5e9c80f15234e724ae9e5994c Mon Sep 17 00:00:00 2001
From: Serge Pavlov <sepavloff at gmail.com>
Date: Mon, 9 Oct 2023 11:23:17 +0700
Subject: [PATCH 1/2] [test] Align behavior of interrupts.test on different
 platforms

The test llvm/Support/interrupts.test behaves differently on Linux and
Windows. On Linux the function 'run_wrapper' runs process with stderr
connected to pipe, while on Windows stderr is mapped to stderr of the
running script.

When no output was made to stderr, this difference was not observable.
The new version of llvm-symbolizer (https://reviews.llvm.org/D149759)
complains about missing binary file, so stderr is not empty anymore and
the test fails on Windows and passes on Linux.
---
 llvm/test/Support/interrupts.test | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/test/Support/interrupts.test b/llvm/test/Support/interrupts.test
index 86730f5139c042d..5ef9df46c76febc 100644
--- a/llvm/test/Support/interrupts.test
+++ b/llvm/test/Support/interrupts.test
@@ -10,7 +10,8 @@ import sys
 import time
 
 def run_symbolizer():
-    proc = subprocess.Popen([sys.argv[2]], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+    proc = subprocess.Popen([sys.argv[2]], stdout=subprocess.PIPE,
+                            stdin=subprocess.PIPE, stderr=sys.stderr)
     # Write then read some output to ensure the process has started fully.
     proc.stdin.write(b'foo bar\n')
     proc.stdin.flush()
@@ -34,8 +35,8 @@ def run_wrapper():
                                 startupinfo=startupinfo,
                                 creationflags=subprocess.CREATE_NEW_CONSOLE)
     else:
-        proc = subprocess.Popen(args,
-                                stderr=subprocess.PIPE)
+        proc = subprocess.Popen(args, stderr=sys.stderr)
+        proc.wait()
 
 if sys.argv[1] == 'wrapper':
     run_wrapper()

>From 5c3ebb692feabaecc41992192216ed955356911a Mon Sep 17 00:00:00 2001
From: Serge Pavlov <sepavloff at gmail.com>
Date: Mon, 30 Oct 2023 18:53:39 +0700
Subject: [PATCH 2/2] Use subprocess.run

---
 llvm/test/Support/interrupts.test | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/llvm/test/Support/interrupts.test b/llvm/test/Support/interrupts.test
index 5ef9df46c76febc..752426c5292b098 100644
--- a/llvm/test/Support/interrupts.test
+++ b/llvm/test/Support/interrupts.test
@@ -30,13 +30,10 @@ def run_wrapper():
     if os.name == 'nt':
         startupinfo = subprocess.STARTUPINFO()
         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
-        proc = subprocess.Popen(args,
-                                stderr=sys.stderr,
-                                startupinfo=startupinfo,
-                                creationflags=subprocess.CREATE_NEW_CONSOLE)
+        subprocess.run(args, stderr=sys.stderr, startupinfo=startupinfo,
+                       creationflags=subprocess.CREATE_NEW_CONSOLE)
     else:
-        proc = subprocess.Popen(args, stderr=sys.stderr)
-        proc.wait()
+        subprocess.run(args, stderr=sys.stderr)
 
 if sys.argv[1] == 'wrapper':
     run_wrapper()



More information about the llvm-commits mailing list