Expand description
Generic test suite for file system operations.
This module provides comprehensive tests for any implementation of the
FileSystemOperations trait. It includes tests for:
- File operations (create, lookup, remove)
- Directory operations (create, lookup, remove, nested)
- Rename and move operations
- Attribute get/set operations
- Error handling and edge cases
- File system consistency
- Special cases (root directory, long names, special characters)
§Usage
§Using the Macro (Recommended)
The easiest way to test your file system implementation is to use the
implement_file_system_tests! macro, which generates individual test
functions for each test category:
ⓘ
use file_system::implement_file_system_tests;
mod tests {
use super::*;
implement_file_system_tests! {
instance: MyFileSystem::new()
}
}This will generate 32+ individual #[test] functions, each testing a specific
aspect of your file system implementation.
§Using Individual Test Functions
You can also call individual test functions directly:
ⓘ
use file_system::operations::file_system::tests;
#[test]
fn test_my_file_system() {
let fs = MyFileSystem::new();
// Run all tests
tests::run_all_tests(&fs);
// Or run individual test categories
tests::test_file_operations(&fs);
tests::test_directory_operations(&fs);
tests::test_rename_operations(&fs);
}§Test Categories
§File System Structure Tests
test_file_operations- Basic file CRUD operationstest_directory_operations- Basic directory operationstest_nested_directories- Nested directory hierarchytest_rename_operations- File/directory rename and movetest_attribute_operations- Metadata get/set operations
§File I/O Tests
test_file_read_operations- Reading data from filestest_file_write_operations- Writing data to filestest_file_write_pattern- Pattern-based writingtest_file_write_vectored- Vectored (scatter-gather) I/Otest_file_position_operations- Position-based read/writetest_file_read_until- Reading until delimitertest_file_flush- Flushing buffered datatest_large_file_operations- Large file handling
§Directory I/O Tests
test_directory_read_operations- Reading directory entriestest_directory_position_operations- Directory position managementtest_directory_rewind- Rewinding directory streamtest_empty_directory_read- Reading empty directories
§Error Handling & Edge Cases
test_error_handling- Error case validationtest_file_system_consistency- Consistency checkstest_root_directory_operations- Root directory special casestest_invalid_paths- Invalid path handling
§Test Execution
implement_file_system_tests!- Macro to generate all test functions (recommended)run_all_tests- Function to execute all test categories sequentially
Macros§
- implement_
file_ system_ tests - Macro to implement all file system operation tests for a given file system instance.
Structs§
- File
System Test Capabilities - Attribute capabilities used by the generic test suite.
Functions§
- test_
attribute_ operations - Test attribute get/set operations
- test_
attribute_ operations_ with_ capabilities - Test attribute operations for a backend with explicitly configured readable and writable fields.
- test_
directory_ attributes - Test attribute operations on directories
- test_
directory_ entry_ metadata - Test directory entry metadata
- test_
directory_ operations - Test directory operations: create, lookup, remove
- test_
directory_ position_ operations - Test directory position operations
- test_
directory_ read_ operations - Test directory read operations
- test_
directory_ rewind - Test directory rewind and re-read
- test_
empty_ directory_ read - Test reading empty directory
- test_
empty_ file_ operations - Test empty file operations
- test_
error_ handling - Test error handling for various scenarios
- test_
file_ creation_ edge_ cases - Test file creation with various edge cases
- test_
file_ flush - Test file flush operation
- test_
file_ operations - Test basic file operations: create, lookup, remove
- test_
file_ position_ operations - Test file read/write at specific positions
- test_
file_ read_ operations - Test file read operations (when FileOperations::read is available)
- test_
file_ read_ until - Test file read until delimiter
- test_
file_ system_ consistency - Test file system consistency
- test_
file_ system_ operations - Generic test suite for file system operations.
- test_
file_ write_ operations - Test file write operations with various patterns
- test_
file_ write_ pattern - Test file write pattern operations
- test_
file_ write_ vectored - Test file write vectored operations
- test_
invalid_ paths - Test invalid path handling
- test_
large_ file_ operations - Test large file operations
- test_
long_ filenames - Test long file names
- test_
lookup_ with_ flags - Test file lookup with different flags
- test_
move_ between_ directories - Test moving files between directories
- test_
multiple_ operations - Test concurrent operations (if file system supports it)
- test_
nested_ directories - Test nested directory operations
- test_
open_ close_ operations - Test open and close operations
- test_
rename_ edge_ cases - Test rename edge cases
- test_
rename_ operations - Test rename/move operations
- test_
root_ directory_ operations - Test operations on root directory
- test_
special_ characters_ in_ names - Test special characters in filenames