Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Enable extern-fn-reachable test #13741

Merged
merged 2 commits into from
Apr 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/test/run-make/extern-fn-reachable/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-include ../tools.mk

all:
$(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so
$(RUSTC) main.rs
$(call RUN,main)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -7,9 +7,18 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-test

pub fn main() {
let s = shell!( uname -a );
log(debug, s);
#![crate_type = "dylib"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file will need a license header (due to tidy)

#![allow(dead_code)]

#[no_mangle] pub extern "C" fn fun1() {}
#[no_mangle] extern "C" fn fun2() {}

mod foo {
#[no_mangle] pub extern "C" fn fun3() {}
}
pub mod bar {
#[no_mangle] pub extern "C" fn fun4() {}
}

#[no_mangle] pub fn fun5() {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-win32 dynamic_lib can read dllexported symbols only
// ignore-linux apparently dlsym doesn't work on program symbols?
// ignore-android apparently dlsym doesn't work on program symbols?
// ignore-freebsd apparently dlsym doesn't work on program symbols?

use std::unstable::dynamic_lib::DynamicLibrary;

#[no_mangle] pub extern "C" fn fun1() {}
#[no_mangle] extern "C" fn fun2() {}

mod foo {
#[no_mangle] pub extern "C" fn fun3() {}
}
pub mod bar {
#[no_mangle] pub extern "C" fn fun4() {}
}

#[no_mangle] pub fn fun5() {}
use std::os;

pub fn main() {
unsafe {
let a = DynamicLibrary::open(None).unwrap();
let path = Path::new("libdylib.so");
let a = DynamicLibrary::open(Some(&path)).unwrap();
assert!(a.symbol::<int>("fun1").is_ok());
assert!(a.symbol::<int>("fun2").is_err());
assert!(a.symbol::<int>("fun3").is_err());
assert!(a.symbol::<int>("fun4").is_ok());
assert!(a.symbol::<int>("fun5").is_err());
assert!(a.symbol::<int>("fun5").is_ok());
}
}
2 changes: 1 addition & 1 deletion src/test/run-pass/borrowck-nested-calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

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

Expand Down
25 changes: 0 additions & 25 deletions src/test/run-pass/int-conversion-coherence.rs

This file was deleted.

72 changes: 0 additions & 72 deletions src/test/run-pass/select-macro.rs

This file was deleted.

22 changes: 12 additions & 10 deletions src/test/run-pass/tag-align-dyn-u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

enum a_tag<A> {
a_tag(A)
use std::cast;

enum Tag<A> {
Tag(A)
}

struct t_rec {
struct Rec {
c8: u8,
t: a_tag<u64>
t: Tag<u64>
}

fn mk_rec() -> t_rec {
return t_rec { c8:0u8, t:a_tag(0u64) };
fn mk_rec() -> Rec {
return Rec { c8:0u8, t:Tag(0u64) };
}

fn is_8_byte_aligned(u: &a_tag<u64>) -> bool {
let p = ptr::to_unsafe_ptr(u) as uint;
fn is_8_byte_aligned(u: &Tag<u64>) -> bool {
let p: uint = unsafe { cast::transmute(u) };
return (p & 7u) == 0u;
}

Expand Down
30 changes: 16 additions & 14 deletions src/test/run-pass/tag-align-dyn-variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,36 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

enum a_tag<A,B> {
varA(A),
varB(B)
use std::cast;

enum Tag<A,B> {
VarA(A),
VarB(B),
}

struct t_rec<A,B> {
struct Rec<A,B> {
chA: u8,
tA: a_tag<A,B>,
tA: Tag<A,B>,
chB: u8,
tB: a_tag<A,B>
tB: Tag<A,B>,
}

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

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

fn variant_data_is_aligned<A,B>(amnt: uint, u: &a_tag<A,B>) -> bool {
fn variant_data_is_aligned<A,B>(amnt: uint, u: &Tag<A,B>) -> bool {
match u {
&varA(ref a) => is_aligned(amnt, a),
&varB(ref b) => is_aligned(amnt, b)
&VarA(ref a) => is_aligned(amnt, a),
&VarB(ref b) => is_aligned(amnt, b)
}
}

Expand Down
24 changes: 13 additions & 11 deletions src/test/run-pass/tag-align-u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

enum a_tag {
a_tag(u64)
use std::cast;

enum Tag {
Tag(u64)
}

struct t_rec {
struct Rec {
c8: u8,
t: a_tag
t: Tag
}

fn mk_rec() -> t_rec {
return t_rec { c8:0u8, t:a_tag(0u64) };
fn mk_rec() -> Rec {
return Rec { c8:0u8, t:Tag(0u64) };
}

fn is_8_byte_aligned(u: &a_tag) -> bool {
let p = ptr::to_unsafe_ptr(u) as u64;
return (p & 7u64) == 0u64;
fn is_8_byte_aligned(u: &Tag) -> bool {
let p: uint = unsafe { cast::transmute(u) };
return (p & 7u) == 0u;
}

pub fn main() {
Expand Down