forked from theseus-os/Theseus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'theseus_main' into idle-task-in-cpu-local
Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
- Loading branch information
Showing
42 changed files
with
727 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: QEMU Test | ||
on: | ||
pull_request: | ||
types: [synchronize, opened, reopened] | ||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: "Initialize git submodules" | ||
run: | | ||
git submodule update --init --recursive | ||
- name: "Install dependencies" | ||
run: | | ||
sudo apt update | ||
sudo apt install make gcc nasm pkg-config grub-pc-bin mtools xorriso qemu qemu-kvm wget | ||
- name: "Run tests" | ||
working-directory: . | ||
run: make test | ||
timeout-minutes: 10 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "qemu_test" | ||
version = "0.1.0" | ||
authors = ["Klim Tsoutsman <klim@tsoutsman.com>"] | ||
description = "Automated test runner" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
app_io = { path = "../../kernel/app_io" } | ||
path = { path = "../../kernel/path" } | ||
qemu-exit = "3.0.2" | ||
spawn = { path = "../../kernel/spawn" } | ||
task = { path = "../../kernel/task" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
//! An automated test runner. | ||
//! | ||
//! The application assumes it is running in a QEMU virtual machine and exits | ||
//! from QEMU with different exit codes depending on whether the tests passed or | ||
//! failed. | ||
|
||
#![no_std] | ||
|
||
use alloc::{boxed::Box, string::String, vec::Vec}; | ||
|
||
use app_io::{print, println}; | ||
use path::Path; | ||
use qemu_exit::{QEMUExit, X86}; | ||
use task::{ExitValue, KillReason}; | ||
|
||
extern crate alloc; | ||
|
||
static QEMU_EXIT_HANDLE: X86 = X86::new(0xf4, 0x11); | ||
|
||
pub fn main(_: Vec<String>) -> isize { | ||
task::set_kill_handler(Box::new(|_| { | ||
QEMU_EXIT_HANDLE.exit_failure(); | ||
})) | ||
.unwrap(); | ||
|
||
let dir = task::get_my_current_task() | ||
.map(|t| t.get_namespace().dir().clone()) | ||
.expect("couldn't get namespace dir"); | ||
|
||
let object_files = dir.lock().list(); | ||
|
||
let test_paths = object_files | ||
.into_iter() | ||
.filter_map(|file_name| { | ||
if file_name.starts_with("test_") { | ||
// We must release the lock prior to calling `get_absolute_path` to avoid | ||
// deadlock. | ||
let file = dir.lock().get_file(file_name.as_ref()).unwrap(); | ||
let path = file.lock().get_absolute_path(); | ||
Some((file_name, Path::new(path))) | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
let total = test_paths.len(); | ||
println!("running {} tests", total); | ||
|
||
let mut num_ignored = 0; | ||
let mut num_failed = 0; | ||
|
||
for (file_name, path) in test_paths.into_iter() { | ||
print!("test {} ... ", path); | ||
if ignore(&file_name) { | ||
num_ignored += 1; | ||
println!("ignored"); | ||
} else { | ||
match run_test(path) { | ||
Ok(_) => println!("ok"), | ||
Err(_) => { | ||
num_failed += 1; | ||
println!("failed"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
let result_str = if num_failed > 0 { "failed" } else { "ok" }; | ||
let num_passed = total - num_failed; | ||
println!( | ||
"test result: {result_str}. {num_passed} passed; {num_failed} failed; {num_ignored} \ | ||
ignored", | ||
); | ||
|
||
if num_failed == 0 { | ||
QEMU_EXIT_HANDLE.exit_success(); | ||
} else { | ||
QEMU_EXIT_HANDLE.exit_failure(); | ||
} | ||
} | ||
|
||
#[allow(clippy::result_unit_err)] | ||
pub fn run_test(path: Path) -> Result<(), ()> { | ||
match spawn::new_application_task_builder(path, None) | ||
.unwrap() | ||
.argument(Vec::new()) | ||
.spawn() | ||
.unwrap() | ||
.join() | ||
.unwrap() | ||
{ | ||
ExitValue::Completed(status) => match status.downcast_ref::<isize>() { | ||
Some(0) => Ok(()), | ||
_ => Err(()), | ||
}, | ||
ExitValue::Killed(KillReason::Requested) => unreachable!(), | ||
ExitValue::Killed(KillReason::Panic(_)) => Err(()), | ||
ExitValue::Killed(KillReason::Exception(_)) => Err(()), | ||
} | ||
} | ||
|
||
fn ignore(name: &str) -> bool { | ||
const IGNORED_TESTS: [&str; 3] = [ | ||
// `test_libc` requires extra Make commands to run. | ||
"test_libc", | ||
// `test_panic` panics on success, which isn't easily translatable to | ||
// `ExitValue::Completed(0)`. | ||
"test_panic", | ||
// TODO: Remove | ||
// `test_channel` has a bug that causes deadlock. | ||
"test_channel", | ||
]; | ||
for test in IGNORED_TESTS { | ||
if name.starts_with(test) { | ||
return true; | ||
} | ||
} | ||
false | ||
} |
2 changes: 1 addition & 1 deletion
2
applications/test_serial_echo/Cargo.toml → applications/serial_echo/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.