Skip to content

Commit

Permalink
chore: set the size of the testcases image dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed May 21, 2024
1 parent 372cee8 commit af23f2e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion apps/monolithic_userboot/test_cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
test_one "LOG=off"
test_one "LOG=off FEATURES=img"
17 changes: 11 additions & 6 deletions build_img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -40,6 +42,9 @@ while [ "$1" != "" ]; do
-file | --testcase ) shift
FILE=$1
;;
-s | --size ) shift
size=$1
;;
-h | --help ) display_help
exit
;;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/app_test_for_monolithic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af23f2e

Please sign in to comment.