From af23f2efcf755ec020cc5d9e9411da2267d90d57 Mon Sep 17 00:00:00 2001 From: Youjie Zheng Date: Tue, 21 May 2024 21:44:45 +0800 Subject: [PATCH] chore: set the size of the testcases image dynamically --- .github/workflows/build.yml | 2 +- .github/workflows/test.yml | 2 +- apps/monolithic_userboot/test_cmd | 2 +- build_img.sh | 17 +++++++++++------ scripts/test/app_test_for_monolithic.sh | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 23a6f8b..acb366f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -335,5 +335,5 @@ jobs: - name: Bulld monolithic-userboot working-directory: ${{ env.WORKING_DIRECTORY }} run: | - sh ./build_img.sh -m ${{ matrix.arch }} + sh ./build_img.sh -a ${{ matrix.arch }} make ARCH=${{ matrix.arch }} A=apps/monolithic_userboot diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 365e0b4..76bef55 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -156,6 +156,6 @@ jobs: - name: Run app tests working-directory: ${{ needs.prepare_for_external_test.outputs.TopTestDirectory }} run: | - sh ./build_img.sh -m ${{ matrix.arch }} -fs ext4 + sh ./build_img.sh -a ${{ matrix.arch }} -fs ext4 export MONOLITHIC_TESTCASE=other make ARCH=${{ matrix.arch }} A=apps/monolithic_userboot APP_FEATURES=batch FEATURES="ext4fs" LOG=off ACCEL=n run \ No newline at end of file diff --git a/apps/monolithic_userboot/test_cmd b/apps/monolithic_userboot/test_cmd index c3aec76..4d3def2 100644 --- a/apps/monolithic_userboot/test_cmd +++ b/apps/monolithic_userboot/test_cmd @@ -1 +1 @@ -test_one "LOG=off" +test_one "LOG=off FEATURES=img" diff --git a/build_img.sh b/build_img.sh index c42185d..d865752 100755 --- a/build_img.sh +++ b/build_img.sh @@ -3,21 +3,23 @@ # MacOS : brew install dosfstools # Ubuntu : apt-get install dosfstools # Usage: -# build_img.sh -m [arch] -fs [ext4|fat32] -file [testcast] +# build_img.sh -a [arch] -fs [ext4|fat32] -file [testcast] -s [size] ################################################################ # default setting arch=x86_64 fs=fat32 +size=128 FILE= display_help() { echo "" - echo "./build_img.sh -m [arch] -fs [filesystem] -file [testcast]" + echo "./build_img.sh -a [arch] -fs [filesystem] -file [testcast]" # 若不指定参数,则使用默认的测例 - echo " -m | --arch architecture: x86_64|riscv64|aarch64", default is x86_64 + echo " -a | --arch architecture: x86_64|riscv64|aarch64", default is x86_64 echo " -fs | --filesystem filesystem: ext4|fat32", default is fat32 echo " -file | --testcase If not specified, use the default testcases for different architectures." + echi " -s | --size size of the disk image in MB, default is 128MB" echo " default testcases:" echo " x86_64: x86_64_linux_musl" echo " riscv64: riscv64_linux_musl" @@ -27,11 +29,11 @@ display_help() exit 1 } -# 可能接受三类参数 -m [arch] -fs [filesystem] -file [testcast] +# 可能接受四类参数 -a [arch] -fs [filesystem] -file [testcast] -s [size] # 但是不一定只有一个参数,所以使用 while 循环 while [ "$1" != "" ]; do case $1 in - -m | --arch ) shift + -a | --arch ) shift arch=$1 ;; -fs | --filesystem ) shift @@ -40,6 +42,9 @@ while [ "$1" != "" ]; do -file | --testcase ) shift FILE=$1 ;; + -s | --size ) shift + size=$1 + ;; -h | --help ) display_help exit ;; @@ -68,7 +73,7 @@ if [ ! -d "./testcases/$FILE" ]; then fi rm -f disk.img -dd if=/dev/zero of=disk.img bs=4M count=1024 +dd if=/dev/zero of=disk.img bs=1M count=$size if [ "$fs" = "ext4" ]; then mkfs.ext4 -t ext4 disk.img diff --git a/scripts/test/app_test_for_monolithic.sh b/scripts/test/app_test_for_monolithic.sh index a03b3e1..8ea24d5 100755 --- a/scripts/test/app_test_for_monolithic.sh +++ b/scripts/test/app_test_for_monolithic.sh @@ -38,7 +38,7 @@ function run_and_compare() { echo -ne " run with \"${BLOD_C}$args${END_C}\": " # if the app contain "apps/monolithic_userboot", then make disk img - sh ./build_img.sh -m $ARCH + sh ./build_img.sh -a $ARCH make -C "$ROOT" A="$APP" $args > "$actual" 2>&1 if [ $? -ne 0 ]; then