[compiler-rt] [llvm-lit] Fix Command Not Found Errors in compiler-rt when using lit internal shell (PR #102197)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 11:44:36 PDT 2024
https://github.com/Harini0924 created https://github.com/llvm/llvm-project/pull/102197
Resolved Command Not Found Errors in compiler-rt tests. Some tests when using lit's internal shell found command not found errors when calling the `DIR` environment variable. I removed the use of the `DIR` environment variable and simplified the test to directly use `%t_workdir` for managing temporary directories. Also, ensured that the clang command arguments are directly included in the test to avoid issues with environment variable expansion.
>From d36c22eb7662f454400d2d4bf307447bb2139f2e Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Tue, 6 Aug 2024 17:40:13 +0000
Subject: [PATCH] [llvm-lit] Fix Command Not Found Error in compiler-rt
(internal shell)
Resolved Command Not Found Errors in compiler-rt tests. Some tests when using
lit's internal shell found command not found error when calling `DIR`
environment variable. I removed the use of the `DIR` enviornment
variable to prevent command no found errors. Simplified the test to
directly use `%t_workdir` for managing temporary directories.
---
.../sanitizer_coverage_allowlist_ignorelist.cpp | 9 ++++-----
.../TestCases/sanitizer_coverage_symbolize.cpp | 9 ++++-----
.../sanitizer_coverage_trace_pc_guard-dso.cpp | 16 +++++++---------
.../sanitizer_coverage_trace_pc_guard-init.cpp | 16 +++++++---------
.../sanitizer_coverage_trace_pc_guard.cpp | 9 ++++-----
5 files changed, 26 insertions(+), 33 deletions(-)
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 2fbace52696a9..6fdd23b84432f 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 b168954a1c92c..ba59e28f688a7 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 e27d552f3c318..9a27bc89a5fae 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 0b2da9aebac8e..cd5ea30713a57 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 eea92d0ba9e83..b4b491455c390 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