[−][src]Crate test_cdylib
test-cdylib is a library for dynamically linking to cdylib projects from test code. This allows testing for the existence of exported items.
Testing a cdylib project
A cdylib project can be tested like this:
#[test] fn api_test() { let dylib_path = test_cdylib::build_current_project(); // Or load the shared library using any other method of your choice. let dylib = dlopen::symbor::Library::open(&dylib_path).unwrap(); // Test the api as necessary. }
This will build the current project, if it is not already built, and return the path to the compiled library.
Testing a cdylib building library
Libraries that are meant to help create cdylib interfaces can be tested like this:
#[test] fn api_gen_test() { let dylib_path = test_cdylib::build_path("tests/cdylib/api_test.rs"); // Or load the shared library using any other method of your choice. let dylib = dlopen::symbor::Library::open(&dylib_path).unwrap(); // Test the api as necessary. }
This will build the given file as a cdylib project, and return the path to the compiled library. All dependencies and dev-dependencies are available.
Functions
build_current_project | Builds the current project as a cdylib and returns the path to the compiled object. |
build_file | Builds the given file as a cdylib and returns the path to the compiled object. |