xref: /minix3/external/bsd/llvm/dist/clang/test/Modules/system_version.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc// Test checking that we're hashing a system version file in the
2f4a2713aSLionel Sambuc// module hash.
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc// First, build a system root.
5f4a2713aSLionel Sambuc// RUN: rm -rf %t
6f4a2713aSLionel Sambuc// RUN: mkdir -p %t/usr/include
7f4a2713aSLionel Sambuc// RUN: cp %S/Inputs/Modified/A.h %t/usr/include
8f4a2713aSLionel Sambuc// RUN: cp %S/Inputs/Modified/B.h %t/usr/include
9f4a2713aSLionel Sambuc// RUN: cp %S/Inputs/Modified/module.map %t/usr/include
10f4a2713aSLionel Sambuc
11f4a2713aSLionel Sambuc// Run once with no system version file. We should end up with one module.
12f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify
13*0a6a1f1dSLionel Sambuc// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 1
14f4a2713aSLionel Sambuc
15f4a2713aSLionel Sambuc// Add a system version file and run again. We should now have two
16f4a2713aSLionel Sambuc// module variants.
17f4a2713aSLionel Sambuc// RUN: mkdir -p %t/System/Library/CoreServices
18f4a2713aSLionel Sambuc// RUN: echo "hello" > %t/System/Library/CoreServices/SystemVersion.plist
19f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify
20*0a6a1f1dSLionel Sambuc// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 2
21f4a2713aSLionel Sambuc
22f4a2713aSLionel Sambuc// Change the system version file and run again. We should now have three
23f4a2713aSLionel Sambuc// module variants.
24f4a2713aSLionel Sambuc// RUN: mkdir -p %t/System/Library/CoreServices
25f4a2713aSLionel Sambuc// RUN: echo "modules" > %t/System/Library/CoreServices/SystemVersion.plist
26f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify
27*0a6a1f1dSLionel Sambuc// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 3
28f4a2713aSLionel Sambuc
29f4a2713aSLionel Sambuc// expected-no-diagnostics
30f4a2713aSLionel Sambuc@import ModA;
31f4a2713aSLionel Sambuc
32