Skip to content

Commit 0be4c33

Browse files
committed
auto merge of #13741 : klutzy/rust/test-reachable, r=alexcrichton
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. Second commit removes/updates some old tests.
2 parents a28a701 + 550f975 commit 0be4c33

File tree

9 files changed

+66
-157
lines changed

9 files changed

+66
-157
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
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -7,9 +7,18 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
// ignore-test
1110

12-
pub fn main() {
13-
let s = shell!( uname -a );
14-
log(debug, s);
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() {}
1519
}
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
}

src/test/run-pass/borrowck-nested-calls.rs

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

11-
// ignore-test FIXME (#5074) nested method calls
11+
// ignore-test FIXME (#6268) nested method calls
1212

1313
// Test that (safe) nested calls with `&mut` receivers are permitted.
1414

src/test/run-pass/int-conversion-coherence.rs

-25
This file was deleted.

src/test/run-pass/select-macro.rs

-72
This file was deleted.

src/test/run-pass/tag-align-dyn-u64.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test #7340 fails on 32-bit linux
12-
use std::ptr;
11+
// ignore-linux #7340 fails on 32-bit linux
12+
// ignore-macos #7340 fails on 32-bit macos
1313

14-
enum a_tag<A> {
15-
a_tag(A)
14+
use std::cast;
15+
16+
enum Tag<A> {
17+
Tag(A)
1618
}
1719

18-
struct t_rec {
20+
struct Rec {
1921
c8: u8,
20-
t: a_tag<u64>
22+
t: Tag<u64>
2123
}
2224

23-
fn mk_rec() -> t_rec {
24-
return t_rec { c8:0u8, t:a_tag(0u64) };
25+
fn mk_rec() -> Rec {
26+
return Rec { c8:0u8, t:Tag(0u64) };
2527
}
2628

27-
fn is_8_byte_aligned(u: &a_tag<u64>) -> bool {
28-
let p = ptr::to_unsafe_ptr(u) as uint;
29+
fn is_8_byte_aligned(u: &Tag<u64>) -> bool {
30+
let p: uint = unsafe { cast::transmute(u) };
2931
return (p & 7u) == 0u;
3032
}
3133

src/test/run-pass/tag-align-dyn-variants.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,36 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test #7340 fails on 32-bit linux
12-
use std::ptr;
11+
// ignore-linux #7340 fails on 32-bit linux
12+
// ignore-macos #7340 fails on 32-bit macos
1313

14-
enum a_tag<A,B> {
15-
varA(A),
16-
varB(B)
14+
use std::cast;
15+
16+
enum Tag<A,B> {
17+
VarA(A),
18+
VarB(B),
1719
}
1820

19-
struct t_rec<A,B> {
21+
struct Rec<A,B> {
2022
chA: u8,
21-
tA: a_tag<A,B>,
23+
tA: Tag<A,B>,
2224
chB: u8,
23-
tB: a_tag<A,B>
25+
tB: Tag<A,B>,
2426
}
2527

26-
fn mk_rec<A,B>(a: A, b: B) -> t_rec<A,B> {
27-
return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
28+
fn mk_rec<A,B>(a: A, b: B) -> Rec<A,B> {
29+
Rec { chA:0u8, tA:VarA(a), chB:1u8, tB:VarB(b) }
2830
}
2931

3032
fn is_aligned<A>(amnt: uint, u: &A) -> bool {
31-
let p = ptr::to_unsafe_ptr(u) as uint;
33+
let p: uint = unsafe { cast::transmute(u) };
3234
return (p & (amnt-1u)) == 0u;
3335
}
3436

35-
fn variant_data_is_aligned<A,B>(amnt: uint, u: &a_tag<A,B>) -> bool {
37+
fn variant_data_is_aligned<A,B>(amnt: uint, u: &Tag<A,B>) -> bool {
3638
match u {
37-
&varA(ref a) => is_aligned(amnt, a),
38-
&varB(ref b) => is_aligned(amnt, b)
39+
&VarA(ref a) => is_aligned(amnt, a),
40+
&VarB(ref b) => is_aligned(amnt, b)
3941
}
4042
}
4143

src/test/run-pass/tag-align-u64.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,27 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test #7340 fails on 32-bit linux
12-
use std::ptr;
11+
// ignore-linux #7340 fails on 32-bit linux
12+
// ignore-macos #7340 fails on 32-bit macos
1313

14-
enum a_tag {
15-
a_tag(u64)
14+
use std::cast;
15+
16+
enum Tag {
17+
Tag(u64)
1618
}
1719

18-
struct t_rec {
20+
struct Rec {
1921
c8: u8,
20-
t: a_tag
22+
t: Tag
2123
}
2224

23-
fn mk_rec() -> t_rec {
24-
return t_rec { c8:0u8, t:a_tag(0u64) };
25+
fn mk_rec() -> Rec {
26+
return Rec { c8:0u8, t:Tag(0u64) };
2527
}
2628

27-
fn is_8_byte_aligned(u: &a_tag) -> bool {
28-
let p = ptr::to_unsafe_ptr(u) as u64;
29-
return (p & 7u64) == 0u64;
29+
fn is_8_byte_aligned(u: &Tag) -> bool {
30+
let p: uint = unsafe { cast::transmute(u) };
31+
return (p & 7u) == 0u;
3032
}
3133

3234
pub fn main() {

0 commit comments

Comments
 (0)