|
|
@ -328,7 +328,7 @@ mod tests {
|
|
|
|
data: [u8; PAGE_SIZE * 2],
|
|
|
|
data: [u8; PAGE_SIZE * 2],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn fake_mmap(buf: &mut MMappedBuf) {
|
|
|
|
fn fake_mmap(buf: &MMappedBuf) {
|
|
|
|
override_syscall(|call| match call {
|
|
|
|
override_syscall(|call| match call {
|
|
|
|
Syscall::PerfEventOpen { .. } | Syscall::PerfEventIoctl { .. } => Ok(42),
|
|
|
|
Syscall::PerfEventOpen { .. } | Syscall::PerfEventIoctl { .. } => Ok(42),
|
|
|
|
_ => panic!(),
|
|
|
|
_ => panic!(),
|
|
|
@ -355,10 +355,10 @@ mod tests {
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg_attr(miri, ignore)]
|
|
|
|
#[cfg_attr(miri, ignore)]
|
|
|
|
fn test_no_out_bufs() {
|
|
|
|
fn test_no_out_bufs() {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
|
|
|
|
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
assert_matches!(buf.read_events(&mut []), Err(PerfBufferError::NoBuffers))
|
|
|
|
assert_matches!(buf.read_events(&mut []), Err(PerfBufferError::NoBuffers))
|
|
|
@ -367,10 +367,10 @@ mod tests {
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg_attr(miri, ignore)]
|
|
|
|
#[cfg_attr(miri, ignore)]
|
|
|
|
fn test_no_events() {
|
|
|
|
fn test_no_events() {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
|
|
|
|
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let out_buf = BytesMut::with_capacity(4);
|
|
|
|
let out_buf = BytesMut::with_capacity(4);
|
|
|
@ -386,7 +386,7 @@ mod tests {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
|
|
|
|
|
|
|
|
let evt = LostSamples {
|
|
|
|
let evt = LostSamples {
|
|
|
|
header: perf_event_header {
|
|
|
|
header: perf_event_header {
|
|
|
@ -451,7 +451,7 @@ mod tests {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
write_sample(&mut mmapped_buf, 0, 0xCAFEBABEu32);
|
|
|
|
write_sample(&mut mmapped_buf, 0, 0xCAFEBABEu32);
|
|
|
@ -469,7 +469,7 @@ mod tests {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let next = write_sample(&mut mmapped_buf, 0, 0xCAFEBABEu32);
|
|
|
|
let next = write_sample(&mut mmapped_buf, 0, 0xCAFEBABEu32);
|
|
|
@ -492,7 +492,7 @@ mod tests {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let next = write_sample(&mut mmapped_buf, 0, 0xCAFEBABEu32);
|
|
|
|
let next = write_sample(&mut mmapped_buf, 0, 0xCAFEBABEu32);
|
|
|
@ -514,7 +514,7 @@ mod tests {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let offset = PAGE_SIZE - mem::size_of::<PerfSample<u32>>();
|
|
|
|
let offset = PAGE_SIZE - mem::size_of::<PerfSample<u32>>();
|
|
|
@ -534,7 +534,7 @@ mod tests {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let header = perf_event_header {
|
|
|
|
let header = perf_event_header {
|
|
|
@ -563,7 +563,7 @@ mod tests {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
let mut mmapped_buf = MMappedBuf {
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
data: [0; PAGE_SIZE * 2],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
fake_mmap(&mut mmapped_buf);
|
|
|
|
fake_mmap(&mmapped_buf);
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
let mut buf = PerfBuffer::open(1, PAGE_SIZE, 1).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
let sample = PerfSample {
|
|
|
|
let sample = PerfSample {
|
|
|
|