Skip to content

Commit e51b9e4

Browse files
committed
[llvm-objdump][test] Improve testing of some switches #2
This patch focuses on adding additional testing for the --source switch. For reference, the source-interleave-x86_64.ll test file has been split into two parts - the input (shared with the other tests) and the test itself. Reviewed by: MaskRay, rupprecht, grimar Differential Revision: https://reviews.llvm.org/D61996 llvm-svn: 361479
1 parent f5d9d23 commit e51b9e4

6 files changed

+100
-16
lines changed

Diff for: llvm/test/tools/llvm-objdump/X86/source-interleave-x86_64.ll renamed to llvm/test/tools/llvm-objdump/X86/Inputs/source-interleave.ll

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
; RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %s > %t.ll
2-
; RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %t.ll
3-
; RUN: llvm-objdump -d -l %t.o >%t0
4-
; RUN: llvm-objdump -dl %t.o >%t1
5-
; RUN: llvm-objdump -d -S %t.o >%t2
6-
; RUN: llvm-objdump -dS %t.o >%t3
7-
; RUN: cmp %t0 %t1
8-
; RUN: cmp %t2 %t3
9-
; RUN: FileCheck --check-prefix=LINES %t.ll < %t0
10-
; RUN: FileCheck --check-prefix=SOURCE --strict-whitespace %t.ll < %t2
1+
; NOTE: To be able to use this file as an input, the string SRC_CMPDIR needs
2+
; replacing with a directory path by using sed or similar.
3+
114
; ModuleID = 'source-interleave-x86_64.bc'
125
source_filename = "source-interleave-x86_64.c"
136
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@@ -71,9 +64,3 @@ attributes #1 = { nounwind readnone }
7164
!21 = !DILocation(line: 8, column: 15, scope: !14)
7265
!22 = !DILocation(line: 8, column: 13, scope: !14)
7366
!23 = !DILocation(line: 8, column: 3, scope: !14)
74-
; LINES: main:
75-
; LINES-NEXT: ; {{[ -\(\)_A-Za-z0-9.\\/:]+}}source-interleave-x86_64.c:6
76-
77-
; SOURCE: main:
78-
; SOURCE-NEXT: ; int main() {
79-
; SOURCE: ; int *b = &a;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Test llvm-objdump's --source behaviour when a line number is greater than the
2+
## file length.
3+
4+
# RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %p/Inputs/source-interleave.ll > %t.ll
5+
# RUN: sed -e "s,line: 7,line: 9999,g" %t.ll > %t2.ll
6+
7+
# RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %t.ll
8+
# RUN: llc -o %t2.o -filetype=obj -mtriple=x86_64-pc-linux %t2.ll
9+
10+
# RUN: llvm-objdump --source %t.o | FileCheck %s --check-prefixes=CHECK,GOOD
11+
# RUN: llvm-objdump --source %t2.o | FileCheck %s --implicit-check-not="int *b = &a;"
12+
13+
# CHECK: main:
14+
# CHECK-NEXT: ; int main() {
15+
# GOOD: ; int *b = &a;
16+
# CHECK: ; return *b + foo();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Test that if the source cannot be found that disassembly is still printed,
2+
## and that no source is printed.
3+
4+
# RUN: sed -e "s,SRC_COMPDIR,%/t,g" %p/Inputs/source-interleave.ll > %t.ll
5+
# RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %p/Inputs/source-interleave.ll > %t2.ll
6+
7+
# RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %t.ll
8+
# RUN: llc -o %t2.o -filetype=obj -mtriple=x86_64-pc-linux %t2.ll
9+
10+
# RUN: llvm-objdump --source %t.o | FileCheck %s --implicit-check-not=main
11+
# RUN: llvm-objdump --source %t2.o | FileCheck %s --check-prefixes=CHECK,SOURCE
12+
13+
# CHECK: 0000000000000010 main:
14+
# SOURCE-NEXT: ; int main() {
15+
# CHECK-NEXT: 10: 55 pushq %rbp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Test that if an object has no debug information, only the disassembly is
2+
## printed when --source is specified.
3+
4+
# RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %p/Inputs/source-interleave.ll > %t.ll
5+
# RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %t.ll
6+
# RUN: llvm-objcopy --strip-debug %t.o %t2.o
7+
8+
# RUN: llvm-objdump --source %t.o | FileCheck %s --check-prefixes=CHECK,SOURCE
9+
# RUN: llvm-objdump --source %t2.o | FileCheck %s --implicit-check-not=main
10+
11+
# CHECK: 0000000000000010 main:
12+
# SOURCE-NEXT: ; int main() {
13+
# CHECK-NEXT: 10: 55 pushq %rbp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Test that llvm-objdump prints source and disassembly for relative directory
2+
## paths for appropriate working directories. We also test that when the directory
3+
## string is empty the behaviour is the same as the current working directory.
4+
5+
# RUN: mkdir -p %t/a/b
6+
# RUN: cp %p/Inputs/source-interleave-x86_64.c %t/a/source-interleave-x86_64.c
7+
8+
# RUN: sed -e "s,SRC_COMPDIR,a,g" %p/Inputs/source-interleave.ll > %t.ll
9+
# RUN: sed -e "s,SRC_COMPDIR,,g" %p/Inputs/source-interleave.ll > %t2.ll
10+
# RUN: sed -e "s,SRC_COMPDIR,.,g" %p/Inputs/source-interleave.ll > %t3.ll
11+
# RUN: sed -e "s,SRC_COMPDIR,..,g" %p/Inputs/source-interleave.ll > %t4.ll
12+
13+
# RUN: llc -o %t/a/a.o -filetype=obj -mtriple=x86_64-pc-linux %t.ll
14+
# RUN: llc -o %t/a/b.o -filetype=obj -mtriple=x86_64-pc-linux %t2.ll
15+
# RUN: llc -o %t/a/c.o -filetype=obj -mtriple=x86_64-pc-linux %t3.ll
16+
# RUN: llc -o %t/a/d.o -filetype=obj -mtriple=x86_64-pc-linux %t4.ll
17+
18+
# RUN: cd %t
19+
# RUN: llvm-objdump --source a/a.o | FileCheck %s --check-prefixes=CHECK,SOURCE
20+
# RUN: llvm-objdump --source a/b.o | FileCheck %s --implicit-check-not=main
21+
# RUN: llvm-objdump --source a/c.o | FileCheck %s --implicit-check-not=main
22+
# RUN: llvm-objdump --source a/d.o | FileCheck %s --implicit-check-not=main
23+
# RUN: cd a
24+
# RUN: llvm-objdump --source a.o | FileCheck %s --implicit-check-not=main
25+
# RUN: llvm-objdump --source b.o | FileCheck %s --check-prefixes=CHECK,SOURCE
26+
# RUN: llvm-objdump --source c.o | FileCheck %s --check-prefixes=CHECK,SOURCE
27+
# RUN: llvm-objdump --source d.o | FileCheck %s --implicit-check-not=main
28+
# RUN: cd b
29+
# RUN: llvm-objdump --source ../a.o | FileCheck %s --implicit-check-not=main
30+
# RUN: llvm-objdump --source ../b.o | FileCheck %s --implicit-check-not=main
31+
# RUN: llvm-objdump --source ../c.o | FileCheck %s --implicit-check-not=main
32+
# RUN: llvm-objdump --source ../d.o | FileCheck %s --check-prefixes=CHECK,SOURCE
33+
34+
# CHECK: 0000000000000010 main:
35+
# SOURCE-NEXT: ; int main() {
36+
# CHECK-NEXT: 10: 55 pushq %rbp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# RUN: sed -e "s,SRC_COMPDIR,%/p/Inputs,g" %p/Inputs/source-interleave.ll > %t.ll
2+
# RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %t.ll
3+
# RUN: llvm-objdump -d -l %t.o >%t0
4+
# RUN: llvm-objdump -dl %t.o >%t1
5+
# RUN: llvm-objdump -d -S %t.o >%t2
6+
# RUN: llvm-objdump -dS %t.o >%t3
7+
# RUN: cmp %t0 %t1
8+
# RUN: cmp %t2 %t3
9+
# RUN: FileCheck --check-prefix=LINES %s < %t0
10+
# RUN: FileCheck --check-prefix=SOURCE --strict-whitespace %s < %t2
11+
12+
# LINES: main:
13+
# LINES-NEXT: ; {{[ -\(\)_A-Za-z0-9.\\/:]+}}source-interleave-x86_64.c:6
14+
15+
# SOURCE: main:
16+
# SOURCE-NEXT: ; int main() {
17+
# SOURCE: ; int *b = &a;

0 commit comments

Comments
 (0)