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