Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler-rt/test/asan/TestCases/log-path_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// RUN: FileCheck %s --check-prefix=CHECK-BAD-DIR < %t.out

// Too long log_path.
// RUN: %env_asan_opts=log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \
// RUN: %python -c "for i in range(0, 10000): print(i, end='')" > %t.long_log_path
// RUN: %env_asan_opts=log_path=%{readfile:%t.long_log_path} \
// RUN: not %run %t 2> %t.out
// RUN: FileCheck %s --check-prefix=CHECK-LONG < %t.out

Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/asan/TestCases/scariness_score_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// RUN: %clangxx_asan -O0 -mllvm -asan-use-stack-safety=0 %s -o %t
// On OSX and Windows, alloc_dealloc_mismatch=1 isn't 100% reliable, so it's
// off by default. It's safe for these tests, though, so we turn it on.
// RUN: export %env_asan_opts=symbolize=0:detect_stack_use_after_return=1:handle_abort=1:print_scariness=1:alloc_dealloc_mismatch=1
// RUN: %export_asan_opts=symbolize=0:detect_stack_use_after_return=1:handle_abort=1:print_scariness=1:alloc_dealloc_mismatch=1
// Make sure the stack is limited (may not be the default under GNU make)
// RUN: ulimit -s 4096
// RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK1
Expand Down Expand Up @@ -41,7 +41,7 @@
// RUN: %clangxx_asan -O0 %s -o %t -fsanitize-address-use-after-return=always -mllvm -asan-use-stack-safety=0
// On OSX and Windows, alloc_dealloc_mismatch=1 isn't 100% reliable, so it's
// off by default. It's safe for these tests, though, so we turn it on.
// RUN: export %env_asan_opts=symbolize=0:handle_abort=1:print_scariness=1:alloc_dealloc_mismatch=1
// RUN: %export_asan_opts=symbolize=0:handle_abort=1:print_scariness=1:alloc_dealloc_mismatch=1
// Make sure the stack is limited (may not be the default under GNU make)
// RUN: ulimit -s 4096
// RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK1
Expand Down
3 changes: 3 additions & 0 deletions compiler-rt/test/asan/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def get_required_attr(config, attr_name):
config.substitutions.append(
("%env_asan_opts=", "env ASAN_OPTIONS=" + default_asan_opts_str)
)
config.substitutions.append(
("%export_asan_opts=", "export ASAN_OPTIONS=" + default_asan_opts_str)
)

# Setup source root.
config.test_source_root = os.path.dirname(__file__)
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/test/lit.common.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,3 +1066,5 @@ def target_page_size():
# llvm.
config.substitutions.append(("%crt_src", config.compiler_rt_src_root))
config.substitutions.append(("%llvm_src", config.llvm_src_root))

config.substitutions.append(("%python", '"%s"' % (sys.executable)))
3 changes: 2 additions & 1 deletion compiler-rt/test/memprof/TestCases/log_path_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
// RUN: %env_memprof_opts=print_text=true:log_path=/dev/null/INVALID not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BAD-DIR --dump-input=always

// Too long log_path.
// RUN: %env_memprof_opts=print_text=true:log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \
// RUN: %python -c "for i in range(0, 10000): print(i, end='')" > %t.long_log_path
// RUN: %env_memprof_opts=print_text=true:log_path=%{readfile:%t.long_log_path} \
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LONG --dump-input=always

// Specifying the log name via the __memprof_profile_filename variable.
Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/test/msan/allocator_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// mapping the heap early, in __msan_init.
//
// RUN: %clangxx_msan -O0 %s -o %t_1
// RUN: %clangxx_msan -O0 -DHEAP_ADDRESS=$(%run %t_1) %s -o %t_2 && %run %t_2
// RUN: %run %t_1 > %t.heap_address
// RUN: %clangxx_msan -O0 -DHEAP_ADDRESS=%{readfile:%t.heap_address} %s -o %t_2 && %run %t_2
//
// This test only makes sense for the 64-bit allocator. The 32-bit allocator
// does not have a fixed mapping. Exclude platforms that use the 32-bit
Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/test/nsan/Posix/allocator_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/// Test that a module constructor can not map memory over the NSan heap
/// (without MAP_FIXED, of course).
// RUN: %clangxx_nsan -O0 %s -o %t_1
// RUN: %clangxx_nsan -O0 -DHEAP_ADDRESS=$(%run %t_1) %s -o %t_2 && %run %t_2
// RUN: %run %t_1 > %t.heap_address
// RUN: %clangxx_nsan -O0 -DHEAP_ADDRESS=%{readfile:%t.heap_address} %s -o %t_2 && %run %t_2

#include <assert.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/profile/instrprof-hostname.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_profgen -o %t -O3 %s
// RUN: env LLVM_PROFILE_FILE=%h.%t-%h.profraw_%h %run %t
// RUN: %run uname -n > %t.n
// RUN: llvm-profdata merge -o %t.profdata `cat %t.n`.%t-`cat %t.n`.profraw_`cat %t.n`
// RUN: %run uname -n | tr -d '\n' > %t.n
// RUN: llvm-profdata merge -o %t.profdata %{readfile:%t.n}.%t-%{readfile:%t.n}.profraw_%{readfile:%t.n}
// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
// REQUIRES: shell

Expand Down
8 changes: 5 additions & 3 deletions compiler-rt/test/tsan/ignore_lib0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
// RUN: %clangxx_tsan -O1 -fno-builtin %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib0.so
// RUN: %clangxx_tsan -O1 %s -L%t-dir -lignore_lib0 %link_libcxx_tsan -o %t
// RUN: echo running w/o suppressions:
// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP
// RUN: echo -n %t-dir > %t.ld_library_path
// RUN: python -c "if 'LD_LIBRARY_PATH' in __import__('os').environ: print(':' + __import__('os').environ['LD_LIBRARY_PATH'])" | tr -d '\n' >> %t.ld_library_path
// RUN: env LD_LIBRARY_PATH=%{readfile:%t.ld_library_path} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP
// RUN: echo running with suppressions:
// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
// RUN: env LD_LIBRARY_PATH=%{readfile:%t.ld_library_path} %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
// RUN: echo running with generic suppression of noninstrumented code:
// RUN: env LD_LIBRARY_PATH=%t-dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %env_tsan_opts=ignore_noninstrumented_modules=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
// RUN: env LD_LIBRARY_PATH=%{readfile:%t.ld_library_path} %env_tsan_opts=ignore_noninstrumented_modules=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP

// Tests that interceptors coming from a library specified in called_from_lib
// suppression are ignored.
Expand Down
5 changes: 3 additions & 2 deletions compiler-rt/test/xray/TestCases/Posix/fdr-single-thread.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// RUN: %clangxx_xray -g -std=c++11 %s -o %t
// RUN: rm -f fdr-logging-1thr-*
// RUN: XRAY_OPTIONS=XRAY_OPTIONS="verbosity=1 patch_premain=true \
// RUN: env XRAY_OPTIONS=XRAY_OPTIONS="verbosity=1 patch_premain=true \
// RUN: xray_fdr_log=true \
// RUN: xray_fdr_log_func_duration_threshold_us=0 \
// RUN: xray_logfile_base=fdr-logging-1thr-" %run %t 2>&1
// RUN: ls fdr-logging-1thr-* | head -n1 | tr -d '\n' > %t.xray_input
// RUN: %llvm_xray convert --output-format=yaml --symbolize --instr_map=%t \
// RUN: "`ls fdr-logging-1thr-* | head -n1`" | FileCheck %s
// RUN: "%{readfile:%t.xray_input}" | FileCheck %s
// RUN: rm fdr-logging-1thr-*

// UNSUPPORTED: target=arm{{.*}}
Expand Down
26 changes: 19 additions & 7 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,20 +600,31 @@ def executeBuiltinUmask(cmd, shenv):

def executeBuiltinUlimit(cmd, shenv):
"""executeBuiltinUlimit - Change the current limits."""
if os.name != "posix":
try:
# Try importing the resource module (available on POSIX systems) and
# emit an error where it does not exist (e.g., Windows).
import resource
except ImportError:
raise InternalShellError(cmd, "'ulimit' not supported on this system")
if len(cmd.args) != 3:
raise InternalShellError(cmd, "'ulimit' requires two arguments")
try:
new_limit = int(cmd.args[2])
if cmd.args[2] == "unlimited":
new_limit = resource.RLIM_INFINITY
else:
new_limit = int(cmd.args[2])
except ValueError as err:
raise InternalShellError(cmd, "Error: 'ulimit': %s" % str(err))
if cmd.args[1] == "-v":
shenv.ulimit["RLIMIT_AS"] = new_limit * 1024
if new_limit != resource.RLIM_INFINITY:
new_limit = new_limit * 1024
shenv.ulimit["RLIMIT_AS"] = new_limit
elif cmd.args[1] == "-n":
shenv.ulimit["RLIMIT_NOFILE"] = new_limit
elif cmd.args[1] == "-s":
shenv.ulimit["RLIMIT_STACK"] = new_limit * 1024
if new_limit != resource.RLIM_INFINITY:
new_limit = new_limit * 1024
shenv.ulimit["RLIMIT_STACK"] = new_limit
elif cmd.args[1] == "-f":
shenv.ulimit["RLIMIT_FSIZE"] = new_limit
else:
Expand Down Expand Up @@ -815,6 +826,10 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
not_args = []
not_count = 0
not_crash = False

# Expand all late substitutions.
args = _expandLateSubstitutions(j, args, cmd_shenv.cwd)

while True:
if args[0] == "env":
# Create a copy of the global environment and modify it for
Expand Down Expand Up @@ -864,9 +879,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
# Ensure args[0] is hashable.
args[0] = expand_glob(args[0], cmd_shenv.cwd)[0]

# Expand all late substitutions.
args = _expandLateSubstitutions(j, args, cmd_shenv.cwd)

inproc_builtin = inproc_builtins.get(args[0], None)
if inproc_builtin and (args[0] != "echo" or len(cmd.commands) == 1):
# env calling an in-process builtin is useless, so we take the safe
Expand Down
6 changes: 6 additions & 0 deletions llvm/utils/lit/tests/Inputs/shtest-readfile/env.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Tests that readfile works with the env builtin.
# RUN: echo -n "hello" > %t.1
# RUN: env TEST=%{readfile:%t.1} python3 -c "import os; print(os.environ['TEST'])"

## Fail the test so we can assert on the output.
# RUN: not echo return
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# RUN: ulimit -f 5
# RUN: %{python} %S/print_limits.py
# RUN: ulimit -f unlimited
# RUN: %{python} %S/print_limits.py
# Fail the test so that we can assert on the output.
# RUN: not echo return
2 changes: 1 addition & 1 deletion llvm/utils/lit/tests/shtest-readfile-external.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# UNSUPPORTED: system-windows
# RUN: env LIT_USE_INTERNAL_SHELL=0 not %{lit} -a -v %{inputs}/shtest-readfile | FileCheck -match-full-lines -DTEMP_PATH=%S/Inputs/shtest-readfile/Output %s

# CHECK: -- Testing: 4 tests{{.*}}
# CHECK: -- Testing: 5 tests{{.*}}

# CHECK-LABEL: FAIL: shtest-readfile :: absolute-paths.txt ({{[^)]*}})
# CHECK: echo $(cat [[TEMP_PATH]]/absolute-paths.txt.tmp) && test -e [[TEMP_PATH]]/absolute-paths.txt.tmp {{.*}}
Expand Down
6 changes: 5 additions & 1 deletion llvm/utils/lit/tests/shtest-readfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

# RUN: env LIT_USE_INTERNAL_SHELL=1 not %{lit} -a -v %{inputs}/shtest-readfile | FileCheck -match-full-lines -DTEMP_PATH=%S%{fs-sep}Inputs%{fs-sep}shtest-readfile%{fs-sep}Output %s

# CHECK: -- Testing: 4 tests{{.*}}
# CHECK: -- Testing: 5 tests{{.*}}

# CHECK-LABEL: FAIL: shtest-readfile :: absolute-paths.txt ({{[^)]*}})
# CHECK: echo hello
# CHECK: # executed command: echo '%{readfile:[[TEMP_PATH]]{{[\\\/]}}absolute-paths.txt.tmp}'

# CHECK-LABEL: FAIL: shtest-readfile :: env.txt ({{[^)]*}})
# CHECK: env TEST=hello python3 -c "import os; print(os.environ['TEST'])"
# CHECK: # | hello

# CHECK-LABEL: FAIL: shtest-readfile :: file-does-not-exist.txt ({{[^)]*}})
# CHECK: # executed command: @echo 'echo %{readfile:/file/does/not/exist}'
# CHECK: # | File specified in readfile substitution does not exist: {{.*}}/file/does/not/exist
Expand Down
8 changes: 7 additions & 1 deletion llvm/utils/lit/tests/shtest-ulimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# RUN: not %{lit} -a -v %{inputs}/shtest-ulimit --order=lexical \
# RUN: | FileCheck -DBASE_NOFILE_LIMIT=%{readfile:%t.nofile_limit} %s

# CHECK: -- Testing: 3 tests{{.*}}
# CHECK: -- Testing: 4 tests{{.*}}

# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit-bad-arg.txt ({{[^)]*}})
# CHECK: ulimit -n
Expand All @@ -25,3 +25,9 @@

# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_reset.txt ({{[^)]*}})
# CHECK: RLIMIT_NOFILE=[[BASE_NOFILE_LIMIT]]

# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_unlimited.txt ({{[^)]*}})
# CHECK: ulimit -f 5
# CHECK: RLIMIT_FSIZE=5
# CHECK: ulimit -f unlimited
# CHECK: RLIMIT_FSIZE=-1
Loading