Skip to content

Commit

Permalink
ci: add ci test for perf
Browse files Browse the repository at this point in the history
Signed-off-by: Qinghao Shi <[email protected]>
  • Loading branch information
jamesbeyond committed May 11, 2024
1 parent 560782d commit 108ae90
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 19 deletions.
84 changes: 84 additions & 0 deletions .github/ci_scripts/check_qemu.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/expect -f

if { $argc < 1 } {
puts "Usage: $argv0 <COMMAND> <TIMEOUT> <FAIL STR> <PASS STR>"
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
}
}
39 changes: 20 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -218,6 +218,9 @@ jobs:

steps:

- name: Checkout source
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
Expand All @@ -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
Expand All @@ -257,6 +258,9 @@ jobs:

steps:

- name: Checkout source
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
Expand All @@ -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

0 comments on commit 108ae90

Please sign in to comment.