compiletest/runtest/
assembly.rs1use camino::Utf8PathBuf;
2
3use crate::runtest::{AllowUnused, CompilerKind, Emit, LinkToAux, ProcRes, TargetLocation, TestCx};
4
5impl TestCx<'_> {
6 pub(super) fn run_assembly_test(&self) {
7 if self.config.llvm_filecheck.is_none() {
8 self.fatal("missing --llvm-filecheck");
9 }
10
11 let (proc_res, output_path) = self.compile_test_and_save_assembly();
12 if !proc_res.status.success() {
13 self.fatal_proc_rec("compilation failed!", &proc_res);
14 }
15
16 if !self.props.skip_filecheck {
17 let proc_res = self.verify_with_filecheck(&output_path);
18 if !proc_res.status.success() {
19 self.fatal_proc_rec("verification with 'FileCheck' failed", &proc_res);
20 }
21 }
22 }
23
24 fn compile_test_and_save_assembly(&self) -> (ProcRes, Utf8PathBuf) {
25 let output_path = self.output_base_name().with_extension("s");
28 let input_file = &self.testpaths.file;
29
30 let emit = match self.props.assembly_output.as_deref() {
32 Some("emit-asm") => Emit::Asm,
33 Some("bpf-linker") => Emit::LinkArgsAsm,
34 Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")),
35 None => self.fatal("missing 'assembly-output' directive"),
36 };
37
38 let rustc = self.make_compile_args(
39 CompilerKind::Rustc,
40 input_file,
41 TargetLocation::ThisFile(output_path.clone()),
42 emit,
43 AllowUnused::No,
44 LinkToAux::Yes,
45 Vec::new(),
46 );
47
48 let proc_res = self.compose_and_run_compiler(rustc, None);
49 (proc_res, output_path)
50 }
51}