| 1 | // Test that compiling using a PCH doesn't leak file descriptors. |
| 2 | // https://bugs.chromium.org/p/chromium/issues/detail?id=924225 |
| 3 | // |
| 4 | // This test requires bash loops and ulimit. |
| 5 | // REQUIRES: shell |
| 6 | // UNSUPPORTED: win32 |
| 7 | // |
| 8 | // Set up source files. lib/lib.h includes lots of lib*.h files in that dir. |
| 9 | // client.c includes lib/lib.h, and also the individual files directly. |
| 10 | // |
| 11 | // RUN: rm -rf %t |
| 12 | // RUN: mkdir %t |
| 13 | // RUN: cd %t |
| 14 | // RUN: mkdir lib |
| 15 | // RUN: for i in {1..300}; do touch lib/lib$i.h; done |
| 16 | // RUN: for i in {1..300}; do echo "#include \"lib$i.h\"" >> lib/lib.h; done |
| 17 | // RUN: echo "#include \"lib/lib.h\"" > client.c |
| 18 | // RUN: for i in {1..300}; do echo "#include \"lib/lib$i.h\"" >> client.c; done |
| 19 | // |
| 20 | // We want to verify that we don't hold all the files open at the same time. |
| 21 | // This is important e.g. on mac, which has a low default FD limit. |
| 22 | // RUN: ulimit -n 100 |
| 23 | // |
| 24 | // Test without PCH. |
| 25 | // RUN: %clang_cc1 -fsyntax-only -Ilib/ client.c |
| 26 | // |
| 27 | // Test with PCH. |
| 28 | // RUN: %clang_cc1 -emit-pch -o pch -Ilib/ client.c |
| 29 | // RUN: %clang_cc1 -include-pch pch -Ilib/ client.c -fsyntax-only |
| 30 | |