diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index da78d516..44d5e944 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -26,6 +26,8 @@ jobs: steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + lfs: true - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | diff --git a/alioth/src/loader/linux/x86_64.rs b/alioth/src/loader/linux/x86_64.rs index 09f35c8d..77be4f5b 100644 --- a/alioth/src/loader/linux/x86_64.rs +++ b/alioth/src/loader/linux/x86_64.rs @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#[cfg(test)] +#[path = "x86_64_test.rs"] +mod tests; + use std::fs::File; use std::io::{BufReader, Read, Seek, SeekFrom}; use std::mem::{size_of, size_of_val}; diff --git a/alioth/src/loader/linux/x86_64_test.rs b/alioth/src/loader/linux/x86_64_test.rs new file mode 100644 index 00000000..cdfbfff2 --- /dev/null +++ b/alioth/src/loader/linux/x86_64_test.rs @@ -0,0 +1,38 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::env; +use std::path::Path; + +use crate::loader::linux::load; +use crate::mem::mapped::{ArcMemPages, RamBus}; +use crate::mem::{MemRegionEntry, MemRegionType}; + +#[test] +fn test_load() { + let pages = ArcMemPages::from_anonymous(30 << 20, None, None).unwrap(); + let ram = RamBus::new(); + ram.add(0, pages).unwrap(); + + let entries = [( + 0, + MemRegionEntry { + size: 30 << 20, + type_: MemRegionType::Ram, + }, + )]; + let dir = env::var_os("CARGO_MANIFEST_DIR").unwrap(); + let path = Path::new(&dir).join("../resources/vmlinuz-x86_64-6.17.y"); + load(&ram, &entries, &path, None, None).unwrap(); +} diff --git a/resources/vmlinuz-x86_64-6.17.y b/resources/vmlinuz-x86_64-6.17.y new file mode 100755 index 00000000..09f6d82c --- /dev/null +++ b/resources/vmlinuz-x86_64-6.17.y @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d8c5bd312ca72dafaae0efb0726e8f84d7af6fa5c7391fdabe578d3e0689548 +size 7004160