43 lines · c
1// Check that we can operate on files from /dev/fd.2// REQUIRES: dev-fd-fs3 4// Check reading from named pipes. We cat the input here instead of redirecting5// 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 > %t8// RUN: FileCheck --check-prefix DEV-FD-INPUT < %t %s9//10// RUN: cat %s | %clang -x c %s -E -DINCLUDE_FROM_STDIN > %t11// RUN: FileCheck --check-prefix DEV-FD-INPUT \12// RUN: --check-prefix DEV-FD-INPUT-INCLUDE < %t %s13//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 we20// get a named pipe.21//22// RUN: %clang -x c %s -E -o /dev/fd/1 | cat > %t23// RUN: FileCheck --check-prefix DEV-FD-FIFO-OUTPUT < %t %s24//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 > %t31// RUN: FileCheck --check-prefix DEV-FD-REG-OUTPUT < %t %s32//33// DEV-FD-REG-OUTPUT: int x;34 35#ifdef INCLUDE_FROM_STDIN36#undef INCLUDE_FROM_STDIN37int w;38#include "/dev/fd/0"39int y;40#else41int x;42#endif43