[compiler-rt] c69b8c4 - [compiler-rt][NFC] Replace environment variable with %t (#102197)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 14:56:55 PDT 2024
Author: Harini0924
Date: 2024-08-09T14:56:52-07:00
New Revision: c69b8c445a6b7efd29e67b665adaf04575f3ed92
URL: https://github.com/llvm/llvm-project/commit/c69b8c445a6b7efd29e67b665adaf04575f3ed92
DIFF: https://github.com/llvm/llvm-project/commit/c69b8c445a6b7efd29e67b665adaf04575f3ed92.diff
LOG: [compiler-rt][NFC] Replace environment variable with %t (#102197)
Certain tests within the compiler-rt subproject encountered "command not
found" errors when using lit's internal shell, particularly when trying
to use the `DIR` environment variable. When checking with the command
`LIT_USE_INTERNAL_SHELL=1 ninja check-compiler-rt`, I encountered the
following error:
```
********************
Testing:
FAIL: SanitizerCommon-ubsan-i386-Linux :: sanitizer_coverage_trace_pc_guard-init.cpp (146 of 9570)
******************** TEST 'SanitizerCommon-ubsan-i386-Linux :: sanitizer_coverage_trace_pc_guard-init.cpp' FAILED ********************
Exit Code: 127
Command Output (stdout):
--
# RUN: at line 5
DIR=/usr/local/google/home/harinidonthula/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/ubsan-i386-Linux/Output/sanitizer_coverage_trace_pc_guard-init.cpp.tmp_workdir
# executed command: DIR=/usr/local/google/home/harinidonthula/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/ubsan-i386-Linux/Output/sanitizer_coverage_trace_pc_guard-init.cpp.tmp_workdir
# .---command stderr------------
# | 'DIR=/usr/local/google/home/harinidonthula/llvm-project/build/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/ubsan-i386-Linux/Output/sanitizer_coverage_trace_pc_guard-init.cpp.tmp_workdir': command not found
# `-----------------------------
# error: command failed with exit status: 127
```
In this patch, I resolved these issues by removing the use of the `DIR`
environment variable. Instead, the tests now directly utilize
`%t_workdir` for managing temporary directories. Additionally, I
simplified the tests by embedding the clang command arguments directly
into the test scripts, which avoids complications with environment
variable expansion under lit's internal shell.
This fix ensures that the tests run smoothly with lit's internal shell
and prevents the "command not found" errors, improving the reliability
of the test suite when executed in this environment.
fixes: #102395
[link to
RFC](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
Added:
Modified:
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cpp
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cpp
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp
index 2fbace52696a9e..6fdd23b84432f9 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp
@@ -7,10 +7,9 @@
// XFAIL: ubsan,tsan
// XFAIL: android && asan
-// RUN: DIR=%t_workdir
-// RUN: rm -rf $DIR
-// RUN: mkdir -p $DIR
-// RUN: cd $DIR
+// RUN: rm -rf %t_workdir
+// RUN: mkdir -p %t_workdir
+// RUN: cd %t_workdir
// RUN: echo -e "src:*\nfun:*" > al_all.txt
// RUN: echo -e "" > al_none.txt
@@ -82,7 +81,7 @@
// RUN: %clangxx -O0 %s -S -o - -emit-llvm -fsanitize-coverage=inline-8bit-counters,indirect-calls,trace-cmp,pc-table -fsanitize-coverage-allowlist=al_bar.txt -fsanitize-coverage-ignorelist=bl_bar.txt 2>&1 | not grep -f patterns.txt
// RUN: cd -
-// RUN: rm -rf $DIR
+// RUN: rm -rf %t_workdir
// foo has 3 instrumentation points, 0 indirect call, 1 comparison point
diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cpp
index b168954a1c92cf..ba59e28f688a71 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_symbolize.cpp
@@ -3,15 +3,14 @@
// REQUIRES: x86_64-linux
// XFAIL: tsan
//
-// RUN: DIR=%t_workdir
-// RUN: rm -rf $DIR
-// RUN: mkdir -p $DIR
-// RUN: cd $DIR
+// RUN: rm -rf %t_workdir
+// RUN: mkdir -p %t_workdir
+// RUN: cd %t_workdir
/// In glibc 2.39+, fprintf has a nonnull attribute. Disable nonnull-attribute,
/// which would increase counters for ubsan.
// RUN: %clangxx -O0 -fsanitize-coverage=trace-pc-guard -fno-sanitize=nonnull-attribute %s -o %t
// RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
-// RUN: rm -rf $DIR
+// RUN: rm -rf %t_workdir
#include <stdio.h>
diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cpp
index e27d552f3c3184..9a27bc89a5fae1 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cpp
@@ -5,19 +5,17 @@
// XFAIL: tsan,darwin
// XFAIL: android && asan
-// RUN: DIR=%t_workdir
-// RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
-// RUN: rm -rf $DIR
-// RUN: mkdir -p $DIR
-// RUN: cd $DIR
-// RUN: %clangxx -DSHARED1 $CLANG_ARGS -shared %s -o %t_1.so -fPIC
-// RUN: %clangxx -DSHARED2 $CLANG_ARGS -shared %s -o %t_2.so -fPIC
-// RUN: %clangxx -DMAIN $CLANG_ARGS %s -o %t %t_1.so %t_2.so
+// RUN: rm -rf %t_workdir
+// RUN: mkdir -p %t_workdir
+// RUN: cd %t_workdir
+// RUN: %clangxx -DSHARED1 -O0 -fsanitize-coverage=trace-pc-guard -shared %s -o %t_1.so -fPIC
+// RUN: %clangxx -DSHARED2 -O0 -fsanitize-coverage=trace-pc-guard -shared %s -o %t_2.so -fPIC
+// RUN: %clangxx -DMAIN -O0 -fsanitize-coverage=trace-pc-guard %s -o %t %t_1.so %t_2.so
// RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
// RUN: %sancovcc -covered-functions -strip_path_prefix=TestCases/ *.sancov \
// RUN: %t %t_1.so %t_2.so 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-SANCOV %s
-// RUN: rm -rf $DIR
+// RUN: rm -rf %t_workdir
#include <stdio.h>
diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
index 0b2da9aebac8e2..cd5ea30713a578 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp
@@ -2,16 +2,14 @@
//
// REQUIRES: has_sancovcc,stable-runtime,x86_64-linux
//
-// RUN: DIR=%t_workdir
-// RUN: CLANG_ARGS="-O0 -fsanitize-coverage=trace-pc-guard"
-// RUN: rm -rf $DIR
-// RUN: mkdir -p $DIR
-// RUN: cd $DIR
-// RUN: %clangxx -DSHARED1 $CLANG_ARGS -shared %s -o %t_1.so -fPIC
-// RUN: %clangxx -DSTATIC1 $CLANG_ARGS %s -c -o %t_2.o
-// RUN: %clangxx -DMAIN $CLANG_ARGS %s -o %t %t_1.so %t_2.o
+// RUN: rm -rf %t_workdir
+// RUN: mkdir -p %t_workdir
+// RUN: cd %t_workdir
+// RUN: %clangxx -DSHARED1 -O0 -fsanitize-coverage=trace-pc-guard -shared %s -o %t_1.so -fPIC
+// RUN: %clangxx -DSTATIC1 -O0 -fsanitize-coverage=trace-pc-guard %s -c -o %t_2.o
+// RUN: %clangxx -DMAIN -O0 -fsanitize-coverage=trace-pc-guard %s -o %t %t_1.so %t_2.o
// RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
-// RUN: rm -rf $DIR
+// RUN: rm -rf %t_workdir
#include <stdio.h>
#include <stdint.h>
diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cpp
index eea92d0ba9e838..b4b491455c390a 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cpp
@@ -7,16 +7,15 @@
// XFAIL: tsan
// XFAIL: android && asan
-// RUN: DIR=%t_workdir
-// RUN: rm -rf $DIR
-// RUN: mkdir -p $DIR
-// RUN: cd $DIR
+// RUN: rm -rf %t_workdir
+// RUN: mkdir -p %t_workdir
+// RUN: cd %t_workdir
// RUN: %clangxx -O0 -fsanitize-coverage=trace-pc-guard %s -o %t
// RUN: %env_tool_opts=coverage=1 %t 2>&1 | FileCheck %s
// RUN: %sancovcc -covered-functions -strip_path_prefix=TestCases/ *.sancov %t 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-SANCOV %s
// RUN: %env_tool_opts=coverage=0 %t 2>&1 | FileCheck --check-prefix=CHECK-NOCOV %s
-// RUN: rm -rf $DIR
+// RUN: rm -rf %t_workdir
// Make some room to stabilize line numbers
#include <stdio.h>
More information about the llvm-commits
mailing list