From 0f52122fa23a3b0e853bc8b4ebe29d6102201274 Mon Sep 17 00:00:00 2001 From: klutzy Date: Fri, 25 Apr 2014 13:57:54 +0900 Subject: [PATCH 1/2] 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. --- .../run-make/extern-fn-reachable/Makefile | 6 +++++ .../run-make/extern-fn-reachable/dylib.rs | 24 +++++++++++++++++++ .../extern-fn-reachable/main.rs} | 23 ++++-------------- 3 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 src/test/run-make/extern-fn-reachable/Makefile create mode 100644 src/test/run-make/extern-fn-reachable/dylib.rs rename src/test/{run-pass/extern-fn-reachable.rs => run-make/extern-fn-reachable/main.rs} (55%) diff --git a/src/test/run-make/extern-fn-reachable/Makefile b/src/test/run-make/extern-fn-reachable/Makefile new file mode 100644 index 0000000000000..0560626c9994f --- /dev/null +++ b/src/test/run-make/extern-fn-reachable/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so + $(RUSTC) main.rs + $(call RUN,main) diff --git a/src/test/run-make/extern-fn-reachable/dylib.rs b/src/test/run-make/extern-fn-reachable/dylib.rs new file mode 100644 index 0000000000000..f24265e7a5229 --- /dev/null +++ b/src/test/run-make/extern-fn-reachable/dylib.rs @@ -0,0 +1,24 @@ +// 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. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +#![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() {} diff --git a/src/test/run-pass/extern-fn-reachable.rs b/src/test/run-make/extern-fn-reachable/main.rs similarity index 55% rename from src/test/run-pass/extern-fn-reachable.rs rename to src/test/run-make/extern-fn-reachable/main.rs index 615013888bd13..e05d43145d7e2 100644 --- a/src/test/run-pass/extern-fn-reachable.rs +++ b/src/test/run-make/extern-fn-reachable/main.rs @@ -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::("fun1").is_ok()); assert!(a.symbol::("fun2").is_err()); assert!(a.symbol::("fun3").is_err()); assert!(a.symbol::("fun4").is_ok()); - assert!(a.symbol::("fun5").is_err()); + assert!(a.symbol::("fun5").is_ok()); } } From 550f975f6d0b32470d3b2cabf88c9fa78e22959e Mon Sep 17 00:00:00 2001 From: klutzy Date: Fri, 25 Apr 2014 14:29:30 +0900 Subject: [PATCH 2/2] test: Remove/update some old ignored tests --- src/test/run-pass/borrowck-nested-calls.rs | 2 +- src/test/run-pass/int-conversion-coherence.rs | 25 ------- src/test/run-pass/select-macro.rs | 72 ------------------- src/test/run-pass/syntax-extension-shell.rs | 15 ---- src/test/run-pass/tag-align-dyn-u64.rs | 22 +++--- src/test/run-pass/tag-align-dyn-variants.rs | 30 ++++---- src/test/run-pass/tag-align-u64.rs | 24 ++++--- 7 files changed, 42 insertions(+), 148 deletions(-) delete mode 100644 src/test/run-pass/int-conversion-coherence.rs delete mode 100644 src/test/run-pass/select-macro.rs delete mode 100644 src/test/run-pass/syntax-extension-shell.rs diff --git a/src/test/run-pass/borrowck-nested-calls.rs b/src/test/run-pass/borrowck-nested-calls.rs index 993b8d506d25e..315f6c80d4e11 100644 --- a/src/test/run-pass/borrowck-nested-calls.rs +++ b/src/test/run-pass/borrowck-nested-calls.rs @@ -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. diff --git a/src/test/run-pass/int-conversion-coherence.rs b/src/test/run-pass/int-conversion-coherence.rs deleted file mode 100644 index ad414bec22692..0000000000000 --- a/src/test/run-pass/int-conversion-coherence.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test -// -// Problem here is that transactions aren't implemented for integer literal -// inference. - -trait plus { - fn plus() -> int; -} - -impl foo of plus for uint { fn plus() -> int { self as int + 20 } } -impl foo of plus for int { fn plus() -> int { self + 10 } } - -pub fn main() { - assert_eq!(10.plus(), 20); -} diff --git a/src/test/run-pass/select-macro.rs b/src/test/run-pass/select-macro.rs deleted file mode 100644 index 7ab36c622668b..0000000000000 --- a/src/test/run-pass/select-macro.rs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - this isn't really a test. - - { - -// select! -macro_rules! select_if ( - - { - $index:expr, - $count:expr - } => { - fail!() - }; - - { - $index:expr, - $count:expr, - $port:path => [ - $(type_this $message:path$(($(x $x: ident),+))dont_type_this* - -> $next:ident => { $e:expr }),+ - ] - $(, $ports:path => [ - $(type_this $messages:path$(($(x $xs: ident),+))dont_type_this* - -> $nexts:ident => { $es:expr }),+ - ] )* - } => { - if $index == $count { - match pipes::try_recv($port) { - $(Some($message($($($x,)+)* next)) => { - let $next = next; - $e - })+ - _ => fail!() - } - } else { - select_if!( - $index, - $count + 1 - $(, $ports => [ - $(type_this $messages$(($(x $xs),+))dont_type_this* - -> $nexts => { $es }),+ - ])* - ) - } - }; -) - -macro_rules! select ( - { - $( $port:path => { - $($message:path$(($($x: ident),+))dont_type_this* - -> $next:ident $e:expr),+ - } )+ - } => { - let index = pipes::selecti([$(($port).header()),+]); - select_if!(index, 0 $(, $port => [ - $(type_this $message$(($(x $x),+))dont_type_this* -> $next => { $e }),+ - ])+) - } -) - -} diff --git a/src/test/run-pass/syntax-extension-shell.rs b/src/test/run-pass/syntax-extension-shell.rs deleted file mode 100644 index 15c8b7a835e8b..0000000000000 --- a/src/test/run-pass/syntax-extension-shell.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , 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); -} diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs index 60786075697ba..72f2917a2129a 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -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_tag(A) +use std::cast; + +enum Tag { + Tag(A) } -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 uint; +fn is_8_byte_aligned(u: &Tag) -> bool { + let p: uint = unsafe { cast::transmute(u) }; return (p & 7u) == 0u; } diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 41ae28f0a9d94..70590b768b1d6 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -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 { - varA(A), - varB(B) +use std::cast; + +enum Tag { + VarA(A), + VarB(B), } -struct t_rec { +struct Rec { chA: u8, - tA: a_tag, + tA: Tag, chB: u8, - tB: a_tag + tB: Tag, } -fn mk_rec(a: A, b: B) -> t_rec { - return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) }; +fn mk_rec(a: A, b: B) -> Rec { + Rec { chA:0u8, tA:VarA(a), chB:1u8, tB:VarB(b) } } fn is_aligned(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(amnt: uint, u: &a_tag) -> bool { +fn variant_data_is_aligned(amnt: uint, u: &Tag) -> 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) } } diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index 351c2dec99b7e..4c126d68fef90 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -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() {