Add tests for profile sample file parsing.
authorDiego Novillo <dnovillo@google.com>
Mon, 2 Dec 2013 15:12:50 +0000 (15:12 +0000)
committerDiego Novillo <dnovillo@google.com>
Mon, 2 Dec 2013 15:12:50 +0000 (15:12 +0000)
The profile file parser needed some tests for its parsing actions.
This adds tests for each of the error messages emitted by the parser.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196106 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/SampleProfile/Inputs/bad_fn_header.prof [new file with mode: 0644]
test/Transforms/SampleProfile/Inputs/bad_sample_line.prof [new file with mode: 0644]
test/Transforms/SampleProfile/Inputs/missing_num_syms.prof [new file with mode: 0644]
test/Transforms/SampleProfile/Inputs/missing_samples.prof [new file with mode: 0644]
test/Transforms/SampleProfile/Inputs/missing_symtab.prof [new file with mode: 0644]
test/Transforms/SampleProfile/syntax.ll [new file with mode: 0644]

diff --git a/test/Transforms/SampleProfile/Inputs/bad_fn_header.prof b/test/Transforms/SampleProfile/Inputs/bad_fn_header.prof
new file mode 100644 (file)
index 0000000..90459e6
--- /dev/null
@@ -0,0 +1,6 @@
+symbol table
+1
+empty
+empty:100:BAD
+0: 0
+1: 100
diff --git a/test/Transforms/SampleProfile/Inputs/bad_sample_line.prof b/test/Transforms/SampleProfile/Inputs/bad_sample_line.prof
new file mode 100644 (file)
index 0000000..8c0d763
--- /dev/null
@@ -0,0 +1,6 @@
+symbol table
+1
+empty
+empty:100:0:1
+0: 0
+1: BAD
diff --git a/test/Transforms/SampleProfile/Inputs/missing_num_syms.prof b/test/Transforms/SampleProfile/Inputs/missing_num_syms.prof
new file mode 100644 (file)
index 0000000..7cd0536
--- /dev/null
@@ -0,0 +1,5 @@
+symbol table
+empty
+empty:100:0:1
+0: 0
+1: 100
diff --git a/test/Transforms/SampleProfile/Inputs/missing_samples.prof b/test/Transforms/SampleProfile/Inputs/missing_samples.prof
new file mode 100644 (file)
index 0000000..edd36c2
--- /dev/null
@@ -0,0 +1,6 @@
+symbol table
+1
+empty
+empty:100:0:10
+0: 0
+1: 100
diff --git a/test/Transforms/SampleProfile/Inputs/missing_symtab.prof b/test/Transforms/SampleProfile/Inputs/missing_symtab.prof
new file mode 100644 (file)
index 0000000..2a82613
--- /dev/null
@@ -0,0 +1,5 @@
+1
+empty
+empty:100:0:1
+0: 0
+1: 100
diff --git a/test/Transforms/SampleProfile/syntax.ll b/test/Transforms/SampleProfile/syntax.ll
new file mode 100644 (file)
index 0000000..baf3852
--- /dev/null
@@ -0,0 +1,17 @@
+; RUN: not opt < %s -sample-profile -sample-profile-file=missing.prof 2>&1 | FileCheck -check-prefix=MISSING-FILE %s
+; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/missing_symtab.prof 2>&1 | FileCheck -check-prefix=MISSING-SYMTAB %s
+; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/missing_num_syms.prof 2>&1 | FileCheck -check-prefix=MISSING-NUM-SYMS %s
+; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_fn_header.prof 2>&1 | FileCheck -check-prefix=BAD-FN-HEADER %s
+; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_sample_line.prof 2>&1 | FileCheck -check-prefix=BAD-SAMPLE-LINE %s
+; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/missing_samples.prof 2>&1 | FileCheck -check-prefix=MISSING-SAMPLES %s
+
+define void @empty() {
+entry:
+  ret void
+}
+; MISSING-FILE: LLVM ERROR: Could not open profile file missing.prof: No such file or directory
+; MISSING-SYMTAB: LLVM ERROR: {{.*}}missing_symtab.prof:1: Expected 'symbol table', found 1
+; MISSING-NUM-SYMS: LLVM ERROR: {{.*}}missing_num_syms.prof:2: Expected a number, found empty
+; BAD-FN-HEADER: LLVM ERROR: {{.*}}bad_fn_header.prof:4: Expected 'mangled_name:NUM:NUM:NUM', found empty:100:BAD
+; BAD-SAMPLE-LINE: LLVM ERROR: {{.*}}bad_sample_line.prof:6: Expected 'mangled_name:NUM:NUM:NUM', found 1: BAD
+; MISSING-SAMPLES: LLVM ERROR: {{.*}}missing_samples.prof:6: Unexpected end of file