1;; Test --prefix option. 2 3;; Separators change from platform to platform. In POSIX the full path for the 4;; directory './Inputs' appended with the file 'source-interleave-x86_64.c' is 5;; './Inputs/source-interleave-x86_64.c'. For Windows it is 6;; './Inputs\source-interleave-x86_64.c'. Platform specific tests are needed 7;; since '\' may or may not be a separator. 8 9;; Test prefix option ignored for relative paths. 10;; For the test below it is possible to accept both '/' and '\' as a separator. 11 12; RUN: sed -e "s,SRC_COMPDIR,./Inputs,g" %p/Inputs/source-interleave.ll > %t-relative-path.ll 13; RUN: llc -o %t-relative-path.o -filetype=obj -mtriple=x86_64-pc-linux %t-relative-path.ll 14; RUN: llvm-objdump --prefix myprefix --source %t-relative-path.o 2>&1 | \ 15; RUN: FileCheck %s --check-prefix=CHECK-BROKEN-PREFIX -DFILE=%t-relative-path.o -DPREFIX=. -DCOMPDIR=/Inputs 16; CHECK-BROKEN-PREFIX: warning: '[[FILE]]': failed to find source [[PREFIX]][[COMPDIR]]{{[/\\]}}source-interleave-x86_64.c 17 18;; Test invalid source interleave fixed by adding the correct prefix. 19 20; RUN: sed -e "s,SRC_COMPDIR,/Inputs,g" %p/Inputs/source-interleave.ll > %t-missing-prefix.ll 21; RUN: llc -o %t-missing-prefix.o -filetype=obj -mtriple=x86_64-pc-linux %t-missing-prefix.ll 22; RUN: llvm-objdump --prefix %p --source %t-missing-prefix.o 2>&1 | \ 23; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX 24; CHECK-MISSING-PREFIX-FIX: ; int foo() { 25 26;; Test valid source interleave broken by adding an incorrect prefix. 27 28; RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %p/Inputs/source-interleave.ll > %t-correct-prefix.ll 29; RUN: llc -o %t-correct-prefix.o -filetype=obj -mtriple=x86_64-pc-linux %t-correct-prefix.ll 30; RUN: llvm-objdump --prefix myprefix --source %t-correct-prefix.o 2>&1 | \ 31; RUN: FileCheck %s --check-prefix=CHECK-BROKEN-PREFIX -DFILE=%t-correct-prefix.o -DPREFIX=myprefix%/p -DCOMPDIR=/Inputs 32 33;; Using only a prefix separator is the same as not using the `--prefix` option. 34 35; RUN: llvm-objdump --prefix / --source %t-missing-prefix.o 2>&1 | \ 36; RUN: FileCheck %s --check-prefix=CHECK-BROKEN-PREFIX -DFILE=%t-missing-prefix.o -DPREFIX='' -DCOMPDIR=/Inputs 37 38;; All trailing separators on the prefix are discarded. 39;; The prefix 'myprefix//' is converted to 'myprefix'. 40 41; RUN: llvm-objdump --prefix myprefix// --source %t-missing-prefix.o 2>&1 | \ 42; RUN: FileCheck %s --check-prefix=CHECK-BROKEN-PREFIX -DFILE=%t-missing-prefix.o -DPREFIX=myprefix -DCOMPDIR=/Inputs 43 44;; Test invalid source interleave fixed by adding the correct prefix and 45;; stripping out an extra directory from the path. 46 47; RUN: sed -e "s,SRC_COMPDIR,/extra/Inputs,g" %p/Inputs/source-interleave.ll > %t-extra-path-prefix.ll 48; RUN: llc -o %t-extra-path-prefix.o -filetype=obj -mtriple=x86_64-pc-linux %t-extra-path-prefix.ll 49; RUN: llvm-objdump --prefix %p --prefix-strip 1 --source %t-extra-path-prefix.o 2>&1 | \ 50; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX 51 52;; Test do not skip extra separators. The --prefix-strip should take into 53;; account each separator individually. Hence, to fix '/extra/Inputs' 54;; --prefix-strip needs to be 1. To fix '//extra/Inputs' --prefix-strip 55;; needs to be 2. 56 57; RUN: sed -e "s,SRC_COMPDIR,//extra/Inputs,g" %p/Inputs/source-interleave.ll > %t-extra-sep-path-prefix.ll 58; RUN: llc -o %t-extra-sep-path-prefix.o -filetype=obj -mtriple=x86_64-pc-linux %t-extra-sep-path-prefix.ll 59; RUN: llvm-objdump --prefix %p --prefix-strip 2 --source %t-extra-sep-path-prefix.o 2>&1 | \ 60; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX 61 62;; Test --prefix-strip value of 0. No effect. 63;; SRC_COMPDIR is set to '/Inputs' before and after --prefix-strip 0. 64 65; RUN: llvm-objdump --prefix %p --prefix-strip 0 --source %t-missing-prefix.o 2>&1 | \ 66; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX 67 68;; Test --prefix-strip value equal to the number of directory components. 69;; SRC_COMPDIR is set to '/Inputs' before --prefix-strip 1. 70;; SRC_COMPDIR becomes '' after --prefix-strip 1. 71 72; RUN: llvm-objdump --prefix %p/Inputs --prefix-strip 1 --source %t-missing-prefix.o 2>&1 | \ 73; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX 74 75;; Test --prefix-strip value greater than the number of components. 76;; SRC_COMPDIR is set to '/Inputs' before --prefix-strip 2. 77;; SRC_COMPDIR becomes '' after --prefix-strip 2. 78 79; RUN: llvm-objdump --prefix %p/Inputs --prefix-strip 2 --source %t-missing-prefix.o 2>&1 | \ 80; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX 81 82;; Test negative value --prefix-strip. Reports an error. 83 84; RUN: not llvm-objdump --prefix %p --prefix-strip '-1' --source %t-missing-prefix.o 2>&1 | \ 85; RUN: FileCheck %s --check-prefix=CHECK-INVALID-PREFIX-STRIP -DOPTION='-1' 86; CHECK-INVALID-PREFIX-STRIP: {{.*}}llvm-objdump{{.*}}: error: --prefix-strip: expected a non-negative integer, but got '[[OPTION]]' 87 88;; Test text value --prefix-strip. Reports an error. 89 90; RUN: not llvm-objdump --prefix %p --prefix-strip foo --source %t-missing-prefix.o 2>&1 | \ 91; RUN: FileCheck %s --check-prefix=CHECK-INVALID-PREFIX-STRIP -DOPTION='foo' 92 93;; Test use of --prefix= and --prefix-strip= 94 95; RUN: sed -e "s,SRC_COMPDIR,/extra/Inputs,g" %p/Inputs/source-interleave.ll > %t-extra-path-prefix.ll 96; RUN: llc -o %t-extra-path-prefix.o -filetype=obj -mtriple=x86_64-pc-linux %t-extra-path-prefix.ll 97; RUN: llvm-objdump --prefix=%p --prefix-strip=1 --source %t-extra-path-prefix.o 2>&1 | \ 98; RUN: FileCheck %s --check-prefix=CHECK-MISSING-PREFIX-FIX 99