xref: /aosp_15_r20/external/clang/test/Misc/dev-fd-fs.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Check that we can operate on files from /dev/fd.
2*67e74705SXin Li // REQUIRES: dev-fd-fs
3*67e74705SXin Li 
4*67e74705SXin Li // Check reading from named pipes. We cat the input here instead of redirecting
5*67e74705SXin Li // it to ensure that /dev/fd/0 is a named pipe, not just a redirected file.
6*67e74705SXin Li //
7*67e74705SXin Li // RUN: cat %s | %clang -x c /dev/fd/0 -E > %t
8*67e74705SXin Li // RUN: FileCheck --check-prefix DEV-FD-INPUT < %t %s
9*67e74705SXin Li //
10*67e74705SXin Li // DEV-FD-INPUT: int x;
11*67e74705SXin Li 
12*67e74705SXin Li 
13*67e74705SXin Li // Check writing to /dev/fd named pipes. We use cat here as before to ensure we
14*67e74705SXin Li // get a named pipe.
15*67e74705SXin Li //
16*67e74705SXin Li // RUN: %clang -x c %s -E -o /dev/fd/1 | cat > %t
17*67e74705SXin Li // RUN: FileCheck --check-prefix DEV-FD-FIFO-OUTPUT < %t %s
18*67e74705SXin Li //
19*67e74705SXin Li // DEV-FD-FIFO-OUTPUT: int x;
20*67e74705SXin Li 
21*67e74705SXin Li 
22*67e74705SXin Li // Check writing to /dev/fd regular files.
23*67e74705SXin Li //
24*67e74705SXin Li // RUN: %clang -x c %s -E -o /dev/fd/1 > %t
25*67e74705SXin Li // RUN: FileCheck --check-prefix DEV-FD-REG-OUTPUT < %t %s
26*67e74705SXin Li //
27*67e74705SXin Li // DEV-FD-REG-OUTPUT: int x;
28*67e74705SXin Li 
29*67e74705SXin Li int x;
30