Fix `redundant_test_prefix`

This commit is contained in:
Ruihan Li 2026-02-07 23:45:31 +08:00 committed by Tate, Hongliang Tian
parent bc9f8fe964
commit c9032ad97c
23 changed files with 73 additions and 73 deletions

View File

@ -5,7 +5,7 @@ use lending_iterator::LendingIterator;
use super::{CpioDecoder, FileType, error::*};
#[test]
fn test_decoder() {
fn decoder() {
use std::process::{Command, Stdio};
let manifest_path = std::env::var("CARGO_MANIFEST_DIR").unwrap();
@ -63,7 +63,7 @@ fn test_decoder() {
}
#[test]
fn test_short_buffer() {
fn short_buffer() {
let short_buffer: Vec<u8> = Vec::new();
let mut decoder = CpioDecoder::new(short_buffer.as_slice());
let entry_result = decoder.next().unwrap();
@ -72,7 +72,7 @@ fn test_short_buffer() {
}
#[test]
fn test_invalid_buffer() {
fn invalid_buffer() {
let buffer: &[u8] = b"invalidmagic.invalidmagic.invalidmagic.invalidmagic.invalidmagic.invalidmagic.invalidmagic.invalidmagic.invalidmagic.invalidmagic";
let mut decoder = CpioDecoder::new(buffer);
let entry_result = decoder.next().unwrap();

View File

@ -260,7 +260,7 @@ mod test {
const JHASH_INITVAL: u32 = 0;
#[test]
fn test_jhash_3vals() {
fn jhash_3vals_works() {
assert_eq!(jhash_3vals(1, 2, 3, JHASH_INITVAL), 2757843189);
assert_eq!(jhash_3vals(4, 5, 6, JHASH_INITVAL), 3701334656);
@ -275,7 +275,7 @@ mod test {
}
#[test]
fn test_jhash_2vals() {
fn jhash_2vals_works() {
assert_eq!(jhash_2vals(1, 2, JHASH_INITVAL), 2337044857);
assert_eq!(jhash_2vals(3, 4, JHASH_INITVAL), 3842257880);
assert_eq!(jhash_2vals(0, 0, JHASH_INITVAL), 1489077439);
@ -285,7 +285,7 @@ mod test {
}
#[test]
fn test_jhash_1vals() {
fn jhash_1vals_works() {
assert_eq!(jhash_1vals(1, JHASH_INITVAL), 1923623579);
assert_eq!(jhash_1vals(5, JHASH_INITVAL), 4121471414);
assert_eq!(jhash_1vals(0, JHASH_INITVAL), 76781240);
@ -295,7 +295,7 @@ mod test {
}
#[test]
fn test_jhash_u32_array() {
fn jhash_u32_array_works() {
assert_eq!(jhash_u32_array(&[1, 2, 3], JHASH_INITVAL), 2757843189);
assert_eq!(jhash_u32_array(&[4, 5, 6, 7, 8], JHASH_INITVAL), 581654130);
assert_eq!(jhash_u32_array(&[], JHASH_INITVAL), 3735928559);
@ -309,7 +309,7 @@ mod test {
}
#[test]
fn test_jhash_slice() {
fn jhash_slice_works() {
assert_eq!(jhash_slice(b"hello world", JHASH_INITVAL), 1252609637);
assert_eq!(jhash_slice(b"12345", JHASH_INITVAL), 729031446);
assert_eq!(jhash_slice(b"\n\t\r", JHASH_INITVAL), 483925400);

View File

@ -158,7 +158,7 @@ fn init_demo_subsystem() {
}
#[ktest]
fn test_config_fs() {
fn config_fs() {
init_demo_subsystem();
let config_fs = super::fs::ConfigFs::singleton();

View File

@ -539,7 +539,7 @@ mod test {
}
#[ktest]
fn test_read_empty() {
fn read_empty() {
test_blocking(
|writer| {
assert_eq!(write(writer.as_ref(), &[1]).unwrap(), 1);
@ -554,7 +554,7 @@ mod test {
}
#[ktest]
fn test_write_full() {
fn write_full() {
test_blocking(
|writer| {
assert_eq!(write(writer.as_ref(), &[1, 2, 3]).unwrap(), 2);
@ -572,7 +572,7 @@ mod test {
}
#[ktest]
fn test_read_closed() {
fn read_closed() {
test_blocking(
drop,
|reader| {
@ -584,7 +584,7 @@ mod test {
}
#[ktest]
fn test_write_closed() {
fn write_closed() {
test_blocking(
|writer| {
assert_eq!(write(writer.as_ref(), &[1, 2, 3]).unwrap(), 2);
@ -599,7 +599,7 @@ mod test {
}
#[ktest]
fn test_write_atomicity() {
fn write_atomicity() {
test_blocking(
|writer| {
assert_eq!(write(writer.as_ref(), &[1]).unwrap(), 1);

View File

@ -245,7 +245,7 @@ fn init_sysfs_with_mock_tree() -> Arc<SysFs> {
}
#[ktest]
fn test_sysfs_root_lookup() {
fn root_lookup() {
// Setup: Create SysFs instance backed by the mock systree
let sysfs = init_sysfs_with_mock_tree();
let root_inode = sysfs.root_inode(); // Get the sysfs root inode
@ -280,7 +280,7 @@ fn test_sysfs_root_lookup() {
}
#[ktest]
fn test_sysfs_branch_lookup() {
fn branch_lookup() {
let sysfs = init_sysfs_with_mock_tree();
let root_inode = sysfs.root_inode();
// Action: Lookup a branch node within sysfs
@ -313,7 +313,7 @@ fn test_sysfs_branch_lookup() {
}
#[ktest]
fn test_sysfs_leaf_lookup() {
fn leaf_lookup() {
let sysfs = init_sysfs_with_mock_tree();
let root_inode = sysfs.root_inode();
// Action: Lookup a leaf node (represented as a directory in sysfs)
@ -350,7 +350,7 @@ fn test_sysfs_leaf_lookup() {
}
#[ktest]
fn test_sysfs_read_attr() {
fn read_attr() {
let sysfs = init_sysfs_with_mock_tree();
let root_inode = sysfs.root_inode();
let leaf1_dir_inode = root_inode
@ -381,7 +381,7 @@ fn test_sysfs_read_attr() {
}
#[ktest]
fn test_sysfs_write_attr() {
fn write_attr() {
let sysfs = init_sysfs_with_mock_tree();
let root_inode = sysfs.root_inode();
let leaf1_dir_inode = root_inode
@ -426,7 +426,7 @@ fn test_sysfs_write_attr() {
}
#[ktest]
fn test_sysfs_read_link() {
fn read_link() {
use crate::fs::utils::SymbolicLink;
let sysfs = init_sysfs_with_mock_tree();
@ -462,7 +462,7 @@ impl DirentVisitor for TestDirentVisitor {
}
#[ktest]
fn test_sysfs_readdir_leaf() {
fn readdir_leaf() {
let sysfs = init_sysfs_with_mock_tree();
let root_inode = sysfs.root_inode();
let leaf1_inode = root_inode
@ -510,7 +510,7 @@ fn test_sysfs_readdir_leaf() {
}
#[ktest]
fn test_sysfs_mode_permissions() {
fn mode_permissions() {
let sysfs = init_sysfs_with_mock_tree();
let root_inode = sysfs.root_inode();
let leaf1_dir_inode = root_inode

View File

@ -254,7 +254,7 @@ mod test {
use ostd::prelude::*;
#[ktest]
fn test_mkmod_and_chmod() {
fn mkmod_and_chmod() {
let mode0 = mkmod!(a+rw);
assert!(mode0.bits() == 0o666);

View File

@ -281,7 +281,7 @@ mod test {
use crate::thread::{Thread, kernel_thread::ThreadOptions};
#[ktest]
fn test_waiter_pause() {
fn waiter_pause() {
let wait_queue = Arc::new(WaitQueue::new());
let wait_queue_cloned = wait_queue.clone();

View File

@ -398,7 +398,7 @@ mod test {
use super::*;
#[ktest]
fn test_notify_before() {
fn notify_before() {
let pollee = Pollee::new();
pollee.notify(IoEvents::OUT);
@ -417,7 +417,7 @@ mod test {
}
#[ktest]
fn test_notify_middle() {
fn notify_middle() {
let pollee = Pollee::new();
assert_eq!(
@ -439,7 +439,7 @@ mod test {
}
#[ktest]
fn test_notify_after() {
fn notify_after() {
let pollee = Pollee::new();
assert_eq!(
@ -460,7 +460,7 @@ mod test {
}
#[ktest]
fn test_nested_notify_before() {
fn nested_notify_before() {
let pollee = Pollee::new();
pollee.notify(IoEvents::OUT);
@ -486,7 +486,7 @@ mod test {
}
#[ktest]
fn test_nested_notify_between() {
fn nested_notify_between() {
let pollee = Pollee::new();
assert_eq!(
@ -513,7 +513,7 @@ mod test {
}
#[ktest]
fn test_nested_notify_inside() {
fn nested_notify_inside() {
let pollee = Pollee::new();
assert_eq!(

View File

@ -271,7 +271,7 @@ mod test {
use crate::thread::{Thread, kernel_thread::ThreadOptions};
#[ktest]
fn test_condvar_wait() {
fn wait() {
let pair = Arc::new((Mutex::new(false), Condvar::new()));
let pair2 = Arc::clone(&pair);
@ -295,7 +295,7 @@ mod test {
}
#[ktest]
fn test_condvar_wait_timeout() {
fn wait_timeout() {
let pair = Arc::new((Mutex::new(false), Condvar::new()));
let pair2 = Arc::clone(&pair);
@ -321,7 +321,7 @@ mod test {
}
#[ktest]
fn test_condvar_wait_while() {
fn wait_while() {
let pair = Arc::new((Mutex::new(true), Condvar::new()));
let pair2 = Arc::clone(&pair);
@ -344,7 +344,7 @@ mod test {
}
#[ktest]
fn test_condvar_wait_timeout_while() {
fn wait_timeout_while() {
let pair = Arc::new((Mutex::new(true), Condvar::new()));
let pair2 = Arc::clone(&pair);

View File

@ -511,7 +511,7 @@ mod test {
use super::*;
#[ktest]
fn test_rb_basics() {
fn basics() {
let mut rb = RingBuffer::<i32>::new(4);
rb.push(-100).unwrap();
rb.push_slice(&[-1]).unwrap();
@ -536,7 +536,7 @@ mod test {
}
#[ktest]
fn test_rb_write_read_one() {
fn write_read_one() {
let rb = RingBuffer::<u8>::new(1);
let (mut prod, mut cons) = rb.split();
@ -582,7 +582,7 @@ mod test {
}
#[ktest]
fn test_rb_write_read_all() {
fn write_read_all() {
let rb = RingBuffer::<u8>::new(4 * PAGE_SIZE);
assert_eq!(rb.capacity(), 4 * PAGE_SIZE);

View File

@ -261,7 +261,7 @@ mod tests {
}
#[ktest]
fn test_insert_and_find_one() {
fn insert_and_find_one() {
let mut set = IntervalSet::new();
let interval = TestInterval { range: 10..20 };
set.insert(interval.clone());
@ -271,7 +271,7 @@ mod tests {
}
#[ktest]
fn test_remove() {
fn remove() {
let mut set = IntervalSet::new();
let interval = TestInterval { range: 10..20 };
set.insert(interval.clone());
@ -281,7 +281,7 @@ mod tests {
}
#[ktest]
fn test_iter() {
fn iter() {
let mut set = IntervalSet::new();
let interval1 = TestInterval { range: 10..20 };
let interval2 = TestInterval { range: 30..40 };
@ -293,7 +293,7 @@ mod tests {
}
#[ktest]
fn test_find() {
fn find() {
let mut set = IntervalSet::new();
let interval1 = TestInterval { range: 10..20 };
let interval2 = TestInterval { range: 30..40 };
@ -309,7 +309,7 @@ mod tests {
}
#[ktest]
fn test_take_one() {
fn take_one() {
let mut set = IntervalSet::new();
let interval1 = TestInterval { range: 10..20 };
let interval2 = TestInterval { range: 20..30 };
@ -321,7 +321,7 @@ mod tests {
}
#[ktest]
fn test_take() {
fn take() {
let mut set = IntervalSet::new();
let interval1 = TestInterval { range: 10..20 };
let interval2 = TestInterval { range: 30..40 };
@ -337,7 +337,7 @@ mod tests {
}
#[ktest]
fn test_clear() {
fn clear() {
let mut set = IntervalSet::new();
let interval1 = TestInterval { range: 10..20 };
let interval2 = TestInterval { range: 20..30 };

View File

@ -132,7 +132,7 @@ mod test {
use super::*;
#[ktest]
fn test_cow_copy_pt() {
fn cow_copy_pt_basic() {
let vm_space = VmSpace::new();
let map_range = PAGE_SIZE..(PAGE_SIZE * 2);
let cow_range = 0..PAGE_SIZE * 512 * 512;
@ -264,7 +264,7 @@ mod test {
}
#[ktest]
fn test_cow_copy_pt_iomem() {
fn cow_copy_pt_iomem() {
/// A very large address (1TiB) beyond typical physical memory for testing.
const IOMEM_PADDR: usize = 0x100_000_000_000;

View File

@ -257,7 +257,7 @@ mod test {
use ostd::prelude::ktest;
#[ktest]
fn test_greater_order_of() {
fn greater_order_of_works() {
#[track_caller]
fn assert_greater_order_of(nframes: usize, expected: BuddyOrder) {
assert_eq!(greater_order_of(nframes * PAGE_SIZE), expected);
@ -275,7 +275,7 @@ mod test {
}
#[ktest]
fn test_lesser_order_of() {
fn lesser_order_of_works() {
#[track_caller]
fn assert_lesser_order_of(nframes: usize, expected: BuddyOrder) {
assert_eq!(lesser_order_of(nframes * PAGE_SIZE), expected);
@ -293,7 +293,7 @@ mod test {
}
#[ktest]
fn test_max_order_from() {
fn max_order_from_works() {
#[track_caller]
fn assert_max_order_from(frame_num: usize, expected: BuddyOrder) {
assert_eq!(max_order_from(frame_num * PAGE_SIZE), expected);
@ -315,7 +315,7 @@ mod test {
}
#[ktest]
fn test_split_to_chunks() {
fn split_to_chunks_works() {
use alloc::{vec, vec::Vec};
#[track_caller]
@ -346,7 +346,7 @@ mod test {
}
#[ktest]
fn test_split_to_order() {
fn split_to_order_works() {
use alloc::{vec, vec::Vec};
#[track_caller]
@ -374,7 +374,7 @@ mod test {
}
#[ktest]
fn test_free_chunk_ops() {
fn free_chunk_ops() {
let order = 3;
let size = size_of_order(order);
let region = MockMemoryRegion::alloc(size);

View File

@ -107,7 +107,7 @@ mod test {
use ostd::prelude::ktest;
#[ktest]
fn test_buddy_set_insert_alloc() {
fn buddy_set_insert_alloc() {
let region_order = 4;
let region_size = size_of_order(region_order);
let region = MockMemoryRegion::alloc(region_size);

View File

@ -88,7 +88,7 @@ mod test {
use ostd::{cpu::PinCurrentCpu, irq, prelude::*};
#[ktest]
fn test_per_cpu_counter() {
fn per_cpu_counter() {
fast_smp_counter! {
/// The total size of free memory.
pub static FREE_SIZE_COUNTER: usize;

View File

@ -124,7 +124,7 @@ mod path_test {
use super::*;
#[ktest]
fn test_ktest_path() {
fn basics() {
let mut path = KtestPath::new();
path.push_back("a");
path.push_back("b");
@ -137,7 +137,7 @@ mod path_test {
}
#[ktest]
fn test_ktest_path_starts_with() {
fn starts_with() {
let mut path = KtestPath::new();
path.push_back("a");
path.push_back("b");
@ -152,7 +152,7 @@ mod path_test {
}
#[ktest]
fn test_ktest_path_ends_with() {
fn ends_with() {
let mut path = KtestPath::new();
path.push_back("a");
path.push_back("b");
@ -263,7 +263,7 @@ mod suffix_trie_test {
];
#[ktest]
fn test_contains() {
fn contains() {
let trie = SuffixTrie::from_paths(TEST_PATHS.iter().map(|&s| KtestPath::from(s)));
assert!(trie.contains(KtestPath::from("e::f::g::a::b::c::d").iter()));
@ -280,7 +280,7 @@ mod suffix_trie_test {
}
#[ktest]
fn test_matches() {
fn matches() {
let trie = SuffixTrie::from_paths(TEST_PATHS.iter().map(|&s| KtestPath::from(s)));
assert!(trie.matches(KtestPath::from("a::b::c::d").iter()));

View File

@ -252,7 +252,7 @@ mod tests {
}
#[ktest]
fn test_tree_iter() {
fn tree_iter() {
let tree = gen_test_case!();
let mut iter = tree.iter();
let c1 = iter.next().unwrap();
@ -263,7 +263,7 @@ mod tests {
}
#[ktest]
fn test_crate_iter() {
fn crate_iter() {
let tree = gen_test_case!();
for crate_ in tree.iter() {
if crate_.name() == "crate1" {
@ -287,7 +287,7 @@ mod tests {
}
#[ktest]
fn test_module_iter() {
fn module_iter() {
let tree = gen_test_case!();
let mut collection = Vec::<&KtestItem>::new();
for crate_ in tree.iter() {

View File

@ -76,7 +76,7 @@ mod test {
use super::*;
#[test]
fn test_align_up() {
fn align_up() {
let input_ns = [0usize, 1, 2, 9, 15, 21, 32, 47, 50];
let input_as = [2usize, 2, 2, 2, 4, 4, 8, 8, 8];
let output_ns = [0usize, 2, 2, 10, 16, 24, 32, 48, 56];
@ -90,7 +90,7 @@ mod test {
}
#[test]
fn test_align_down() {
fn align_down() {
let input_ns = [0usize, 1, 2, 9, 15, 21, 32, 47, 50];
let input_as = [2usize, 2, 2, 2, 4, 4, 8, 8, 8];
let output_ns = [0usize, 0, 2, 8, 12, 20, 32, 40, 48];

View File

@ -266,7 +266,7 @@ mod tests {
use super::*;
#[test]
fn test_screen_info_offsets() {
fn screen_info_offsets() {
assert_eq!(offset_of!(ScreenInfo, orig_x), 0x00);
assert_eq!(offset_of!(ScreenInfo, orig_y), 0x01);
assert_eq!(offset_of!(ScreenInfo, ext_mem_k), 0x02);
@ -305,7 +305,7 @@ mod tests {
}
#[test]
fn test_boot_params_offsets() {
fn boot_params_offsets() {
assert_eq!(offset_of!(BootParams, screen_info), 0x000);
assert_eq!(offset_of!(BootParams, apm_bios_info), 0x040);
assert_eq!(offset_of!(BootParams, tboot_addr), 0x058);

View File

@ -317,7 +317,7 @@ mod test {
use ostd_macros::ktest;
#[ktest]
fn test_cpu_local() {
fn cpu_local() {
crate::cpu_local! {
static FOO: RefCell<usize> = RefCell::new(1);
}
@ -330,7 +330,7 @@ mod test {
}
#[ktest]
fn test_cpu_local_cell() {
fn cpu_local_cell() {
crate::cpu_local_cell! {
static BAR: usize = 3;
}

View File

@ -106,7 +106,7 @@ impl FrameAllocOptions {
}
#[cfg(ktest)]
#[ktest]
#[ktest(expect_redundant_test_prefix)]
fn test_alloc_dealloc() {
// Here we allocate and deallocate frames in random orders to test the allocator.
// We expect the test to fail if the underlying implementation panics.

View File

@ -155,7 +155,7 @@ mod test_utils {
}
}
#[ktest]
#[ktest(expect_redundant_test_prefix)]
fn test_subset_iter() {
use alloc::{vec, vec::Vec};
@ -964,7 +964,7 @@ mod protection_and_query {
}
#[ktest]
fn test_protect_next_empty_entry() {
fn protect_next_empty_entry() {
let page_table = PageTable::<TestPtConfig>::empty();
let range = 0x1000..0x2000;
let preempt_guard = disable_preempt();
@ -979,7 +979,7 @@ mod protection_and_query {
}
#[ktest]
fn test_protect_next_touches_empty_range() {
fn protect_next_touches_empty_range() {
let page_table = PageTable::<TestPtConfig>::empty();
let range = 0x1000..0x3000; // Range spanning multiple pages.
let preempt_guard = disable_preempt();

View File

@ -140,7 +140,7 @@ mod test {
// A regression test for a bug fixed in [#1279](https://github.com/asterinas/asterinas/pull/1279).
#[ktest]
fn test_mutex_try_lock_does_not_unlock() {
fn try_lock_does_not_unlock() {
let lock = Mutex::new(0);
assert!(!lock.lock.load(Ordering::Relaxed));