Add prebuilt apps test in docker image

This commit is contained in:
Qingsong Chen 2025-07-17 12:52:24 +00:00 committed by Tate, Hongliang Tian
parent 12c40de5a9
commit edbab2093a
2 changed files with 89 additions and 60 deletions

View File

@ -2,6 +2,7 @@
ARCH ?= x86_64
SMP ?= 1
VERBOSE ?= 1
SYSCALL_TEST_SUITE ?= ltp
SYSCALL_TEST_WORKDIR ?= /tmp
ENABLE_BASIC_TEST ?= false
@ -37,6 +38,11 @@ else
ENABLE_SYSCALL_TEST = false
endif
# Decreases the level of verbosity of diagnostic messages from Nix.
ifeq ($(VERBOSE), 0)
NIX_QUIET = --quiet -Q
endif
.PHONY: all
all: build
@ -72,6 +78,79 @@ $(INITRAMFS):
--out-link $@ \
nix -A initramfs
# Prebuild x86_64 packages
x86_64_pkgs:
@nix-build \
nix/default.nix \
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
$(NIX_QUIET) \
--argstr target x86_64 \
--arg enableBenchmark true \
--arg enableSyscallTest true \
--out-link /nix/var/nix/gcroots/auto/x86_64-pkgs \
-A busybox \
-A apps.package \
-A benchmark.fio \
-A benchmark.hackbench \
-A benchmark.iperf3 \
-A benchmark.lmbench \
-A benchmark.memcached \
-A benchmark.nginx \
-A benchmark.redis \
-A benchmark.schbench \
-A benchmark.sqlite-speedtest1 \
-A benchmark.sysbench \
-A syscall.ltp
# Prebuild riscv64 packages
# Note: This may cause GitHub Runner ResourceExhausted errors when publish nix docker image.
# If such errors occur, try building each package individually and clear the build cache.
riscv64_pkgs:
@nix-build \
nix/default.nix \
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
$(NIX_QUIET) \
--argstr target riscv64 \
--arg enableBenchmark true \
--arg enableSyscallTest true \
--out-link /nix/var/nix/gcroots/auto/riscv64-pkgs \
-A busybox \
-A apps.package \
-A benchmark.fio \
-A benchmark.hackbench \
-A benchmark.iperf3 \
-A benchmark.lmbench \
-A benchmark.memcached \
-A benchmark.nginx \
-A benchmark.redis \
-A benchmark.schbench \
-A benchmark.sqlite-speedtest1 \
-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 linux_vdso \
-A apps.mongoose_src
install_host_pkgs:
@nix-env \
--file nix/default.nix \
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
--install \
-A apacheHttpd \
-A iperf3 \
-A libmemcached \
-A lmbench \
-A redis
nix_gc:
@nix-collect-garbage -d
@nix-store --optimise
$(EXT2_IMAGE):
@dd if=/dev/zero of=$(EXT2_IMAGE) bs=2G count=1
@mke2fs $(EXT2_IMAGE)

View File

@ -19,75 +19,25 @@ RUN sh <(curl -L https://nixos.org/nix/install) --daemon --yes \
#= Build Nix packages ======================================================
COPY test/nix /root/nix
WORKDIR /root
COPY test /root/test
WORKDIR /root/test
ENV PATH="/nix/var/nix/profiles/default/bin:${PATH}"
# Build riscv64 packages
# Note: This may cause GitHub Runner ResourceExhausted errors. If such errors occur,
# try building each package individually and clear the build cache.
RUN nix-build \
./nix/default.nix \
--quiet -Q \
--argstr target riscv64 \
--arg enableBenchmark true \
--arg enableSyscallTest true \
--out-link /nix/var/nix/gcroots/auto/riscv64-pkgs \
-A busybox \
-A benchmark.fio \
-A benchmark.hackbench \
-A benchmark.iperf3 \
-A benchmark.lmbench \
-A benchmark.memcached \
-A benchmark.nginx \
-A benchmark.redis \
-A benchmark.schbench \
-A benchmark.sqlite-speedtest1 \
-A syscall.ltp \
&& nix-collect-garbage -d \
&& nix-store --optimise
RUN make riscv64_pkgs VERBOSE=0 \
&& make nix_gc
# Build x86_64 packages
RUN nix-build \
./nix/default.nix \
--quiet -Q \
--argstr target x86_64 \
--arg enableBenchmark true \
--arg enableSyscallTest true \
--out-link /nix/var/nix/gcroots/auto/x86_64-pkgs \
-A busybox \
-A benchmark.fio \
-A benchmark.hackbench \
-A benchmark.iperf3 \
-A benchmark.lmbench \
-A benchmark.memcached \
-A benchmark.nginx \
-A benchmark.redis \
-A benchmark.schbench \
-A benchmark.sqlite-speedtest1 \
-A benchmark.sysbench \
-A syscall.ltp \
&& nix-collect-garbage -d \
&& nix-store --optimise
RUN make x86_64_pkgs VERBOSE=0 \
&& make nix_gc
# Build general packages and install host required packages
RUN nix-build \
./nix/default.nix \
--quiet -Q \
--out-link /nix/var/nix/gcroots/auto/linux_vdso \
-A linux_vdso \
&& nix-env --install \
--file ./nix/default.nix \
-A apacheHttpd \
-A iperf3 \
-A libmemcached \
-A lmbench \
-A redis \
&& nix-collect-garbage -d \
&& nix-store --optimise
RUN make general_pkgs VERBOSE=0 \
&& make install_host_pkgs \
&& make nix_gc
# Clean source files
RUN rm -rf /root/nix
RUN rm -rf /root/test
VOLUME [ "/root/asterinas" ]