blob: 7c462e20fcef9265bfc15b700d943794d488a6a0 [file] [log] [blame]
Michal Gorny29935ac2018-12-05 11:17:50 +00001// NetBSD: noatime mounts currently inhibit 'touch -a' updates
2// UNSUPPORTED: system-netbsd
3
Douglas Gregor527b1c92013-03-25 21:19:16 +00004// Test the automatic pruning of module cache entries.
5#ifdef IMPORT_DEPENDS_ON_MODULE
6@import DependsOnModule;
7#else
8@import Module;
9#endif
10
Douglas Gregor527b1c92013-03-25 21:19:16 +000011// Clear out the module cache
12// RUN: rm -rf %t
13// Run Clang twice so we end up creating the timestamp file (the second time).
Bruno Cardoso Lopes297299192017-12-22 02:53:30 +000014// RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -Wno-private-module -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -fimplicit-module-maps -F %S/Inputs -fmodules-cache-path=%t %s -verify
15// RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -Wno-private-module -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -fimplicit-module-maps -F %S/Inputs -fmodules-cache-path=%t %s -verify
Douglas Gregor527b1c92013-03-25 21:19:16 +000016// RUN: ls %t | grep modules.timestamp
Ben Langmuirbeee15e2014-04-14 18:00:01 +000017// RUN: ls -R %t | grep ^Module.*pcm
18// RUN: ls -R %t | grep DependsOnModule.*pcm
Douglas Gregor527b1c92013-03-25 21:19:16 +000019
20// Set the timestamp back more than two days. We should try to prune,
21// but nothing gets pruned because the module files are new enough.
Douglas Gregor1f37ddd2013-03-25 21:27:57 +000022// RUN: touch -m -a -t 201101010000 %t/modules.timestamp
Bruno Cardoso Lopes297299192017-12-22 02:53:30 +000023// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -Wno-private-module -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
Douglas Gregor527b1c92013-03-25 21:19:16 +000024// RUN: ls %t | grep modules.timestamp
Ben Langmuirbeee15e2014-04-14 18:00:01 +000025// RUN: ls -R %t | grep ^Module.*pcm
26// RUN: ls -R %t | grep DependsOnModule.*pcm
Douglas Gregor527b1c92013-03-25 21:19:16 +000027
28// Set the DependsOnModule access time back more than four days.
29// This shouldn't prune anything, because the timestamp has been updated, so
30// the pruning mechanism won't fire.
Reid Kleckner2e1538f2016-10-20 23:11:45 +000031// RUN: find %t -name DependsOnModule*.pcm | sed -e 's/\\/\//g' | xargs touch -a -t 201101010000
Bruno Cardoso Lopes297299192017-12-22 02:53:30 +000032// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -F %S/Inputs -Wno-private-module -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
Douglas Gregor527b1c92013-03-25 21:19:16 +000033// RUN: ls %t | grep modules.timestamp
Ben Langmuirbeee15e2014-04-14 18:00:01 +000034// RUN: ls -R %t | grep ^Module.*pcm
35// RUN: ls -R %t | grep DependsOnModule.*pcm
Douglas Gregor527b1c92013-03-25 21:19:16 +000036
37// Set both timestamp and DependsOnModule.pcm back beyond the cutoff.
38// This should trigger pruning, which will remove DependsOnModule but not Module.
Douglas Gregor1f37ddd2013-03-25 21:27:57 +000039// RUN: touch -m -a -t 201101010000 %t/modules.timestamp
Reid Kleckner2e1538f2016-10-20 23:11:45 +000040// RUN: find %t -name DependsOnModule*.pcm | sed -e 's/\\/\//g' | xargs touch -a -t 201101010000
Bruno Cardoso Lopes297299192017-12-22 02:53:30 +000041// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -F %S/Inputs -Wno-private-module -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify
Douglas Gregor527b1c92013-03-25 21:19:16 +000042// RUN: ls %t | grep modules.timestamp
Ben Langmuirbeee15e2014-04-14 18:00:01 +000043// RUN: ls -R %t | grep ^Module.*pcm
44// RUN: ls -R %t | not grep DependsOnModule.*pcm
Douglas Gregor527b1c92013-03-25 21:19:16 +000045
46// expected-no-diagnostics