Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2bf06d5

Browse files
committed
integration test for existing simple file system code
1 parent d8affc4 commit 2bf06d5

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

‎uefi-test-runner/src/proto/media/mod.rs‎

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
mod known_disk;
22

33
use uefi::prelude::*;
4-
use uefi::proto::media::file::{Directory, File, FileSystemInfo, FileSystemVolumeLabel};
4+
use uefi::proto::media::file::{
5+
Directory, File, FileAttribute, FileMode, FileSystemInfo, FileSystemVolumeLabel, FileType,
6+
};
57
use uefi::proto::media::fs::SimpleFileSystem;
68
use uefi::proto::media::partition::PartitionInfo;
79
use uefi::table::boot::{OpenProtocolAttributes, OpenProtocolParams};
10+
use uefi::CString16;
811

912
/// Test `FileSystemInfo` and `FileSystemVolumeLabel`.
1013
fn test_file_system_info(directory: &mut Directory) {
@@ -24,8 +27,8 @@ fn test_file_system_info(directory: &mut Directory) {
2427
assert_eq!(fs_info.volume_label(), fs_vol.volume_label());
2528
}
2629

27-
pub fn test(image: Handle, bt: &BootServices) {
28-
info!("Testing Media Access protocols");
30+
pub fn test_simple_file_system_protocol(image: Handle, bt: &BootServices) {
31+
info!("Testing Simple File System Protocol");
2932

3033
if let Ok(handle) = bt.get_handle_for_protocol::<SimpleFileSystem>() {
3134
let mut sfs = bt
@@ -39,10 +42,10 @@ pub fn test(image: Handle, bt: &BootServices) {
3942
)
4043
.expect("failed to open SimpleFileSystem protocol");
4144

42-
let mut directory = sfs.open_volume().unwrap();
45+
let mut root_directory = sfs.open_volume().unwrap();
4346
let mut buffer = vec![0; 128];
4447
loop {
45-
let file_info = match directory.read_entry(&mut buffer) {
48+
let file_info = match root_directory.read_entry(&mut buffer) {
4649
Ok(info) => {
4750
if let Some(info) = info {
4851
info
@@ -60,12 +63,35 @@ pub fn test(image: Handle, bt: &BootServices) {
6063
};
6164
info!("Root directory entry: {:?}", file_info);
6265
}
63-
directory.reset_entry_readout().unwrap();
66+
root_directory.reset_entry_readout().unwrap();
6467

65-
test_file_system_info(&mut directory);
68+
test_file_system_info(&mut root_directory);
69+
70+
assert_eq!(Ok(true), root_directory.is_directory());
71+
assert_eq!(Ok(false), root_directory.is_regular_file());
72+
73+
info!("creating file in root volume");
74+
let created_file = root_directory
75+
.open(
76+
CString16::try_from("foo").unwrap().as_ref(),
77+
FileMode::CreateReadWrite,
78+
FileAttribute::empty(),
79+
)
80+
.unwrap();
81+
assert_eq!(Ok(true), created_file.is_regular_file());
82+
let created_file = match created_file.into_type().unwrap() {
83+
FileType::Regular(file) => file,
84+
_ => panic!("unsupported value"),
85+
};
86+
assert_eq!(Ok(true), created_file.is_regular_file());
87+
assert_eq!(Ok(false), created_file.is_directory());
6688
} else {
6789
warn!("`SimpleFileSystem` protocol is not available");
6890
}
91+
}
92+
93+
pub fn test_partition_info_protocol(image: Handle, bt: &BootServices) {
94+
info!("Testing Partition Info protocols");
6995

7096
let handles = bt
7197
.find_handles::<PartitionInfo>()

‎uefi-test-runner/src/proto/mod.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
1515
debug::test(image, bt);
1616
device_path::test(image, bt);
1717
loaded_image::test(image, bt);
18-
media::test(image, bt);
18+
media::test_simple_file_system_protocol(image, bt);
19+
media::test_partition_info_protocol(image, bt);
1920
network::test(image, bt);
2021
pi::test(image, bt);
2122
rng::test(image, bt);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /