Skip to content

Commit bc7ea02

Browse files
committed
wip: test(loader): load x86_64 Linux bzImage
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
1 parent 8e97104 commit bc7ea02

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

alioth/src/loader/linux/x86_64.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#[cfg(test)]
16+
#[path = "x86_64_test.rs"]
17+
mod tests;
18+
1519
use std::fs::File;
1620
use std::io::{BufReader, Read, Seek, SeekFrom};
1721
use std::mem::{size_of, size_of_val};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use std::env;
16+
use std::path::Path;
17+
18+
use crate::loader::linux::load;
19+
use crate::mem::mapped::{ArcMemPages, RamBus};
20+
use crate::mem::{MemRegionEntry, MemRegionType};
21+
22+
#[test]
23+
fn test_load() {
24+
let pages = ArcMemPages::from_anonymous(30 << 20, None, None).unwrap();
25+
let ram = RamBus::new();
26+
ram.add(0, pages).unwrap();
27+
28+
let entries = [(
29+
0,
30+
MemRegionEntry {
31+
size: 30 << 20,
32+
type_: MemRegionType::Ram,
33+
},
34+
)];
35+
let dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
36+
let path = Path::new(&dir).join("../resources/vmlinuz-x86_64-6.17.y");
37+
load(&ram, &entries, &path, None, None).unwrap();
38+
}

resources/vmlinuz-x86_64-6.17.y

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5d8c5bd312ca72dafaae0efb0726e8f84d7af6fa5c7391fdabe578d3e0689548
3+
size 7004160

0 commit comments

Comments
 (0)