Skip to content

Commit

Permalink
Simplify some uses of cfg in test cases
Browse files Browse the repository at this point in the history
While adding PowerPC64 support it was noticed that some testcases should
just use target_pointer_width, and others should select between
x86 and !x86.
  • Loading branch information
antonblanchard committed Jan 13, 2016
1 parent 7ff64b2 commit 12aec07
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 26 deletions.
3 changes: 1 addition & 2 deletions src/test/auxiliary/extern_calling_convention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) {
}

#[inline(never)]
#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64",
target_arch = "powerpc64", target_arch = "powerpc64le"))]
#[cfg(not(target_arch = "x86_64"))]
pub extern fn foo(a: isize, b: isize, c: isize, d: isize) {
assert_eq!(a, 1);
assert_eq!(b, 2);
Expand Down
5 changes: 2 additions & 3 deletions src/test/run-pass/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[cfg(any(target_arch = "x86", target_arch = "arm"))]
#[cfg(any(target_pointer_width = "32"))]
fn target() {
assert_eq!(-1000isize as usize >> 3_usize, 536870787_usize);
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64",
target_arch = "powerpc64", target_arch = "powerpc64le"))]
#[cfg(any(target_pointer_width = "64"))]
fn target() {
assert_eq!(-1000isize as usize >> 3_usize, 2305843009213693827_usize);
}
Expand Down
4 changes: 1 addition & 3 deletions src/test/run-pass/intrinsic-alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ mod m {
}

#[main]
#[cfg(any(target_arch = "x86_64", target_arch = "arm",
target_arch = "aarch64", target_arch = "powerpc64",
target_arch = "powerpc64le"))]
#[cfg(not(target_arch = "x86"))]
pub fn main() {
unsafe {
assert_eq!(::rusti::pref_align_of::<u64>(), 8);
Expand Down
5 changes: 2 additions & 3 deletions src/test/run-pass/issue-2895.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ impl Drop for Kitty {
fn drop(&mut self) {}
}

#[cfg(any(target_arch = "x86_64", target_arch="aarch64",
target_arch="powerpc64", target_arch="powerpc64le"))]
#[cfg(target_pointer_width = "64")]
pub fn main() {
assert_eq!(mem::size_of::<Cat>(), 8 as usize);
assert_eq!(mem::size_of::<Kitty>(), 16 as usize);
}

#[cfg(any(target_arch = "x86", target_arch = "arm"))]
#[cfg(target_pointer_width = "32")]
pub fn main() {
assert_eq!(mem::size_of::<Cat>(), 4 as usize);
assert_eq!(mem::size_of::<Kitty>(), 8 as usize);
Expand Down
9 changes: 0 additions & 9 deletions src/test/run-pass/rec-align-u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ struct Outer {
t: Inner
}


#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64",
target_arch = "powerpc64", target_arch = "powerpc64le"))]
mod m {
pub fn align() -> usize { 4 }
pub fn size() -> usize { 8 }
}

#[cfg(target_arch = "x86_64")]
mod m {
pub fn align() -> usize { 4 }
pub fn size() -> usize { 8 }
Expand Down
4 changes: 1 addition & 3 deletions src/test/run-pass/rec-align-u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ mod m {
pub fn size() -> usize { 12 }
}

#[cfg(any(target_arch = "x86_64", target_arch = "arm",
target_arch = "aarch64", target_arch = "powerpc64",
target_arch = "powerpc64le"))]
#[cfg(not(target_arch = "x86"))]
pub mod m {
pub fn align() -> usize { 8 }
pub fn size() -> usize { 16 }
Expand Down
5 changes: 2 additions & 3 deletions src/test/run-pass/struct-return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ fn test1() {
}
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64",
target_arch = "powerpc64", target_arch = "powerpc64le"))]
#[cfg(target_pointer_width = "64")]
fn test2() {
unsafe {
let f = Floats { a: 1.234567890e-15_f64,
Expand All @@ -60,7 +59,7 @@ fn test2() {
}
}

#[cfg(any(target_arch = "x86", target_arch = "arm"))]
#[cfg(target_pointer_width = "32")]
fn test2() {
}

Expand Down

0 comments on commit 12aec07

Please sign in to comment.