From d08105482e1582fcdf96fca8b179439643c40304 Mon Sep 17 00:00:00 2001 From: Andrew Ng Date: Wed, 8 Apr 2020 20:21:16 +0100 Subject: [PATCH] [ELF][test] Improve reproduce tests and enable for Windows This patch changes the reproduce tests so that they no longer extract the "long" paths of the generated reproduce tar archives. This extraction prevented them from being run on Windows due to potential issues relating to the Windows path length limit. This patch also reduces the use of diff in these tests, as this was raised as a performance concern in review D77659 and deemed unnecessary. Differential Revision: https://reviews.llvm.org/D77750 --- lld/test/ELF/reproduce-deplibs.s | 11 ++-- lld/test/ELF/reproduce-error.s | 6 +-- lld/test/ELF/reproduce-linkerscript.s | 13 ++--- lld/test/ELF/reproduce-thin-archive.s | 20 ++++---- lld/test/ELF/reproduce-windows.s | 4 +- lld/test/ELF/reproduce-windows2.s | 5 +- lld/test/ELF/reproduce.s | 96 +++++++++++++++++------------------ 7 files changed, 75 insertions(+), 80 deletions(-) diff --git a/lld/test/ELF/reproduce-deplibs.s b/lld/test/ELF/reproduce-deplibs.s index 612f7802..06c25a2 100644 --- a/lld/test/ELF/reproduce-deplibs.s +++ b/lld/test/ELF/reproduce-deplibs.s @@ -1,8 +1,4 @@ -# REQUIRES: x86, shell - -## The 'shell' requirement is to prevent this test from running by default on -## Windows as the extraction of the tar archive can cause problems related to -## path length limits. +# REQUIRES: x86 # RUN: rm -rf %t.dir # RUN: mkdir -p %t.dir @@ -13,8 +9,9 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o bar.o # RUN: ld.lld bar.o -o /dev/null --reproduce repro.tar -# RUN: tar xf repro.tar -# RUN: cmp foo.a repro/%:t.dir/foo.a +# RUN: tar tf repro.tar | FileCheck -DPATH='%:t.dir' %s + +# CHECK: [[PATH]]/foo.a .globl _start _start: diff --git a/lld/test/ELF/reproduce-error.s b/lld/test/ELF/reproduce-error.s index 3a99815..9fdb879 100644 --- a/lld/test/ELF/reproduce-error.s +++ b/lld/test/ELF/reproduce-error.s @@ -1,6 +1,3 @@ -# REQUIRES: shell -# Extracting the tar archive can get over the path limit on windows. - # RUN: rm -rf %t.dir # RUN: mkdir -p %t.dir # RUN: cd %t.dir @@ -8,7 +5,6 @@ # RUN: not ld.lld --reproduce repro.tar abc -o t 2>&1 | FileCheck %s # CHECK: cannot open abc: {{N|n}}o such file or directory -# RUN: tar xf repro.tar -# RUN: FileCheck --check-prefix=RSP %s < repro/response.txt +# RUN: tar xOf repro.tar repro/response.txt | FileCheck --check-prefix=RSP %s # RSP: abc # RSP: -o t diff --git a/lld/test/ELF/reproduce-linkerscript.s b/lld/test/ELF/reproduce-linkerscript.s index 2b00815..7cc070c 100644 --- a/lld/test/ELF/reproduce-linkerscript.s +++ b/lld/test/ELF/reproduce-linkerscript.s @@ -1,4 +1,4 @@ -# REQUIRES: x86, shell +# REQUIRES: x86 # RUN: rm -rf %t.dir # RUN: mkdir -p %t.dir/build @@ -7,11 +7,12 @@ # RUN: echo "INCLUDE \"%t.dir/build/bar.script\"" >> %t.dir/build/foo.script # RUN: echo "/* empty */" > %t.dir/build/bar.script # RUN: cd %t.dir -# RUN: ld.lld build/foo.script -o bar --reproduce repro.tar -# RUN: tar xf repro.tar -# RUN: diff build/foo.script repro/%:t.dir/build/foo.script -# RUN: diff build/bar.script repro/%:t.dir/build/bar.script -# RUN: diff build/foo.o repro/%:t.dir/build/foo.o +# RUN: ld.lld build/foo.script -o /dev/null --reproduce repro.tar +# RUN: tar tf repro.tar | FileCheck -DPATH='%:t.dir' %s + +# CHECK: [[PATH]]/build/foo.script +# CHECK: [[PATH]]/build/foo.o +# CHECK: [[PATH]]/build/bar.script .globl _start _start: diff --git a/lld/test/ELF/reproduce-thin-archive.s b/lld/test/ELF/reproduce-thin-archive.s index c3e6e88..6c33ac2 100644 --- a/lld/test/ELF/reproduce-thin-archive.s +++ b/lld/test/ELF/reproduce-thin-archive.s @@ -1,4 +1,4 @@ -# REQUIRES: x86, shell +# REQUIRES: x86 # RUN: rm -rf %t.dir # RUN: mkdir -p %t.dir @@ -6,15 +6,17 @@ # RUN: cd %t.dir # RUN: llvm-ar --format=gnu rcT foo.a foo.o -# RUN: ld.lld -m elf_x86_64 foo.a -o bar --reproduce repro.tar -# RUN: tar xf repro.tar -# RUN: diff foo.a repro/%:t.dir/foo.a -# RUN: diff foo.o repro/%:t.dir/foo.o +# RUN: ld.lld -m elf_x86_64 foo.a -o /dev/null --reproduce repro.tar +# RUN: tar tf repro.tar | FileCheck -DPATH='repro/%:t.dir' %s -# RUN: ld.lld -m elf_x86_64 --whole-archive foo.a -o bar --reproduce repro2.tar -# RUN: tar xf repro2.tar -# RUN: diff foo.a repro2/%:t.dir/foo.a -# RUN: diff foo.o repro2/%:t.dir/foo.o +# CHECK: [[PATH]]/foo.a +# CHECK: [[PATH]]/foo.o + +# RUN: ld.lld -m elf_x86_64 --whole-archive foo.a -o /dev/null --reproduce repro2.tar +# RUN: tar tf repro2.tar | FileCheck -DPATH='repro2/%:t.dir' --check-prefix=CHECK2 %s + +# CHECK2: [[PATH]]/foo.a +# CHECK2: [[PATH]]/foo.o .globl _start _start: diff --git a/lld/test/ELF/reproduce-windows.s b/lld/test/ELF/reproduce-windows.s index 6dd1fe2..2c4a777 100644 --- a/lld/test/ELF/reproduce-windows.s +++ b/lld/test/ELF/reproduce-windows.s @@ -6,7 +6,7 @@ # RUN: llvm-mc %s -o %t.dir/build/foo.o -filetype=obj -triple=x86_64-pc-linux # RUN: cd %t.dir # RUN: ld.lld build/foo.o --reproduce repro.tar -# RUN: tar tf repro.tar | FileCheck %s +# RUN: tar tf repro.tar | FileCheck -DPATH='repro/%:t.dir' %s # CHECK: repro/response.txt -# CHECK: repro/{{.*}}/build/foo.o +# CHECK: [[PATH]]/build/foo.o diff --git a/lld/test/ELF/reproduce-windows2.s b/lld/test/ELF/reproduce-windows2.s index 38e0024..62691ba 100644 --- a/lld/test/ELF/reproduce-windows2.s +++ b/lld/test/ELF/reproduce-windows2.s @@ -6,5 +6,6 @@ # RUN: llvm-mc %s -o %t.dir/build/foo.o -filetype=obj -triple=x86_64-pc-linux # RUN: cd %t.dir # RUN: ld.lld build/foo.o --reproduce repro.tar -# RUN: tar -O -x -f repro.tar repro/response.txt | FileCheck %s -# CHECK: {{.*}}/build/foo.o +# RUN: tar xOf repro.tar repro/response.txt | FileCheck -DPATH='%:t.dir' %s + +# CHECK: [[PATH]]/build/foo.o diff --git a/lld/test/ELF/reproduce.s b/lld/test/ELF/reproduce.s index 463d604..3f42c20 100644 --- a/lld/test/ELF/reproduce.s +++ b/lld/test/ELF/reproduce.s @@ -1,34 +1,34 @@ # REQUIRES: x86 -# REQUIRES: shell - -# Extracting the tar archive can get over the path limit on windows. # RUN: rm -rf %t.dir # RUN: mkdir -p %t.dir/build1 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.dir/build1/foo.o # RUN: cd %t.dir -# RUN: ld.lld --hash-style=gnu build1/foo.o -o bar -shared --as-needed --reproduce repro.tar -# RUN: tar xf repro.tar -# RUN: diff build1/foo.o repro/%:t.dir/build1/foo.o +# RUN: ld.lld --hash-style=gnu build1/foo.o -o bar -shared --as-needed --reproduce repro1.tar +# RUN: tar xOf repro1.tar repro1/%:t.dir/build1/foo.o > build1-foo.o +# RUN: cmp build1/foo.o build1-foo.o -# RUN: FileCheck %s --check-prefix=RSP < repro/response.txt -# RSP: {{^}}--hash-style gnu{{$}} -# RSP-NOT: {{^}}repro{{[/\\]}} -# RSP-NEXT: {{[/\\]}}foo.o -# RSP-NEXT: -o bar -# RSP-NEXT: -shared -# RSP-NEXT: --as-needed +# RUN: tar xf repro1.tar repro1/response.txt repro1/version.txt +# RUN: FileCheck %s --check-prefix=RSP1 < repro1/response.txt +# RSP1: {{^}}--hash-style gnu{{$}} +# RSP1-NOT: {{^}}repro1{{[/\\]}} +# RSP1-NEXT: {{[/\\]}}foo.o +# RSP1-NEXT: -o bar +# RSP1-NEXT: -shared +# RSP1-NEXT: --as-needed -# RUN: FileCheck %s --check-prefix=VERSION < repro/version.txt +# RUN: FileCheck %s --check-prefix=VERSION < repro1/version.txt # VERSION: LLD # RUN: mkdir -p %t.dir/build2/a/b/c # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.dir/build2/foo.o # RUN: cd %t.dir/build2/a/b/c -# RUN: env LLD_REPRODUCE=repro.tar ld.lld ./../../../foo.o -o bar -shared --as-needed -# RUN: tar xf repro.tar -# RUN: diff %t.dir/build2/foo.o repro/%:t.dir/build2/foo.o +# RUN: env LLD_REPRODUCE=repro2.tar ld.lld ./../../../foo.o -o /dev/null -shared --as-needed +# RUN: tar xOf repro2.tar repro2/%:t.dir/build2/foo.o > build2-foo.o +# RUN: cmp %t.dir/build2/foo.o build2-foo.o +# RUN: mkdir -p %t.dir/build3 +# RUN: cd %t.dir/build3 # RUN: echo "{ local: *; };" > ver # RUN: echo "{};" > dyn # RUN: echo > file @@ -36,46 +36,44 @@ # RUN: echo "_start" > order # RUN: mkdir "sysroot with spaces" # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o 'foo bar' -# RUN: ld.lld --reproduce repro2.tar 'foo bar' -L"foo bar" -Lfile -Tfile2 \ +# RUN: ld.lld --reproduce repro3.tar 'foo bar' -L"foo bar" -Lfile -Tfile2 \ # RUN: --dynamic-list dyn -rpath file --script=file --symbol-ordering-file order \ # RUN: --sysroot "sysroot with spaces" --sysroot="sysroot with spaces" \ # RUN: --version-script ver --dynamic-linker "some unusual/path" -soname 'foo bar' \ # RUN: -soname='foo bar' -# RUN: tar xf repro2.tar -# RUN: FileCheck %s --check-prefix=RSP2 < repro2/response.txt -# RSP2: --chroot . -# RSP2: "{{.*}}foo bar" -# RSP2-NEXT: --library-path "[[BASEDIR:.+]]/foo bar" -# RSP2-NEXT: --library-path [[BASEDIR]]/file -# RSP2-NEXT: --script [[BASEDIR]]/file2 -# RSP2-NEXT: --dynamic-list [[BASEDIR]]/dyn -# RSP2-NEXT: -rpath [[BASEDIR]]/file -# RSP2-NEXT: --script [[BASEDIR]]/file -# RSP2-NEXT: --symbol-ordering-file [[BASEDIR]]/order -# RSP2-NEXT: --sysroot "[[BASEDIR]]/sysroot with spaces" -# RSP2-NEXT: --sysroot "[[BASEDIR]]/sysroot with spaces" -# RSP2-NEXT: --version-script [[BASEDIR]]/ver -# RSP2-NEXT: --dynamic-linker "some unusual/path" -# RSP2-NEXT: -soname "foo bar" -# RSP2-NEXT: -soname "foo bar" +# RUN: tar xOf repro3.tar repro3/response.txt | FileCheck %s --check-prefix=RSP3 +# RSP3: --chroot . +# RSP3: "{{.*}}foo bar" +# RSP3-NEXT: --library-path "[[BASEDIR:.+]]/foo bar" +# RSP3-NEXT: --library-path [[BASEDIR]]/file +# RSP3-NEXT: --script [[BASEDIR]]/file2 +# RSP3-NEXT: --dynamic-list [[BASEDIR]]/dyn +# RSP3-NEXT: -rpath [[BASEDIR]]/file +# RSP3-NEXT: --script [[BASEDIR]]/file +# RSP3-NEXT: --symbol-ordering-file [[BASEDIR]]/order +# RSP3-NEXT: --sysroot "[[BASEDIR]]/sysroot with spaces" +# RSP3-NEXT: --sysroot "[[BASEDIR]]/sysroot with spaces" +# RSP3-NEXT: --version-script [[BASEDIR]]/ver +# RSP3-NEXT: --dynamic-linker "some unusual/path" +# RSP3-NEXT: -soname "foo bar" +# RSP3-NEXT: -soname "foo bar" -# RUN: tar tf repro2.tar | FileCheck %s -# CHECK: repro2/response.txt -# CHECK-NEXT: repro2/version.txt -# CHECK-NEXT: repro2/{{.*}}/order -# CHECK-NEXT: repro2/{{.*}}/dyn -# CHECK-NEXT: repro2/{{.*}}/ver -# CHECK-NEXT: repro2/{{.*}}/foo bar -# CHECK-NEXT: repro2/{{.*}}/file2 -# CHECK-NEXT: repro2/{{.*}}/file +# RUN: tar tf repro3.tar | FileCheck %s +# CHECK: repro3/response.txt +# CHECK-NEXT: repro3/version.txt +# CHECK-NEXT: repro3/{{.*}}/order +# CHECK-NEXT: repro3/{{.*}}/dyn +# CHECK-NEXT: repro3/{{.*}}/ver +# CHECK-NEXT: repro3/{{.*}}/foo bar +# CHECK-NEXT: repro3/{{.*}}/file2 +# CHECK-NEXT: repro3/{{.*}}/file ## Check that directory path is stripped from -o -# RUN: mkdir -p %t.dir/build3/a/b/c +# RUN: mkdir -p %t.dir/build4/a/b/c # RUN: cd %t.dir -# RUN: ld.lld build1/foo.o -o build3/a/b/c/bar -shared --as-needed --reproduce=repro3.tar -# RUN: tar xf repro3.tar -# RUN: FileCheck %s --check-prefix=RSP3 < repro3/response.txt -# RSP3: -o bar +# RUN: ld.lld build1/foo.o -o build4/a/b/c/bar -shared --as-needed --reproduce=repro4.tar +# RUN: tar xOf repro4.tar repro4/response.txt | FileCheck %s --check-prefix=RSP4 +# RSP4: -o bar .globl _start _start: -- 2.7.4