https://github.com/karka228 created https://github.com/llvm/llvm-project/pull/96457
The test clang/test/Preprocessor/embed_weird.cpp create 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 create a separate temporary directory where the the null_byte.bin file is created along with the rest of copies of the other embed-files needed for the testcase. >From abf92edafdaae4b8e39cd11f21c366b8c5afc0d0 Mon Sep 17 00:00:00 2001 From: Karl-Johan Karlsson <karl-johan.karls...@ericsson.com> Date: Mon, 24 Jun 2024 08:49:12 +0200 Subject: [PATCH] [clang][test] Avoid writing to a potentially write-protected dir The test clang/test/Preprocessor/embed_weird.cpp create 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 create a separate temporary directory where the the null_byte.bin file is created along with the rest of copies of the other embed-files needed for the testcase. --- clang/test/Preprocessor/embed_weird.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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> ; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits