File tree Expand file tree Collapse file tree 5 files changed +111
-2
lines changed Expand file tree Collapse file tree 5 files changed +111
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ configure_lit_site_cfg(
5
5
6
6
add_lit_testsuite (check-mlgo-utils "Running mlgo-utils tests"
7
7
${CMAKE_CURRENT_BINARY_DIR}
8
- DEPENDS "FileCheck" "not" "count"
8
+ DEPENDS "FileCheck" "not" "count" "split-file" "yaml2obj" "llvm-objcopy"
9
9
)
10
10
11
11
set_target_properties (check-mlgo-utils PROPERTIES FOLDER "Tests" )
Original file line number Diff line number Diff line change
1
+ # REQUIRES: python-38, absl, system-linux
2
+
3
+ ## Testing that the combine_trainig_corpus script works as expected when
4
+ ## invoked.
5
+
6
+ # RUN: rm -rf %t.dir && mkdir %t.dir
7
+ # RUN: split-file %s %t.dir
8
+ # RUN: %python %scripts_dir/corpus/combine_training_corpus.py --root_dir=%t.dir
9
+ # RUN: cat %t.dir/corpus_description.json | FileCheck %s
10
+
11
+ ## Check that we end up with the same properties as the original corpora
12
+ # CHECK: "has_thinlto": false
13
+
14
+ ## Check that the modules end up in the combined corpus. Order does not matter.
15
+ # CHECK-DAG: "subcorpus1/test1.o"
16
+ # CHECK-DAG: "subcorpus2/test2.o"
17
+
18
+ #--- subcorpus1/corpus_description.json
19
+ {
20
+ "has_thinlto": false,
21
+ "modules": [
22
+ "test1.o"
23
+ ]
24
+ }
25
+ #--- subcorpus2/corpus_description.json
26
+ {
27
+ "has_thinlto": false,
28
+ "modules": [
29
+ "test2.o"
30
+ ]
31
+ }
Original file line number Diff line number Diff line change
1
+ # REQUIRES: python-38, absl, system-linux
2
+
3
+ ## Test that invoking the extract_ir script work as expected.
4
+
5
+ # RUN: rm -rf %t.dir && mkdir %t.dir
6
+ # RUN: yaml2obj %s -o %t.dir/test1.o
7
+ # RUN: yaml2obj %s -o %t.dir/test2.o
8
+ # RUN: rm -rf %t.dir.out && mkdir %t.dir.out
9
+
10
+ # RUN: %python %scripts_dir/corpus/extract_ir.py --input=%t.dir --input_type=directory --output_dir=%t.dir.out --llvm_objcopy_path=llvm-objcopy
11
+ # RUN: cat %t.dir.out/corpus_description.json | FileCheck %s
12
+
13
+ ## Check that this is not a thinLTO build
14
+ # CHECK: "has_thinlto": false
15
+ ## Check that the expected modules end up in the corpus description
16
+ # CHECK-DAG: "test1.o"
17
+ # CHECK-DAG: "test2.o"
18
+
19
+ # RUN: ls %t.dir.out | FileCheck %s --check-prefix CHECK-DIR
20
+
21
+ # CHECK-DIR: test1.o.bc
22
+ # CHECK-DIR: test1.o.cmd
23
+ # CHECK-DIR: test2.o.bc
24
+ # CHECK-DIR: test2.o.cmd
25
+
26
+ --- !ELF
27
+ FileHeader:
28
+ Class: ELFCLASS64
29
+ Data: ELFDATA2LSB
30
+ Type: ET_REL
31
+ Machine: EM_X86_64
32
+ SectionHeaderStringTable: .strtab
33
+ Sections:
34
+ - Name: .text
35
+ Type: SHT_PROGBITS
36
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
37
+ AddressAlign: 0x10
38
+ Content: 55
39
+ - Name: .llvmbc
40
+ Type: SHT_PROGBITS
41
+ AddressAlign: 0x1
42
+ Content: 55
43
+ - Name: .llvmcmd
44
+ Type: SHT_PROGBITS
45
+ AddressAlign: 0x1
46
+ Content: ff
Original file line number Diff line number Diff line change
1
+ # REQUIRES: python-38, absl, system-linux
2
+
3
+ ## Testing that the make_corpus script works as expected when invoked.
4
+
5
+ # RUN: rm -rf %t.dir && mkdir %t.dir
6
+ # RUN: touch %t.dir/test1.bc
7
+ # RUN: touch %t.dir/test2.bc
8
+ # RUN: rm -rf %t.out.dir && mkdir %t.out.dir
9
+
10
+ # RUN: %python %scripts_dir/corpus/make_corpus.py --input_dir=%t.dir --output_dir=%t.out.dir --default_args="-test"
11
+
12
+ # RUN: cat %t.out.dir/corpus_description.json | FileCheck %s
13
+
14
+ ## Check that we get the expected command in the global command override
15
+ # CHECK: "-test"
16
+ # CHECK: "has_thinlto": false
17
+ ## Check that the modules are in the corpus description
18
+ # CHECK: "test1"
19
+ # CHECK: "test2"
20
+
21
+ # RUN: ls %t.out.dir | FileCheck %s --check-prefix CHECK-DIR
22
+
23
+ # CHECK-DIR: test1.bc
24
+ # CHECK-DIR: test2.bc
Original file line number Diff line number Diff line change
1
+ import os
2
+
1
3
import lit.formats
2
4
3
5
from lit.llvm import llvm_config
4
6
5
7
config.name = " mlgo-utils"
6
8
config.test_format = lit.formats.ShTest(execute_external =False)
7
9
8
- config.suffixes = [" .py" ]
10
+ config.suffixes = [" .py" , " .test " ]
9
11
10
12
config.test_source_root = os.path.dirname(__file__)
11
13
config.test_exec_root = config.obj_root
12
14
13
15
config.environment[" PYTHONPATH" ] = os.path.join(config.src_root, " utils" , " mlgo-utils" )
14
16
15
17
llvm_config.use_default_substitutions()
18
+ config.substitutions.append((" split-file" , llvm_config.use_llvm_tool(" split-file" )))
19
+ config.substitutions.append((" yaml2obj" , llvm_config.use_llvm_tool(" yaml2obj" )))
20
+ config.substitutions.append((" llvm-objcopy" , llvm_config.use_llvm_tool(" llvm-objcopy" )))
21
+
22
+ scripts_dir = os.path.join(config.src_root, " utils/mlgo-utils/mlgo" )
23
+ config.substitutions.append((" %scripts_dir" , scripts_dir))
You can’t perform that action at this time.
0 commit comments