fixed llmp test, moved to xxh3 const
This commit is contained in:
parent
91ab778f9e
commit
634cdcf217
@ -17,7 +17,7 @@ std = []
|
|||||||
hashbrown = { version = "0.9", features = ["serde"] } # A faster hashmap, nostd compatible
|
hashbrown = { version = "0.9", features = ["serde"] } # A faster hashmap, nostd compatible
|
||||||
libc = "0.2" # For (*nix) libc
|
libc = "0.2" # For (*nix) libc
|
||||||
num = "*"
|
num = "*"
|
||||||
xxhash-rust = { version = "0.8.0-beta.5", features = ["xxh3"] } # xxh3 hashing for rust
|
xxhash-rust = { version = "0.8.0-beta.5", features = ["const_xxh3"] } # xxh3 hashing for rust
|
||||||
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
|
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
|
||||||
typetag = "0.1"
|
typetag = "0.1"
|
||||||
postcard = "0.5.1" # no_std compatible serde serialization fromat
|
postcard = "0.5.1" # no_std compatible serde serialization fromat
|
@ -80,7 +80,7 @@ unsafe fn test_adder_clientloop(client: *mut llmp_client, _data: *mut c_void) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn broker_message_hook(
|
unsafe fn broker_message_hook(
|
||||||
_broker: *mut llmp_broker,
|
_broker: *mut LlmpBroker,
|
||||||
client_metadata: *mut llmp_broker_client_metadata,
|
client_metadata: *mut llmp_broker_client_metadata,
|
||||||
message: *mut llmp_message,
|
message: *mut llmp_message,
|
||||||
_data: *mut c_void,
|
_data: *mut c_void,
|
||||||
@ -118,32 +118,17 @@ fn main() {
|
|||||||
counter_thread_count
|
counter_thread_count
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut broker = llmp_broker {
|
|
||||||
last_msg_sent: ptr::null_mut(),
|
|
||||||
broadcast_map_count: 0,
|
|
||||||
broadcast_maps: ptr::null_mut(),
|
|
||||||
msg_hook_count: 0,
|
|
||||||
msg_hooks: ptr::null_mut(),
|
|
||||||
llmp_client_count: 0,
|
|
||||||
llmp_clients: ptr::null_mut(),
|
|
||||||
};
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
let mut broker = LlmpBroker::new().expect("Failed to create llmp broker");
|
||||||
llmp_broker_init(&mut broker).expect("Could not init");
|
|
||||||
for i in 0..counter_thread_count {
|
for i in 0..counter_thread_count {
|
||||||
println!("Adding client {}", i);
|
println!("Adding client {}", i);
|
||||||
broker.register_childprocess_clientloop(
|
broker
|
||||||
llmp_test_clientloop,
|
.register_childprocess_clientloop(llmp_test_clientloop, ptr::null_mut())
|
||||||
ptr::null_mut(),
|
|
||||||
)
|
|
||||||
.expect("could not add child clientloop");
|
.expect("could not add child clientloop");
|
||||||
}
|
}
|
||||||
|
|
||||||
broker.register_childprocess_clientloop(
|
broker
|
||||||
test_adder_clientloop,
|
.register_childprocess_clientloop(test_adder_clientloop, ptr::null_mut())
|
||||||
ptr::null_mut(),
|
|
||||||
)
|
|
||||||
.expect("Error registering childprocess");
|
.expect("Error registering childprocess");
|
||||||
|
|
||||||
println!("Spawning broker");
|
println!("Spawning broker");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use core::any::{Any, TypeId};
|
use core::any::Any;
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use core::convert::Into;
|
use core::convert::Into;
|
||||||
use core::default::Default;
|
use core::default::Default;
|
||||||
|
@ -160,7 +160,7 @@ const LLMP_CLIENT_TYPE_CHILD_PROCESS: LlmpClientType = 2;
|
|||||||
/// A share mem page, as used by llmp internally
|
/// A share mem page, as used by llmp internally
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
struct llmp_page {
|
pub struct llmp_page {
|
||||||
pub sender: u32,
|
pub sender: u32,
|
||||||
pub save_to_unmap: c_ushort,
|
pub save_to_unmap: c_ushort,
|
||||||
pub sender_dead: c_ushort,
|
pub sender_dead: c_ushort,
|
||||||
@ -342,7 +342,7 @@ unsafe fn llmp_recv(page: *mut llmp_page, last_msg: *mut llmp_message) -> *mut l
|
|||||||
}
|
}
|
||||||
/* Blocks/spins until the next message gets posted to the page,
|
/* Blocks/spins until the next message gets posted to the page,
|
||||||
then returns that message. */
|
then returns that message. */
|
||||||
unsafe fn llmp_recv_blocking(
|
pub unsafe fn llmp_recv_blocking(
|
||||||
page: *mut llmp_page,
|
page: *mut llmp_page,
|
||||||
last_msg: *mut llmp_message,
|
last_msg: *mut llmp_message,
|
||||||
) -> *mut llmp_message {
|
) -> *mut llmp_message {
|
||||||
|
@ -19,6 +19,7 @@ use alloc::string::String;
|
|||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use xxhash_rust::const_xxh3::xxh3_64_with_seed;
|
||||||
|
|
||||||
/// Main error struct for AFL
|
/// Main error struct for AFL
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -78,3 +79,8 @@ mod tests {
|
|||||||
assert_eq!(2 + 2, 4);
|
assert_eq!(2 + 2, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn test_xxh3_hash() -> u64 {
|
||||||
|
xxh3_64_with_seed(b"test", 0)
|
||||||
|
}
|
||||||
|
@ -4,12 +4,12 @@ use alloc::rc::Rc;
|
|||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use core::debug_assert;
|
use core::debug_assert;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use xxhash_rust::xxh3::xxh3_64_with_seed;
|
use xxhash_rust::const_xxh3::xxh3_64_with_seed;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
pub type StdRand = XorShift64Rand;
|
pub type StdRand = Xoshiro256StarRand;
|
||||||
|
|
||||||
/// Ways to get random around here
|
/// Ways to get random around here
|
||||||
pub trait Rand: Debug {
|
pub trait Rand: Debug {
|
||||||
@ -303,6 +303,8 @@ pub const fn next_pow2(val: u64) -> u64 {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use xxhash_rust::const_xxh3::xxh3_64_with_seed;
|
||||||
|
|
||||||
use crate::utils::{next_pow2, Rand, StdRand};
|
use crate::utils::{next_pow2, Rand, StdRand};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -337,4 +339,9 @@ mod tests {
|
|||||||
assert_eq!(next_pow2(1000), 1024);
|
assert_eq!(next_pow2(1000), 1024);
|
||||||
assert_eq!(next_pow2(0xFFFFFFFF as u64), (0xFFFFFFFF as u64) + 1);
|
assert_eq!(next_pow2(0xFFFFFFFF as u64), (0xFFFFFFFF as u64) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_xxh3_hash() {
|
||||||
|
assert_eq!(xxh3_64_with_seed(b"test", 0), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user