mirror of
https://github.com/extism/extism.git
synced 2026-01-11 23:08:06 -05:00
Compare commits
3 Commits
kernel-tes
...
fix-clippy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bebf1cb0c | ||
|
|
04cf39e751 | ||
|
|
7133dfc4e0 |
@@ -13,7 +13,7 @@ description = "Traits to make Rust types usable with Extism"
|
||||
anyhow = "1.0.75"
|
||||
base64 = "~0.22"
|
||||
bytemuck = {version = "1.14.0", optional = true }
|
||||
prost = { version = "0.13.1", optional = true }
|
||||
prost = { version = "0.14.1", optional = true }
|
||||
protobuf = { version = "3.2.0", optional = true }
|
||||
rmp-serde = { version = "1.1.2", optional = true }
|
||||
serde = "1.0.186"
|
||||
|
||||
@@ -112,7 +112,8 @@ let mut plugin = Plugin::new(&manifest, [], true);
|
||||
let res = plugin.call::<&str, &str>("count_vowels", "Yellow, world!").unwrap();
|
||||
println!("{}", res);
|
||||
# => {"count": 3, "total": 3, "vowels": "aeiouAEIOU"}
|
||||
let mut plugin = Plugin::new(&manifest, [], true).with_config_key("vowels", "aeiouyAEIOUY");
|
||||
let manifest = Manifest::new([url]).with_config_key("vowels", "aeiouyAEIOUY");
|
||||
let mut plugin = Plugin::new(&manifest, [], true).unwrap();
|
||||
let res = plugin.call::<&str, &str>("count_vowels", "Yellow, world!").unwrap();
|
||||
println!("{}", res);
|
||||
# => {"count": 4, "total": 4, "vowels": "aeiouyAEIOUY"}
|
||||
|
||||
Binary file not shown.
@@ -225,26 +225,6 @@ fn test_kernel_allocations() {
|
||||
extism_free(&mut store, instance, q);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_kernel_page_allocations() {
|
||||
let (mut store, mut instance) = init_kernel_test();
|
||||
let instance = &mut instance;
|
||||
|
||||
let a = extism_alloc(&mut store, instance, 65500 * 4);
|
||||
let a_size = extism_length(&mut store, instance, a);
|
||||
let b = extism_alloc(&mut store, instance, 65539);
|
||||
|
||||
extism_free(&mut store, instance, a);
|
||||
let c = extism_alloc(&mut store, instance, 65500 * 2);
|
||||
let c_size = extism_length(&mut store, instance, c);
|
||||
|
||||
let d = extism_alloc(&mut store, instance, 65536);
|
||||
|
||||
assert_eq!(a + (a_size - c_size), c);
|
||||
assert!(c < b);
|
||||
assert!(d < b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_kernel_error() {
|
||||
let (mut store, mut instance) = init_kernel_test();
|
||||
@@ -456,32 +436,3 @@ quickcheck! {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
quickcheck! {
|
||||
fn check_block_reuse(allocs: Vec<u16>) -> bool {
|
||||
let (mut store, mut instance) = init_kernel_test();
|
||||
let instance = &mut instance;
|
||||
let init = extism_alloc(&mut store, instance, allocs.iter().map(|x| *x as u64).sum::<u64>() + (allocs.len() as u64 * (65535 + 128)));
|
||||
let bounds = init + extism_length(&mut store, instance, init);
|
||||
extism_free(&mut store, instance, init);
|
||||
for a in allocs {
|
||||
let ptr = extism_alloc(&mut store, instance, a as u64 + 65535);
|
||||
if ptr == 0 {
|
||||
continue
|
||||
}
|
||||
if extism_length(&mut store, instance, ptr) != a as u64 + 65535 {
|
||||
println!("FAILED ALLOC");
|
||||
return false
|
||||
}
|
||||
|
||||
extism_free(&mut store, instance, ptr);
|
||||
|
||||
if ptr > bounds {
|
||||
println!("ptr={ptr}, bounds={bounds}");
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,9 @@ fn it_works() {
|
||||
.unwrap();
|
||||
let native_avg: std::time::Duration = native_sum / native_num_tests as u32;
|
||||
|
||||
println!("native function call (avg, N = {native_num_tests}): {native_avg:?}");
|
||||
println!(
|
||||
"native function call (avg, N = {native_num_tests}): {native_avg:?}"
|
||||
);
|
||||
|
||||
let num_tests = test_times.len();
|
||||
let sum: std::time::Duration = test_times
|
||||
|
||||
Reference in New Issue
Block a user