Move test/* to test/initramfs/*

This commit is contained in:
Chen Chengjun 2026-01-12 02:02:10 +00:00 committed by Tate, Hongliang Tian
parent 4fa2b55e47
commit bae5de9e8f
498 changed files with 41 additions and 42 deletions

View File

@ -1,6 +1,6 @@
# Ignore binaries to avoid performance issues # Ignore binaries to avoid performance issues
target/ target/
test/build/ test/initramfs/build/
# QEMU log file # QEMU log file
qemu.log qemu.log

View File

@ -41,7 +41,7 @@ runs:
shell: bash shell: bash
run: | run: |
make install_osdk make install_osdk
bash test/src/benchmark/bench_linux_and_aster.sh "${{ matrix.benchmarks }}" "${{ inputs.platform }}" bash test/initramfs/src/benchmark/bench_linux_and_aster.sh "${{ matrix.benchmarks }}" "${{ inputs.platform }}"
BENCHMARK_ARTIFACT=results_$(echo "${{ matrix.benchmarks }}" | tr '/' '-') BENCHMARK_ARTIFACT=results_$(echo "${{ matrix.benchmarks }}" | tr '/' '-')
echo "BENCHMARK_ARTIFACT=$BENCHMARK_ARTIFACT" >> $GITHUB_ENV echo "BENCHMARK_ARTIFACT=$BENCHMARK_ARTIFACT" >> $GITHUB_ENV
@ -76,8 +76,8 @@ runs:
BENCHMARK_DIR=$(echo "$benchmark_id" | sed 's/-/\//g') BENCHMARK_DIR=$(echo "$benchmark_id" | sed 's/-/\//g')
BENCHMARK_SUITE=$(echo "$BENCHMARK_DIR" | awk -F'/' '{print $1}') BENCHMARK_SUITE=$(echo "$BENCHMARK_DIR" | awk -F'/' '{print $1}')
BENCHMARK_NAME=$(echo "$BENCHMARK_DIR" | sed -E 's|^[^/]+/||; s|/bench_results||g; s|/|_|g') BENCHMARK_NAME=$(echo "$BENCHMARK_DIR" | sed -E 's|^[^/]+/||; s|/bench_results||g; s|/|_|g')
BENCH_RESULT_YAML="test/src/benchmark/${BENCHMARK_DIR}/bench_result.yaml" BENCH_RESULT_YAML="test/initramfs/src/benchmark/${BENCHMARK_DIR}/bench_result.yaml"
[ -f "$BENCH_RESULT_YAML" ] || BENCH_RESULT_YAML="test/src/benchmark/${BENCHMARK_DIR}.yaml" [ -f "$BENCH_RESULT_YAML" ] || BENCH_RESULT_YAML="test/initramfs/src/benchmark/${BENCHMARK_DIR}.yaml"
if [ ! -f "$BENCH_RESULT_YAML" ]; then if [ ! -f "$BENCH_RESULT_YAML" ]; then
echo "Warning: YAML file not found for $benchmark_id at $BENCH_RESULT_YAML. Skipping config generation." echo "Warning: YAML file not found for $benchmark_id at $BENCH_RESULT_YAML. Skipping config generation."
@ -91,9 +91,9 @@ runs:
DESCRIPTION=$(yq -r '.chart.description // "No description provided"' "$BENCH_RESULT_YAML") DESCRIPTION=$(yq -r '.chart.description // "No description provided"' "$BENCH_RESULT_YAML")
# Generate summary JSON if needed (only once per suite) # Generate summary JSON if needed (only once per suite)
SUMMARY_JSON="test/src/benchmark/$BENCHMARK_SUITE/summary.json" SUMMARY_JSON="test/initramfs/src/benchmark/$BENCHMARK_SUITE/summary.json"
if [ ! -f "$SUMMARY_JSON" ]; then if [ ! -f "$SUMMARY_JSON" ]; then
SUMMARY_YAML="test/src/benchmark/$BENCHMARK_SUITE/summary.yaml" SUMMARY_YAML="test/initramfs/src/benchmark/$BENCHMARK_SUITE/summary.yaml"
if [ -f "$SUMMARY_YAML" ]; then if [ -f "$SUMMARY_YAML" ]; then
yq . "$SUMMARY_YAML" > "$SUMMARY_JSON" yq . "$SUMMARY_YAML" > "$SUMMARY_JSON"
echo "Generated $SUMMARY_JSON" echo "Generated $SUMMARY_JSON"

View File

@ -35,8 +35,8 @@ check-file = false
# Files listed below are ignored to check. # Files listed below are ignored to check.
[files] [files]
extend-exclude = [ extend-exclude = [
"test/src/syscall/gvisor/blocklists/pty_test", "test/initramfs/src/syscall/gvisor/blocklists/pty_test",
"test/build/initramfs/opt/gvisor/blocklists/pty_test", "test/initramfs/build/initramfs/opt/gvisor/blocklists/pty_test",
"test/src/syscall/gvisor/blocklists/sync_test", "test/initramfs/src/syscall/gvisor/blocklists/sync_test",
"test/build/initramfs/opt/gvisor/blocklists/sync_test", "test/initramfs/build/initramfs/opt/gvisor/blocklists/sync_test",
] ]

View File

@ -21,7 +21,7 @@ OSTD_TASK_STACK_SIZE_IN_PAGES ?= 64
FEATURES ?= FEATURES ?=
NO_DEFAULT_FEATURES ?= 0 NO_DEFAULT_FEATURES ?= 0
COVERAGE ?= 0 COVERAGE ?= 0
# Specify whether to build regression tests under `test/src/apps`. # Specify whether to build regression tests under `test/initramfs/src/apps`.
ENABLE_BASIC_TEST ?= false ENABLE_BASIC_TEST ?= false
# Specify the primary system console (supported: hvc0, tty0). # Specify the primary system console (supported: hvc0, tty0).
# - hvc0: The virtio-console terminal. # - hvc0: The virtio-console terminal.
@ -192,7 +192,7 @@ endif
# Skip GZIP to make encoding and decoding of initramfs faster # Skip GZIP to make encoding and decoding of initramfs faster
ifeq ($(INITRAMFS_SKIP_GZIP),1) ifeq ($(INITRAMFS_SKIP_GZIP),1)
CARGO_OSDK_INITRAMFS_OPTION := --initramfs=$(abspath test/build/initramfs.cpio) CARGO_OSDK_INITRAMFS_OPTION := --initramfs=$(abspath test/initramfs/build/initramfs.cpio)
CARGO_OSDK_COMMON_ARGS += $(CARGO_OSDK_INITRAMFS_OPTION) CARGO_OSDK_COMMON_ARGS += $(CARGO_OSDK_INITRAMFS_OPTION)
endif endif
@ -296,7 +296,7 @@ check_vdso:
.PHONY: initramfs .PHONY: initramfs
initramfs: check_vdso initramfs: check_vdso
@$(MAKE) --no-print-directory -C test @$(MAKE) --no-print-directory -C test/initramfs
# Build the kernel with an initramfs # Build the kernel with an initramfs
.PHONY: kernel .PHONY: kernel
@ -425,7 +425,7 @@ book:
format: format:
@./tools/format_all.sh @./tools/format_all.sh
@nixfmt ./distro @nixfmt ./distro
@$(MAKE) --no-print-directory -C test format @$(MAKE) --no-print-directory -C test/initramfs format
.PHONY: check .PHONY: check
check: initramfs $(CARGO_OSDK) check: initramfs $(CARGO_OSDK)
@ -469,7 +469,7 @@ check: initramfs $(CARGO_OSDK)
done done
@ @
@# Check formatting issues of the C code and Nix files (regression tests) @# Check formatting issues of the C code and Nix files (regression tests)
@$(MAKE) --no-print-directory -C test check @$(MAKE) --no-print-directory -C test/initramfs check
@ @
@# Check typos @# Check typos
@typos @typos
@ -485,6 +485,6 @@ clean:
@echo "Cleaning up mdBook output files" @echo "Cleaning up mdBook output files"
@cd book && mdbook clean @cd book && mdbook clean
@echo "Cleaning up test target files" @echo "Cleaning up test target files"
@$(MAKE) --no-print-directory -C test clean @$(MAKE) --no-print-directory -C test/initramfs clean
@echo "Uninstalling OSDK" @echo "Uninstalling OSDK"
@rm -f $(CARGO_OSDK) @rm -f $(CARGO_OSDK)

View File

@ -22,7 +22,7 @@ kcmd_args = [
"init=/usr/bin/busybox", "init=/usr/bin/busybox",
] ]
init_args = ["sh", "-l"] init_args = ["sh", "-l"]
initramfs = "test/build/initramfs.cpio.gz" initramfs = "test/initramfs/build/initramfs.cpio.gz"
# Special options for testing # Special options for testing
[test.qemu] [test.qemu]
@ -62,8 +62,8 @@ qemu.args = """\
-serial chardev:mux \ -serial chardev:mux \
-monitor chardev:mux \ -monitor chardev:mux \
-chardev stdio,id=mux,mux=on,signal=off,logfile=qemu.log \ -chardev stdio,id=mux,mux=on,signal=off,logfile=qemu.log \
-drive if=none,format=raw,id=x0,file=./test/build/ext2.img \ -drive if=none,format=raw,id=x0,file=./test/initramfs/build/ext2.img \
-drive if=none,format=raw,id=x1,file=./test/build/exfat.img \ -drive if=none,format=raw,id=x1,file=./test/initramfs/build/exfat.img \
# NOTE: The `/etc/profile.d/init.sh` assumes that `ext2.img` appears as the first block device (`/dev/vda`). # NOTE: The `/etc/profile.d/init.sh` assumes that `ext2.img` appears as the first block device (`/dev/vda`).
# The ordering below ensures `x1` (ext2.img) is discovered before `x0`, maintaining this assumption. # The ordering below ensures `x1` (ext2.img) is discovered before `x0`, maintaining this assumption.
# TODO: Once UUID-based mounting is implemented, this strict ordering will no longer be required. # TODO: Once UUID-based mounting is implemented, this strict ordering will no longer be required.

View File

@ -34,7 +34,7 @@ cargo osdk test
### General Test ### General Test
The following command builds and runs the test binaries in `test/src/apps` directory on Asterinas. The following command builds and runs the test binaries in `test/initramfs/src/apps` directory on Asterinas.
```bash ```bash
make run_kernel AUTO_TEST=test make run_kernel AUTO_TEST=test

View File

@ -119,7 +119,7 @@ mod test {
} }
} }
/// Exfat disk image /// Exfat disk image
static EXFAT_IMAGE: &[u8] = include_bytes!("../../../../test/build/exfat.img"); static EXFAT_IMAGE: &[u8] = include_bytes!("../../../../test/initramfs/build/exfat.img");
/// Read exfat disk image /// Read exfat disk image
fn new_vm_segment_from_image() -> Segment<()> { fn new_vm_segment_from_image() -> Segment<()> {

View File

@ -1,6 +1,6 @@
# Test Suite Overview # Initramfs-Based Test Suites
This directory contains the test suites of Asterinas, including various test programs, benchmarks, syscall test suites, and necessary configuration files. The structure of the test directory is designed to be modular and flexible, supporting multiple CPU architectures and a streamlined workflow for building and running tests. This directory contains the test suites of Asterinas running in initramfs, including various test programs, benchmarks, syscall test suites, and necessary configuration files. The structure of the test directory is designed to be modular and flexible, supporting multiple CPU architectures and a streamlined workflow for building and running tests.
## Directory Structure ## Directory Structure
@ -22,8 +22,6 @@ test/
└── README.md └── README.md
``` ```
---
## Building and Packaging Tests ## Building and Packaging Tests
Most tests in this directory are compiled and packaged using [Nix](https://nixos.org/), a powerful package manager. This ensures consistency and reproducibility across environments. Most tests in this directory are compiled and packaged using [Nix](https://nixos.org/), a powerful package manager. This ensures consistency and reproducibility across environments.
@ -35,6 +33,7 @@ Most tests in this directory are compiled and packaged using [Nix](https://nixos
While most tests rely on `Nix` for compilation, the `gvisor` syscall test suite currently cannot be built with `Nix`. Instead, the `gvisor` tests are compiled in the Docker image. For details, refer to `tools/docker/Dockerfile`. While most tests rely on `Nix` for compilation, the `gvisor` syscall test suite currently cannot be built with `Nix`. Instead, the `gvisor` tests are compiled in the Docker image. For details, refer to `tools/docker/Dockerfile`.
### Multi-Architecture Support ### Multi-Architecture Support
The test suite supports building for multiple architectures, including `x86_64` and `riscv64`. You can specify the desired architecture by running: The test suite supports building for multiple architectures, including `x86_64` and `riscv64`. You can specify the desired architecture by running:
```bash ```bash
@ -43,7 +42,7 @@ make kernel OSDK_TARGET_ARCH=x86_64
make kernel OSDK_TARGET_ARCH=riscv64 make kernel OSDK_TARGET_ARCH=riscv64
``` ```
The build artifacts (initramfs) can be found in the `test/build` directory after the compilation. The build artifacts (initramfs) can be found in the `test/initramfs/build` directory after the compilation.
## Supported Benchmarks ## Supported Benchmarks
@ -70,11 +69,11 @@ These benchmarks are precompiled and packaged into the Docker image for convenie
We recommend utilizing `Nix` when adding new benchmarks. To check if a benchmark is already available, use the [`Nix Package Search`](https://search.nixos.org/packages?channel=25.05). If a package exists in the Nix channel, you can directly use it or modify it if necessary. We recommend utilizing `Nix` when adding new benchmarks. To check if a benchmark is already available, use the [`Nix Package Search`](https://search.nixos.org/packages?channel=25.05). If a package exists in the Nix channel, you can directly use it or modify it if necessary.
If the desired benchmark is not available or cannot be easily adapted, you can add a custom `.nix` file to package it manually. Place the `.nix` files under the `test/nix/benchmark` directory. If the desired benchmark is not available or cannot be easily adapted, you can add a custom `.nix` file to package it manually. Place the `.nix` files under the `test/initramfs/nix/benchmark` directory.
## Configuration Files ## Configuration Files
Configuration files required by benchmarks or apps should be placed in the `test/src/etc` directory. Configuration files required by benchmarks or apps should be placed in the `test/initramfs/src/etc` directory.
If additional configuration files or directories are needed, ensure they are appropriately packaged by updating the `initramfs.nix` file. If additional configuration files or directories are needed, ensure they are appropriately packaged by updating the `initramfs.nix` file.

Some files were not shown because too many files have changed in this diff Show More