Add OSDK demos in Asterinas Book in OSDK integration test

This commit is contained in:
Jianfeng Jiang
2024-03-14 09:17:49 +00:00
committed by Tate, Hongliang Tian
parent 11ff0521e7
commit 63499c675c
15 changed files with 240 additions and 35 deletions

View File

@ -0,0 +1,46 @@
// SPDX-License-Identifier: MPL-2.0
use std::{fs, path::PathBuf};
use crate::util::cargo_osdk;
#[test]
fn create_a_kernel_project() {
let workdir = "/tmp";
let kernel = "my_foo_os";
let kernel_path = PathBuf::from(workdir).join(kernel);
if kernel_path.exists() {
fs::remove_dir_all(&kernel_path).unwrap();
}
cargo_osdk(&["new", "--kernel", kernel])
.current_dir(workdir)
.unwrap();
assert!(kernel_path.is_dir());
assert!(kernel_path.join("Cargo.toml").is_file());
assert!(kernel_path.join("rust-toolchain.toml").is_file());
fs::remove_dir_all(&kernel_path).unwrap();
}
#[test]
fn create_a_library_project() {
let workdir = "/tmp";
let module = "my_foo_module";
let module_path = PathBuf::from(workdir).join(module);
if module_path.exists() {
fs::remove_dir_all(&module_path).unwrap();
}
cargo_osdk(&["new", module]).current_dir(workdir).unwrap();
assert!(module_path.is_dir());
assert!(module_path.join("Cargo.toml").is_file());
assert!(module_path.join("rust-toolchain.toml").is_file());
fs::remove_dir_all(&module_path).unwrap();
}