Skip to content

Commit

Permalink
chore: update CI for different monolithic testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed May 12, 2024
1 parent 9a97f7e commit 0b66290
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 141 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
- name: Run app tests
run: |
make disk_img
make pre_libc && make test ARCH=${{ matrix.arch }}
make pre_libc
make test ARCH=${{ matrix.arch }}
app-test-for-monolithic:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -66,4 +67,35 @@ jobs:
- name: Run app tests
run: |
make disk_img
make test_monolithic ARCH=${{ matrix.arch }}
make test_monolithic ARCH=${{ matrix.arch }}
app-test-for-ext4fs:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
arch: [x86_64, riscv64, aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.rust-toolchain }}
components: rust-src
- uses: actions-rs/[email protected]
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
- uses: ./.github/workflows/actions/setup-qemu
with:
qemu-version: ${{ env.qemu-version }}
- uses: ./.github/workflows/actions/setup-musl
with:
arch: ${{ matrix.arch }}
- name: Run app tests
run: |
sh ./build_img.sh -m ${{ matrix.arch }} -fs ext4
make pre_libc
export MONOLITHIC_TESTCASE=other
make A=apps/monolithic_userboot APP_FEATURES=batch FEATURES="ext4fs" LOG=off run
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ $ cargo install kbuild
$ mkdir crates

# Load crates

$ kbuild patch add linux_syscall_api

$ kbuild patch add axstarry
Expand All @@ -66,4 +65,10 @@ $ kbuild patch remove axstarry

# Please verify that crates don't have any uncommitted changes before removing them.

```
```

## Notes

- Please remove unnecessary dependencies in `Cargo.toml` before your commit.
- After pulling a new crate to the local workspace, maybe you need to execute `make clean` to update the cache.

132 changes: 73 additions & 59 deletions apps/monolithic_userboot/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,83 @@ extern crate alloc;
use alloc::boxed::Box;

#[allow(dead_code)]
pub const SDCARD_TESTCASES: &[&str] = &[
// "./runtest.exe -w entry-static.exe socket",
// "busybox du",
// "./MediaServer -h",
// "busybox sh ./test_all.sh",
// "./riscv64-linux-musl-native/bin/riscv64-linux-musl-gcc ./hello.c -static",
// "./a.out",
// "./time-test",
// "./interrupts-test-1",
// "./interrupts-test-2",
// "./copy-file-range-test-1",
// "./copy-file-range-test-2",
// "./copy-file-range-test-3",
// "./copy-file-range-test-4",
// "busybox echo hello",
// "busybox sh ./unixbench_testcode.sh",
// "busybox echo hello",
// "busybox sh ./iperf_testcode.sh",
// "busybox echo hello",
// "busybox sh busybox_testcode.sh",
// "busybox echo hello",
// "busybox sh ./iozone_testcode.sh",
// "busybox echo latency measurements",
// "lmbench_all lat_syscall -P 1 null",
// "lmbench_all lat_syscall -P 1 read",
// "lmbench_all lat_syscall -P 1 write",
// "busybox mkdir -p /var/tmp",
// "busybox touch /var/tmp/lmbench",
// "lmbench_all lat_syscall -P 1 stat /var/tmp/lmbench",
// "lmbench_all lat_syscall -P 1 fstat /var/tmp/lmbench",
// "lmbench_all lat_syscall -P 1 open /var/tmp/lmbench",
// "lmbench_all lat_select -n 100 -P 1 file",
// "lmbench_all lat_sig -P 1 install",
// "lmbench_all lat_sig -P 1 catch",
// "lmbench_all lat_sig -P 1 prot lat_sig",
// "lmbench_all lat_pipe -P 1",
// "lmbench_all lat_proc -P 1 fork",
// "lmbench_all lat_proc -P 1 exec",
// "busybox cp hello /tmp",
// "lmbench_all lat_proc -P 1 shell",
// "lmbench_all lmdd label=\"File /var/tmp/XXX write bandwidth:\" of=/var/tmp/XXX move=1m fsync=1 print=3",
// "lmbench_all lat_pagefault -P 1 /var/tmp/XXX",
// "lmbench_all lat_mmap -P 1 512k /var/tmp/XXX",
// "busybox echo file system latency",
// "lmbench_all lat_fs /var/tmp",
// "busybox echo Bandwidth measurements",
// "lmbench_all bw_pipe -P 1",
// "lmbench_all bw_file_rd -P 1 512k io_only /var/tmp/XXX",
// "lmbench_all bw_file_rd -P 1 512k open2close /var/tmp/XXX",
// "lmbench_all bw_mmap_rd -P 1 512k mmap_only /var/tmp/XXX",
// "lmbench_all bw_mmap_rd -P 1 512k open2close /var/tmp/XXX",
// "busybox echo context switch overhead",
// "lmbench_all lat_ctx -P 1 -s 32 2 4 8 16 24 32 64 96",
"busybox sh libctest_testcode.sh",
// "busybox sh lua_testcode.sh",
// "libc-bench",
// "busybox sh ./netperf_testcode.sh",
// "busybox sh ./cyclictest_testcode.sh",
const BUSYBOX_TESTCASES: &[&str] = &[
"busybox sh busybox_testcode.sh",
"busybox sh lua_testcode.sh",
];

#[allow(dead_code)]
const LIBC_TESTCASES: &[&str] = &["libctest_testcode.sh", "libc-bench"];

#[allow(dead_code)]
const NET_TESTCASES: &[&str] = &[
"busybox sh netperf_testcode.sh",
"busybox sh iperf_testcode.sh",
];

#[allow(dead_code)]
const LMBENCH_TESTCASES: &[&str] = &[
"busybox echo latency measurements",
"lmbench_all lat_syscall -P 1 null",
"lmbench_all lat_syscall -P 1 read",
"lmbench_all lat_syscall -P 1 write",
"busybox mkdir -p /var/tmp",
"busybox touch /var/tmp/lmbench",
"lmbench_all lat_syscall -P 1 stat /var/tmp/lmbench",
"lmbench_all lat_syscall -P 1 fstat /var/tmp/lmbench",
"lmbench_all lat_syscall -P 1 open /var/tmp/lmbench",
"lmbench_all lat_select -n 100 -P 1 file",
"lmbench_all lat_sig -P 1 install",
"lmbench_all lat_sig -P 1 catch",
"lmbench_all lat_sig -P 1 prot lat_sig",
"lmbench_all lat_pipe -P 1",
"lmbench_all lat_proc -P 1 fork",
"lmbench_all lat_proc -P 1 exec",
"busybox cp hello /tmp",
"lmbench_all lat_proc -P 1 shell",
"lmbench_all lmdd label=\"File /var/tmp/XXX write bandwidth:\" of=/var/tmp/XXX move=1m fsync=1 print=3",
"lmbench_all lat_pagefault -P 1 /var/tmp/XXX",
"lmbench_all lat_mmap -P 1 512k /var/tmp/XXX",
"busybox echo file system latency",
"lmbench_all lat_fs /var/tmp",
"busybox echo Bandwidth measurements",
"lmbench_all bw_pipe -P 1",
"lmbench_all bw_file_rd -P 1 512k io_only /var/tmp/XXX",
"lmbench_all bw_file_rd -P 1 512k open2close /var/tmp/XXX",
"lmbench_all bw_mmap_rd -P 1 512k mmap_only /var/tmp/XXX",
"lmbench_all bw_mmap_rd -P 1 512k open2close /var/tmp/XXX",
"busybox echo context switch overhead",
"lmbench_all lat_ctx -P 1 -s 32 2 4 8 16 24 32 64 96",
];

#[allow(dead_code)]
const IOZONE_TESTCASES: &[&str] = &["busybox sh ./iozone_testcode.sh"];

/// FIXME: This test case is not working
#[allow(dead_code)]
const UNIX_TESTCASES: &[&str] = &["busybox sh ./unixbench_testcode.sh"];

#[allow(dead_code)]
const CYCLE_TESTCASES: &[&str] = &["busybox sh ./cyclictest_testcode.sh"];

#[allow(dead_code)]
const OTHER_TESTCASES: &[&str] = &["./time-test"];

#[allow(unused)]
pub fn run_batch_testcases() {
let mut test_iter = Box::new(SDCARD_TESTCASES.iter());
let testcase_str = option_env!("MONOLITHIC_TESTCASE").unwrap_or("");
let mut test_iter = match testcase_str {
"busybox" => Box::new(BUSYBOX_TESTCASES.iter()),
"libc" => Box::new(LIBC_TESTCASES.iter()),
"net" => Box::new(NET_TESTCASES.iter()),
"lmbench" => Box::new(LMBENCH_TESTCASES.iter()),
"iozone" => Box::new(IOZONE_TESTCASES.iter()),
"unixbench" => Box::new(UNIX_TESTCASES.iter()),
"cycle" => Box::new(CYCLE_TESTCASES.iter()),
"other" => Box::new(OTHER_TESTCASES.iter()),
_ => Box::new(LIBC_TESTCASES.iter()),
};

for testcase in test_iter {
axstarry::run_testcase(testcase);
}
Expand Down
89 changes: 32 additions & 57 deletions build_img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,41 @@ display_help()
{
echo ""
echo "./build_img.sh -m [arch] -fs [filesystem] -file [testcast]"
# 若不指定参数,则使用默认的测例
echo " -m | --arch architecture: x86_64|riscv64|aarch64"
echo " -fs | --filesystem filesystem: ext4|fat32"
echo " -file | --testcase If not specified, use the default testcases"
echo " default testcases:"
echo " x86_64: x86_64_linux_musl"
echo " riscv64: riscv64_linux_musl"
echo " aarch64: aarch64-linux-musl"
echo " -h | --help display help"
echo ""
exit 1
}

while [ -n "$1" ]; do
# 可能接受三类参数 -m [arch] -fs [filesystem] -file [testcast]
# 但是不一定只有一个参数,所以使用 while 循环
while [ "$1" != "" ]; do
case $1 in
-m)
shift
arch="$1"
;;
-fs)
shift
fs="$1"
;;
-file)
shift
FILE="$1"
;;
riscv64)
arch=riscv64
;;
x86_64)
arch=x86_64
;;
aarch64)
arch=aarch64
;;
fat32)
fs=fat32
;;
ext4)
fs=ext4
;;
riscv64_linux_musl)
FILE=riscv64_linux_musl
;;
riscv64_gcc)
FILE=riscv64_gcc
;;
riscv64_redis)
FILE=riscv64_redis
;;
x86_64_linux_musl)
FILE=x86_64_linux_musl
;;
x86_64_ZLM)
FILE=x86_64_ZLM
;;
riscv64_libctest_dynamic)
FILE=riscv64_libctest_dynamic
;;
riscv64_libctest_static)
FILE=riscv64_libctest_static
;;
aarch64-linux-musl)
FILE=aarch64-linux-musl
;;
*)
display_help
;;
-m | --arch ) shift
arch=$1
;;
-fs | --filesystem ) shift
fs=$1
;;
-file | --testcase ) shift
FILE=$1
;;
-h | --help ) display_help
exit
;;
* ) display_help
exit 1
esac
shift
done


if [ -z "$FILE" ]; then # use default testcases
if [ "$arch" = "riscv64" ]; then
FILE=riscv64_linux_musl
Expand All @@ -87,6 +57,7 @@ if [ -z "$FILE" ]; then # use default testcases
elif [ "$arch" = "aarch64" ]; then
FILE=aarch64-linux-musl
else
echo "Unknown architecture: $arch"
exit 1
fi
fi
Expand All @@ -101,9 +72,13 @@ dd if=/dev/zero of=disk.img bs=4M count=30

if [ "$fs" = "ext4" ]; then
mkfs.ext4 -t ext4 disk.img
else
else if [ "$fs" = "fat32" ]; then
fs=fat32
mkfs.vfat -F 32 disk.img
else
echo "Unknown filesystem: $fs"
exit 1
fi
fi

mkdir -p mnt
Expand Down
Loading

0 comments on commit 0b66290

Please sign in to comment.