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