Skip to content

Commit 679694a

Browse files
authored
Merge pull request #1415 from nicholasbishop/bishop-more-bt-cleanup
test-runner: Remove remaining tests for deprecated table types
2 parents 9275ece + bb806a7 commit 679694a

File tree

4 files changed

+78
-269
lines changed

4 files changed

+78
-269
lines changed

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

+14-53
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
use alloc::vec::Vec;
2-
use uefi::boot;
3-
use uefi::mem::memory_map::{MemoryMap, MemoryMapMut, MemoryMapOwned, MemoryType};
4-
use uefi::table::boot::{AllocateType, BootServices};
2+
use uefi::boot::{self, AllocateType};
3+
use uefi::mem::memory_map::{MemoryMap, MemoryMapMut, MemoryType};
54

6-
pub fn test(bt: &BootServices) {
5+
pub fn test() {
76
info!("Testing memory functions");
87

9-
test_allocate_pages_freestanding();
10-
test_allocate_pool_freestanding();
8+
test_allocate_pages();
9+
test_allocate_pool();
1110

12-
allocate_pages(bt);
1311
vec_alloc();
1412
alloc_alignment();
1513

16-
memory_map(bt);
17-
memory_map_freestanding();
14+
test_memory_map();
1815
}
1916

20-
fn test_allocate_pages_freestanding() {
17+
fn test_allocate_pages() {
2118
let num_pages = 1;
2219
let ptr =
2320
boot::allocate_pages(AllocateType::AnyPages, MemoryType::LOADER_DATA, num_pages).unwrap();
@@ -34,7 +31,7 @@ fn test_allocate_pages_freestanding() {
3431
unsafe { boot::free_pages(ptr, num_pages) }.unwrap();
3532
}
3633

37-
fn test_allocate_pool_freestanding() {
34+
fn test_allocate_pool() {
3835
let ptr = boot::allocate_pool(MemoryType::LOADER_DATA, 10).unwrap();
3936

4037
// Verify the allocation can be written to.
@@ -46,28 +43,6 @@ fn test_allocate_pool_freestanding() {
4643
unsafe { boot::free_pool(ptr) }.unwrap();
4744
}
4845

49-
fn allocate_pages(bt: &BootServices) {
50-
info!("Allocating some pages of memory");
51-
52-
let ty = AllocateType::AnyPages;
53-
let mem_ty = MemoryType::LOADER_DATA;
54-
let pgs = bt
55-
.allocate_pages(ty, mem_ty, 1)
56-
.expect("Failed to allocate a page of memory");
57-
58-
assert_eq!(pgs % 4096, 0, "Page pointer is not page-aligned");
59-
60-
// Reinterpret the page as an array of bytes
61-
let buf = unsafe { &mut *(pgs as *mut [u8; 4096]) };
62-
63-
// If these don't fail then we properly allocated some memory.
64-
buf[0] = 0xF0;
65-
buf[4095] = 0x23;
66-
67-
// Clean up to avoid memory leaks.
68-
unsafe { bt.free_pages(pgs, 1) }.unwrap();
69-
}
70-
7146
// Simple test to ensure our custom allocator works with the `alloc` crate.
7247
fn vec_alloc() {
7348
info!("Allocating a vector through the `alloc` crate");
@@ -94,7 +69,12 @@ fn alloc_alignment() {
9469
assert_eq!(value.as_ptr() as usize % 0x100, 0, "Wrong alignment");
9570
}
9671

97-
fn check_memory_map(mut memory_map: MemoryMapOwned) {
72+
fn test_memory_map() {
73+
info!("Testing memory map functions");
74+
75+
let mut memory_map =
76+
boot::memory_map(MemoryType::LOADER_DATA).expect("Failed to retrieve UEFI memory map");
77+
9878
memory_map.sort();
9979

10080
// Collect the descriptors into a vector
@@ -125,22 +105,3 @@ fn check_memory_map(mut memory_map: MemoryMapOwned) {
125105
let page_count = first_desc.page_count;
126106
assert!(page_count != 0, "Memory map entry has size zero");
127107
}
128-
129-
fn memory_map(bt: &BootServices) {
130-
info!("Testing memory map functions");
131-
132-
let memory_map = bt
133-
.memory_map(MemoryType::LOADER_DATA)
134-
.expect("Failed to retrieve UEFI memory map");
135-
136-
check_memory_map(memory_map);
137-
}
138-
139-
fn memory_map_freestanding() {
140-
info!("Testing memory map functions (freestanding)");
141-
142-
let memory_map =
143-
boot::memory_map(MemoryType::LOADER_DATA).expect("Failed to retrieve UEFI memory map");
144-
145-
check_memory_map(memory_map);
146-
}

0 commit comments

Comments
 (0)