summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/block_cache.rs117
1 files changed, 91 insertions, 26 deletions
diff --git a/src/tests/block_cache.rs b/src/tests/block_cache.rs
index bbea3a0..90875ae 100644
--- a/src/tests/block_cache.rs
+++ b/src/tests/block_cache.rs
@@ -62,7 +62,10 @@ fn test_inode_allocation() {
}
let double_indirect = inode.double_indirect;
- println!("double indirect is {} after allocation", inode.double_indirect);
+ println!(
+ "double indirect is {} after allocation",
+ inode.double_indirect
+ );
fs.update_inode(inode_index, inode);
@@ -96,7 +99,10 @@ fn test_inode_deallocation() {
assert!(fs.data_bitmap.query(inode.double_indirect as usize));
for i in 0..INDIRECT_NUMBER + 5 {
- println!("Deallocated {}", fs.deallocate_block_for(&mut inode).unwrap());
+ println!(
+ "Deallocated {}",
+ fs.deallocate_block_for(&mut inode).unwrap()
+ );
}
println!("single indirect is {}", inode.single_indirect);
@@ -121,57 +127,116 @@ fn test_multiple_inode_allocation() {
const DIRECT_NUMBER: u32 = 15;
const INDIRECT_NUMBER: u32 = 1024;
- for i in 0 .. DIRECT_NUMBER + INDIRECT_NUMBER {
- println!("Allcoated {} in inode {}", fs.allocate_block_for(&mut inode_1).unwrap(), inode_index_1);
- println!("Allcoated {} in inode {}", fs.allocate_block_for(&mut inode_2).unwrap(), inode_index_2);
+ for i in 0..DIRECT_NUMBER + INDIRECT_NUMBER {
+ println!(
+ "Allocated {} in inode {}",
+ fs.allocate_block_for(&mut inode_1).unwrap(),
+ inode_index_1
+ );
+ println!(
+ "Allocated {} in inode {}",
+ fs.allocate_block_for(&mut inode_2).unwrap(),
+ inode_index_2
+ );
}
let inode_index_3 = fs.create_inode(0o755, InodeMode::IFDIR, 0, 0, 0).unwrap();
let mut inode_3 = fs.get_inode(inode_index_3).unwrap().clone();
- for _i in 0 .. INDIRECT_NUMBER {
- println!("Deallcoated {} in inode {}", fs.deallocate_block_for(&mut inode_1).unwrap(), inode_index_1);
- println!("Allcoated {} in inode {}", fs.allocate_block_for(&mut inode_3).unwrap(), inode_index_3);
+ for _i in 0..INDIRECT_NUMBER {
+ println!(
+ "Deallocated {} in inode {}",
+ fs.deallocate_block_for(&mut inode_1).unwrap(),
+ inode_index_1
+ );
+ println!(
+ "Allocated {} in inode {}",
+ fs.allocate_block_for(&mut inode_3).unwrap(),
+ inode_index_3
+ );
}
- for _i in 0 .. DIRECT_NUMBER {
- println!("Deallcoated {} in inode {}", fs.deallocate_block_for(&mut inode_1).unwrap(), inode_index_1);
+ for _i in 0..DIRECT_NUMBER {
+ println!(
+ "Deallocated {} in inode {}",
+ fs.deallocate_block_for(&mut inode_1).unwrap(),
+ inode_index_1
+ );
}
assert!(fs.deallocate_block_for(&mut inode_1).is_none());
- println!("single indirect is {} for {}", inode_1.single_indirect, inode_index_1);
- println!("double indirect is {} for {}", inode_1.double_indirect, inode_index_1);
- println!("single indirect is {} for {}", inode_2.single_indirect, inode_index_2);
- println!("double indirect is {} for {}", inode_2.double_indirect, inode_index_2);
- println!("single indirect is {} for {}", inode_3.single_indirect, inode_index_3);
- println!("double indirect is {} for {}", inode_3.double_indirect, inode_index_3);
-
- assert_eq!(fs.data_bitmap.query(inode_1.single_indirect as usize), false);
+ println!(
+ "single indirect is {} for {}",
+ inode_1.single_indirect, inode_index_1
+ );
+ println!(
+ "double indirect is {} for {}",
+ inode_1.double_indirect, inode_index_1
+ );
+ println!(
+ "single indirect is {} for {}",
+ inode_2.single_indirect, inode_index_2
+ );
+ println!(
+ "double indirect is {} for {}",
+ inode_2.double_indirect, inode_index_2
+ );
+ println!(
+ "single indirect is {} for {}",
+ inode_3.single_indirect, inode_index_3
+ );
+ println!(
+ "double indirect is {} for {}",
+ inode_3.double_indirect, inode_index_3
+ );
+
+ assert_eq!(
+ fs.data_bitmap.query(inode_1.single_indirect as usize),
+ false
+ );
assert!(fs.data_bitmap.query(inode_2.single_indirect as usize));
- assert_eq!(fs.data_bitmap.query(inode_2.double_indirect as usize), false);
+ assert_eq!(
+ fs.data_bitmap.query(inode_2.double_indirect as usize),
+ false
+ );
assert!(fs.data_bitmap.query(inode_3.single_indirect as usize));
- assert_eq!(fs.data_bitmap.query(inode_3.double_indirect as usize), false);
+ assert_eq!(
+ fs.data_bitmap.query(inode_3.double_indirect as usize),
+ false
+ );
fs.allocate_block_for(&mut inode_2).unwrap();
println!("-----------------");
- println!("double indirect is {} for {}", inode_2.double_indirect, inode_index_2);
+ println!(
+ "double indirect is {} for {}",
+ inode_2.double_indirect, inode_index_2
+ );
assert!(fs.data_bitmap.query(inode_2.double_indirect as usize));
- for _i in 0 .. DIRECT_NUMBER {
+ for _i in 0..DIRECT_NUMBER {
fs.allocate_block_for(&mut inode_3).unwrap();
}
println!("-----------------");
- println!("double indirect is {} for {}", inode_3.double_indirect, inode_index_3);
- assert_eq!(fs.data_bitmap.query(inode_3.double_indirect as usize), false);
+ println!(
+ "double indirect is {} for {}",
+ inode_3.double_indirect, inode_index_3
+ );
+ assert_eq!(
+ fs.data_bitmap.query(inode_3.double_indirect as usize),
+ false
+ );
fs.allocate_block_for(&mut inode_3).unwrap();
println!("-----------------");
- println!("double indirect is {} for {}", inode_3.double_indirect, inode_index_3);
+ println!(
+ "double indirect is {} for {}",
+ inode_3.double_indirect, inode_index_3
+ );
assert!(fs.data_bitmap.query(inode_3.double_indirect as usize));
fs.update_inode(inode_index_1, inode_1);
fs.update_inode(inode_index_2, inode_2);
fs.update_inode(inode_index_3, inode_3);
-} \ No newline at end of file
+}