1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Suppress the flurry of warnings caused by using "C" naming conventions
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

// This matches bindgen::Builder output
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn it_works() {
        unsafe {
            let stack_size = 16 * 1024;
            let heap_size = 16 * 1024;
            let err_buf: [std::os::raw::c_char; 128];
            if !wasm_runtime_init() {
                println!("init failed");
            }
            let file = include_bytes!("add.wasm");
            let wasm_module = wasm_runtime_load(file, file.len() as u32, err_buf as ptr, 0);
            assert_eq!(2 + 2, 4);
        }
    }
}