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