()
| 72 | } |
| 73 | |
| 74 | pub fn get_module() -> Result<ForeignLibraryModule> { |
| 75 | let expected_version = crate::version(); |
| 76 | |
| 77 | let crate_root = Path::new(env!("CARGO_MANIFEST_DIR")); |
| 78 | let target_dir = crate_root |
| 79 | .parent() |
| 80 | .expect("Failed to find crate parent") |
| 81 | .parent() |
| 82 | .expect("Failed to find workspace root") |
| 83 | .join("target"); |
| 84 | |
| 85 | let library_dir = compute_library_dir(target_dir.as_path()); |
| 86 | let lib_path = find_cdylib(&library_dir.join("deps"))?; |
| 87 | |
| 88 | // Load the library using libloading |
| 89 | let lib = unsafe { |
| 90 | libloading::Library::new(&lib_path) |
| 91 | .map_err(|e| DataFusionError::External(Box::new(e)))? |
| 92 | }; |
| 93 | |
| 94 | let get_module: libloading::Symbol<extern "C" fn() -> ForeignLibraryModule> = unsafe { |
| 95 | lib.get(b"datafusion_ffi_get_module") |
| 96 | .map_err(|e| DataFusionError::External(Box::new(e)))? |
| 97 | }; |
| 98 | |
| 99 | let module = get_module(); |
| 100 | |
| 101 | assert_eq!((module.version)(), expected_version); |
| 102 | |
| 103 | // Leak the library to keep it loaded for the duration of the test |
| 104 | std::mem::forget(lib); |
| 105 | |
| 106 | Ok(module) |
| 107 | } |
no test coverage detected
searching dependent graphs…