Skip to content

Commit 303bea8

Browse files
[lld] Make cache-warning* tests work with internal shell
These tests were using subexpressions to change the cache size. Change them up to write out the necessary commands to a response file and then load that on the lld command line. Towards #102700. Reviewers: ilovepi, cmtice, mysterymath, MaskRay, petrhosek Reviewed By: MaskRay Pull Request: #156537
1 parent 9c7727c commit 303bea8

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

lld/test/COFF/lto-cache-warnings.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; REQUIRES: x86, shell
1+
; REQUIRES: x86
22

33
; RUN: opt -module-hash -module-summary %s -o %t.o
44
; RUN: opt -module-hash -module-summary %p/Inputs/lto-cache.ll -o %t2.o
@@ -20,13 +20,17 @@
2020
;; Get the total size of created cache files.
2121
; RUN: rm -rf %t && mkdir %t && cd %t
2222
; RUN: lld-link /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_bytes=32k /out:%t3 /entry:main %t2.o %t.o 2>&1
23-
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
23+
; RUN: %python -c "import os, sys; size=sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')); print(size+5); print(size-5)" > %t.size.txt
2424

2525
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
26-
; RUN: lld-link /verbose /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --implicit-check-not=warning:
26+
; RUN: echo -n "/lldltocachepolicy:prune_interval=0s:cache_size_bytes=" > %t.response
27+
; RUN: head -1 %t.size.txt >> %t.response
28+
; RUN: lld-link /verbose /lldltocache:%t @%t.response /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --implicit-check-not=warning:
2729

2830
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
29-
; RUN: lld-link /verbose /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --check-prefix=SIZE
31+
; RUN: echo -n "/lldltocachepolicy:prune_interval=0s:cache_size_bytes=" > %t.response
32+
; RUN: tail -1 %t.size.txt >> %t.response
33+
; RUN: lld-link /verbose /lldltocache:%t @%t.response /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --check-prefix=SIZE
3034

3135
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
3236
; RUN: lld-link /lldltocache:%t /lldltocachepolicy:prune_interval=0s:cache_size_files=1:cache_size_bytes=1 /out:%t3 /entry:main %t2.o %t.o 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE

lld/test/ELF/lto/cache-warnings.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; REQUIRES: x86, shell
1+
; REQUIRES: x86
22
; UNSUPPORTED: main-run-twice
33

44
; RUN: opt -module-hash -module-summary %s -o %t.o
@@ -21,13 +21,17 @@
2121
;; Get the total size of created cache files.
2222
; RUN: rm -rf %t && mkdir %t && cd %t
2323
; RUN: ld.lld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=32k %t2.o %t.o -o %t3 2>&1
24-
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
24+
; RUN: %python -c "import os, sys; size=sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')); print(size+5); print(size-5)" > %t.size.txt
2525

2626
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
27-
; RUN: ld.lld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
27+
; RUN: echo -n "--thinlto-cache-policy=prune_interval=0s:cache_size_bytes=" > %t.response
28+
; RUN: head -1 %t.size.txt >> %t.response
29+
; RUN: ld.lld --verbose --thinlto-cache-dir=%t @%t.response %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
2830

2931
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
30-
; RUN: ld.lld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
32+
; RUN: echo -n "--thinlto-cache-policy=prune_interval=0s:cache_size_bytes=" > %t.response
33+
; RUN: tail -1 %t.size.txt >> %t.response
34+
; RUN: ld.lld --verbose --thinlto-cache-dir=%t @%t.response %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
3135

3236
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
3337
; RUN: ld.lld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1:cache_size_bytes=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE,WARN

lld/test/MachO/lto-cache-warnings.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; REQUIRES: x86, shell
1+
; REQUIRES: x86
22

33
; RUN: rm -rf %t; split-file %s %t
44
; RUN: opt -module-hash -module-summary %t/foo.ll -o %t/foo.o
@@ -19,13 +19,17 @@
1919
;; Get the total size of created cache files.
2020
; RUN: cd %t
2121
; RUN: %lld -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=32k %t/foo.o %t/bar.o -o %t/test 2>&1
22-
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
22+
; RUN: %python -c "import os, sys; size=sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')); print(size+5); print(size-5)" > %t.size.txt
2323

2424
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
25-
; RUN: %lld -v -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --implicit-check-not=warning:
25+
; RUN: echo -n "--thinlto-cache-policy=prune_interval=0s:cache_size_bytes=" > %t.response
26+
; RUN: head -1 %t.size.txt >> %t.response
27+
; RUN: %lld -v -cache_path_lto %t @%t.response %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --implicit-check-not=warning:
2628

2729
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
28-
; RUN: %lld -v -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
30+
; RUN: echo -n "--thinlto-cache-policy=prune_interval=0s:cache_size_bytes=" > %t.response
31+
; RUN: tail -1 %t.size.txt >> %t.response
32+
; RUN: %lld -v -cache_path_lto %t @%t.response %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
2933

3034
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
3135
; RUN: %lld -cache_path_lto %t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1:cache_size_bytes=1 %t/foo.o %t/bar.o -o %t/test 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE,WARN

lld/test/wasm/lto/cache-warnings.ll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
; REQUIRES: shell
2-
31
; RUN: opt -module-hash -module-summary %s -o %t.o
42
; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
53

@@ -20,13 +18,17 @@
2018
;; Get the total size of created cache files.
2119
; RUN: rm -rf %t && mkdir %t && cd %t
2220
; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=32k %t2.o %t.o -o %t3 2>&1
23-
; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt
21+
; RUN: %python -c "import os, sys; size=sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')); print(size+5); print(size-5)" > %t.size.txt
2422

2523
;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning.
26-
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
24+
; RUN: echo -n "--thinlto-cache-policy=prune_interval=0s:cache_size_bytes=" > %t.response
25+
; RUN: head -1 %t.size.txt >> %t.response
26+
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t @%t.response %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning:
2727

2828
;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given.
29-
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
29+
; RUN: echo -n "--thinlto-cache-policy=prune_interval=0s:cache_size_bytes=" > %t.response
30+
; RUN: tail -1 %t.size.txt >> %t.response
31+
; RUN: wasm-ld --verbose --thinlto-cache-dir=%t @%t.response %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN
3032

3133
;; Check emit two warnings if pruning happens due to reach both the size and number limits.
3234
; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1:cache_size_bytes=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE,WARN

0 commit comments

Comments
 (0)