Movatterモバイル変換


[0]ホーム

URL:


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

Commit7312f31

Browse files
committed
uefi-test-runner: test that BootService::memory_map memory is freed
This is now a benefit compared to the old API. This wasn't possible.
1 parentca26bfa commit7312f31

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

‎uefi-test-runner/src/boot/memory.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,41 @@ fn alloc_alignment() {
6363
fnmemory_map(bt:&BootServices){
6464
info!("Testing memory map functions");
6565

66-
letmut memory_map = bt
67-
.memory_map(MemoryType::LOADER_DATA)
68-
.expect("Failed to retrieve UEFI memory map");
66+
// Ensure that the memory map is freed after each iteration (on drop).
67+
// Otherwise, we will have an OOM.
68+
for _in0..200000{
69+
letmut memory_map = bt
70+
.memory_map(MemoryType::LOADER_DATA)
71+
.expect("Failed to retrieve UEFI memory map");
6972

70-
memory_map.sort();
73+
memory_map.sort();
7174

72-
// Collect the descriptors into a vector
73-
let descriptors = memory_map.entries().copied().collect::<Vec<_>>();
75+
// Collect the descriptors into a vector
76+
let descriptors = memory_map.entries().copied().collect::<Vec<_>>();
7477

75-
// Ensured we have at least one entry.
76-
// Real memory maps usually have dozens of entries.
77-
assert!(!descriptors.is_empty(),"Memory map is empty");
78+
// Ensured we have at least one entry.
79+
// Real memory maps usually have dozens of entries.
80+
assert!(!descriptors.is_empty(),"Memory map is empty");
7881

79-
letmut curr_value = descriptors[0];
82+
letmut curr_value = descriptors[0];
8083

81-
for valuein descriptors.iter().skip(1){
82-
if value.phys_start <= curr_value.phys_start{
83-
panic!("memory map sorting failed");
84+
for valuein descriptors.iter().skip(1){
85+
if value.phys_start <= curr_value.phys_start{
86+
panic!("memory map sorting failed");
87+
}
88+
curr_value =*value;
8489
}
85-
curr_value =*value;
86-
}
8790

88-
// This is pretty much a sanity test to ensure returned memory isn't filled with random values.
89-
let first_desc = descriptors[0];
91+
// This is pretty much a basic sanity test to ensure returned memory
92+
// isn't filled with random values.
93+
let first_desc = descriptors[0];
9094

91-
#[cfg(target_arch ="x86_64")]
92-
{
93-
let phys_start = first_desc.phys_start;
94-
assert_eq!(phys_start,0,"Memory does not start at address 0");
95+
#[cfg(target_arch ="x86_64")]
96+
{
97+
let phys_start = first_desc.phys_start;
98+
assert_eq!(phys_start,0,"Memory does not start at address 0");
99+
}
100+
let page_count = first_desc.page_count;
101+
assert!(page_count !=0,"Memory map entry has size zero");
95102
}
96-
let page_count = first_desc.page_count;
97-
assert!(page_count !=0,"Memory map entry has zero size");
98103
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp