Skip to content

Commit 87fe070

Browse files
committed
[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
1 parent 7d97678 commit 87fe070

File tree

10 files changed

+25
-0
lines changed

10 files changed

+25
-0
lines changed

libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// XFAIL: LIBCXX-WINDOWS-FIXME
1414

15+
// UNSUPPORTED: executor-has-no-bash
1516
// FILE_DEPENDENCIES: ../check-stderr.sh
1617
// RUN: %{build}
1718
// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cin.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// istream cin;
1212

13+
// UNSUPPORTED: executor-has-no-bash
1314
// FILE_DEPENDENCIES: ../send-stdin.sh
1415
// RUN: %{build}
1516
// RUN: %{exec} bash send-stdin.sh "%t.exe" "1234"

libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/clog.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// XFAIL: LIBCXX-WINDOWS-FIXME
1414

15+
// UNSUPPORTED: executor-has-no-bash
1516
// FILE_DEPENDENCIES: ../check-stderr.sh
1617
// RUN: %{build}
1718
// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// XFAIL: LIBCXX-WINDOWS-FIXME
1414

15+
// UNSUPPORTED: executor-has-no-bash
1516
// FILE_DEPENDENCIES: ../check-stdout.sh
1617
// RUN: %{build}
1718
// RUN: %{exec} bash check-stdout.sh "%t.exe" "1234"

libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// XFAIL: libcpp-has-no-wide-characters
1414
// XFAIL: LIBCXX-WINDOWS-FIXME
1515

16+
// UNSUPPORTED: executor-has-no-bash
1617
// FILE_DEPENDENCIES: ../check-stderr.sh
1718
// RUN: %{build}
1819
// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcin.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
// XFAIL: libcpp-has-no-wide-characters
1414

15+
// UNSUPPORTED: executor-has-no-bash
1516
// FILE_DEPENDENCIES: ../send-stdin.sh
1617
// RUN: %{build}
1718
// RUN: %{exec} bash send-stdin.sh "%t.exe" "1234"

libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wclog.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// XFAIL: libcpp-has-no-wide-characters
1414
// XFAIL: LIBCXX-WINDOWS-FIXME
1515

16+
// UNSUPPORTED: executor-has-no-bash
1617
// FILE_DEPENDENCIES: ../check-stderr.sh
1718
// RUN: %{build}
1819
// RUN: %{exec} bash check-stderr.sh "%t.exe" "1234"

libcxx/test/std/input.output/iostream.objects/wide.stream.objects/wcout.sh.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// XFAIL: libcpp-has-no-wide-characters
1414
// XFAIL: LIBCXX-WINDOWS-FIXME
1515

16+
// UNSUPPORTED: executor-has-no-bash
1617
// FILE_DEPENDENCIES: ../check-stdout.sh
1718
// RUN: %{build}
1819
// RUN: %{exec} bash check-stdout.sh "%t.exe" "1234"

libcxx/utils/libcxx/test/dsl.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ def hasCompileFlag(config, flag):
168168
])
169169
return exitCode == 0
170170

171+
@_memoizeExpensiveOperation(lambda c, s: (c.substitutions, c.environment, s))
172+
def runScriptExitCode(config, script):
173+
"""
174+
Runs the given script as a Lit test, and returns the exit code of the execution.
175+
176+
The script must be a list of commands, each of which being something that
177+
could appear on the right-hand-side of a `RUN:` keyword.
178+
"""
179+
with _makeConfigTest(config) as test:
180+
_, _, exitCode, _ = _executeScriptInternal(test, script)
181+
return exitCode
182+
171183
@_memoizeExpensiveOperation(lambda c, l: (c.substitutions, c.environment, l))
172184
def hasAnyLocale(config, locales):
173185
"""

libcxx/utils/libcxx/test/features.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
void f() { new int(3); }
7373
""", ['-shared'])),
7474

75+
# Whether Bash can run on the executor.
76+
# This is not always the case, for example when running on embedded systems.
77+
Feature(name='executor-has-no-bash',
78+
when=lambda cfg: runScriptExitCode(cfg, ['%{exec} bash --version']) != 0),
79+
7580
Feature(name='apple-clang', when=_isAppleClang),
7681
Feature(name=lambda cfg: 'apple-clang-{__clang_major__}'.format(**compilerMacros(cfg)), when=_isAppleClang),
7782
Feature(name=lambda cfg: 'apple-clang-{__clang_major__}.{__clang_minor__}'.format(**compilerMacros(cfg)), when=_isAppleClang),

0 commit comments

Comments
 (0)