Debian Codegraph @

clang/test/Misc/dev-fd-fs.c

raw
1 // Check that we can operate on files from /dev/fd.
2 // REQUIRES: dev-fd-fs
3
4 // Check reading from named pipes. We cat the input here instead of redirecting
5 // it to ensure that /dev/fd/0 is a named pipe, not just a redirected file.
6 //
7 // RUN: cat %s | %clang -x c /dev/fd/0 -E > %t
8 // RUN: FileCheck --check-prefix DEV-FD-INPUT < %t %s
9 //
10 // RUN: cat %s | %clang -x c %s -E -DINCLUDE_FROM_STDIN > %t
11 // RUN: FileCheck --check-prefix DEV-FD-INPUT \
12 // RUN: --check-prefix DEV-FD-INPUT-INCLUDE < %t %s
13 //
14 // DEV-FD-INPUT-INCLUDE: int w;
15 // DEV-FD-INPUT: int x;
16 // DEV-FD-INPUT-INCLUDE: int y;
17
18
19 // Check writing to /dev/fd named pipes. We use cat here as before to ensure we
20 // get a named pipe.
21 //
22 // RUN: %clang -x c %s -E -o /dev/fd/1 | cat > %t
23 // RUN: FileCheck --check-prefix DEV-FD-FIFO-OUTPUT < %t %s
24 //
25 // DEV-FD-FIFO-OUTPUT: int x;
26
27
28 // Check writing to /dev/fd regular files.
29 //
30 // RUN: %clang -x c %s -E -o /dev/fd/1 > %t
31 // RUN: FileCheck --check-prefix DEV-FD-REG-OUTPUT < %t %s
32 //
33 // DEV-FD-REG-OUTPUT: int x;
34
35 #ifdef INCLUDE_FROM_STDIN
36 #undef INCLUDE_FROM_STDIN
37 int w;
38 #include "/dev/fd/0"
39 int y;
40 #else
41 int x;
42 #endif