Skip to content

Commit 7e77353

Browse files
authored
[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.
1 parent 8dd9494 commit 7e77353

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

clang/test/Preprocessor/embed_weird.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
// RUN: printf "\0" > %S/Inputs/null_byte.bin
2-
// RUN: %clang_cc1 %s -fsyntax-only --embed-dir=%S/Inputs -verify=expected,cxx -Wno-c23-extensions
3-
// RUN: %clang_cc1 -x c -std=c23 %s -fsyntax-only --embed-dir=%S/Inputs -verify=expected,c
4-
// RUN: rm %S/Inputs/null_byte.bin
1+
// RUN: rm -rf %t && mkdir -p %t/media
2+
// RUN: cp %S/Inputs/single_byte.txt %S/Inputs/jk.txt %S/Inputs/numbers.txt %t/
3+
// RUN: cp %S/Inputs/media/empty %t/media/
4+
// RUN: printf "\0" > %t/null_byte.bin
5+
// RUN: %clang_cc1 %s -fsyntax-only --embed-dir=%t -verify=expected,cxx -Wno-c23-extensions
6+
// RUN: %clang_cc1 -x c -std=c23 %s -fsyntax-only --embed-dir=%t -verify=expected,c
57
#embed <media/empty>
68
;
79

0 commit comments

Comments
 (0)