diff --git a/clang/test/Analysis/analyzer-checker-config.c b/clang/test/Analysis/analyzer-checker-config.c --- a/clang/test/Analysis/analyzer-checker-config.c +++ b/clang/test/Analysis/analyzer-checker-config.c @@ -1,12 +1,9 @@ -// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.mallo:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni.:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config ..:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unrelated:Optimistic=true 2>&1 | FileCheck %s -// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.DynamicMemoryModeling:Optimistic=true +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.mallo:Optimistic=true %s 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni:Optimistic=true %s 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni.:Optimistic=true %s 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config ..:Optimistic=true %s 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.:Optimistic=true %s 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unrelated:Optimistic=true %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.DynamicMemoryModeling:Optimistic=true %s 2>&1 -// Just to test clang is working. -# foo - -// CHECK: error: +// CHECK: error: no analyzer checkers or packages are associated with diff --git a/clang/test/Analysis/analyzer-config.c b/clang/test/Analysis/analyzer-config.c --- a/clang/test/Analysis/analyzer-config.c +++ b/clang/test/Analysis/analyzer-config.c @@ -1,4 +1,4 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ConfigDumper > %t 2>&1 +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ConfigDumper %s > %t 2>&1 // RUN: FileCheck --input-file=%t %s --match-full-lines // CHECK: [config] diff --git a/clang/test/Driver/cc1-response-files.c b/clang/test/Driver/cc1-response-files.c --- a/clang/test/Driver/cc1-response-files.c +++ b/clang/test/Driver/cc1-response-files.c @@ -1,2 +1,2 @@ -// RUN: %clang @%S/Inputs/cc1-response.txt -fsyntax-only -disable-llvm-passes +// RUN: %clang @%S/Inputs/cc1-response.txt -fsyntax-only -disable-llvm-passes %s int main() {} diff --git a/clang/test/Interpreter/incremental-mode.cpp b/clang/test/Interpreter/incremental-mode.cpp --- a/clang/test/Interpreter/incremental-mode.cpp +++ b/clang/test/Interpreter/incremental-mode.cpp @@ -1,3 +1,3 @@ -// RUN: clang-repl -Xcc -E -// RUN: clang-repl -Xcc -emit-llvm +// RUN: clang-repl -Xcc -E %s +// RUN: clang-repl -Xcc -emit-llvm %s // expected-no-diagnostics diff --git a/clang/test/Modules/load-module-with-errors.m b/clang/test/Modules/load-module-with-errors.m --- a/clang/test/Modules/load-module-with-errors.m +++ b/clang/test/Modules/load-module-with-errors.m @@ -16,14 +16,14 @@ // RUN: mkdir %t // RUN: mkdir %t/prebuilt -// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: echo "" | %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ // RUN: -fmodule-name=error -o %t/prebuilt/error.pcm \ // RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap -// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: echo "" | %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ // RUN: -fmodule-file=error=%t/prebuilt/error.pcm \ // RUN: -fmodule-name=use_error_a -o %t/prebuilt/use_error_a.pcm \ // RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap -// RUN: %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ +// RUN: echo "" | %clang_cc1 -fmodules -fallow-pcm-with-compiler-errors \ // RUN: -fmodule-file=error=%t/prebuilt/error.pcm \ // RUN: -fmodule-name=use_error_b -o %t/prebuilt/use_error_b.pcm \ // RUN: -x objective-c -emit-module %S/Inputs/error/module.modulemap @@ -60,7 +60,7 @@ // RUN: -fmodule-file=%t/prebuilt/error.pcm \ // RUN: -fmodule-file=%t/prebuilt/use_error_a.pcm \ // RUN: -fmodule-file=%t/prebuilt/use_error_b.pcm \ -// RUN: -fmodules-cache-path=%t 2>&1 | \ +// RUN: -fmodules-cache-path=%t %s 2>&1 | \ // RUN: grep "PCH file contains compiler errors" // Shouldn't build the cached modules (that have errors) when not allowing @@ -91,7 +91,7 @@ // allow-pcm-with-compiler-errors should also allow errors in PCH // RUN: %clang_cc1 -fallow-pcm-with-compiler-errors -x objective-c \ -// RUN: -o %t/check.pch -emit-pch %S/Inputs/error/error.h +// RUN: -o %t/check.pch -emit-pch %S/Inputs/error/error.h %s // CHECK: @interface Error // CHECK-NEXT: - (int)method; diff --git a/clang/test/OpenMP/target_uses_allocators.c b/clang/test/OpenMP/target_uses_allocators.c --- a/clang/test/OpenMP/target_uses_allocators.c +++ b/clang/test/OpenMP/target_uses_allocators.c @@ -1,7 +1,7 @@ // Test host codegen. -// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu +// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu %s // expected-no-diagnostics #ifndef HEADER diff --git a/clang/test/Preprocessor/elfiamcu-predefines.c b/clang/test/Preprocessor/elfiamcu-predefines.c --- a/clang/test/Preprocessor/elfiamcu-predefines.c +++ b/clang/test/Preprocessor/elfiamcu-predefines.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s +// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu %s | FileCheck %s // CHECK: #define __USER_LABEL_PREFIX__ {{$}} // CHECK: #define __WINT_TYPE__ unsigned int diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -640,7 +640,7 @@ procs = [] proc_not_counts = [] - default_stdin = subprocess.PIPE + default_stdin = None stderrTempFiles = [] opened_files = [] named_temp_files = [] diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py --- a/llvm/utils/lit/lit/util.py +++ b/llvm/utils/lit/lit/util.py @@ -321,7 +321,7 @@ * working directory ``cwd`` (str), use None to use the current working directory * environment ``env`` (dict), use None for none - * Input to the command ``input`` (str), use string to pass + * Input to the command ``input`` (str), use None to pass no input. * Max execution time ``timeout`` (int) seconds. Use 0 for no timeout. * ``redirect_stderr`` (bool), use True if redirect stderr to stdout @@ -339,7 +339,7 @@ input = to_bytes(input) err_out = subprocess.STDOUT if redirect_stderr else subprocess.PIPE p = subprocess.Popen(command, cwd=cwd, - stdin=subprocess.PIPE, + stdin=subprocess.PIPE if input else None, stdout=subprocess.PIPE, stderr=err_out, env=env, close_fds=kUseCloseFDs) diff --git a/llvm/utils/lit/tests/Inputs/shtest-stdin/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-stdin/lit.cfg new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-stdin/lit.cfg @@ -0,0 +1,26 @@ +# -*- Python -*- +import os +import sys + +import lit.formats + +config.name = 'shtest-stdin' + +externalShell = lit_config.params.get('external', '1') != '0' +config.test_format = lit.formats.ShTest(execute_external=externalShell) +config.suffixes = ['.py'] + +config.test_source_root = os.path.dirname(__file__) +config.test_exec_root = config.test_source_root +config.target_triple = '(unused)' +src_root = os.path.join(config.test_source_root, '..') + +pythonpath_list = [src_root] +# Ensure the user's PYTHONPATH is included. +if 'PYTHONPATH' in os.environ: + pythonpath_list.append(os.environ['PYTHONPATH']) +if 'PYTHONPATH' in config.environment: + pythonpath_list.append(config.environment['PYTHONPATH']) +config.environment['PYTHONPATH'] = os.pathsep.join(pythonpath_list) + +config.substitutions.append(('%{python}', '"%s"' % (sys.executable))) diff --git a/llvm/utils/lit/tests/Inputs/shtest-stdin/print-stdin.py b/llvm/utils/lit/tests/Inputs/shtest-stdin/print-stdin.py new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-stdin/print-stdin.py @@ -0,0 +1,5 @@ +# Checks that lit provides no input to stdin. +# RUN: %{python} %s +import sys + +print(sys.stdin.read()) \ No newline at end of file diff --git a/llvm/utils/lit/tests/shtest-stdin.py b/llvm/utils/lit/tests/shtest-stdin.py new file mode 100644 --- /dev/null +++ b/llvm/utils/lit/tests/shtest-stdin.py @@ -0,0 +1,28 @@ +# REQUIRES: lit-max-individual-test-time + +############################################################################### +# Check tests do not receive spurious stdin input. +############################################################################### +# RUN: not %{lit} %{inputs}/shtest-stdin/print-stdin.py \ +# RUN: --param external=0 --timeout 1 \ +# RUN: | FileCheck --check-prefix=CHECK-STDIN %s +# +# RUN: not %{lit} %{inputs}/shtest-stdin/print-stdin.py \ +# RUN: --param external=1 --timeout 1 \ +# RUN: | FileCheck --check-prefix=CHECK-STDIN %s +# +# CHECK-STDIN: TIMEOUT: shtest-stdin :: print-stdin.py + +############################################################################### +# Check tests do receive piped stdin input. +############################################################################### +# RUN: echo foobar | %{lit} %{inputs}/shtest-stdin/print-stdin.py \ +# RUN: --param external=0 -a \ +# RUN: | FileCheck --check-prefix=CHECK-PIPE %s +# +# RUN: echo foobar | %{lit} %{inputs}/shtest-stdin/print-stdin.py \ +# RUN: --param external=1 -a \ +# RUN: | FileCheck --check-prefix=CHECK-PIPE %s +# +# CHECK-PIPE: foobar + diff --git a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel @@ -33,5 +33,15 @@ "//llvm:not", ] + glob(["Inputs/**"]), ) - for src in glob(["*/*.py"]) + for src in glob( + include = ["**/*.py"], + exclude = [ + "Inputs/**", + # FIXME: these tests fail under bazel. + "discovery.py", + "max-time.py", + "selecting.py", + "shtest-recursive-substitution.py", + ] + ) ]