152385592SDaniel Dunbar // Check that we can operate on files from /dev/fd. 252385592SDaniel Dunbar // REQUIRES: dev-fd-fs 37f2b79e4SDavid Blaikie // REQUIRES: shell 452385592SDaniel Dunbar 552385592SDaniel Dunbar // Check reading from named pipes. We cat the input here instead of redirecting 652385592SDaniel Dunbar // it to ensure that /dev/fd/0 is a named pipe, not just a redirected file. 752385592SDaniel Dunbar // 852385592SDaniel Dunbar // RUN: cat %s | %clang -x c /dev/fd/0 -E > %t 952385592SDaniel Dunbar // RUN: FileCheck --check-prefix DEV-FD-INPUT < %t %s 10d9cb0ba6SDaniel Dunbar // 11*245218bbSDuncan P. N. Exon Smith // RUN: cat %s | %clang -x c %s -E -DINCLUDE_FROM_STDIN > %t 12*245218bbSDuncan P. N. Exon Smith // RUN: FileCheck --check-prefix DEV-FD-INPUT \ 13*245218bbSDuncan P. N. Exon Smith // RUN: --check-prefix DEV-FD-INPUT-INCLUDE < %t %s 14*245218bbSDuncan P. N. Exon Smith // 15*245218bbSDuncan P. N. Exon Smith // DEV-FD-INPUT-INCLUDE: int w; 1652385592SDaniel Dunbar // DEV-FD-INPUT: int x; 17*245218bbSDuncan P. N. Exon Smith // DEV-FD-INPUT-INCLUDE: int y; 18d9cb0ba6SDaniel Dunbar 19d9cb0ba6SDaniel Dunbar 20d9cb0ba6SDaniel Dunbar // Check writing to /dev/fd named pipes. We use cat here as before to ensure we 21d9cb0ba6SDaniel Dunbar // get a named pipe. 22d9cb0ba6SDaniel Dunbar // 23d9cb0ba6SDaniel Dunbar // RUN: %clang -x c %s -E -o /dev/fd/1 | cat > %t 24d9cb0ba6SDaniel Dunbar // RUN: FileCheck --check-prefix DEV-FD-FIFO-OUTPUT < %t %s 25d9cb0ba6SDaniel Dunbar // 26d9cb0ba6SDaniel Dunbar // DEV-FD-FIFO-OUTPUT: int x; 27d9cb0ba6SDaniel Dunbar 28d9cb0ba6SDaniel Dunbar 29d9cb0ba6SDaniel Dunbar // Check writing to /dev/fd regular files. 30d9cb0ba6SDaniel Dunbar // 31d9cb0ba6SDaniel Dunbar // RUN: %clang -x c %s -E -o /dev/fd/1 > %t 32d9cb0ba6SDaniel Dunbar // RUN: FileCheck --check-prefix DEV-FD-REG-OUTPUT < %t %s 33d9cb0ba6SDaniel Dunbar // 34d9cb0ba6SDaniel Dunbar // DEV-FD-REG-OUTPUT: int x; 35d9cb0ba6SDaniel Dunbar 36*245218bbSDuncan P. N. Exon Smith #ifdef INCLUDE_FROM_STDIN 37*245218bbSDuncan P. N. Exon Smith #undef INCLUDE_FROM_STDIN 38*245218bbSDuncan P. N. Exon Smith int w; 39*245218bbSDuncan P. N. Exon Smith #include "/dev/fd/0" 40*245218bbSDuncan P. N. Exon Smith int y; 41*245218bbSDuncan P. N. Exon Smith #else 4252385592SDaniel Dunbar int x; 43*245218bbSDuncan P. N. Exon Smith #endif 44