Merge f6f896ef64 into f4102e7db4
This commit is contained in:
commit
86d8fcb7f3
|
|
@ -6,7 +6,7 @@ branding:
|
|||
inputs:
|
||||
# Test Configuration
|
||||
auto_test:
|
||||
description: 'Test type (general, osdk, boot, syscall, test)'
|
||||
description: 'Test type (general, osdk, boot, syscall, regression)'
|
||||
required: true
|
||||
release:
|
||||
description: 'Whether to run in release mode'
|
||||
|
|
|
|||
|
|
@ -85,12 +85,12 @@ jobs:
|
|||
boot_protocol: 'multiboot2'
|
||||
smp: 4
|
||||
|
||||
# General Test (Linux EFI Handover) (Debug Build)
|
||||
- test_id: 'general-handover64-debug'
|
||||
# Regression Test (Linux EFI Handover) (Debug Build)
|
||||
- test_id: 'regression-handover64-debug'
|
||||
release: false
|
||||
boot_protocol: 'linux-efi-handover64'
|
||||
# SMP General Test (Multiboot2)
|
||||
- test_id: 'general-multiboot2-smp4'
|
||||
# SMP Regression Test (Multiboot2)
|
||||
- test_id: 'regression-multiboot2-smp4'
|
||||
boot_protocol: 'multiboot2'
|
||||
smp: 4
|
||||
fail-fast: false
|
||||
|
|
@ -103,7 +103,7 @@ jobs:
|
|||
uses: ./.github/actions/test
|
||||
with:
|
||||
auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') ||
|
||||
(startsWith(matrix.test_id, 'syscall') && 'syscall') || 'test' }}
|
||||
(startsWith(matrix.test_id, 'syscall') && 'syscall') || 'regression' }}
|
||||
release: ${{ !contains(matrix.release, 'false') }}
|
||||
enable_kvm: ${{ !contains(matrix.enable_kvm, 'false') }}
|
||||
smp: ${{ matrix.smp }}
|
||||
|
|
@ -118,7 +118,7 @@ jobs:
|
|||
uses: ./.github/actions/test
|
||||
with:
|
||||
auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') ||
|
||||
(startsWith(matrix.test_id, 'syscall') && 'syscall') || 'test' }}
|
||||
(startsWith(matrix.test_id, 'syscall') && 'syscall') || 'regression' }}
|
||||
release: ${{ !contains(matrix.release, 'false') }}
|
||||
enable_kvm: ${{ !contains(matrix.enable_kvm, 'false') }}
|
||||
smp: ${{ matrix.smp }}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ jobs:
|
|||
netdev: 'tap'
|
||||
smp: 4
|
||||
|
||||
# General Test
|
||||
- test_id: 'general'
|
||||
# SMP General Test
|
||||
- test_id: 'general-tap-smp4'
|
||||
# Regression Test
|
||||
- test_id: 'regression'
|
||||
# SMP Regression Test
|
||||
- test_id: 'regression-tap-smp4'
|
||||
netdev: 'tap'
|
||||
smp: 4
|
||||
fail-fast: false
|
||||
|
|
@ -46,7 +46,7 @@ jobs:
|
|||
uses: ./.github/actions/test
|
||||
with:
|
||||
auto_test: ${{ startsWith(matrix.test_id, 'boot') && 'boot' ||
|
||||
startsWith(matrix.test_id, 'syscall') && 'syscall' || 'test' }}
|
||||
startsWith(matrix.test_id, 'syscall') && 'syscall' || 'regression' }}
|
||||
intel_tdx: true
|
||||
release: true
|
||||
smp: ${{ matrix.smp }}
|
||||
|
|
|
|||
22
Makefile
22
Makefile
|
|
@ -21,8 +21,8 @@ OSTD_TASK_STACK_SIZE_IN_PAGES ?= 64
|
|||
FEATURES ?=
|
||||
NO_DEFAULT_FEATURES ?= 0
|
||||
COVERAGE ?= 0
|
||||
# Specify whether to build regression tests under `test/initramfs/src/apps`.
|
||||
ENABLE_BASIC_TEST ?= false
|
||||
# Specify whether to build regression tests under `test/initramfs/src/regression`.
|
||||
ENABLE_REGRESSION_TEST ?= false
|
||||
# Specify the primary system console (supported: tty0, ttyS0, hvc0).
|
||||
# - tty0: The active virtual terminal (VT).
|
||||
# - ttyS0: The serial (UART) terminal.
|
||||
|
|
@ -97,18 +97,14 @@ CARGO_OSDK_BUILD_ARGS += --kcmd-args="SYSCALL_TEST_SUITE=$(SYSCALL_TEST_SUITE)"
|
|||
CARGO_OSDK_BUILD_ARGS += --kcmd-args="SYSCALL_TEST_WORKDIR=$(SYSCALL_TEST_WORKDIR)"
|
||||
CARGO_OSDK_BUILD_ARGS += --kcmd-args="EXTRA_BLOCKLISTS_DIRS=$(EXTRA_BLOCKLISTS_DIRS)"
|
||||
CARGO_OSDK_BUILD_ARGS += --init-args="/opt/syscall_test/run_syscall_test.sh"
|
||||
else ifeq ($(AUTO_TEST), test)
|
||||
ENABLE_BASIC_TEST := true
|
||||
ifneq ($(SMP), 1)
|
||||
CARGO_OSDK_BUILD_ARGS += --kcmd-args="BLOCK_UNSUPPORTED_SMP_TESTS=1"
|
||||
endif
|
||||
else ifeq ($(AUTO_TEST), regression)
|
||||
ENABLE_REGRESSION_TEST := true
|
||||
CARGO_OSDK_BUILD_ARGS += --kcmd-args="INTEL_TDX=$(INTEL_TDX)"
|
||||
CARGO_OSDK_BUILD_ARGS += --init-args="/test/run_general_test.sh"
|
||||
CARGO_OSDK_BUILD_ARGS += --init-args="/test/run_regression_test.sh"
|
||||
else ifeq ($(AUTO_TEST), boot)
|
||||
ENABLE_BASIC_TEST := true
|
||||
CARGO_OSDK_BUILD_ARGS += --init-args="/test/boot_hello.sh"
|
||||
else ifeq ($(AUTO_TEST), vsock)
|
||||
ENABLE_BASIC_TEST := true
|
||||
ENABLE_REGRESSION_TEST := true
|
||||
export VSOCK=on
|
||||
CARGO_OSDK_BUILD_ARGS += --init-args="/test/run_vsock_test.sh"
|
||||
endif
|
||||
|
|
@ -315,9 +311,9 @@ run_kernel: initramfs $(CARGO_OSDK)
|
|||
ifeq ($(AUTO_TEST), syscall)
|
||||
@tail --lines 100 qemu.log | grep -q "^All syscall tests passed." \
|
||||
|| (echo "Syscall test failed" && exit 1)
|
||||
else ifeq ($(AUTO_TEST), test)
|
||||
@tail --lines 100 qemu.log | grep -q "^All general tests passed." \
|
||||
|| (echo "General test failed" && exit 1)
|
||||
else ifeq ($(AUTO_TEST), regression)
|
||||
@tail --lines 100 qemu.log | grep -q "^All regression tests passed." \
|
||||
|| (echo "Regression test failed" && exit 1)
|
||||
else ifeq ($(AUTO_TEST), boot)
|
||||
@tail --lines 100 qemu.log | grep -q "^Successfully booted." \
|
||||
|| (echo "Boot test failed" && exit 1)
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ cargo osdk test
|
|||
|
||||
## Integration Test
|
||||
|
||||
### General Test
|
||||
### Regression Test
|
||||
|
||||
The following command builds and runs the test binaries in `test/initramfs/src/apps` directory on Asterinas.
|
||||
The following command builds and runs the test binaries in `test/initramfs/src/regression` directory on Asterinas.
|
||||
|
||||
```bash
|
||||
make run_kernel AUTO_TEST=test
|
||||
make run_kernel AUTO_TEST=regression
|
||||
```
|
||||
|
||||
### Syscall Test
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ SMP ?= 1
|
|||
VERBOSE ?= 1
|
||||
SYSCALL_TEST_SUITE ?= ltp
|
||||
SYSCALL_TEST_WORKDIR ?= /tmp
|
||||
ENABLE_BASIC_TEST ?= false
|
||||
ENABLE_REGRESSION_TEST ?= false
|
||||
# Specify platform macros when building regression tests (supported: asterinas, linux).
|
||||
# - asterinas: Define both `__asterinas__` and `__linux__`. Tests may fail in Linux.
|
||||
# - linux: Define only `__linux__`. Tests may fail in Asterinas.
|
||||
BASIC_TEST_PLATFORM ?= asterinas
|
||||
TEST_PLATFORM ?= asterinas
|
||||
DNS_SERVER ?= none
|
||||
# Set Nix's cached tarballs to be live for a longer period of time (30 days) to avoid network traffics.
|
||||
# Nix's default value is rather small (1 hour or 3600 seconds).
|
||||
|
|
@ -65,9 +65,9 @@ $(INITRAMFS_IMAGE): $(INITRAMFS)
|
|||
@nix-build \
|
||||
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
|
||||
--argstr target $(OSDK_TARGET_ARCH) \
|
||||
--arg enableBasicTest $(ENABLE_BASIC_TEST) \
|
||||
--argstr basicTestPlatform $(BASIC_TEST_PLATFORM) \
|
||||
--argstr testPlatform $(TEST_PLATFORM) \
|
||||
--arg enableBenchmark $(ENABLE_BENCHMARK) \
|
||||
--arg enableRegressionTest $(ENABLE_REGRESSION_TEST) \
|
||||
--arg enableSyscallTest $(ENABLE_SYSCALL_TEST) \
|
||||
--argstr syscallTestSuite $(SYSCALL_TEST_SUITE) \
|
||||
--argstr syscallTestWorkDir $(SYSCALL_TEST_WORKDIR) \
|
||||
|
|
@ -82,9 +82,9 @@ $(INITRAMFS):
|
|||
@nix-build \
|
||||
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
|
||||
--argstr target $(OSDK_TARGET_ARCH) \
|
||||
--arg enableBasicTest $(ENABLE_BASIC_TEST) \
|
||||
--argstr basicTestPlatform $(BASIC_TEST_PLATFORM) \
|
||||
--argstr testPlatform $(TEST_PLATFORM) \
|
||||
--arg enableBenchmark $(ENABLE_BENCHMARK) \
|
||||
--arg enableRegressionTest $(ENABLE_REGRESSION_TEST) \
|
||||
--arg enableSyscallTest $(ENABLE_SYSCALL_TEST) \
|
||||
--argstr syscallTestSuite $(SYSCALL_TEST_SUITE) \
|
||||
--argstr syscallTestWorkDir $(SYSCALL_TEST_WORKDIR) \
|
||||
|
|
@ -104,7 +104,7 @@ x86_64_pkgs:
|
|||
--arg enableSyscallTest true \
|
||||
--out-link /nix/var/nix/gcroots/auto/x86_64-pkgs \
|
||||
-A busybox \
|
||||
-A apps.package \
|
||||
-A regression.package \
|
||||
-A benchmark.fio \
|
||||
-A benchmark.hackbench \
|
||||
-A benchmark.iperf3 \
|
||||
|
|
@ -130,17 +130,9 @@ riscv64_pkgs:
|
|||
--arg enableSyscallTest true \
|
||||
--out-link /nix/var/nix/gcroots/auto/riscv64-pkgs \
|
||||
-A busybox \
|
||||
-A apps.package \
|
||||
-A regression.package \
|
||||
-A syscall.ltp
|
||||
|
||||
general_pkgs:
|
||||
@nix-build \
|
||||
nix/default.nix \
|
||||
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
|
||||
$(NIX_QUIET) \
|
||||
--out-link /nix/var/nix/gcroots/auto/general \
|
||||
-A apps.mongoose_src
|
||||
|
||||
install_host_pkgs:
|
||||
@nix-env \
|
||||
--file nix/default.nix \
|
||||
|
|
@ -178,12 +170,12 @@ $(EXFAT_IMAGE):
|
|||
|
||||
.PHONY: format
|
||||
format:
|
||||
@$(MAKE) --no-print-directory -C src/apps format
|
||||
@$(MAKE) --no-print-directory -C src/regression format
|
||||
@nixfmt nix
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
@$(MAKE) --no-print-directory -C src/apps check
|
||||
@$(MAKE) --no-print-directory -C src/regression check
|
||||
@nixfmt --check nix
|
||||
|
||||
.PHONY: clean
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@ This directory contains the test suites of Asterinas running in initramfs, inclu
|
|||
## Directory Structure
|
||||
|
||||
```
|
||||
test/
|
||||
initramfs/
|
||||
├── src/
|
||||
│ ├── apps/ # Handwritten test applications
|
||||
│ ├── benchmark/ # Supported benchmark test suites
|
||||
│ ├── regression/ # Regression tests
|
||||
│ ├── etc/ # Configuration files
|
||||
│ └── syscall/ # Syscall test suites
|
||||
│ ├── ltp/ # LTP syscall test suite
|
||||
│ └── gvisor/ # Gvisor syscall test suite
|
||||
├── nix/
|
||||
│ ├── benchmark/ # Nix expressions for `benchmark`
|
||||
│ ├── regression/ # Nix expressions for `regression`
|
||||
│ ├── syscall/ # Nix expressions for `syscall`
|
||||
│ ├── apps.nix # Nix expression for `apps`
|
||||
│ └── initramfs.nix # Nix expression for packaging initramfs
|
||||
├── Makefile
|
||||
└── README.md
|
||||
|
|
@ -26,7 +26,7 @@ test/
|
|||
|
||||
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.
|
||||
|
||||
> **Note**: If you are adding a new test to the `apps` directory, ensure that it supports multiple architectures. Some of the existing apps lack proper architecture-specific handling.
|
||||
> **Note**: If you are adding a new test to the `regression` directory, ensure that it supports multiple architectures. Some of the existing tests lack proper architecture-specific handling.
|
||||
|
||||
### Syscall Test Suite - Gvisor Exception
|
||||
|
||||
|
|
@ -73,11 +73,11 @@ If the desired benchmark is not available or cannot be easily adapted, you can a
|
|||
|
||||
## Configuration Files
|
||||
|
||||
Configuration files required by benchmarks or apps should be placed in the `test/initramfs/src/etc` directory.
|
||||
Configuration files required by benchmarks or regression tests 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.
|
||||
|
||||
## Notes for Developers
|
||||
|
||||
- **Nix Usage**: Use `Nix` whenever possible to manage dependencies and builds for ease of maintenance and consistency.
|
||||
- **Multi-Architecture Support**: Ensure new apps or benchmarks properly support multiple CPU architectures.
|
||||
- **Multi-Architecture Support**: Ensure new regression tests or benchmarks properly support multiple CPU architectures.
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
{ lib, stdenv, fetchFromGitHub, hostPlatform, glibc, libnl, callPackage
|
||||
, testPlatform, }: rec {
|
||||
|
||||
tdxAttest = lib.optionalAttrs (builtins.getEnv "INTEL_TDX" == "1")
|
||||
(callPackage ./tdx-attest.nix { });
|
||||
|
||||
mongoose_src = fetchFromGitHub {
|
||||
owner = "cesanta";
|
||||
repo = "mongoose";
|
||||
rev = "7.13";
|
||||
sha256 = "sha256-9XHUE8SVOG/X7SIB52C8EImPx4XZ7B/5Ojwmb0PkiuI";
|
||||
};
|
||||
|
||||
package = stdenv.mkDerivation {
|
||||
pname = "apps";
|
||||
version = "0.1.0";
|
||||
src = lib.fileset.toSource {
|
||||
root = ./../src;
|
||||
fileset = ./../src/apps;
|
||||
};
|
||||
|
||||
MONGOOSE_DIR = "${mongoose_src}";
|
||||
|
||||
INTEL_TDX = builtins.getEnv "INTEL_TDX";
|
||||
TDX_ATTEST_DIR = lib.optionalString (builtins.getEnv "INTEL_TDX" == "1")
|
||||
"${tdxAttest}/QuoteGeneration";
|
||||
|
||||
HOST_PLATFORM = "${hostPlatform.system}";
|
||||
CC = "${stdenv.cc.targetPrefix}cc";
|
||||
C_FLAGS = "-I${libnl.dev}/include/libnl3"
|
||||
+ (if testPlatform == "asterinas" then " -D__asterinas__" else "");
|
||||
# FIXME: Excluding `glibc` allows the build to succeed, but causes some tests to fail.
|
||||
buildInputs = [ glibc glibc.static libnl ];
|
||||
buildCommand = ''
|
||||
BUILD_DIR=$(mktemp -d)
|
||||
mkdir -p $BUILD_DIR
|
||||
cp -r $src/apps $BUILD_DIR/
|
||||
|
||||
pushd $BUILD_DIR
|
||||
make --no-print-directory -C apps
|
||||
popd
|
||||
|
||||
mkdir -p $out
|
||||
mv build/initramfs/test/* $out/
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{ target ? "x86_64", enableBasicTest ? false, basicTestPlatform ? "asterinas"
|
||||
, enableBenchmark ? false, enableSyscallTest ? false, syscallTestSuite ? "ltp"
|
||||
, syscallTestWorkDir ? "/tmp", dnsServer ? "none", smp ? 1
|
||||
, initramfsCompressed ? true, }:
|
||||
{ target ? "x86_64", testPlatform ? "asterinas", enableBenchmark ? false
|
||||
, enableRegressionTest ? false, enableSyscallTest ? false
|
||||
, syscallTestSuite ? "ltp", syscallTestWorkDir ? "/tmp", dnsServer ? "none"
|
||||
, smp ? 1, initramfsCompressed ? true, }:
|
||||
let
|
||||
crossSystem.config = if target == "x86_64" then
|
||||
"x86_64-unknown-linux-gnu"
|
||||
|
|
@ -23,9 +23,9 @@ let
|
|||
};
|
||||
in rec {
|
||||
# Packages needed by initramfs
|
||||
apps = pkgs.callPackage ./apps.nix { testPlatform = basicTestPlatform; };
|
||||
busybox = pkgs.busybox;
|
||||
benchmark = pkgs.callPackage ./benchmark { };
|
||||
regression = pkgs.callPackage ./regression { inherit testPlatform; };
|
||||
syscall = pkgs.callPackage ./syscall {
|
||||
inherit smp;
|
||||
testSuite = syscallTestSuite;
|
||||
|
|
@ -33,7 +33,7 @@ in rec {
|
|||
};
|
||||
initramfs = pkgs.callPackage ./initramfs.nix {
|
||||
inherit busybox;
|
||||
apps = if enableBasicTest then apps else null;
|
||||
regression = if enableRegressionTest then regression else null;
|
||||
benchmark = if enableBenchmark then benchmark else null;
|
||||
syscall = if enableSyscallTest then syscall else null;
|
||||
dnsServer = dnsServer;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{ lib, stdenvNoCC, fetchFromGitHub, hostPlatform, writeClosure, busybox, apps
|
||||
, benchmark, syscall, dnsServer, pkgs }:
|
||||
{ lib, stdenvNoCC, fetchFromGitHub, hostPlatform, writeClosure, busybox
|
||||
, regression, benchmark, syscall, dnsServer, pkgs }:
|
||||
let
|
||||
boot_hello = builtins.path { path = ./../src/boot_hello.sh; };
|
||||
etc = lib.fileset.toSource {
|
||||
root = ./../src/etc;
|
||||
fileset = ./../src/etc;
|
||||
|
|
@ -16,7 +17,7 @@ let
|
|||
# Whether the initramfs should include evtest, a common tool to debug input devices (`/dev/input/eventX`)
|
||||
is_evtest_included = false;
|
||||
all_pkgs = [ busybox etc resolv_conf ]
|
||||
++ lib.optionals (apps != null) [ apps.package ]
|
||||
++ lib.optionals (regression != null) [ regression.package ]
|
||||
++ lib.optionals (benchmark != null) [ benchmark.package ]
|
||||
++ lib.optionals (syscall != null) [ syscall.package ]
|
||||
++ lib.optionals is_evtest_included [ pkgs.evtest ];
|
||||
|
|
@ -37,10 +38,12 @@ in stdenvNoCC.mkDerivation {
|
|||
|
||||
cp -r ${etc}/* $out/etc/
|
||||
|
||||
cp ${boot_hello} $out/test/boot_hello.sh
|
||||
|
||||
cp ${resolv_conf}/resolv.conf $out/etc/
|
||||
|
||||
${lib.optionalString (apps != null) ''
|
||||
cp -r ${apps.package}/* $out/test/
|
||||
${lib.optionalString (regression != null) ''
|
||||
cp -r ${regression.package}/* $out/test/
|
||||
''}
|
||||
|
||||
${lib.optionalString (benchmark != null) ''
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
{ lib, stdenv, glibc, hostPlatform, dir, testPlatform ? "asterinas"
|
||||
, extraEnv ? { }, extraBuildInputs ? [ ] }:
|
||||
stdenv.mkDerivation ({
|
||||
pname = "${dir}-test";
|
||||
version = "0.1.0";
|
||||
src = lib.fileset.toSource {
|
||||
root = ./../../src/regression;
|
||||
fileset = lib.fileset.unions [
|
||||
./../../src/regression/common
|
||||
./../../src/regression/${dir}
|
||||
];
|
||||
};
|
||||
|
||||
HOST_PLATFORM = "${hostPlatform.system}";
|
||||
TEST_PLATFORM = "${testPlatform}";
|
||||
|
||||
CC = "${stdenv.cc.targetPrefix}cc";
|
||||
|
||||
buildInputs = [ glibc glibc.static ] ++ extraBuildInputs;
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
make --no-print-directory BUILD_DIR=$(mktemp -d) OUTPUT_DIR=$out -C "$src/${dir}"
|
||||
'';
|
||||
} // extraEnv)
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
{ lib, pkgs, stdenv, callPackage, testPlatform ? "asterinas", }: rec {
|
||||
scripts = lib.fileset.toSource {
|
||||
root = ./../../src/regression/scripts;
|
||||
fileset = lib.fileset.fileFilter (file: file.hasExt "sh")
|
||||
./../../src/regression/scripts;
|
||||
};
|
||||
|
||||
allPkgs = lib.listToAttrs (map (dir: {
|
||||
name = dir;
|
||||
value = callPackage ./common.nix { inherit dir testPlatform; };
|
||||
}) [ "device" "fs" "hello_world" "io" "ipc" "memory" "process" "security" ])
|
||||
// {
|
||||
network = callPackage ./common.nix {
|
||||
dir = "network";
|
||||
inherit testPlatform;
|
||||
extraEnv = { C_FLAGS = " -I${pkgs.libnl.dev}/include/libnl3"; };
|
||||
extraBuildInputs = [ pkgs.libnl ];
|
||||
};
|
||||
} // lib.optionalAttrs (pkgs.hostPlatform.system == "x86_64-linux") {
|
||||
intel_tdx = callPackage ./common.nix {
|
||||
dir = "intel_tdx";
|
||||
inherit testPlatform;
|
||||
extraEnv = {
|
||||
TDX_ATTEST_DIR =
|
||||
"${callPackage ./tdx-attest.nix { }}/QuoteGeneration";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
package = stdenv.mkDerivation {
|
||||
pname = "regression";
|
||||
version = "0.1.0";
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
cp ${scripts}/* $out
|
||||
|
||||
${lib.concatMapStringsSep "\n"
|
||||
(name: "ln -s ${toString allPkgs.${name}}/${name} $out/${name}")
|
||||
(lib.attrNames allPkgs)}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
HOST_PLATFORM ?= x86_64-linux
|
||||
|
||||
# Prevent the implicit rules from compiling ".c" or ".s" files automatically.
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
||||
|
||||
INITRAMFS ?= $(CUR_DIR)/../../build/initramfs
|
||||
TEST_BUILD_DIR ?= $(INITRAMFS)/test
|
||||
|
||||
# These test apps are sorted by name
|
||||
TEST_APPS := \
|
||||
alarm \
|
||||
capability \
|
||||
chroot \
|
||||
clone3 \
|
||||
cpu_affinity \
|
||||
devfs \
|
||||
epoll \
|
||||
eventfd2 \
|
||||
execve \
|
||||
exit \
|
||||
ext2 \
|
||||
fdatasync \
|
||||
file_io \
|
||||
fork_c \
|
||||
getcpu \
|
||||
getpid \
|
||||
hello_pie \
|
||||
inotify \
|
||||
itimer \
|
||||
mmap \
|
||||
mongoose \
|
||||
namespace \
|
||||
network \
|
||||
pipe \
|
||||
prctl \
|
||||
process \
|
||||
procfs \
|
||||
pseudofs \
|
||||
pthread \
|
||||
pty \
|
||||
sched \
|
||||
shm \
|
||||
vsock \
|
||||
|
||||
# TODO: Refactor those tests for target CPU arch using C macro-based conditional compilation.
|
||||
ifeq ($(HOST_PLATFORM), x86_64-linux)
|
||||
TEST_APPS += \
|
||||
fork \
|
||||
hello_c \
|
||||
hello_world \
|
||||
signal_c
|
||||
endif
|
||||
|
||||
ifeq ($(INTEL_TDX), 1)
|
||||
TEST_APPS += generate_tdx_quote
|
||||
endif
|
||||
|
||||
# The C head and source files of all the apps, excluding the downloaded mongoose files
|
||||
C_SOURCES := \
|
||||
$(shell find . -type f \( -name "*.c" -or -name "*.h" \) \
|
||||
! -name "mongoose.c" ! -name "mongoose.h")
|
||||
|
||||
.PHONY: all
|
||||
all: $(TEST_APPS) scripts
|
||||
|
||||
.PHONY: $(TEST_APPS)
|
||||
$(TEST_APPS):
|
||||
@make --no-print-directory -C $@
|
||||
|
||||
.PHONY: format
|
||||
format:
|
||||
@echo "Fixing code format for general tests..."
|
||||
@clang-format -i $(C_SOURCES)
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
@echo "Checking code format for general tests..."
|
||||
@clang-format --dry-run --Werror $(C_SOURCES)
|
||||
|
||||
$(TEST_BUILD_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
.PHONY: scripts
|
||||
scripts: | $(TEST_BUILD_DIR)
|
||||
@make --no-print-directory BUILD_DIR=$(TEST_BUILD_DIR) -C scripts
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS := -static
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS := -static -mno-sse
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1 +0,0 @@
|
|||
mongoose.*
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
CUR_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
BUILD_DIR := $(CUR_DIR)/../../../build/initramfs/test/network
|
||||
ATOMIC_WGET := $(CUR_DIR)/../../../../tools/atomic_wget.sh
|
||||
MONGOOSE_DIR ?= $(CUR_DIR)
|
||||
MONGOOSE_C := $(MONGOOSE_DIR)/mongoose.c
|
||||
MONGOOSE_H := $(MONGOOSE_DIR)/mongoose.h
|
||||
MONGOOSE_FILES := $(MONGOOSE_C) $(MONGOOSE_H)
|
||||
MONGOOSE_O := $(MONGOOSE_DIR)/mongoose.o
|
||||
SERVER_C := http_server.c
|
||||
SERVER_BIN := $(BUILD_DIR)/http_server
|
||||
CLIENT_C := http_client.c
|
||||
CLIENT_BIN := $(BUILD_DIR)/http_client
|
||||
BINS := $(SERVER_BIN) $(CLIENT_BIN)
|
||||
CC ?= cc
|
||||
CFLAGS ?= -W -Wall -Wextra -I. -I$(MONGOOSE_DIR) -DMG_ENABLE_LINES=1
|
||||
|
||||
.PHONY: all
|
||||
all: $(BINS)
|
||||
|
||||
$(SERVER_BIN): $(SERVER_C) $(MONGOOSE_C) | $(BUILD_DIR)
|
||||
$(CC) $^ $(CFLAGS) -o $@
|
||||
|
||||
$(CLIENT_BIN): $(CLIENT_C) $(MONGOOSE_C) | $(BUILD_DIR)
|
||||
$(CC) $^ $(CFLAGS) -o $@
|
||||
|
||||
$(MONGOOSE_C): $(MONGOOSE_H)
|
||||
$(ATOMIC_WGET) $@ "https://raw.githubusercontent.com/cesanta/mongoose/7.13/$(notdir $@)"
|
||||
|
||||
$(MONGOOSE_H):
|
||||
$(ATOMIC_WGET) $@ "https://raw.githubusercontent.com/cesanta/mongoose/7.13/$(notdir $@)"
|
||||
|
||||
$(BUILD_DIR) $(MONGOOSE_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
PHONY: clean
|
||||
clean:
|
||||
@rm -f $(BINS) $(MONGOOSE_O) $(MONGOOSE_FILES)
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#include "mongoose.h"
|
||||
|
||||
static const char *s_url = "http://127.0.0.1:8080/";
|
||||
static const char *s_post_data = NULL; // POST data
|
||||
|
||||
// Print HTTP response and signal that we're done
|
||||
static void fn(struct mg_connection *c, int ev, void *ev_data)
|
||||
{
|
||||
if (ev == MG_EV_CONNECT) {
|
||||
// Connected to server. Send request
|
||||
struct mg_str host = mg_url_host(s_url);
|
||||
int content_length = s_post_data ? (int)strlen(s_post_data) : 0;
|
||||
|
||||
mg_printf(c,
|
||||
"%s %s HTTP/1.1\r\n"
|
||||
"Host: %.*s\r\n"
|
||||
"Content-Length: %d\r\n"
|
||||
"\r\n",
|
||||
s_post_data ? "POST" : "GET", mg_url_uri(s_url),
|
||||
(int)host.len, host.ptr, content_length);
|
||||
|
||||
mg_send(c, s_post_data, content_length);
|
||||
} else if (ev == MG_EV_HTTP_MSG) {
|
||||
// Response is received. Print it
|
||||
struct mg_http_message *hm = (struct mg_http_message *)ev_data;
|
||||
printf("%.*s", (int)hm->message.len, hm->message.ptr);
|
||||
c->is_draining = 1; // Tell mongoose to close this connection
|
||||
*(bool *)c->fn_data = true; // Tell event loop to stop
|
||||
} else if (ev == MG_EV_ERROR) {
|
||||
*(bool *)c->fn_data = true; // Error, tell event loop to stop
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct mg_mgr mgr;
|
||||
if (argc > 1)
|
||||
s_url = argv[1]; // Use URL provided on the command line
|
||||
bool done = false;
|
||||
|
||||
mg_mgr_init(&mgr); // Initialize event manager
|
||||
|
||||
mg_http_connect(&mgr, s_url, fn, &done); // Create client connection
|
||||
while (!done)
|
||||
mg_mgr_poll(&mgr, 50);
|
||||
|
||||
mg_mgr_free(&mgr); // Free resources
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "mongoose.h"
|
||||
|
||||
static int s_debug_level = MG_LL_INFO;
|
||||
static const char *s_listening_address = "http://127.0.0.1:8080/";
|
||||
|
||||
static int s_signo;
|
||||
static void signal_handler(int signo)
|
||||
{
|
||||
s_signo = signo;
|
||||
}
|
||||
|
||||
// Event handler for the listening connection.
|
||||
static void cb(struct mg_connection *c, int ev, void *ev_data)
|
||||
{
|
||||
if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = ev_data;
|
||||
if (mg_match(hm->uri, mg_str("/"), NULL)) {
|
||||
// Generate a random number
|
||||
srand(time(NULL));
|
||||
int random_number = rand();
|
||||
char response[100];
|
||||
sprintf(response, "Random number: %d\n", random_number);
|
||||
MG_INFO(("Send a random number : %d", random_number));
|
||||
mg_http_reply(c, 200, "", "%s", response);
|
||||
} else {
|
||||
// Serve 404 for other routes
|
||||
mg_http_reply(c, 404, "", "Not found");
|
||||
}
|
||||
// Remove this line if you need a long running server
|
||||
// signal_handler(SIGTERM);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct mg_mgr mgr;
|
||||
struct mg_connection *c;
|
||||
|
||||
// Parse command-line flags
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-l") == 0) {
|
||||
s_listening_address = argv[++i];
|
||||
} else if (strcmp(argv[i], "-v") == 0) {
|
||||
s_debug_level = atoi(argv[++i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise stuff
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
mg_log_set(s_debug_level);
|
||||
mg_mgr_init(&mgr);
|
||||
if ((c = mg_http_listen(&mgr, s_listening_address, cb, &mgr)) == NULL) {
|
||||
MG_ERROR(("Cannot listen on %s. Use http://ADDR:PORT or :PORT",
|
||||
s_listening_address));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Start infinite event loop
|
||||
MG_INFO(("Mongoose version : v%s", MG_VERSION));
|
||||
MG_INFO(("Listening on : %s", s_listening_address));
|
||||
while (s_signo == 0)
|
||||
mg_mgr_poll(&mgr, 1000);
|
||||
mg_mgr_free(&mgr);
|
||||
MG_INFO(("Exiting on signal %d", s_signo));
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=/test
|
||||
cd ${SCRIPT_DIR}/..
|
||||
|
||||
echo "Start process test......"
|
||||
# These test programs are sorted by name.
|
||||
tests="
|
||||
chroot/chroot_jail
|
||||
clone3/clone_exit_signal
|
||||
clone3/clone_files
|
||||
clone3/clone_no_exit_signal
|
||||
clone3/clone_parent
|
||||
clone3/clone_process
|
||||
cpu_affinity/cpu_affinity
|
||||
execve/execve
|
||||
execve/execve_err
|
||||
execve/execve_mt_parent
|
||||
execve/execve_memfd
|
||||
exit/exit_code
|
||||
exit/exit_procfs
|
||||
eventfd2/eventfd2
|
||||
fork/fork
|
||||
fork_c/fork
|
||||
getcpu/getcpu
|
||||
getpid/getpid
|
||||
hello_pie/hello
|
||||
hello_world/hello_world
|
||||
inotify/inotify_align
|
||||
inotify/inotify_poll
|
||||
inotify/inotify_unlink
|
||||
itimer/setitimer
|
||||
itimer/timer_create
|
||||
mmap/mmap_and_fork
|
||||
mmap/mmap_and_mprotect
|
||||
mmap/mmap_and_mremap
|
||||
mmap/mmap_beyond_the_file
|
||||
mmap/mmap_err
|
||||
mmap/mmap_holes
|
||||
mmap/mmap_shared_filebacked
|
||||
mmap/mmap_readahead
|
||||
mmap/mmap_vmrss
|
||||
namespace/mnt_ns
|
||||
namespace/setns
|
||||
namespace/unshare
|
||||
process/group_session
|
||||
process/job_control
|
||||
process/pidfd
|
||||
process/pidfd_getfd
|
||||
process/wait4
|
||||
procfs/dentry_cache
|
||||
procfs/pid_mem
|
||||
pseudofs/pseudo_dentry
|
||||
pseudofs/pseudo_inode
|
||||
pseudofs/pseudo_mount
|
||||
pseudofs/memfd_access_err
|
||||
pthread/pthread_test
|
||||
pty/close_pty
|
||||
pty/open_ptmx
|
||||
pty/open_pty
|
||||
pty/pty_blocking
|
||||
pty/pty_packet_mode
|
||||
sched/sched_attr_getset
|
||||
sched/sched_param_getset
|
||||
sched/sched_param_idle
|
||||
shm/posix_shm
|
||||
signal_c/kill
|
||||
signal_c/parent_death_signal
|
||||
signal_c/pidfd_send_signal
|
||||
signal_c/sigaltstack
|
||||
signal_c/signal_fd
|
||||
signal_c/signal_fpu
|
||||
signal_c/signal_test
|
||||
signal_c/signal_test2
|
||||
"
|
||||
|
||||
# Add TDX-specific tests
|
||||
if [ "$INTEL_TDX" = "1" ]; then
|
||||
tests="${tests}
|
||||
generate_tdx_quote/generate_tdx_quote
|
||||
"
|
||||
fi
|
||||
|
||||
for testcase in ${tests}
|
||||
do
|
||||
echo "Running test ${testcase}......"
|
||||
${SCRIPT_DIR}/${testcase}
|
||||
done
|
||||
echo "All process test passed."
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=/test
|
||||
cd ${SCRIPT_DIR}
|
||||
|
||||
./shell_cmd.sh
|
||||
./test_epoll_pwait.sh
|
||||
./cgroup.sh
|
||||
|
||||
# TODO: Support the following tests with SMP
|
||||
if [ -z $BLOCK_UNSUPPORTED_SMP_TESTS ]; then
|
||||
./fs.sh # will hang
|
||||
./process.sh # will randomly hang
|
||||
./network.sh # will hang
|
||||
fi
|
||||
|
||||
echo "All general tests passed."
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
SCRIPT_DIR=/test
|
||||
cd ${SCRIPT_DIR}
|
||||
|
||||
touch hello.txt
|
||||
mv hello.txt hello_world.txt
|
||||
rm hello_world.txt
|
||||
|
||||
awk '{print $2}' shell_cmd.sh
|
||||
cp shell_cmd.sh shell_cmd_backup.sh
|
||||
cat shell_cmd_backup.sh
|
||||
rm shell_cmd_backup.sh
|
||||
|
||||
ln -s shell_cmd.sh tesk_cmd_soft_link
|
||||
readlink -f tesk_cmd_soft_link
|
||||
tail -n 1 tesk_cmd_soft_link
|
||||
rm tesk_cmd_soft_link
|
||||
|
||||
ln shell_cmd.sh tesk_cmd_hard_link
|
||||
tail -n 1 tesk_cmd_hard_link
|
||||
unlink tesk_cmd_hard_link
|
||||
|
||||
sed 3q shell_cmd.sh
|
||||
|
||||
find . -name "*shell_cmd*"
|
||||
|
||||
mkdir foo
|
||||
rmdir foo
|
||||
|
||||
echo "Hello world from asterinas" > hello.txt
|
||||
rm hello.txt
|
||||
|
||||
cd ..
|
||||
|
||||
ps -T | grep ps
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
# Removed `-static` to enable dynamic linking.
|
||||
# Refer to "signal_rflags_df.c" for details on how dynamic linking affects DF flag testing.
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
MAIN_MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
||||
INCLUDE_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
CUR_DIR := $(shell dirname $(realpath $(MAIN_MAKEFILE)))
|
||||
CUR_DIR_NAME := $(shell basename $(realpath $(CUR_DIR)))
|
||||
BUILD_DIR := $(CUR_DIR)/../../../build
|
||||
OBJ_OUTPUT_DIR := $(BUILD_DIR)/initramfs/test/$(CUR_DIR_NAME)
|
||||
DEP_OUTPUT_DIR := $(BUILD_DIR)/dep/$(CUR_DIR_NAME)
|
||||
C_SRCS := $(wildcard *.c)
|
||||
C_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(C_SRCS:%.c=%))
|
||||
C_DEPS := $(addprefix $(DEP_OUTPUT_DIR)/,$(C_SRCS:%.c=%.d))
|
||||
ASM_SRCS := $(wildcard *.S)
|
||||
ASM_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(ASM_SRCS:%.S=%))
|
||||
CC ?= gcc
|
||||
C_FLAGS += -Wall -Werror
|
||||
|
||||
.PHONY: all
|
||||
all: $(C_OBJS) $(ASM_OBJS)
|
||||
|
||||
$(OBJ_OUTPUT_DIR) $(DEP_OUTPUT_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
$(OBJ_OUTPUT_DIR)/%: %.c | $(OBJ_OUTPUT_DIR) $(DEP_OUTPUT_DIR)
|
||||
@$(CC) $(C_FLAGS) $< -o $@ $(EXTRA_C_FLAGS) \
|
||||
-MMD -MF $(DEP_OUTPUT_DIR)/$*.d
|
||||
@echo "CC <= $@"
|
||||
|
||||
-include $(C_DEPS)
|
||||
|
||||
$(OBJ_OUTPUT_DIR)/%: %.S | $(OBJ_OUTPUT_DIR)
|
||||
@$(CC) $(C_FLAGS) $(EXTRA_C_FLAGS) $< -o $@
|
||||
@echo "CC <= $@"
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
HOST_PLATFORM ?= x86_64-linux
|
||||
|
||||
# Prevent the implicit rules from compiling ".c" or ".s" files automatically.
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
||||
BUILD_DIR ?= $(CUR_DIR)/../../build
|
||||
OUTPUT_DIR ?= $(BUILD_DIR)/initramfs/test
|
||||
|
||||
SUBDIRS := \
|
||||
device \
|
||||
fs \
|
||||
hello_world \
|
||||
io \
|
||||
ipc \
|
||||
memory \
|
||||
network \
|
||||
process \
|
||||
scripts \
|
||||
security \
|
||||
|
||||
ifeq ($(HOST_PLATFORM), x86_64-linux)
|
||||
SUBDIRS += intel_tdx
|
||||
endif
|
||||
|
||||
# The C head and source files of all testcases.
|
||||
C_SOURCES := $(shell find . -type f \( -name "*.c" -or -name "*.h" \))
|
||||
|
||||
.PHONY: all
|
||||
all: $(SUBDIRS)
|
||||
|
||||
$(OUTPUT_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
.PHONY: $(SUBDIRS)
|
||||
$(SUBDIRS): $(OUTPUT_DIR)
|
||||
@make --no-print-directory BUILD_DIR=$(BUILD_DIR) OUTPUT_DIR=$(OUTPUT_DIR) -C $@
|
||||
|
||||
.PHONY: format
|
||||
format:
|
||||
@echo "Fixing code format for regression tests..."
|
||||
@clang-format -i $(C_SOURCES)
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
@echo "Checking code format for regression tests..."
|
||||
@clang-format --dry-run --Werror $(C_SOURCES)
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
MAIN_MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
||||
INCLUDE_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
CUR_DIR := $(shell dirname $(realpath $(MAIN_MAKEFILE)))
|
||||
INCLUDE_MAKEFILE_DIR := $(shell dirname $(realpath $(INCLUDE_MAKEFILE)))
|
||||
COMMON_PREFIX := $(shell dirname $(INCLUDE_MAKEFILE_DIR))
|
||||
CUR_DIR_NAME := $(subst $(COMMON_PREFIX)/,,$(CUR_DIR))
|
||||
|
||||
BUILD_DIR ?= $(INCLUDE_MAKEFILE_DIR)/../../../build
|
||||
OUTPUT_DIR ?= $(BUILD_DIR)/initramfs/test
|
||||
OBJ_OUTPUT_DIR := $(OUTPUT_DIR)/$(CUR_DIR_NAME)
|
||||
DEP_OUTPUT_DIR := $(BUILD_DIR)/dep/$(CUR_DIR_NAME)
|
||||
C_SRCS := $(wildcard *.c)
|
||||
C_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(C_SRCS:%.c=%))
|
||||
C_DEPS := $(addprefix $(DEP_OUTPUT_DIR)/,$(C_SRCS:%.c=%.d))
|
||||
ASM_SRCS := $(wildcard *.S)
|
||||
ASM_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(ASM_SRCS:%.S=%))
|
||||
SCRIPTS := $(addprefix $(OBJ_OUTPUT_DIR)/, $(wildcard *.sh))
|
||||
|
||||
CC ?= gcc
|
||||
C_FLAGS += -Wall -Werror
|
||||
|
||||
HOST_PLATFORM ?= x86_64-linux
|
||||
TEST_PLATFORM ?= asterinas
|
||||
|
||||
ifeq ($(TEST_PLATFORM),asterinas)
|
||||
C_FLAGS += -D__asterinas__
|
||||
endif
|
||||
|
||||
ifneq ($(C_OBJS_FILTER),)
|
||||
FILTERED_C_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(C_OBJS_FILTER))
|
||||
C_OBJS := $(filter-out $(FILTERED_C_OBJS),$(C_OBJS))
|
||||
endif
|
||||
|
||||
ifneq ($(ASM_OBJS_FILTER),)
|
||||
FILTERED_ASM_OBJS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(ASM_OBJS_FILTER))
|
||||
ASM_OBJS := $(filter-out $(FILTERED_ASM_OBJS),$(ASM_OBJS))
|
||||
endif
|
||||
|
||||
ifneq ($(SCRIPTS_FILTER),)
|
||||
FILTERED_SCRIPTS := $(addprefix $(OBJ_OUTPUT_DIR)/,$(SCRIPTS_FILTER))
|
||||
SCRIPTS := $(filter-out $(FILTERED_SCRIPTS),$(SCRIPTS))
|
||||
endif
|
||||
|
||||
ifneq ($(SUBDIRS_FILTER),)
|
||||
SUBDIRS := $(filter-out $(SUBDIRS_FILTER),$(SUBDIRS))
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
all: $(C_OBJS) $(ASM_OBJS) $(SUBDIRS) $(SCRIPTS)
|
||||
|
||||
$(OBJ_OUTPUT_DIR) $(DEP_OUTPUT_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
$(OBJ_OUTPUT_DIR)/%: %.c | $(OBJ_OUTPUT_DIR) $(DEP_OUTPUT_DIR)
|
||||
@$(CC) $(C_FLAGS) $< -o $@ $(EXTRA_C_FLAGS) \
|
||||
-MMD -MF $(DEP_OUTPUT_DIR)/$*.d
|
||||
@echo "CC <= $@"
|
||||
|
||||
-include $(C_DEPS)
|
||||
|
||||
$(OBJ_OUTPUT_DIR)/%: %.S | $(OBJ_OUTPUT_DIR)
|
||||
@$(CC) $(C_FLAGS) $(EXTRA_C_FLAGS) $< -o $@
|
||||
@echo "CC <= $@"
|
||||
|
||||
$(OBJ_OUTPUT_DIR)/%.sh: %.sh | $(OBJ_OUTPUT_DIR)
|
||||
@cp $< $@
|
||||
|
||||
.PHONY: $(SUBDIRS)
|
||||
$(SUBDIRS):
|
||||
@make --no-print-directory -C $@
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
/* SPDX-License-Identifier: MPL-2.0 */
|
||||
|
||||
/*
|
||||
* A framework for writing general tests.
|
||||
* A framework for writing regression tests.
|
||||
*
|
||||
* A general test typically consists of two parts, the setup part and the
|
||||
* A regression test typically consists of two parts, the setup part and the
|
||||
* test part. The setup part contains setup functions that set up the context
|
||||
* for the subsequent tests to run. The setup functions cannot fail, and if they
|
||||
* do, execution is aborted because the subsequent tests will not work as
|
||||
* expected either. The test functions, on the other hand, can fail, and if they
|
||||
* do, they are reported as test failures.
|
||||
*
|
||||
* The framework provides basic utilities for writing general tests:
|
||||
* The framework provides basic utilities for writing regression tests:
|
||||
*
|
||||
* - To define a setup function or a test function, FN_SETUP() or FN_TEST() can
|
||||
* be used. These functions are automatically executed in the order of their
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
SUBDIRS := pty
|
||||
|
||||
include ../common/Makefile
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../test.h"
|
||||
#include "../common/test.h"
|
||||
|
||||
#define INPUT_DIR "/dev/input"
|
||||
#define MAX_EVDEV_DEVICES 16
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../test.h"
|
||||
#include "../common/test.h"
|
||||
|
||||
#define FB_DEVICE "/dev/fb0"
|
||||
#define PAGE_SIZE 4096
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/poll.h>
|
||||
#include "../test.h"
|
||||
#include "../common/test.h"
|
||||
|
||||
#define DEVICE_PATH "/dev/full"
|
||||
#define READ_SIZE 100
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
include ../../common/Makefile
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#include <termios.h>
|
||||
#include <pty.h>
|
||||
#include <poll.h>
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
int master;
|
||||
int slave;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#include <pty.h>
|
||||
#include <poll.h>
|
||||
#include <sys/wait.h>
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
#define DEV_PTMX "/dev/ptmx"
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <pty.h>
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#include <termios.h>
|
||||
#include <pty.h>
|
||||
#include <poll.h>
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
int master;
|
||||
int slave;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include "../test.h"
|
||||
#include "../common/test.h"
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
|
||||
./pty/close_pty
|
||||
./pty/open_ptmx
|
||||
./pty/open_pty
|
||||
./pty/pty_blocking
|
||||
./pty/pty_packet_mode
|
||||
./evdev
|
||||
./framebuffer
|
||||
./full
|
||||
./random
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
SUBDIRS := \
|
||||
chroot \
|
||||
ext2 \
|
||||
fdatasync \
|
||||
inotify \
|
||||
overlayfs \
|
||||
procfs \
|
||||
pseudofs \
|
||||
|
||||
include ../common/Makefile
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
FN_SETUP(create_chroot_env)
|
||||
{
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
#define NULL_DEVICE_PATH "/ext2/my_null_device"
|
||||
#define ZERO_DEVICE_PATH "/ext2/my_zero_device"
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
#define SERVER_ADDRESS "/ext2/my_unix_server"
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#include <sys/inotify.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
#define TEST_FILE "/tmp/test1"
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <wait.h>
|
||||
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
FN_TEST(negative_cache_pid)
|
||||
{
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
#define ORIG_STR "ORIGINAL"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
char memfd_path[64];
|
||||
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "../test.h"
|
||||
#include "../../common/test.h"
|
||||
|
||||
int pipe_1[2], pipe_2[2];
|
||||
int sock[2];
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
check_file_size() {
|
||||
local file_name="$1"
|
||||
|
|
@ -45,11 +44,11 @@ test_ext2() {
|
|||
}
|
||||
|
||||
test_fdatasync() {
|
||||
fdatasync/fdatasync /
|
||||
./fdatasync/fdatasync /
|
||||
rm -f /test_fdatasync.txt
|
||||
fdatasync/fdatasync /ext2
|
||||
./fdatasync/fdatasync /ext2
|
||||
rm -f /ext2/test_fdatasync.txt
|
||||
fdatasync/fdatasync /exfat
|
||||
./fdatasync/fdatasync /exfat
|
||||
rm -f /exfat/test_fdatasync.txt
|
||||
}
|
||||
|
||||
|
|
@ -88,8 +87,8 @@ test_mount_bind_file() {
|
|||
|
||||
echo "Start ext2 fs test......"
|
||||
test_ext2 "/ext2" "test_file.txt"
|
||||
ext2/mknod
|
||||
ext2/unix_socket
|
||||
./ext2/mknod
|
||||
./ext2/unix_socket
|
||||
echo "All ext2 fs test passed."
|
||||
|
||||
echo "Start fdatasync test......"
|
||||
|
|
@ -100,14 +99,16 @@ echo "Start mount bind file test......"
|
|||
test_mount_bind_file
|
||||
echo "All mount bind file test passed."
|
||||
|
||||
pipe/pipe_err
|
||||
pipe/short_rw
|
||||
epoll/epoll_err
|
||||
epoll/poll_err
|
||||
file_io/access_err
|
||||
file_io/file_err
|
||||
file_io/iovec_err
|
||||
devfs/full
|
||||
devfs/random
|
||||
devfs/framebuffer
|
||||
devfs/evdev
|
||||
./inotify/inotify_align
|
||||
./inotify/inotify_poll
|
||||
./inotify/inotify_unlink
|
||||
|
||||
./overlayfs/ovl_test
|
||||
|
||||
./procfs/dentry_cache
|
||||
./procfs/pid_mem
|
||||
|
||||
./pseudofs/memfd_access_err
|
||||
./pseudofs/pseudo_dentry
|
||||
./pseudofs/pseudo_inode
|
||||
./pseudofs/pseudo_mount
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
SUBDIRS := \
|
||||
in_c \
|
||||
in_c_pie \
|
||||
|
||||
ifeq ($(HOST_PLATFORM), x86_64-linux)
|
||||
SUBDIRS += in_assembly
|
||||
endif
|
||||
|
||||
include ../common/Makefile
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS := -static -nostdlib
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS := -static
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../../common/Makefile
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
set -e
|
||||
|
||||
./in_c/hello
|
||||
./in_c_pie/hello
|
||||
[ "$(uname -m)" = "x86_64" ] && ./in_assembly/hello
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
SUBDIRS := gen_quote
|
||||
|
||||
include ../common/Makefile
|
||||
|
|
@ -1,27 +1,26 @@
|
|||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
MAIN_MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
||||
INCLUDE_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
CUR_DIR := $(shell dirname $(realpath $(MAIN_MAKEFILE)))
|
||||
CUR_DIR_NAME := $(shell basename $(realpath $(CUR_DIR)))
|
||||
CUR_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
ATOMIC_WGET := $(CUR_DIR)/../../../../../../tools/atomic_wget.sh
|
||||
BUILD_DIR ?= $(CUR_DIR)/../../../../build
|
||||
OUTPUT_DIR ?= $(BUILD_DIR)/initramfs/test
|
||||
BIN_OUTPUT_DIR := $(OUTPUT_DIR)/intel_tdx/gen_quote
|
||||
TDX_ATTEST_DIR ?= $(CUR_DIR)
|
||||
TDX_SRCS := test_tdx_attest.c tdx_attest.c qgs_msg_lib.cpp
|
||||
BUILD_DIR := $(CUR_DIR)/../../../build
|
||||
OBJ_OUTPUT_DIR := $(BUILD_DIR)/initramfs/test/$(CUR_DIR_NAME)
|
||||
CC ?= gcc
|
||||
C_FLAGS ?= -Wall -Werror
|
||||
# FIXME: Disable use-after-free warning as error due to potential false positive
|
||||
# in realloc/free pattern in `tdx_attest.c`.
|
||||
C_FLAGS += -Wno-error
|
||||
DCAP_VERSION := DCAP_1.23
|
||||
DCAP_URL_PREFIX := "https://github.com/intel/SGXDataCenterAttestationPrimitives/raw/$(DCAP_VERSION)/QuoteGeneration/quote_wrapper"
|
||||
ATOMIC_WGET := $(CUR_DIR)/../../../../tools/atomic_wget.sh
|
||||
|
||||
.PHONY: all
|
||||
all: $(BIN_OUTPUT_DIR)/gen_quote
|
||||
|
||||
all: $(OBJ_OUTPUT_DIR) $(OBJ_OUTPUT_DIR)/generate_tdx_quote
|
||||
$(BIN_OUTPUT_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
$(OBJ_OUTPUT_DIR):
|
||||
@mkdir -p $(OBJ_OUTPUT_DIR)
|
||||
|
||||
$(OBJ_OUTPUT_DIR)/generate_tdx_quote: $(addprefix $(TDX_ATTEST_DIR)/,$(TDX_SRCS))
|
||||
$(BIN_OUTPUT_DIR)/gen_quote: $(addprefix $(TDX_ATTEST_DIR)/,$(TDX_SRCS)) | $(BIN_OUTPUT_DIR)
|
||||
@$(CC) $(C_FLAGS) $^ -o $@
|
||||
@echo "CC <= $@"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue