Add ldconfig to initramfs

This commit is contained in:
Chen Chengjun
2024-08-27 12:58:48 +08:00
committed by Tate, Hongliang Tian
parent 86f09eef75
commit d499c1592d
5 changed files with 52 additions and 8 deletions

View File

@ -46,7 +46,7 @@ endif
# If the BENCHMARK is set, we will run the benchmark in the kernel mode.
ifneq ($(BENCHMARK), none)
CARGO_OSDK_ARGS += --init-args="/benchmark/$(BENCHMARK)/run.sh"
CARGO_OSDK_ARGS += --init-args="/benchmark/common/runner.sh $(BENCHMARK)"
endif
ifeq ($(RELEASE_LTO), 1)

View File

@ -13,7 +13,6 @@ INITRAMFS_IMAGE := $(BUILD_DIR)/initramfs.cpio.gz
EXT2_IMAGE := $(BUILD_DIR)/ext2.img
EXFAT_IMAGE := $(BUILD_DIR)/exfat.img
INITRAMFS_EMPTY_DIRS := \
$(INITRAMFS)/sbin \
$(INITRAMFS)/root \
$(INITRAMFS)/tmp \
$(INITRAMFS)/opt \
@ -26,6 +25,7 @@ INITRAMFS_ALL_DIRS := \
$(INITRAMFS)/lib/x86_64-linux-gnu \
$(INITRAMFS)/lib64 \
$(INITRAMFS)/bin \
$(INITRAMFS)/sbin \
$(INITRAMFS)/usr/bin \
$(INITRAMFS)/test \
$(INITRAMFS)/benchmark \
@ -82,6 +82,11 @@ $(INITRAMFS)/bin:
@mkdir -p $@
@/bin/busybox --install -s $@
$(INITRAMFS)/sbin:
@mkdir -p $@
@cp /sbin/ldconfig $@
@cp /sbin/ldconfig.real $@
$(INITRAMFS)/usr/bin: | $(INITRAMFS)/bin
@mkdir -p $@
@cp /usr/bin/busybox $@

45
test/benchmark/common/runner.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
# SPDX-License-Identifier: MPL-2.0
set -e
print_help() {
echo "Usage: $0 bench_name"
echo ""
echo "The bench_name argument must be one of the directory under asterinas/test/benchmark/".
}
BENCH_NAME=$1
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
# Validate arguments
check_bench_name() {
if [ -z "${BENCH_NAME}" ]; then
echo "Error: No directory provided."
print_help
exit 1
fi
local full_path="${SCRIPT_DIR}/../${BENCH_NAME}"
if ! [ -d "${full_path}" ]; then
echo "Directory '${BENCH_NAME}' does not exist in the script directory."
print_help
exit 1
fi
}
check_bench_name
BENCH_SCRIPT=${SCRIPT_DIR}/../${BENCH_NAME}/run.sh
# Prepare the environment
if [ ! -d /tmp ]; then
mkdir /tmp
fi
/sbin/ldconfig
chmod +x ${BENCH_SCRIPT}
# Run the benchmark
${BENCH_SCRIPT}

View File

@ -6,8 +6,5 @@ set -e
echo "*** Running the LMbench exec latency test ***"
if [ ! -d /tmp ]; then
mkdir /tmp
fi
cp /benchmark/bin/lmbench/hello /tmp/
/benchmark/bin/lmbench/lat_proc -P 1 exec

View File

@ -6,8 +6,5 @@ set -e
echo "*** Running the LMbench shell latency test ***"
if [ ! -d /tmp ]; then
mkdir /tmp
fi
cp /benchmark/bin/lmbench/hello /tmp/
/benchmark/bin/lmbench/lat_proc -P 1 shell