From 108ae901f592569e19a2b659c0cf852e3fd414a6 Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Thu, 9 May 2024 16:10:17 +0800 Subject: [PATCH] ci: add ci test for perf Signed-off-by: Qinghao Shi --- .github/ci_scripts/check_qemu.exp | 84 +++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 39 +++++++------- 2 files changed, 104 insertions(+), 19 deletions(-) create mode 100755 .github/ci_scripts/check_qemu.exp diff --git a/.github/ci_scripts/check_qemu.exp b/.github/ci_scripts/check_qemu.exp new file mode 100755 index 0000000000000..bbca31cd68738 --- /dev/null +++ b/.github/ci_scripts/check_qemu.exp @@ -0,0 +1,84 @@ +#!/usr/bin/expect -f + +if { $argc < 1 } { + puts "Usage: $argv0 " + puts "Arguments:" + puts " COMMAND : is requred:" + puts " TIMEOUT : if NOT supplied, will wait forever untill command finshed" + puts " FAIL STR: if supplied, find a match will always FAIL the test" + puts " PASS STR: if supplied, NOT find a match will FAIL the test" + puts " if NOT supplied, COMMAND finished will be treated as PASS" + exit 1 +} + + +set COMMAND [lindex $argv 0] +set TIMEOUT [lindex $argv 1] +set EXP_FAIL [lindex $argv 2] +set EXP_PASS [lindex $argv 3] + +send_user "\n== Check QEMU ==\n" +send_user "COMMAND : $COMMAND\n" +send_user "TIMEOUT : $TIMEOUT\n" +send_user "FAIL STR: $EXP_FAIL\n" +send_user "PASS STR: $EXP_PASS\n" +send_user "================\n\n" + +if { $TIMEOUT == "" } { set timeout -1 } else { set timeout $TIMEOUT } +if { $EXP_FAIL == "" } { set EXP_FAIL THIS_WILL_NEVER_MATCH } ; set fail_flag 0 +if { $EXP_PASS == "" } { set EXP_PASS THIS_WILL_NEVER_MATCH ; set pass_flag 1 } else { set pass_flag 0 } + + +# default telnet connection port +spawn telnet localhost 5678 +send "\r" + +# login handler and send command +expect { + "# " { + send "$COMMAND ;echo Finished $? ExitCode\r\r" + } + "login:" { + send "root\r" + exp_continue + + } + default { + send_user "\n== CheckQemu == ERROR: Timeout! Unable to login!\n" + exit 1 + } +} + +# pass expect handler +expect { + "$EXP_PASS" { + set pass_flag 1 + exp_continue + } + "$EXP_FAIL" { + set fail_flag 1 + exp_continue + } + "Finished 0 ExitCode" { + if {$fail_flag == 1} { + send_user "\n== CheckQemu == FAILED: log output contains FAIL Expect string '$EXP_FAIL' \n" + exit 1 + } + + if {$pass_flag == 1} { + send_user "\n== CheckQemu == PASSED\n" + } else { + send_user "\n== CheckQemu == FAILED: log output NOT contains PASS Expect string '$EXP_PASS' \n" + exit 1 + } + + } + -re "Finished \\d+ ExitCode" { + send_user "\n== CheckQemu == FAILED: Exit Code is not 0! \n" + exit 3 + } + timeout { + send_user "\n== CheckQemu == ERROR: Timeout! commnd NOT finished untill $TIMEOUT sec timeout \n" + exit 2 + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b12b57311d38..77dad25d7f175 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,7 +202,7 @@ jobs: retention-days: 90 - qemu-boot-64lp64: + xt-qemu-64lp64: needs: kernel-build runs-on: ubuntu-latest container: ghcr.io/ruyisdk/linux-xuantie-kernel/xuantie-qemu:latest @@ -218,6 +218,9 @@ jobs: steps: + - name: Checkout source + uses: actions/checkout@v4 + - name: Download artifacts uses: actions/download-artifact@v4 with: @@ -231,19 +234,17 @@ jobs: - name: Run Qemu run: | - qemu-system-riscv64 -cpu ${{ matrix.cpu }} -nographic -smp ${{ matrix.core_count }} -M virt -kernel ./Image -append 'rootwait root=/dev/vda ro' -drive file=./rootfs_rv64.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -monitor none -serial file:qemu_boot.log & - QEMU_PID=$! - sleep 180 - kill -9 $QEMU_PID + qemu-system-riscv64 -cpu ${{ matrix.cpu }} -nographic -smp ${{ matrix.core_count }} -M virt -kernel ./Image -append 'rootwait root=/dev/vda ro' -drive file=./rootfs_rv64.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -monitor none -monitor none -serial telnet:localhost:5678,server & - - name: Check Boot Success - run: | - cat qemu_boot.log - grep -q "login:" qemu_boot.log + - name: Check Qemu Booting Kernel + run: .github/ci_scripts/check_qemu.exp 'cat /proc/version' 180 + + - name: Check perf test + run: .github/ci_scripts/check_qemu.exp 'perf test -s 5,15,16,17,18,21,60,62' 180 FAILED - qemu-boot-32ilp32: + xt-qemu-32ilp32: needs: kernel-build runs-on: ubuntu-latest container: ghcr.io/ruyisdk/linux-xuantie-kernel/xuantie-qemu:latest @@ -257,6 +258,9 @@ jobs: steps: + - name: Checkout source + uses: actions/checkout@v4 + - name: Download artifacts uses: actions/download-artifact@v4 with: @@ -269,13 +273,10 @@ jobs: tar -xvf ${{ matrix.kernel }}.tar.gz - name: Run Qemu - run: | - qemu-system-riscv32 -cpu ${{ matrix.cpu }} -nographic -smp ${{ matrix.core_count }} -M virt -kernel ./Image -append 'rootwait root=/dev/vda ro' -drive file=./rootfs_rv32.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -monitor none -serial file:qemu_boot.log & - QEMU_PID=$! - sleep 180 - kill -9 $QEMU_PID + run: qemu-system-riscv32 -cpu ${{ matrix.cpu }} -nographic -smp ${{ matrix.core_count }} -M virt -kernel ./Image -append 'rootwait root=/dev/vda ro' -drive file=./rootfs_rv32.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -monitor none -serial telnet:localhost:5678,server & - - name: Check Boot Success - run: | - cat qemu_boot.log - grep -q "login:" qemu_boot.log + - name: Check Qemu Booting Kernel + run: .github/ci_scripts/check_qemu.exp 'cat /proc/version' 180 + + - name: Check perf test + run: .github/ci_scripts/check_qemu.exp 'perf test -s 5,15,16,17,18,21,50,60,62' 180 FAILED \ No newline at end of file