Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/github-ci-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,16 @@ jobs:
shell: bash
run: |
env -i DEBIAN_FRONTEND=noninteractive sudo apt-get update
env -i DEBIAN_FRONTEND=noninteractive sudo apt-get install -y qemu-system-arm
env -i DEBIAN_FRONTEND=noninteractive sudo apt-get install -y qemu-system-arm expect
- name: uefi unittest
if: ${{ matrix.project == 'qemu-virt-arm64-test' }}
shell: bash
run: |
./scripts/uefi_unittest.exp
- name: unittest
if: ${{ matrix.project == 'qemu-virt-arm64-test' }}
shell: bash
run: |
python3 scripts/unittest.py
./scripts/unittest.exp

# vim: ts=2 sw=2 expandtab
9 changes: 7 additions & 2 deletions .github/workflows/github-ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ jobs:
shell: bash
run: |
env -i DEBIAN_FRONTEND=noninteractive sudo apt-get update
env -i DEBIAN_FRONTEND=noninteractive sudo apt-get install -y qemu-system-arm
env -i DEBIAN_FRONTEND=noninteractive sudo apt-get install -y qemu-system-arm expect
- name: uefi unittest
if: ${{ matrix.project == 'qemu-virt-arm64-test' }}
shell: bash
run: |
./scripts/uefi_unittest.exp
- name: unittest
if: ${{ matrix.project == 'qemu-virt-arm64-test' }}
shell: bash
run: |
python3 scripts/unittest.py
./scripts/unittest.exp

# vim: ts=2 sw=2 expandtab
78 changes: 78 additions & 0 deletions scripts/uefi_unittest.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/expect -f
Comment thread
zhangxp1998 marked this conversation as resolved.

# Disable pty echo and newline translation to prevent double carriage returns
set stty_init "-onlcr -echo"

proc kill_qemu {} {
global qemu_pid
catch {exec kill -TERM $qemu_pid}
after 1000
catch {exec kill -KILL $qemu_pid}
catch {wait}
}

proc shutdown_qemu {status} {
kill_qemu
exit $status
}

# Set timeout for the first stage: waiting for the shell
set timeout 10

# Spawn the QEMU process
spawn qemu-system-aarch64 \
-cpu max \
-m 512 \
-smp 1 \
-machine virt,highmem=off \
-kernel build-qemu-virt-arm64-test/lk.elf \
-net none \
-nographic \
-drive if=none,file=lib/uefi/helloworld_aa64.efi,id=blk,format=raw \
-device virtio-blk-device,drive=blk
set qemu_pid [exp_pid]

# Wait for the app shell to start
expect {
"starting app shell" {
# Send the command to load the UEFI app
send "uefi_load virtio0\r"
}
timeout {
puts "Timeout waiting for 'starting app shell'"
kill_qemu
exit 1
}
eof {
puts "QEMU exited unexpectedly before shell"
exit 1
}
}

# Set timeout for the second stage: waiting for Hello World!
set timeout 5

# Wait for the expected output from the UEFI app
expect {
"Hello World!" {
# Successfully saw the output, now shut down
shutdown_qemu 0
}
"panic (caller" {
puts "LK panic while running the UEFI unittest"
shutdown_qemu 1
}
"CRASH: starting debug shell" {
puts "LK crashed and entered the debug shell while running the UEFI unittest"
shutdown_qemu 1
}
timeout {
puts "Timeout waiting for 'Hello World!'"
# Try to shut down anyway
shutdown_qemu 1
}
eof {
puts "QEMU exited unexpectedly before Hello World!"
exit 1
}
Comment thread
zhangxp1998 marked this conversation as resolved.
}
80 changes: 80 additions & 0 deletions scripts/unittest.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/expect -f
Comment thread
zhangxp1998 marked this conversation as resolved.

# Disable pty echo and newline translation to prevent double carriage returns
set stty_init "-onlcr -echo"

proc kill_qemu {} {
global qemu_pid
catch {exec kill -TERM $qemu_pid}
after 1000
catch {exec kill -KILL $qemu_pid}
catch {wait}
}

proc shutdown_qemu {status} {
kill_qemu
exit $status
}

# Set timeout for the first stage: waiting for the shell
set timeout 10

# Spawn the QEMU process
spawn qemu-system-aarch64 \
-cpu max \
-m 512 \
-smp 1 \
-machine virt,highmem=off \
-kernel build-qemu-virt-arm64-test/lk.elf \
-net none \
-nographic
set qemu_pid [exp_pid]

# Wait for the app shell to start
expect {
"starting app shell" {
# Send the command to run unittests
send "ut all\r"
}
timeout {
puts "Timeout waiting for 'starting app shell'"
kill_qemu
exit 1
}
eof {
puts "QEMU exited unexpectedly before shell"
exit 1
}
}

# Set timeout for the second stage: waiting for tests to finish
set timeout 30

# Wait for the expected output from the unittests
expect {
"SUCCESS! All test cases passed" {
# Successfully saw the output, now shut down
shutdown_qemu 0
}
"FAILURE! Some test cases failed" {
puts "Some test cases failed!"
shutdown_qemu 1
}
"panic (caller" {
puts "LK panic while running unittests"
shutdown_qemu 1
}
"CRASH: starting debug shell" {
puts "LK crashed and entered the debug shell while running unittests"
shutdown_qemu 1
}
timeout {
puts "Timeout waiting for unittests to complete"
# Try to shut down anyway
shutdown_qemu 1
}
eof {
puts "QEMU exited unexpectedly before unittests completed"
Comment thread
zhangxp1998 marked this conversation as resolved.
exit 1
}
}
100 changes: 0 additions & 100 deletions scripts/unittest.py

This file was deleted.