Skip to content

Commit bdeb1d7

Browse files
committed
Ignore win-tcb test on non-windows
1 parent 2acd6b7 commit bdeb1d7

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
1+
// Copyright 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+
111
extern crate libc;
2-
use libc::{c_void, LPVOID, DWORD};
3-
use libc::types::os::arch::extra::LPWSTR;
412

5-
extern "system" {
6-
fn FormatMessageW(flags: DWORD,
7-
lpSrc: LPVOID,
8-
msgId: DWORD,
9-
langId: DWORD,
10-
buf: LPWSTR,
11-
nsize: DWORD,
12-
args: *const c_void)
13-
-> DWORD;
13+
#[cfg(windows)]
14+
mod imp {
15+
use libc::{c_void, LPVOID, DWORD};
16+
use libc::types::os::arch::extra::LPWSTR;
17+
18+
extern "system" {
19+
fn FormatMessageW(flags: DWORD,
20+
lpSrc: LPVOID,
21+
msgId: DWORD,
22+
langId: DWORD,
23+
buf: LPWSTR,
24+
nsize: DWORD,
25+
args: *const c_void)
26+
-> DWORD;
27+
}
28+
29+
pub fn test() {
30+
let mut buf: [u16, ..50] = [0, ..50];
31+
let ret = unsafe {
32+
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
33+
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
34+
};
35+
// On some 32-bit Windowses (Win7-8 at least) this will fail with segmented
36+
// stacks taking control of pvArbitrary
37+
assert!(ret != 0);
38+
}
1439
}
1540

16-
fn test() {
17-
let mut buf: [u16, ..50] = [0, ..50];
18-
let ret = unsafe {
19-
FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400,
20-
buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void)
21-
};
22-
// On some 32-bit Windowses (Win7-8 at least) this will fail with segmented
23-
// stacks taking control of pvArbitrary
24-
assert!(ret != 0);
41+
#[cfg(not(windows))]
42+
mod imp {
43+
pub fn test() { }
2544
}
45+
2646
fn main() {
27-
test()
28-
}
47+
imp::test()
48+
}

0 commit comments

Comments
 (0)