From 849423b100f419a48169454d661d2f378c4877c4 Mon Sep 17 00:00:00 2001 From: Niels Grewe Date: Wed, 9 Sep 2015 10:57:03 +0200 Subject: [PATCH] Actually add the rust side of the test --- gcc-test/build.rs | 4 ++++ gcc-test/tests/all.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gcc-test/build.rs b/gcc-test/build.rs index 141e36f..132614f 100644 --- a/gcc-test/build.rs +++ b/gcc-test/build.rs @@ -69,4 +69,8 @@ fn main() { println!("cargo:rustc-link-lib=msvc"); println!("cargo:rustc-link-search={}", out.display()); } + + // This tests whether we can build a library but not link it to the main crate. + // The test module will do its own linking. + gcc::Config::new().link(false).file("src/opt_linkage.c").compile("libOptLinkage.a"); } diff --git a/gcc-test/tests/all.rs b/gcc-test/tests/all.rs index ef58550..2537960 100644 --- a/gcc-test/tests/all.rs +++ b/gcc-test/tests/all.rs @@ -2,6 +2,14 @@ extern crate gcc_test; use gcc_test::*; + +// This will cause a link failure if the archive is already +// linked against the gcc_test crate. +#[link(name = "OptLinkage", kind = "static")] +extern { + fn answer() -> i32; +} + #[test] fn foo_here() { unsafe { @@ -46,3 +54,8 @@ fn msvc_here() { msvc(); } } + +#[test] +fn opt_linkage() { + unsafe { assert_eq!(answer(),42); } +}