Skip to content

Commit 8380e92

Browse files
committed
std: Add smoke test for internal dynamic loading on Windows. rust-lang#8818
1 parent 5fb2dfa commit 8380e92

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/libstd/dynamic_lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,28 @@ mod test {
161161
use libc;
162162
use mem;
163163

164+
// This is a basic smoke test that loading from the exe works, in order to provide
165+
// some Windows coverage (FIXME #8818)
166+
#[test]
167+
#[ignore(cfg(target_os="android"))] // FIXME(#10379)
168+
fn test_loading_internal_smoke() {
169+
170+
let none: Option<Path> = None; // appease the typechecker
171+
let thislib = match DynamicLibrary::open(none) {
172+
Err(error) => fail!("Could not load self as module: {}", error),
173+
Ok(thislib) => thislib
174+
};
175+
176+
// 'main' is the only function that happens to have DllExport on windows,
177+
// so let's try to load it (using the wrong sig since we're not calling it)
178+
let _main: extern fn() = unsafe {
179+
match thislib.symbol("main") {
180+
Err(error) => fail!("Could not load function testcos: {}", error),
181+
Ok(cosine) => mem::transmute::<*mut u8, _>(cosine)
182+
}
183+
};
184+
}
185+
164186
#[test]
165187
#[ignore(cfg(windows))] // FIXME #8818
166188
#[ignore(cfg(target_os="android"))] // FIXME(#10379)

0 commit comments

Comments
 (0)