Skip to content

Commit 69e4e1d

Browse files
committed
Add virtio-snd automated integration test
Add virtio-snd automated integration test.
1 parent 4804697 commit 69e4e1d

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.ci/test-sound.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Source common functions and settings
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
export SCRIPT_DIR
8+
source "${SCRIPT_DIR}/common.sh"
9+
10+
SAMPLE_SOUND="/usr/share/sounds/alsa/Front_Center.wav"
11+
12+
# Override timeout for sound tests
13+
# Sound tests need different timeout: 30s for Linux, 900s for macOS
14+
case "${OS_TYPE}" in
15+
Darwin)
16+
TIMEOUT=900
17+
;;
18+
Linux)
19+
TIMEOUT=30
20+
;;
21+
*)
22+
TIMEOUT=30
23+
;;
24+
esac
25+
26+
# Clean up any existing semu processes before starting tests
27+
cleanup
28+
29+
# Test sound device
30+
expect <<DONE
31+
set timeout ${TIMEOUT}
32+
spawn make check
33+
expect "buildroot login:" { send "root\\n" } timeout { exit 1 }
34+
expect "# " { send "uname -a\\n" } timeout { exit 2 }
35+
expect "riscv32 GNU/Linux" { send "aplay ${SAMPLE_SOUND} \\n" } timeout { exit 3 }
36+
expect " Mono" { } timeout { exit 4 }
37+
DONE
38+
39+
ret="$?"
40+
41+
MESSAGES=("OK!" \
42+
"Fail to boot" \
43+
"Fail to login" \
44+
"Fail to run playback commands" \
45+
"Playback fails" \
46+
)
47+
48+
if [ "$ret" -eq 0 ]; then
49+
print_success "${MESSAGES["$ret"]}"
50+
else
51+
print_error "${MESSAGES["$ret"]}"
52+
fi
53+
54+
exit "$ret"

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ jobs:
6969
run: sudo .ci/test-netdev.sh
7070
shell: bash
7171
timeout-minutes: 10
72+
- name: sound test
73+
run: .ci/test-sound.sh
74+
shell: bash
75+
timeout-minutes: 5
7276

7377
semu-macOS:
7478
runs-on: macos-latest
@@ -118,6 +122,10 @@ jobs:
118122
shell: bash
119123
timeout-minutes: 20
120124
if: ${{ success() }}
125+
- name: sound test
126+
run: .ci/test-sound.sh
127+
shell: bash
128+
timeout-minutes: 20
121129

122130
coding_style:
123131
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)