[clang] 7e77353 - [clang][test] Avoid writing to a potentially write-protected dir (#96457)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 25 12:28:00 PDT 2024
Author: Karl-Johan Karlsson
Date: 2024-06-25T21:27:57+02:00
New Revision: 7e77353db6984b2bf07f54fd0ef5f56bf1aa8244
URL: https://github.com/llvm/llvm-project/commit/7e77353db6984b2bf07f54fd0ef5f56bf1aa8244
DIFF: https://github.com/llvm/llvm-project/commit/7e77353db6984b2bf07f54fd0ef5f56bf1aa8244.diff
LOG: [clang][test] Avoid writing to a potentially write-protected dir (#96457)
The test clang/test/Preprocessor/embed_weird.cpp creates a file directly
in the Inputs dir in the llvm-project repo instead of the temporary
directory. The llvm-project repo may be write protected e.g. in a
sandboxed environment.
This patch creates a separate temporary directory where the
null_byte.bin file is created along with the rest of copies of the other
embed-files needed for the testcase.
Added:
Modified:
clang/test/Preprocessor/embed_weird.cpp
Removed:
################################################################################
diff --git a/clang/test/Preprocessor/embed_weird.cpp b/clang/test/Preprocessor/embed_weird.cpp
index a90d3bc330538..31b622c848d6a 100644
--- a/clang/test/Preprocessor/embed_weird.cpp
+++ b/clang/test/Preprocessor/embed_weird.cpp
@@ -1,7 +1,9 @@
-// RUN: printf "\0" > %S/Inputs/null_byte.bin
-// RUN: %clang_cc1 %s -fsyntax-only --embed-dir=%S/Inputs -verify=expected,cxx -Wno-c23-extensions
-// RUN: %clang_cc1 -x c -std=c23 %s -fsyntax-only --embed-dir=%S/Inputs -verify=expected,c
-// RUN: rm %S/Inputs/null_byte.bin
+// RUN: rm -rf %t && mkdir -p %t/media
+// RUN: cp %S/Inputs/single_byte.txt %S/Inputs/jk.txt %S/Inputs/numbers.txt %t/
+// RUN: cp %S/Inputs/media/empty %t/media/
+// RUN: printf "\0" > %t/null_byte.bin
+// RUN: %clang_cc1 %s -fsyntax-only --embed-dir=%t -verify=expected,cxx -Wno-c23-extensions
+// RUN: %clang_cc1 -x c -std=c23 %s -fsyntax-only --embed-dir=%t -verify=expected,c
#embed <media/empty>
;
More information about the cfe-commits
mailing list