Skip to content

Commit 6516f5f

Browse files
Add additional lit tests for Exegesis conversion script (llvm#62)
This patch adds some additional lit regression tests for the Exegesis conversion script to test functionality that was previously implemented/improved now that we actually have testing facilities.
1 parent dfd130a commit 6516f5f

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

gematria/datasets/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ gematria_py_test(
8383
"tests/lit.site.cfg.py",
8484
":convert_bhive_to_llvm_exegesis_input",
8585
"@llvm-project//llvm:FileCheck",
86+
"@llvm-project//llvm:not",
8687
"@llvm-project//llvm:split-file",
8788
] + glob(["tests/*.test"]),
8889
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
; Test that splitting a dataset among multiple JSON files works as expected.
2+
3+
; Test currently fails as underlying functionality needs to be fixed, see #61.
4+
; XFAIL: *
5+
6+
; RUN: split-file %s %t
7+
; RUN: mkdir %t.jsondir
8+
; RUN: %convert_bhive_to_llvm_exegesis_input --json_output_dir=%t.jsondir --bhive_csv=%t/test.csv
9+
; RUN: cat %t.jsondir/0.json | FileCheck --check-prefix FILE1 %s
10+
; RUN: cat %t.jsondir/1.json | FileCheck --check-prefix FILE2 %s
11+
12+
; FILE1-CHECK: [
13+
; FILE1-CHECK: {
14+
; FILE1-CHECK: "Hex": "85c044897c2460",
15+
; FILE1-CHECK: "MemoryDefinitions": [
16+
; FILE1-CHECK: {
17+
; FILE1-CHECK: "Name": "MEM",
18+
; FILE1-CHECK: "Size": 4096,
19+
; FILE1-CHECK: "Value": 305419776
20+
; FILE1-CHECK: }
21+
; FILE1-CHECK: ],
22+
; FILE1-CHECK: "MemoryMappings": [
23+
; FILE1-CHECK: {
24+
; FILE1-CHECK: "Address": 65536,
25+
; FILE1-CHECK: "Value": "MEM"
26+
; FILE1-CHECK: }
27+
; FILE1-CHECK: ]
28+
; FILE1-CHECK: }
29+
; FILE1-CHECK: ]
30+
31+
; FILE2-CHECK: [
32+
; FILE2-CHECK: {
33+
; FILE2-CHECK: "Hex": "3b31",
34+
; FILE2-CHECK: "MemoryDefinitions": [
35+
; FILE2-CHECK: {
36+
; FILE2-CHECK: "Name": "MEM",
37+
; FILE2-CHECK: "Size": 4096,
38+
; FILE2-CHECK: "Value": 305419776
39+
; FILE2-CHECK: }
40+
; FILE2-CHECK: ],
41+
; FILE2-CHECK: "MemoryMappings": [
42+
; FILE2-CHECK: {
43+
; FILE2-CHECK: "Address": 65536,
44+
; FILE2-CHECK: "Value": "MEM"
45+
; FILE2-CHECK: }
46+
; FILE2-CHECK: ]
47+
; FILE2-CHECK: }
48+
; FILE2-CHECK: ]
49+
50+
;--- test.csv
51+
3b31,45.000000
52+
85c044897c2460,98.000000
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; Test various flag combinations that should result in an error.
2+
3+
; Test that not passing in any flags results in an error.
4+
; RUN: %not %convert_bhive_to_llvm_exegesis_input 2>&1 | FileCheck %s --check-prefix=NO-ARGS
5+
6+
; NO-ARGS: Error: --bhive_csv is required
7+
8+
; Test that setting a number of blocks per JSON file less than 1 results in
9+
; an error.
10+
; RUN: split-file %s %t
11+
; RUN: mkdir %t.asmdir
12+
; RUN: %not %convert_bhive_to_llvm_exegesis_input --bhive_csv=%t/test.csv --asm_output_dir=%t.asmdir --blocks_per_json_file=0 2>&1 | FileCheck %s --check-prefix=BAD-BLOCK-COUNT
13+
14+
; BAD-BLOCK-COUNT: Error: --blocks_per_json_file must be greater than 1.
15+
16+
; Test that specifying an unknown annotator type results in an error.
17+
; RUN: %not %convert_bhive_to_llvm_exegesis_input --bhive_csv=%t/test.csv --asm_output_dir=%t.asmdir --annotator_implementation=doesntexist 2>&1 | FileCheck %s --check-prefix=BAD-ANNOTATOR-TYPE
18+
19+
; BAD-ANNOTATOR-TYPE: ERROR: Illegal value 'doesntexist' specified for flag 'annotator_implementation'; unknown annotator type
20+
21+
;--- test.csv
22+
3b31,45.000000

gematria/datasets/tests/lit.cfg.py

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
config.substitutions.append(
1515
('split-file', os.path.join(config.llvm_tools_root, 'split-file'))
1616
)
17+
config.substitutions.append(
18+
('%not', os.path.join(config.llvm_tools_root, 'not'))
19+
)
1720

1821
config.substitutions.append((
1922
'%convert_bhive_to_llvm_exegesis_input',
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; Test that we only annotate up to --max_bb_count BBs.
2+
3+
; RUN: split-file %s %t
4+
; RUN: mkdir %t.asmdir
5+
; RUN: %convert_bhive_to_llvm_exegesis_input --asm_output_dir=%t.asmdir --bhive_csv=%t/test.csv --max_bb_count=1
6+
; RUN: ls %t.asmdir | FileCheck %s
7+
8+
; CHECK: 0.test
9+
; CHECK-NOT: 1.test
10+
11+
;--- test.csv
12+
3b31,45.000000
13+
85c044897c2460,98.000000

0 commit comments

Comments
 (0)