mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 00:06:34 +00:00
Run OSDK tests in host environment
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
aaf101a53e
commit
951b2f98dd
18
.github/workflows/osdk_test.yml
vendored
18
.github/workflows/osdk_test.yml
vendored
@ -14,7 +14,7 @@ on:
|
||||
jobs:
|
||||
osdk-test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
timeout-minutes: 15
|
||||
container: asterinas/asterinas:0.4.1
|
||||
steps:
|
||||
- run: echo "Running in asterinas/asterinas:0.4.1"
|
||||
@ -31,3 +31,19 @@ jobs:
|
||||
- name: Unit test
|
||||
id: unit_test
|
||||
run: cd osdk && cargo build && RUSTUP_HOME=/root/.rustup cargo test
|
||||
|
||||
# Test OSDK in the same environment as described in the OSDK User Guide in the Asterinas Book.
|
||||
osdk_doc_env_test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
container: asterinas/osdk:0.4.0
|
||||
steps:
|
||||
- run: echo "Running in asterinas/osdk:0.4.0"
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Unit test
|
||||
id: unit_test
|
||||
run: cd osdk && cargo build && RUSTUP_HOME=/root/.rustup cargo test
|
||||
|
||||
# TODO: test the demos in Asterinas Book
|
||||
|
@ -27,7 +27,7 @@ the following tools need to be installed:
|
||||
- cargo-binutils
|
||||
- gcc
|
||||
- qemu-system-x86_64
|
||||
- grub-mkrescue
|
||||
- grub
|
||||
- ovmf
|
||||
- xorriso
|
||||
|
||||
@ -42,7 +42,8 @@ cargo install cargo-binutils
|
||||
|
||||
Other tools can be installed by
|
||||
```bash
|
||||
apt install build-essential grub2-common qemu-system-x86 ovmf xorriso
|
||||
apt install build-essential grub-efi-amd64 grub2-common \
|
||||
libpixman-1-dev mtools qemu-system-x86 ovmf xorriso
|
||||
```
|
||||
|
||||
### Install
|
||||
|
@ -44,10 +44,6 @@ fn add_manifest_dependencies(cargo_metadata: &serde_json::Value, crate_name: &st
|
||||
let ktest_dep = toml::Table::from_str(&aster_crate_dep("ktest")).unwrap();
|
||||
dependencies.as_table_mut().unwrap().extend(ktest_dep);
|
||||
|
||||
// If we created a workspace by `osdk new`, we should exclude the `base` crate from the workspace.
|
||||
// let exclude = toml::Table::from_str(r#"exclude = ["target/osdk/base"]"#).unwrap();
|
||||
// manifest.insert("workspace".to_string(), toml::Value::Table(exclude));
|
||||
|
||||
let content = toml::to_string(&manifest).unwrap();
|
||||
fs::write(mainfest_path, content).unwrap();
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use std::{
|
||||
|
||||
use crate::util::{assert_success, cargo_osdk, create_workspace};
|
||||
|
||||
// #[test]
|
||||
#[test]
|
||||
fn build_with_default_manifest() {
|
||||
let workspace = "/tmp/workspace_foo";
|
||||
if Path::new(workspace).exists() {
|
||||
@ -24,7 +24,7 @@ fn build_with_default_manifest() {
|
||||
fs::remove_dir_all(workspace).unwrap();
|
||||
}
|
||||
|
||||
// #[test]
|
||||
#[test]
|
||||
fn build_with_conditional_manifest() {
|
||||
let workspace = "/tmp/workspace_bar";
|
||||
if Path::new(workspace).exists() {
|
||||
|
40
osdk/tools/Dockerfile.ubuntu22.04
Normal file
40
osdk/tools/Dockerfile.ubuntu22.04
Normal file
@ -0,0 +1,40 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
# This image is for the OSDK GitHub CI.
|
||||
# The environment is consistent with the one
|
||||
# described in the OSDK User Guide section of the Asterinas Book.
|
||||
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
grub-efi-amd64 \
|
||||
grub2-common \
|
||||
libpixman-1-dev `# running dependency for QEMU` \
|
||||
mtools `# used by grub-mkrescue` \
|
||||
ovmf \
|
||||
qemu-system-x86 \
|
||||
xorriso \
|
||||
&& apt clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Rust of both nightly and stable channel
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
ARG ASTER_RUST_VERSION
|
||||
RUN curl https://sh.rustup.rs -sSf | \
|
||||
sh -s -- --default-toolchain ${ASTER_RUST_VERSION} -y \
|
||||
&& rustup toolchain install stable \
|
||||
&& rm -rf /root/.cargo/registry && rm -rf /root/.cargo/git \
|
||||
&& cargo -V \
|
||||
&& rustup component add rust-src rustc-dev llvm-tools-preview
|
||||
|
||||
# Install cargo-binutils
|
||||
RUN cargo install cargo-binutils
|
||||
|
||||
VOLUME [ "/root/asterinas" ]
|
||||
|
||||
WORKDIR /root/asterinas
|
18
osdk/tools/build_image.sh
Executable file
18
osdk/tools/build_image.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
ASTER_ROOT_DIR=${SCRIPT_DIR}/../..
|
||||
ASTER_RUST_VERSION=$( grep -m1 -o 'nightly-[0-9]\+-[0-9]\+-[0-9]\+' ${ASTER_ROOT_DIR}/rust-toolchain.toml )
|
||||
VERSION=$( cat ${ASTER_ROOT_DIR}/VERSION )
|
||||
IMAGE_NAME=asterinas/osdk:${VERSION}
|
||||
DOCKERFILE=${SCRIPT_DIR}/Dockerfile.ubuntu22.04
|
||||
|
||||
docker build \
|
||||
-t ${IMAGE_NAME} \
|
||||
--build-arg ASTER_RUST_VERSION=${ASTER_RUST_VERSION} \
|
||||
-f ${DOCKERFILE} \
|
||||
${SCRIPT_DIR}
|
12
osdk/tools/run_container.sh
Executable file
12
osdk/tools/run_container.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
ASTER_ROOT_DIR=${SCRIPT_DIR}/../..
|
||||
VERSION=$( cat ${ASTER_ROOT_DIR}/VERSION )
|
||||
IMAGE_NAME=asterinas/osdk:${VERSION}
|
||||
|
||||
docker run -it -v ${ASTER_ROOT_DIR}:/root/asterinas ${IMAGE_NAME}
|
Reference in New Issue
Block a user