Skip to content

Commit 0f52122

Browse files
committed
test: Enable extern-fn-reachable test
It didn't work because it tried to call itself but symbols are not exported as default in executables. Note that `fun5` is not internal anymore since it is in library.
1 parent 6648651 commit 0f52122

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so
5+
$(RUSTC) main.rs
6+
$(call RUN,main)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type = "dylib"]
12+
#![allow(dead_code)]
13+
14+
#[no_mangle] pub extern "C" fn fun1() {}
15+
#[no_mangle] extern "C" fn fun2() {}
16+
17+
mod foo {
18+
#[no_mangle] pub extern "C" fn fun3() {}
19+
}
20+
pub mod bar {
21+
#[no_mangle] pub extern "C" fn fun4() {}
22+
}
23+
24+
#[no_mangle] pub fn fun5() {}

src/test/run-pass/extern-fn-reachable.rs renamed to src/test/run-make/extern-fn-reachable/main.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-win32 dynamic_lib can read dllexported symbols only
12-
// ignore-linux apparently dlsym doesn't work on program symbols?
13-
// ignore-android apparently dlsym doesn't work on program symbols?
14-
// ignore-freebsd apparently dlsym doesn't work on program symbols?
15-
1611
use std::unstable::dynamic_lib::DynamicLibrary;
17-
18-
#[no_mangle] pub extern "C" fn fun1() {}
19-
#[no_mangle] extern "C" fn fun2() {}
20-
21-
mod foo {
22-
#[no_mangle] pub extern "C" fn fun3() {}
23-
}
24-
pub mod bar {
25-
#[no_mangle] pub extern "C" fn fun4() {}
26-
}
27-
28-
#[no_mangle] pub fn fun5() {}
12+
use std::os;
2913

3014
pub fn main() {
3115
unsafe {
32-
let a = DynamicLibrary::open(None).unwrap();
16+
let path = Path::new("libdylib.so");
17+
let a = DynamicLibrary::open(Some(&path)).unwrap();
3318
assert!(a.symbol::<int>("fun1").is_ok());
3419
assert!(a.symbol::<int>("fun2").is_err());
3520
assert!(a.symbol::<int>("fun3").is_err());
3621
assert!(a.symbol::<int>("fun4").is_ok());
37-
assert!(a.symbol::<int>("fun5").is_err());
22+
assert!(a.symbol::<int>("fun5").is_ok());
3823
}
3924
}

0 commit comments

Comments
 (0)