Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions compiler-rt/test/fuzzer/merge-posix.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ RUN: echo ....U. > %tmp/T2/2
RUN: echo ...Z.. > %tmp/T2/3
RUN: echo ...Z.. > %tmp/T2/4
RUN: echo ....E. > %tmp/T2/5
RUN: echo .....R > %tmp/T2/6
RUN: %python -c "print('.....R' + 'X' * 4096, end='')" > %tmp/T2/6

# Check that we can report an error if file size exceeded
RUN: (ulimit -f 1; not %run %t-FullCoverageSetTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=SIGXFSZ)
RUN: (ulimit -f 4; not %run %t-FullCoverageSetTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=SIGXFSZ)
SIGXFSZ: ERROR: libFuzzer: file size exceeded

# Check that we honor TMPDIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
#include <assert.h>
#include <spawn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>

extern char **environ;

int main(int argc, char **argv) {
if (argc > 1) {
// CHECK: SPAWNED
Expand All @@ -23,11 +27,22 @@ int main(int argc, char **argv) {
argv[0], "2", "3", "4", "2", "3", "4", "2", "3", "4",
"2", "3", "4", "2", "3", "4", "2", "3", "4", NULL,
};
char *const env[] = {
char *env[] = {
"A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B",
"A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", "A=B", NULL,
};

// When this test runs with a runtime (e.g. ASAN), the spawned process needs
// to use the same runtime search path as the parent. Otherwise, it might
// try to load a runtime that doesn't work and crash before hitting main(),
// failing the test. We technically should forward the variable for the
// current platform, but some platforms have multiple such variables and
// it's quite difficult to plumb this through the lit config.
for (char **e = environ; *e; e++)
if (strncmp(*e, "DYLD_LIBRARY_PATH=", sizeof("DYLD_LIBRARY_PATH=") - 1) ==
0)
env[0] = *e;

pid_t pid;
int s = posix_spawn(&pid, argv[0], &file_actions, &attr, args, env);
assert(!s);
Expand Down
6 changes: 5 additions & 1 deletion llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,8 @@ def executeScriptInternal(
results = []
timeoutInfo = None
shenv = ShellEnvironment(cwd, test.config.environment)
shenv.env["LIT_CURRENT_TESTCASE"] = test.getFullName()

exitCode, timeoutInfo = executeShCmd(
cmd, shenv, results, timeout=litConfig.maxIndividualTestTime
)
Expand Down Expand Up @@ -1323,11 +1325,13 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
# run on clang with no real loss.
command = litConfig.valgrindArgs + command

env = dict(test.config.environment)
env["LIT_CURRENT_TESTCASE"] = test.getFullName()
try:
out, err, exitCode = lit.util.executeCommand(
command,
cwd=cwd,
env=test.config.environment,
env=env,
timeout=litConfig.maxIndividualTestTime,
)
return (out, err, exitCode, None)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Tests that the LIT_CURRENT_TESTCASE variable is set to the name of the currently executing testcase

## Check default environment.
# RUN: bash -c 'echo $LIT_CURRENT_TESTCASE' | FileCheck --match-full-lines %s
#
# CHECK: shtest-env :: env-current-testcase.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Tests the env command in various scenarios: without arguments, setting, unsetting, and mixing envrionment variables.
# FIXME: All of these tests are broken and will not even call FileCheck.

## Check default environment.
# RUN: env | FileCheck -check-prefix=NO-ARGS %s
Expand Down
11 changes: 8 additions & 3 deletions llvm/utils/lit/tests/shtest-env-positive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Test the env command's successful executions.

# CHECK: -- Testing: 9 tests{{.*}}
# CHECK: -- Testing: 10 tests{{.*}}

# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
# CHECK: env FOO=1
Expand Down Expand Up @@ -39,6 +39,11 @@
# CHECK-NOT: # error:
# CHECK: --

# CHECK: PASS: shtest-env :: env-current-testcase.txt ({{[^)]*}})
# CHECK: # executed command: bash -c 'echo $LIT_CURRENT_TESTCASE'
# CHECK-NOT: # error:
# CHECK: --

# CHECK: PASS: shtest-env :: env-no-subcommand.txt ({{[^)]*}})
# CHECK: env | {{.*}}
# CHECK: # executed command: env
Expand All @@ -65,6 +70,6 @@
# CHECK-NOT: # error:
# CHECK: --

# CHECK: Total Discovered Tests: 9
# CHECK: Passed: 9 {{\([0-9]*\.[0-9]*%\)}}
# CHECK: Total Discovered Tests: 10
# CHECK: Passed: 10 {{\([0-9]*\.[0-9]*%\)}}
# CHECK-NOT: {{.}}