mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 04:55:03 +00:00
Add LTP syscall tests
This commit is contained in:
parent
a0af7ae680
commit
38c9ab0615
4
.github/actions/test/action.yml
vendored
4
.github/actions/test/action.yml
vendored
@ -36,6 +36,9 @@ inputs:
|
||||
extra_blocklists:
|
||||
description: 'Extra blocklists directories'
|
||||
required: false
|
||||
syscall_test_suite:
|
||||
description: 'Selected syscall test suite'
|
||||
required: false
|
||||
syscall_test_workdir:
|
||||
description: 'Syscall test working directory'
|
||||
required: false
|
||||
@ -85,6 +88,7 @@ runs:
|
||||
[[ -n "${{ inputs.scheme }}" ]] && CMD+=" SCHEME=${{ inputs.scheme }}"
|
||||
[[ -n "${{ inputs.arch }}" ]] && CMD+=" ARCH=${{ inputs.arch }}"
|
||||
[[ -n "${{ inputs.extra_blocklists }}" ]] && CMD+=" EXTRA_BLOCKLISTS_DIRS=${{ inputs.extra_blocklists }}"
|
||||
[[ -n "${{ inputs.syscall_test_suite }}" ]] && CMD+=" SYSCALL_TEST_SUITE=${{ inputs.syscall_test_suite }}"
|
||||
[[ -n "${{ inputs.syscall_test_workdir }}" ]] && CMD+=" SYSCALL_TEST_WORKDIR=${{ inputs.syscall_test_workdir }}"
|
||||
[[ -n "${{ inputs.boot_protocol }}" ]] && CMD+=" BOOT_PROTOCOL=${{ inputs.boot_protocol }}"
|
||||
|
||||
|
18
.github/workflows/test_x86.yml
vendored
18
.github/workflows/test_x86.yml
vendored
@ -76,7 +76,7 @@ jobs:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Run integration tests
|
||||
- name: Run integration tests ${{ (startsWith(matrix.test_id, 'syscall') && 'with LTP') || '' }}
|
||||
uses: ./.github/actions/test
|
||||
with:
|
||||
auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') ||
|
||||
@ -87,6 +87,22 @@ jobs:
|
||||
netdev: ${{ matrix.netdev || 'tap' }}
|
||||
scheme: ${{ matrix.scheme }}
|
||||
extra_blocklists: ${{ matrix.extra_blocklists }}
|
||||
syscall_test_suite: 'ltp'
|
||||
syscall_test_workdir: ${{ matrix.syscall_test_workdir }}
|
||||
boot_protocol: ${{ matrix.boot_protocol || 'linux-efi-handover64' }}
|
||||
- name: Run integration tests ${{ (startsWith(matrix.test_id, 'syscall') && 'with gVisor') || '' }}
|
||||
if: ${{ startsWith(matrix.test_id, 'syscall') }}
|
||||
uses: ./.github/actions/test
|
||||
with:
|
||||
auto_test: ${{ (startsWith(matrix.test_id, 'boot') && 'boot') ||
|
||||
(startsWith(matrix.test_id, 'syscall') && 'syscall') || 'test' }}
|
||||
release: ${{ matrix.release || true }}
|
||||
enable_kvm: ${{ matrix.enable_kvm || true }}
|
||||
smp: ${{ matrix.smp }}
|
||||
netdev: ${{ matrix.netdev || 'tap' }}
|
||||
scheme: ${{ matrix.scheme }}
|
||||
extra_blocklists: ${{ matrix.extra_blocklists }}
|
||||
syscall_test_suite: 'gvisor'
|
||||
syscall_test_workdir: ${{ matrix.syscall_test_workdir }}
|
||||
boot_protocol: ${{ matrix.boot_protocol || 'linux-efi-handover64' }}
|
||||
|
||||
|
@ -28,8 +28,8 @@ check-file = false
|
||||
# Files listed below are ignored to check.
|
||||
[files]
|
||||
extend-exclude = [
|
||||
"test/syscall_test/blocklists/pty_test",
|
||||
"test/build/initramfs/opt/syscall_test/blocklists/pty_test",
|
||||
"test/syscall_test/blocklists/sync_test",
|
||||
"test/build/initramfs/opt/syscall_test/blocklists/sync_test",
|
||||
"test/syscall_test/gvisor/blocklists/pty_test",
|
||||
"test/build/initramfs/opt/gvisor/blocklists/pty_test",
|
||||
"test/syscall_test/gvisor/blocklists/sync_test",
|
||||
"test/build/initramfs/opt/gvisor/blocklists/sync_test",
|
||||
]
|
3
Makefile
3
Makefile
@ -53,6 +53,7 @@ CARGO_OSDK_ARGS := --target-arch=$(ARCH) --kcmd-args="ostd.log_level=$(LOG_LEVEL
|
||||
|
||||
ifeq ($(AUTO_TEST), syscall)
|
||||
BUILD_SYSCALL_TEST := 1
|
||||
CARGO_OSDK_ARGS += --kcmd-args="SYSCALL_TEST_SUITE=$(SYSCALL_TEST_SUITE)"
|
||||
CARGO_OSDK_ARGS += --kcmd-args="SYSCALL_TEST_WORKDIR=$(SYSCALL_TEST_WORKDIR)"
|
||||
CARGO_OSDK_ARGS += --kcmd-args="EXTRA_BLOCKLISTS_DIRS=$(EXTRA_BLOCKLISTS_DIRS)"
|
||||
CARGO_OSDK_ARGS += --init-args="/opt/syscall_test/run_syscall_test.sh"
|
||||
@ -229,7 +230,7 @@ run: initramfs $(CARGO_OSDK)
|
||||
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS)
|
||||
# Check the running status of auto tests from the QEMU log
|
||||
ifeq ($(AUTO_TEST), syscall)
|
||||
@tail --lines 100 qemu.log | grep -q "^.* of .* test cases passed." \
|
||||
@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." \
|
||||
|
@ -1,119 +1,32 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
# A list of enabled system call test suites from Gvisor.
|
||||
# Each test suite consists of multiple test cases,
|
||||
# some of which are disabled by the blocklists.
|
||||
#
|
||||
# Please keep the list sorted by name.
|
||||
TESTS ?= \
|
||||
access_test \
|
||||
chown_test \
|
||||
creat_test \
|
||||
dup_test \
|
||||
epoll_test \
|
||||
eventfd_test \
|
||||
fallocate_test \
|
||||
fcntl_test \
|
||||
flock_test \
|
||||
fsync_test \
|
||||
futex_test \
|
||||
getdents_test \
|
||||
ioctl_test \
|
||||
link_test \
|
||||
lseek_test \
|
||||
mkdir_test \
|
||||
mknod_test \
|
||||
mmap_test \
|
||||
mount_test \
|
||||
open_create_test \
|
||||
open_test \
|
||||
ppoll_test \
|
||||
prctl_setuid_test \
|
||||
pread64_test \
|
||||
preadv2_test \
|
||||
proc_test \
|
||||
pselect_test \
|
||||
pwrite64_test \
|
||||
pwritev2_test \
|
||||
pty_test \
|
||||
read_test \
|
||||
readv_test \
|
||||
rename_test \
|
||||
rlimits_test \
|
||||
sched_test \
|
||||
sched_yield_test \
|
||||
semaphore_test \
|
||||
sendfile_test \
|
||||
sigaction_test \
|
||||
sigaltstack_test \
|
||||
signalfd_test \
|
||||
socket_netlink_route_test \
|
||||
stat_test \
|
||||
stat_times_test \
|
||||
statfs_test \
|
||||
symlink_test \
|
||||
sync_test \
|
||||
sysinfo_test \
|
||||
tcp_socket_test \
|
||||
timerfd_test \
|
||||
timers_test \
|
||||
truncate_test \
|
||||
uidgid_test \
|
||||
unlink_test \
|
||||
utimes_test \
|
||||
vdso_clock_gettime_test \
|
||||
vfork_test \
|
||||
write_test \
|
||||
xattr_test \
|
||||
# The end of the list
|
||||
|
||||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
||||
BUILD_DIR ?= $(CUR_DIR)/../build
|
||||
ifdef ASTER_PREBUILT_SYSCALL_TEST
|
||||
BIN_DIR := $(ASTER_PREBUILT_SYSCALL_TEST)
|
||||
else
|
||||
BIN_DIR := $(BUILD_DIR)/syscall_test_bins
|
||||
SRC_DIR := $(BUILD_DIR)/gvisor_src
|
||||
endif
|
||||
INITRAMFS ?= $(CUR_DIR)/../build/initramfs
|
||||
TARGET_DIR := $(INITRAMFS)/opt/syscall_test
|
||||
RUN_BASH := $(CUR_DIR)/run_syscall_test.sh
|
||||
BLOCK_LIST := $(CUR_DIR)/blocklists
|
||||
EXFAT_BLOCK_LIST := $(CUR_DIR)/blocklists.exfat
|
||||
TARGET_DIR := $(INITRAMFS)/opt/syscall_test
|
||||
SYSCALL_TEST_SUITE ?= ltp
|
||||
GVISOR_DIR := $(INITRAMFS)/opt/gvisor
|
||||
LTP_DIR := $(INITRAMFS)/opt/ltp
|
||||
|
||||
.PHONY: all
|
||||
all: $(TESTS)
|
||||
all: $(TARGET_DIR)
|
||||
|
||||
$(TESTS): $(BIN_DIR) $(TARGET_DIR)
|
||||
@cp -f $</$@ $(TARGET_DIR)/tests
|
||||
|
||||
ifndef ASTER_PREBUILT_SYSCALL_TEST
|
||||
$(BIN_DIR): $(SRC_DIR)
|
||||
@if ! type bazel > /dev/null; then \
|
||||
echo "bazel is not installed, please run tools/install_bazel.sh with sudo permission to install it."; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(TARGET_DIR): $(RUN_BASH) $(GVISOR_DIR) $(LTP_DIR)
|
||||
@rm -rf $@ && mkdir -p $@
|
||||
@cd $(SRC_DIR) && bazel build --test_tag_filters=native //test/syscalls/...
|
||||
@cp $(SRC_DIR)/bazel-bin/test/syscalls/linux/*_test $@
|
||||
|
||||
$(SRC_DIR):
|
||||
@rm -rf $@ && mkdir -p $@
|
||||
@cd $@ && git clone -b 20200921.0 https://github.com/asterinas/gvisor.git .
|
||||
endif
|
||||
|
||||
$(TARGET_DIR): $(RUN_BASH) $(BLOCK_LIST) $(EXFAT_BLOCK_LIST)
|
||||
@rm -rf $@ && mkdir -p $@
|
||||
@# Prepare tests dir for test binaries
|
||||
@mkdir $@/tests
|
||||
@# Copy blocklists
|
||||
@cp -rf $(BLOCK_LIST) $@
|
||||
@# Copy exFAT specific blocklists
|
||||
@cp -rf $(EXFAT_BLOCK_LIST) $@
|
||||
@# Copy bash script
|
||||
@cp -f $(RUN_BASH) $@
|
||||
|
||||
$(GVISOR_DIR):
|
||||
ifeq ($(SYSCALL_TEST_SUITE), gvisor)
|
||||
@$(MAKE) --no-print-directory -C gvisor
|
||||
endif
|
||||
|
||||
$(LTP_DIR):
|
||||
ifeq ($(SYSCALL_TEST_SUITE), ltp)
|
||||
@$(MAKE) --no-print-directory -C ltp
|
||||
endif
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(TARGET_DIR)
|
||||
|
119
test/syscall_test/gvisor/Makefile
Normal file
119
test/syscall_test/gvisor/Makefile
Normal file
@ -0,0 +1,119 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
# A list of enabled system call test suites from Gvisor.
|
||||
# Each test suite consists of multiple test cases,
|
||||
# some of which are disabled by the blocklists.
|
||||
#
|
||||
# Please keep the list sorted by name.
|
||||
TESTS ?= \
|
||||
access_test \
|
||||
chown_test \
|
||||
creat_test \
|
||||
dup_test \
|
||||
epoll_test \
|
||||
eventfd_test \
|
||||
fallocate_test \
|
||||
fcntl_test \
|
||||
flock_test \
|
||||
fsync_test \
|
||||
futex_test \
|
||||
getdents_test \
|
||||
ioctl_test \
|
||||
link_test \
|
||||
lseek_test \
|
||||
mkdir_test \
|
||||
mknod_test \
|
||||
mmap_test \
|
||||
mount_test \
|
||||
open_create_test \
|
||||
open_test \
|
||||
ppoll_test \
|
||||
prctl_setuid_test \
|
||||
pread64_test \
|
||||
preadv2_test \
|
||||
proc_test \
|
||||
pselect_test \
|
||||
pwrite64_test \
|
||||
pwritev2_test \
|
||||
pty_test \
|
||||
read_test \
|
||||
readv_test \
|
||||
rename_test \
|
||||
rlimits_test \
|
||||
sched_test \
|
||||
sched_yield_test \
|
||||
semaphore_test \
|
||||
sendfile_test \
|
||||
sigaction_test \
|
||||
sigaltstack_test \
|
||||
signalfd_test \
|
||||
socket_netlink_route_test \
|
||||
stat_test \
|
||||
stat_times_test \
|
||||
statfs_test \
|
||||
symlink_test \
|
||||
sync_test \
|
||||
sysinfo_test \
|
||||
tcp_socket_test \
|
||||
timerfd_test \
|
||||
timers_test \
|
||||
truncate_test \
|
||||
uidgid_test \
|
||||
unlink_test \
|
||||
utimes_test \
|
||||
vdso_clock_gettime_test \
|
||||
vfork_test \
|
||||
write_test \
|
||||
xattr_test \
|
||||
# The end of the list
|
||||
|
||||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
||||
BUILD_DIR ?= $(CUR_DIR)/../../build
|
||||
ifdef ASTER_PREBUILT_SYSCALL_TEST
|
||||
BIN_DIR := $(ASTER_PREBUILT_SYSCALL_TEST)
|
||||
else
|
||||
BIN_DIR := $(BUILD_DIR)/syscall_test_bins
|
||||
SRC_DIR := $(BUILD_DIR)/gvisor_src
|
||||
endif
|
||||
INITRAMFS ?= $(CUR_DIR)/../../build/initramfs
|
||||
TARGET_DIR := $(INITRAMFS)/opt/gvisor
|
||||
RUN_BASH := $(CUR_DIR)/run_gvisor_test.sh
|
||||
BLOCK_LIST := $(CUR_DIR)/blocklists
|
||||
EXFAT_BLOCK_LIST := $(CUR_DIR)/blocklists.exfat
|
||||
|
||||
.PHONY: all
|
||||
all: $(TESTS)
|
||||
|
||||
$(TESTS): $(BIN_DIR) $(TARGET_DIR)
|
||||
@cp -f $</$@ $(TARGET_DIR)/tests
|
||||
|
||||
ifndef ASTER_PREBUILT_SYSCALL_TEST
|
||||
$(BIN_DIR): $(SRC_DIR)
|
||||
@if ! type bazel > /dev/null; then \
|
||||
echo "bazel is not installed, please run tools/install_bazel.sh with sudo permission to install it."; \
|
||||
exit 1; \
|
||||
fi
|
||||
@rm -rf $@ && mkdir -p $@
|
||||
@cd $(SRC_DIR) && bazel build --test_tag_filters=native //test/syscalls/...
|
||||
@cp $(SRC_DIR)/bazel-bin/test/syscalls/linux/*_test $@
|
||||
|
||||
$(SRC_DIR):
|
||||
@rm -rf $@ && mkdir -p $@
|
||||
@cd $@ && git clone -b 20200921.0 https://github.com/asterinas/gvisor.git .
|
||||
endif
|
||||
|
||||
$(TARGET_DIR): $(RUN_BASH) $(BLOCK_LIST) $(EXFAT_BLOCK_LIST)
|
||||
@rm -rf $@ && mkdir -p $@
|
||||
@# Prepare tests dir for test binaries
|
||||
@mkdir $@/tests
|
||||
@# Copy blocklists
|
||||
@cp -rf $(BLOCK_LIST) $@
|
||||
@# Copy exFAT specific blocklists
|
||||
@cp -rf $(EXFAT_BLOCK_LIST) $@
|
||||
@# Copy bash script
|
||||
@cp -f $(RUN_BASH) $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(TARGET_DIR)
|
74
test/syscall_test/gvisor/run_gvisor_test.sh
Executable file
74
test/syscall_test/gvisor/run_gvisor_test.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
TEST_TMP_DIR=${SYSCALL_TEST_WORKDIR:-/tmp}
|
||||
TEST_BIN_DIR=$SCRIPT_DIR/tests
|
||||
BLOCKLIST_DIR=$SCRIPT_DIR/blocklists
|
||||
FAIL_CASES=$SCRIPT_DIR/fail_cases
|
||||
BLOCK=""
|
||||
TESTS=0
|
||||
PASSED_TESTS=0
|
||||
RESULT=0
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
get_blocklist_subtests(){
|
||||
if [ -f $BLOCKLIST_DIR/$1 ]; then
|
||||
BLOCK=$(grep -v '^#' $BLOCKLIST_DIR/$1 | tr '\n' ':')
|
||||
else
|
||||
BLOCK=""
|
||||
fi
|
||||
|
||||
for extra_dir in $EXTRA_BLOCKLISTS_DIRS ; do
|
||||
if [ -f $SCRIPT_DIR/$extra_dir/$1 ]; then
|
||||
BLOCK="${BLOCK}:$(grep -v '^#' $SCRIPT_DIR/$extra_dir/$1 | tr '\n' ':')"
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
run_one_test(){
|
||||
echo -e "Run Test Case: $1"
|
||||
# The gvisor test framework utilizes the "TEST_TMPDIR" environment variable to dictate the directory's location.
|
||||
export TEST_TMPDIR=$TEST_TMP_DIR
|
||||
ret=0
|
||||
if [ -f $TEST_BIN_DIR/$1 ]; then
|
||||
get_blocklist_subtests $1
|
||||
cd $TEST_BIN_DIR && ./$1 --gtest_filter=-$BLOCK
|
||||
ret=$?
|
||||
#After executing the test, it is necessary to clean the directory to ensure no residual data remains
|
||||
rm -rf $TEST_TMP_DIR/*
|
||||
else
|
||||
echo -e "Warning: $1 test does not exit"
|
||||
ret=1
|
||||
fi
|
||||
echo ""
|
||||
return $ret
|
||||
}
|
||||
|
||||
rm -f $FAIL_CASES && touch $FAIL_CASES
|
||||
rm -rf $TEST_TMP_DIR/*
|
||||
|
||||
for syscall_test in $(find $TEST_BIN_DIR/. -name \*_test) ; do
|
||||
test_name=$(basename "$syscall_test")
|
||||
run_one_test $test_name
|
||||
if [ $? -eq 0 ] && PASSED_TESTS=$((PASSED_TESTS+1));then
|
||||
TESTS=$((TESTS+1))
|
||||
else
|
||||
echo -e "$test_name" >> $FAIL_CASES
|
||||
TESTS=$((TESTS+1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "$GREEN$PASSED_TESTS$NC of $GREEN$TESTS$NC test cases passed."
|
||||
[ $PASSED_TESTS -ne $TESTS ] && RESULT=1
|
||||
if [ $TESTS != $PASSED_TESTS ]; then
|
||||
echo -e "The $RED$(($TESTS-$PASSED_TESTS))$NC failed test cases are as follows:"
|
||||
cat $FAIL_CASES
|
||||
fi
|
||||
|
||||
exit $RESULT
|
52
test/syscall_test/ltp/Makefile
Normal file
52
test/syscall_test/ltp/Makefile
Normal file
@ -0,0 +1,52 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
LTP_DIR ?= /opt/ltp
|
||||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
CUR_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
||||
INITRAMFS ?= $(CUR_DIR)/../../build/initramfs
|
||||
TARGET_DIR := $(INITRAMFS)/opt/ltp
|
||||
RUN_BASH := $(CUR_DIR)/run_ltp_test.sh
|
||||
ALL_TESTS := $(CUR_DIR)/testcases/all.txt
|
||||
EXT2_BLOCKLIST := $(CUR_DIR)/testcases/blocked/ext2.txt
|
||||
EXFAT_BLOCKLIST := $(CUR_DIR)/testcases/blocked/exfat.txt
|
||||
|
||||
.PHONY: all
|
||||
all: $(TARGET_DIR)
|
||||
|
||||
$(TARGET_DIR): $(RUN_BASH) $(ALL_TESTS) $(EXT2_BLOCKLIST) $(EXFAT_BLOCKLIST)
|
||||
@rm -rf $@ && mkdir -p $@
|
||||
@# Prepare tests dir for test binaries
|
||||
@mkdir -p $@/testcases/bin
|
||||
@mkdir -p $@/runtest
|
||||
@awk '!/^#/ && NF' $(ALL_TESTS) > $@/all.txt
|
||||
@if [ "$(SYSCALL_TEST_WORKDIR)" = "/ext2" ]; then \
|
||||
grep -vxF -f $(EXT2_BLOCKLIST) $@/all.txt > $@/filtered.txt; \
|
||||
elif [ "$(SYSCALL_TEST_WORKDIR)" = "/exfat" ]; then \
|
||||
grep -vxF -f $(EXFAT_BLOCKLIST) $@/all.txt > $@/filtered.txt; \
|
||||
else \
|
||||
cp -f $@/all.txt $@/filtered.txt; \
|
||||
fi;
|
||||
@# Process syscall testcases and copy binaries
|
||||
@while read -r syscall binary params; do \
|
||||
if grep -q "^$$syscall$$" $@/filtered.txt; then \
|
||||
if [ -f $(LTP_DIR)/testcases/bin/$$binary ]; then \
|
||||
cp -f $(LTP_DIR)/testcases/bin/$$binary $@/testcases/bin; \
|
||||
echo "$$syscall $$binary $$params" >> $@/runtest/syscalls; \
|
||||
else \
|
||||
echo "Warning: $$binary not found (skipping)"; \
|
||||
fi; \
|
||||
fi; \
|
||||
done < $(LTP_DIR)/runtest/syscalls
|
||||
@# Remove intermediate files
|
||||
@rm -f $@/all.txt $@/filtered.txt
|
||||
@# Copy bash scripts
|
||||
@cp -r $(LTP_DIR)/bin $@
|
||||
@cp -f $(LTP_DIR)/runltp $@
|
||||
@cp -f $(LTP_DIR)/Version $@
|
||||
@cp -f $(LTP_DIR)/ver_linux $@
|
||||
@cp -f $(LTP_DIR)/IDcheck.sh $@
|
||||
@cp -f $(RUN_BASH) $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(TARGET_DIR)
|
21
test/syscall_test/ltp/run_ltp_test.sh
Executable file
21
test/syscall_test/ltp/run_ltp_test.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
LTP_DIR=$(dirname "$0")
|
||||
TEST_TMP_DIR=${SYSCALL_TEST_WORKDIR:-/tmp}
|
||||
LOG_FILE=$TEST_TMP_DIR/result.log
|
||||
RESULT=0
|
||||
|
||||
rm -f $LOG_FILE
|
||||
CREATE_ENTRIES=1 $LTP_DIR/runltp -f syscalls -p -d $TEST_TMP_DIR -l $LOG_FILE
|
||||
if [ $? -ne 0 ]; then
|
||||
RESULT=1
|
||||
fi
|
||||
|
||||
cat $LOG_FILE
|
||||
if ! grep -q "Total Failures: 0" $LOG_FILE; then
|
||||
RESULT=1
|
||||
fi
|
||||
|
||||
exit $RESULT
|
1848
test/syscall_test/ltp/testcases/all.txt
Normal file
1848
test/syscall_test/ltp/testcases/all.txt
Normal file
File diff suppressed because it is too large
Load Diff
89
test/syscall_test/ltp/testcases/blocked/exfat.txt
Normal file
89
test/syscall_test/ltp/testcases/blocked/exfat.txt
Normal file
@ -0,0 +1,89 @@
|
||||
bind04
|
||||
chdir01A
|
||||
chmod01
|
||||
chmod01A
|
||||
chmod08
|
||||
chown05
|
||||
creat03
|
||||
dup05
|
||||
dup203
|
||||
dup205
|
||||
fallocate03
|
||||
fchmod01
|
||||
fchmodat01
|
||||
fchown05
|
||||
fchownat02
|
||||
fstat02
|
||||
fstat02_64
|
||||
fsync02
|
||||
ftruncate01
|
||||
ftruncate01_64
|
||||
getcwd03
|
||||
lchown01
|
||||
link01
|
||||
link02
|
||||
link05
|
||||
linkat01
|
||||
lstat01
|
||||
lstat01_64
|
||||
mkdir04
|
||||
mknod01
|
||||
mmap06
|
||||
mmap19
|
||||
mprotect02
|
||||
mprotect03
|
||||
msync01
|
||||
msync02
|
||||
munmap01
|
||||
munmap02
|
||||
open07
|
||||
open15
|
||||
openat01
|
||||
pread01
|
||||
pread01_64
|
||||
preadv01
|
||||
preadv01_64
|
||||
preadv201
|
||||
preadv201_64
|
||||
pwrite01
|
||||
pwrite02
|
||||
pwrite04
|
||||
pwrite01_64
|
||||
pwrite02_64
|
||||
pwrite04_64
|
||||
pwritev01
|
||||
pwritev01_64
|
||||
pwritev201
|
||||
pwritev201_64
|
||||
read01
|
||||
read02
|
||||
read04
|
||||
readv01
|
||||
rename01A
|
||||
rmdir03A
|
||||
select01
|
||||
sendfile02
|
||||
sendfile02_64
|
||||
sendfile06
|
||||
sendfile06_64
|
||||
sendfile08
|
||||
sendfile08_64
|
||||
stat02
|
||||
stat02_64
|
||||
symlink02
|
||||
symlink04
|
||||
symlinkat01
|
||||
truncate02
|
||||
truncate02_64
|
||||
umask01
|
||||
unlink01
|
||||
unlink05
|
||||
unlinkat01
|
||||
utime07
|
||||
write01
|
||||
write03
|
||||
write06
|
||||
writev02
|
||||
writev05
|
||||
writev06
|
||||
statx02
|
55
test/syscall_test/ltp/testcases/blocked/ext2.txt
Normal file
55
test/syscall_test/ltp/testcases/blocked/ext2.txt
Normal file
@ -0,0 +1,55 @@
|
||||
dup05
|
||||
getcwd02
|
||||
linkat01
|
||||
mknod01
|
||||
# FIXME: The inode number of ext2 will be exhausted by `rename14`.
|
||||
rename14
|
||||
rmdir01
|
||||
rmdir03A
|
||||
rt_sigaction01
|
||||
rt_sigaction02
|
||||
rt_sigaction03
|
||||
rt_sigprocmask01
|
||||
rt_sigprocmask02
|
||||
select01
|
||||
select03
|
||||
sendfile02
|
||||
sendfile02_64
|
||||
sendfile05
|
||||
sendfile05_64
|
||||
sendfile06
|
||||
sendfile06_64
|
||||
sendfile08
|
||||
sendfile08_64
|
||||
sigaltstack02
|
||||
signalfd02
|
||||
signalfd4_01
|
||||
signalfd4_02
|
||||
sigrelse01
|
||||
stat02
|
||||
stat02_64
|
||||
symlink02
|
||||
symlink04
|
||||
symlinkat01
|
||||
truncate02
|
||||
truncate02_64
|
||||
umask01
|
||||
unlink01
|
||||
unlink05
|
||||
unlinkat01
|
||||
utime07
|
||||
waitpid06
|
||||
waitpid07
|
||||
waitpid09
|
||||
waitpid11
|
||||
waitpid12
|
||||
waitid04
|
||||
write01
|
||||
write02
|
||||
write03
|
||||
write06
|
||||
writev02
|
||||
writev05
|
||||
writev06
|
||||
statx02
|
||||
statx03
|
@ -2,73 +2,28 @@
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
TEST_TMP_DIR=${SYSCALL_TEST_WORKDIR:-/tmp}
|
||||
TEST_BIN_DIR=$SCRIPT_DIR/tests
|
||||
BLOCKLIST_DIR=$SCRIPT_DIR/blocklists
|
||||
FAIL_CASES=$SCRIPT_DIR/fail_cases
|
||||
BLOCK=""
|
||||
TESTS=0
|
||||
PASSED_TESTS=0
|
||||
RESULT=0
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
set -e
|
||||
|
||||
get_blocklist_subtests(){
|
||||
if [ -f $BLOCKLIST_DIR/$1 ]; then
|
||||
BLOCK=$(grep -v '^#' $BLOCKLIST_DIR/$1 | tr '\n' ':')
|
||||
else
|
||||
BLOCK=""
|
||||
SYSCALL_TEST_SUITE=${SYSCALL_TEST_SUITE:-ltp}
|
||||
LTP_DIR=/opt/ltp
|
||||
GVISOR_DIR=/opt/gvisor
|
||||
|
||||
if [ "${SYSCALL_TEST_SUITE}" == "ltp" ]; then
|
||||
echo "Running LTP syscall tests..."
|
||||
if ! "${LTP_DIR}/run_ltp_test.sh"; then
|
||||
echo "Error: LTP syscall tests failed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for extra_dir in $EXTRA_BLOCKLISTS_DIRS ; do
|
||||
if [ -f $SCRIPT_DIR/$extra_dir/$1 ]; then
|
||||
BLOCK="${BLOCK}:$(grep -v '^#' $SCRIPT_DIR/$extra_dir/$1 | tr '\n' ':')"
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
run_one_test(){
|
||||
echo -e "Run Test Case: $1"
|
||||
# The gvisor test framework utilizes the "TEST_TMPDIR" environment variable to dictate the directory's location.
|
||||
export TEST_TMPDIR=$TEST_TMP_DIR
|
||||
ret=0
|
||||
if [ -f $TEST_BIN_DIR/$1 ]; then
|
||||
get_blocklist_subtests $1
|
||||
cd $TEST_BIN_DIR && ./$1 --gtest_filter=-$BLOCK
|
||||
ret=$?
|
||||
#After executing the test, it is necessary to clean the directory to ensure no residual data remains
|
||||
rm -rf $TEST_TMP_DIR/*
|
||||
else
|
||||
echo -e "Warning: $1 test does not exit"
|
||||
ret=1
|
||||
elif [ "${SYSCALL_TEST_SUITE}" == "gvisor" ]; then
|
||||
echo "Running gVisor syscall tests..."
|
||||
if ! "${GVISOR_DIR}/run_gvisor_test.sh"; then
|
||||
echo "Error: gVisor syscall tests failed." >&2
|
||||
exit 2
|
||||
fi
|
||||
echo ""
|
||||
return $ret
|
||||
}
|
||||
|
||||
rm -f $FAIL_CASES && touch $FAIL_CASES
|
||||
rm -rf $TEST_TMP_DIR/*
|
||||
|
||||
for syscall_test in $(find $TEST_BIN_DIR/. -name \*_test) ; do
|
||||
test_name=$(basename "$syscall_test")
|
||||
run_one_test $test_name
|
||||
if [ $? -eq 0 ] && PASSED_TESTS=$((PASSED_TESTS+1));then
|
||||
TESTS=$((TESTS+1))
|
||||
else
|
||||
echo -e "$test_name" >> $FAIL_CASES
|
||||
TESTS=$((TESTS+1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "$GREEN$PASSED_TESTS$NC of $GREEN$TESTS$NC test cases passed."
|
||||
[ $PASSED_TESTS -ne $TESTS ] && RESULT=1
|
||||
if [ $TESTS != $PASSED_TESTS ]; then
|
||||
echo -e "The $RED$(($TESTS-$PASSED_TESTS))$NC failed test cases are as follows:"
|
||||
cat $FAIL_CASES
|
||||
else
|
||||
echo "Error: Unknown test suite '${SYSCALL_TEST_SUITE}'." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
exit $RESULT
|
||||
echo "All syscall tests passed."
|
||||
exit 0
|
||||
|
@ -283,11 +283,11 @@ RUN apt clean && rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /root
|
||||
RUN rm -rf bazel
|
||||
|
||||
FROM build-bazel AS syscall_test
|
||||
FROM build-bazel AS build-gvisor
|
||||
|
||||
# Build the syscall test binaries
|
||||
COPY test/syscall_test /root/syscall_test
|
||||
WORKDIR /root/syscall_test
|
||||
# Build the gvisor syscall test binaries
|
||||
COPY test/syscall_test/gvisor /root/gvisor
|
||||
WORKDIR /root/gvisor
|
||||
RUN export BUILD_DIR=build && \
|
||||
make ${BUILD_DIR}/syscall_test_bins
|
||||
|
||||
@ -368,7 +368,7 @@ RUN apt clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Prepare the system call test suite
|
||||
COPY --from=build-ltp /opt/ltp /opt/ltp
|
||||
COPY --from=syscall_test /root/syscall_test/build/syscall_test_bins /root/syscall_test_bins
|
||||
COPY --from=build-gvisor /root/gvisor/build/syscall_test_bins /root/syscall_test_bins
|
||||
ENV ASTER_PREBUILT_SYSCALL_TEST=/root/syscall_test_bins
|
||||
|
||||
# Install Busybox built from the previous stages
|
||||
|
Loading…
x
Reference in New Issue
Block a user