1; RUN: opt -module-hash -module-summary %s -o %t.o
2; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
3; NetBSD: noatime mounts currently inhibit 'touch' from updating atime
4; Windows: no 'touch' command.
5; UNSUPPORTED: system-netbsd, system-windows
6
7; RUN: rm -Rf %t.cache && mkdir %t.cache
8; Create two files that would be removed by cache pruning due to age.
9; We should only remove files matching the pattern "llvmcache-*".
10; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo
11; RUN: wasm-ld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=1h:prune_interval=0s -o %t.wasm %t2.o %t.o
12
13; Two cached objects, plus a timestamp file and "foo", minus the file we removed.
14; RUN: ls %t.cache | count 4
15
16; Create a file of size 64KB.
17; RUN: %python -c "print(' ' * 65536)" > %t.cache/llvmcache-foo
18
19; This should leave the file in place.
20; RUN: wasm-ld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=128k:prune_interval=0s -o %t.wasm %t2.o %t.o
21; RUN: ls %t.cache | count 5
22
23; Increase the age of llvmcache-foo, which will give it the oldest time stamp
24; so that it is processed and removed first.
25; RUN: %python -c 'import os,sys,time; t=time.time()-120; os.utime(sys.argv[1],(t,t))' %t.cache/llvmcache-foo
26
27; This should remove it.
28; RUN: wasm-ld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=32k:prune_interval=0s -o %t.wasm %t2.o %t.o
29; RUN: ls %t.cache | count 4
30
31; Setting max number of files to 0 should disable the limit, not delete everything.
32; RUN: wasm-ld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=0:prune_interval=0s -o %t.wasm %t2.o %t.o
33; RUN: ls %t.cache | count 4
34
35; Delete everything except for the timestamp, "foo" and one cache file.
36; RUN: wasm-ld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=1:prune_interval=0s -o %t.wasm %t2.o %t.o
37; RUN: ls %t.cache | count 3
38
39target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
40target triple = "wasm32-unknown-unknown-wasm"
41
42define void @globalfunc() #0 {
43entry:
44  ret void
45}
46