0.3.0: converge relibc to upstream 0.6.0 + Red Bear patches
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
extern crate dlmalloc;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::thread;
|
||||
|
||||
#[global_allocator]
|
||||
#[cfg(feature = "global")]
|
||||
static A: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc;
|
||||
|
||||
#[test]
|
||||
fn foo() {
|
||||
println!("hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn map() {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(1, 2);
|
||||
m.insert(5, 3);
|
||||
drop(m);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strings() {
|
||||
format!("foo, bar, {}", "baz");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
fn threads() {
|
||||
assert!(thread::spawn(|| panic!()).join().is_err());
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
use arbitrary::Unstructured;
|
||||
use dlmalloc::Dlmalloc;
|
||||
use rand::{rngs::SmallRng, RngCore, SeedableRng};
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
let mut a = Dlmalloc::new();
|
||||
unsafe {
|
||||
let ptr = a.malloc(1, 1);
|
||||
assert!(!ptr.is_null());
|
||||
*ptr = 9;
|
||||
assert_eq!(*ptr, 9);
|
||||
a.free(ptr, 1, 1);
|
||||
|
||||
let ptr = a.malloc(1, 1);
|
||||
assert!(!ptr.is_null());
|
||||
*ptr = 10;
|
||||
assert_eq!(*ptr, 10);
|
||||
a.free(ptr, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[path = "../fuzz/src/lib.rs"]
|
||||
mod fuzz;
|
||||
|
||||
#[test]
|
||||
fn stress() {
|
||||
let mut rng = SmallRng::seed_from_u64(0);
|
||||
let mut buf = vec![0; 4096];
|
||||
let iters = if cfg!(miri) { 5 } else { 2000 };
|
||||
for _ in 0..iters {
|
||||
rng.fill_bytes(&mut buf);
|
||||
let mut u = Unstructured::new(&buf);
|
||||
let _ = fuzz::run(&mut u);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user