1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(dead_code)]
5
6include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
7
8#[cfg(test)]
9mod tests {
10 use super::*;
11 use std::ffi::CString;
12 use std::fs;
13 use std::path::PathBuf;
14
15 #[test]
16 fn test() {
17 unsafe {
18 let hello_lief_pathbuf = PathBuf::from("testbins/hello_lief.bin");
19 let hello_lief_path = {
20 if !hello_lief_pathbuf.exists() {
21 panic!("hello_lief.bin not exists!");
22 }
23 fs::canonicalize(&hello_lief_pathbuf).expect("fs::canonicalize failed!")
24 };
25 if let Some(path) = hello_lief_path.to_str() {
26 let p = CString::new(path);
27 let hello_lief = elf_parse(p.unwrap().as_ptr()).as_mut().unwrap();
28 assert_eq!(
29 hello_lief.header.file_type,
30 LIEF_ELF_E_TYPE::LIEF_ELF_ET_DYN
31 );
32 }
33 }
34 }
35}