Skip to content

Commit 9fba1e9

Browse files
committed
test: add rust import tests
1 parent 3dcab80 commit 9fba1e9

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// RUN: mkdir -p %t
3+
// RUN: rustc --crate-type=lib --emit=llvm-ir -g %S/simple.rs -o %t/example.ll
4+
// RUN: gluc %s -I %t -o %t/import-rust && %t/import-rust | FileCheck -v %s
5+
//
6+
7+
import example;
8+
9+
@no_mangling @c_variadic func printf(s: *Char) -> Int;
10+
11+
func main() {
12+
// CHECK: Pizza count is 42, compiler is Rust
13+
printf("Pizza count is %d, compiler is %.*s\n", example::get_pizza_count(), example::get_cc().length, example::get_cc().data_ptr);
14+
}

test/functional/IRDec/simple.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// RUN: rustc --crate-type=lib --emit=llvm-ir -g %s -o %t.ll
3+
// RUN: gluc %t.ll -print-interface | FileCheck -v %s
4+
//
5+
6+
#![no_main]
7+
8+
// CHECK: @linkage_name({{.*}}) public func get_pizza_count() -> UInt64;
9+
pub fn get_pizza_count() -> u64
10+
{
11+
42
12+
}
13+
14+
// CHECK: @linkage_name({{.*}}) public func get_cc() -> [[STRUCT_NAME:.*]];
15+
pub fn get_cc() -> &'static str
16+
{
17+
"Rust"
18+
}
19+
20+
// CHECK: struct [[STRUCT_NAME]] {
21+
// CHECK-NEXT: data_ptr: *UInt8,
22+
// CHECK-NEXT: length: UInt64,
23+
// CHECK-NEXT: }

test/functional/lit.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import os
33

44
config.name = "Glu functional tests"
55
config.test_format = lit.formats.ShTest(execute_external=True)
6-
config.suffixes = ['.glu', '.c', '.cpp']
6+
config.suffixes = ['.glu', '.c', '.cpp', '.rs']
77

88
# Add LLVM tools directory to PATH
99
llvm_tools_dir = '@LLVM_TOOLS_BINARY_DIR@'

0 commit comments

Comments
 (0)