diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /third_party/rust/pkg-config/tests | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'third_party/rust/pkg-config/tests')
-rw-r--r-- | third_party/rust/pkg-config/tests/foo.pc | 16 | ||||
-rw-r--r-- | third_party/rust/pkg-config/tests/framework.pc | 16 | ||||
-rw-r--r-- | third_party/rust/pkg-config/tests/test.rs | 97 |
3 files changed, 129 insertions, 0 deletions
diff --git a/third_party/rust/pkg-config/tests/foo.pc b/third_party/rust/pkg-config/tests/foo.pc new file mode 100644 index 000000000..b1ae3d8ce --- /dev/null +++ b/third_party/rust/pkg-config/tests/foo.pc @@ -0,0 +1,16 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include/valgrind +arch=amd64 +os=linux +platform=amd64-linux +valt_load_address=0x38000000 + +Name: Valgrind +Description: A dynamic binary instrumentation framework +Version: 3.10.0.SVN +Requires: +Libs: -L${libdir}/valgrind -lcoregrind-amd64-linux -lvex-amd64-linux -lgcc +Cflags: -I${includedir} + diff --git a/third_party/rust/pkg-config/tests/framework.pc b/third_party/rust/pkg-config/tests/framework.pc new file mode 100644 index 000000000..57c0447f1 --- /dev/null +++ b/third_party/rust/pkg-config/tests/framework.pc @@ -0,0 +1,16 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include/valgrind +arch=amd64 +os=linux +platform=amd64-linux +valt_load_address=0x38000000 + +Name: Valgrind +Description: A dynamic binary instrumentation framework +Version: 3.10.0.SVN +Requires: +Libs: -F${libdir} -framework foo +Cflags: -I${includedir} + diff --git a/third_party/rust/pkg-config/tests/test.rs b/third_party/rust/pkg-config/tests/test.rs new file mode 100644 index 000000000..842516690 --- /dev/null +++ b/third_party/rust/pkg-config/tests/test.rs @@ -0,0 +1,97 @@ +#![feature(static_mutex)] + +extern crate pkg_config; + +use pkg_config::Error; +use std::env; +use std::sync::{StaticMutex, MUTEX_INIT}; +use std::path::PathBuf; + +static LOCK: StaticMutex = MUTEX_INIT; + +fn reset() { + for (k, _) in env::vars() { + if k.contains("DYNAMIC") || + k.contains("STATIC") || + k.contains("PKG_CONFIG_ALLOW_CROSS") || + k.contains("FOO_NO_PKG_CONFIG") { + env::remove_var(&k); + } + } + env::remove_var("TARGET"); + env::remove_var("HOST"); + env::set_var("PKG_CONFIG_PATH", &env::current_dir().unwrap().join("tests")); +} + +fn find(name: &str) -> Result<pkg_config::Library, Error> { + pkg_config::probe_library(name) +} + +#[test] +fn cross_disabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + match find("foo") { + Err(Error::CrossCompilation) => {}, + x => panic!("Error::CrossCompilation expected, found `{:?}`", x), + } +} + +#[test] +fn cross_enabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("TARGET", "foo"); + env::set_var("HOST", "bar"); + env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); + find("foo").unwrap(); +} + +#[test] +fn package_disabled() { + let _g = LOCK.lock(); + reset(); + env::set_var("FOO_NO_PKG_CONFIG", "1"); + match find("foo") { + Err(Error::EnvNoPkgConfig(name)) => { + assert_eq!(name, "FOO_NO_PKG_CONFIG") + } + x => panic!("Error::EnvNoPkgConfig expected, found `{:?}`", x), + } +} + +#[test] +fn output_ok() { + let _g = LOCK.lock(); + reset(); + let lib = find("foo").unwrap(); + assert!(lib.libs.contains(&"gcc".to_string())); + assert!(lib.libs.contains(&"coregrind-amd64-linux".to_string())); + assert!(lib.link_paths.contains(&PathBuf::from("/usr/lib/valgrind"))); +} + +#[test] +fn framework() { + let _g = LOCK.lock(); + reset(); + let lib = find("framework").unwrap(); + assert!(lib.frameworks.contains(&"foo".to_string())); + assert!(lib.framework_paths.contains(&PathBuf::from("/usr/lib"))); +} + +#[test] +fn get_variable() { + let _g = LOCK.lock(); + reset(); + let prefix = pkg_config::get_variable("foo", "prefix").unwrap(); + assert_eq!(prefix, "/usr"); +} + +#[test] +fn version() { + let _g = LOCK.lock(); + reset(); + assert_eq!(&find("foo").unwrap().version[..], "3.10.0.SVN"); +} |