[libcxx-commits] [libcxx] 87fe070 - [libc++] Allow detecting whether the executor supports Bash

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 14 13:54:27 PST 2021


Author: Louis Dionne
Date: 2021-12-14T16:54:13-05:00
New Revision: 87fe0709d4ad7c3128f998f14c66245ebb423e4f

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

LOG: [libc++] Allow detecting whether the executor supports Bash

A few tests in the test suite require support for Bash. For example,
tests that run a program and send data through stdin to it require some
way of piping the data in, and we use a Bash script for that.

However, some executors (e.g. an embedded systems simulator) do not
support Bash, so these tests will fail. This commit adds a Lit feature
that tries to detect whether Bash is available through conventional
means, and disables the tests that require it otherwise.

Differential Revision: https://reviews.llvm.org/D114612

Added: 
    

Modified: 
    libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
    libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
    libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
    libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
    libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
    libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
    libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
    libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
    libcxx/utils/libcxx/test/dsl.py
    libcxx/utils/libcxx/test/features.py

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
index cd221e7875b6d..36380f64a9fec 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp
@@ -12,6 +12,7 @@
 
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../check-stderr.sh
 // RUN: %{build}
 // RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

diff  --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
index f4b34289cf511..c394c1b00f3e8 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp
@@ -10,6 +10,7 @@
 
 // istream cin;
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../send-stdin.sh
 // RUN: %{build}
 // RUN: %{exec} bash send-stdin.sh "%t.exe" "1234"

diff  --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
index 884f34598ce88..b740300e8d327 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp
@@ -12,6 +12,7 @@
 
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../check-stderr.sh
 // RUN: %{build}
 // RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

diff  --git a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
index b39dd156dc7b9..c606312fa0547 100644
--- a/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp
@@ -12,6 +12,7 @@
 
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../check-stdout.sh
 // RUN: %{build}
 // RUN: %{exec} bash check-stdout.sh "%t.exe" "1234"

diff  --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
index 8ff1666496c7b..617b2d45c0662 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp
@@ -13,6 +13,7 @@
 // XFAIL: libcpp-has-no-wide-characters
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../check-stderr.sh
 // RUN: %{build}
 // RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

diff  --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
index af7107cd4769d..c9be17125b832 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp
@@ -12,6 +12,7 @@
 
 // XFAIL: libcpp-has-no-wide-characters
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../send-stdin.sh
 // RUN: %{build}
 // RUN: %{exec} bash send-stdin.sh "%t.exe" "1234"

diff  --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
index 1a5b200f27c2b..e0ce4646ea9d4 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp
@@ -13,6 +13,7 @@
 // XFAIL: libcpp-has-no-wide-characters
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../check-stderr.sh
 // RUN: %{build}
 // RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

diff  --git a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
index 3d4af9799973e..6089432b0f566 100644
--- a/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
+++ b/libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp
@@ -13,6 +13,7 @@
 // XFAIL: libcpp-has-no-wide-characters
 // XFAIL: LIBCXX-WINDOWS-FIXME
 
+// UNSUPPORTED: executor-has-no-bash
 // FILE_DEPENDENCIES: ../check-stdout.sh
 // RUN: %{build}
 // RUN: %{exec} bash check-stdout.sh "%t.exe" "1234"

diff  --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index c9e0056725351..52f4d309c2b01 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -168,6 +168,18 @@ def hasCompileFlag(config, flag):
     ])
     return exitCode == 0
 
+ at _memoizeExpensiveOperation(lambda c, s: (c.substitutions, c.environment, s))
+def runScriptExitCode(config, script):
+  """
+  Runs the given script as a Lit test, and returns the exit code of the execution.
+
+  The script must be a list of commands, each of which being something that
+  could appear on the right-hand-side of a `RUN:` keyword.
+  """
+  with _makeConfigTest(config) as test:
+    _, _, exitCode, _ = _executeScriptInternal(test, script)
+    return exitCode
+
 @_memoizeExpensiveOperation(lambda c, l: (c.substitutions, c.environment, l))
 def hasAnyLocale(config, locales):
   """

diff  --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index f70a8613e1d5d..241d1b57a1a5e 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -72,6 +72,11 @@
             void f() { new int(3); }
           """, ['-shared'])),
 
+  # Whether Bash can run on the executor.
+  # This is not always the case, for example when running on embedded systems.
+  Feature(name='executor-has-no-bash',
+          when=lambda cfg: runScriptExitCode(cfg, ['%{exec} bash --version']) != 0),
+
   Feature(name='apple-clang',                                                                                                      when=_isAppleClang),
   Feature(name=lambda cfg: 'apple-clang-{__clang_major__}'.format(**compilerMacros(cfg)),                                          when=_isAppleClang),
   Feature(name=lambda cfg: 'apple-clang-{__clang_major__}.{__clang_minor__}'.format(**compilerMacros(cfg)),                        when=_isAppleClang),


        


More information about the libcxx-commits mailing list