Skip to content

Commit

Permalink
fix: unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Breeze-P committed Nov 1, 2024
1 parent 68be8fb commit 38ec807
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/fd_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ mod tests {
use crate::consumer::session_manager::SessionManager;
use crate::fd_pass::FdRecvServer;
use crate::ringbuf::min_ringbuf_len;
<<<<<<< HEAD
=======
use crate::ringbuf::page_align_size;
>>>>>>> 3ab2ddb (fix: unit test)

#[tokio::test]
async fn test_fd_pass() {
Expand Down Expand Up @@ -273,7 +277,11 @@ mod tests {
let path_c = path.clone();
let join = tokio::spawn(async move {
let file = tempfile::tempfile().unwrap();
<<<<<<< HEAD
file.set_len(min_ringbuf_len()).unwrap();
=======
file.set_len(page_align_size(min_ringbuf_len())).unwrap();
>>>>>>> 3ab2ddb (fix: unit test)
let client_id = format!("client_id_{}", i);
send_fd(path_c, &file, client_id).await.unwrap();
});
Expand Down
5 changes: 3 additions & 2 deletions src/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ mod tests {
use super::Ringbuf;
use crate::error;
use crate::ringbuf;
use crate::ringbuf::min_ringbuf_len;
use crate::ringbuf::page_align_metadata_len;
use crate::ringbuf::page_align_size;

Expand Down Expand Up @@ -473,11 +474,11 @@ mod tests {
#[test]
fn test_ringbuf_remain_bytes() {
let file = tempfile::tempfile().unwrap();
file.set_len(10240).unwrap();
file.set_len(min_ringbuf_len()).unwrap();

let ringbuf_producer = ringbuf::Ringbuf::new(&file).unwrap();

let actual_alloc_bytes = page_align_size(10240) as u32;
let actual_alloc_bytes = page_align_size(min_ringbuf_len()) as u32;
let datapart_len =
actual_alloc_bytes - page_align_metadata_len() as u32;

Expand Down

0 comments on commit 38ec807

Please sign in to comment.