Debian Codegraph @

clang/test/PCH/leakfiles.test

raw
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 uses ulimit.
5 // UNSUPPORTED: system-windows
6 //
7 // Set up source files. lib/lib.h includes lots of lib*.h files in that dir.
8 // client.c includes lib/lib.h, and also the individual files directly.
9 //
10 // RUN: rm -rf %t
11 // RUN: mkdir %t
12 // RUN: cd %t
13 // RUN: mkdir lib
14 // RUN: %python -c "from pathlib import Path; list(map(lambda i: Path(f'lib/lib{i}.h').touch(), range(1, 301)))"
15 // RUN: %python -c "for i in range(1, 301): print(f'#include \"lib{i}.h\"')" > lib/lib.h
16 // RUN: echo "#include \"lib/lib.h\"" > client.c
17 // RUN: %python -c "for i in range(1, 301): print(f'#include \"lib/lib{i}.h\"')" > client.c
18 //
19 // We want to verify that we don't hold all the files open at the same time.
20 // This is important e.g. on mac, which has a low default FD limit.
21 // RUN: ulimit -n 100
22 //
23 // Test without PCH.
24 // RUN: %clang_cc1 -fsyntax-only -Ilib/ client.c
25 //
26 // Test with PCH.
27 // RUN: %clang_cc1 -emit-pch -o pch -Ilib/ client.c
28 // RUN: %clang_cc1 -include-pch pch -Ilib/ client.c -fsyntax-only