Skip to content

Commit c09c30b

Browse files
committed
tests: Bluetooth: Classic: Support github action
Add Bluetooth classic simulation CI entry script. Add github workflow for Bluetooth Classic. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 3b266cd commit c09c30b

File tree

3 files changed

+701
-0
lines changed

3 files changed

+701
-0
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: Run simulation tests of Bluetooth Classic
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/bluetooth_classic_sim_tests.yml'
7+
- "west.yml"
8+
- 'include/zephyr/bluetooth/**'
9+
- "subsys/bluetooth/**"
10+
- 'tests/bluetooth/classic/**'
11+
- "samples/bluetooth/classic/**"
12+
- "boards/native/**"
13+
- "soc/native/**"
14+
- "arch/posix/**"
15+
- "include/zephyr/arch/posix/**"
16+
- "scripts/native_simulator/**"
17+
- "modules/mbedtls/**"
18+
- '!**.rst'
19+
20+
permissions:
21+
contents: read
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
bluetooth_classic_sim_tests:
29+
if: github.repository_owner == 'zephyrproject-rtos'
30+
runs-on: ubuntu-24.04
31+
32+
env:
33+
ZEPHYR_TOOLCHAIN_VARIANT: zephyr
34+
permissions:
35+
checks: write # to create the check run entry with test results
36+
37+
steps:
38+
- name: Apply container owner mismatch workaround
39+
run: |
40+
# FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
41+
# match the container user UID because of the way GitHub
42+
# Actions runner is implemented. Remove this workaround when
43+
# GitHub comes up with a fundamental fix for this problem.
44+
git config --global --add safe.directory ${GITHUB_WORKSPACE}
45+
46+
- name: Print cloud service information
47+
run: |
48+
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
49+
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
50+
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
51+
52+
- name: Clone cached Zephyr repository
53+
continue-on-error: true
54+
run: |
55+
git clone --shared /repo-cache/zephyrproject/zephyr .
56+
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
57+
58+
- name: Checkout
59+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
60+
with:
61+
fetch-depth: 0
62+
63+
- name: Environment Setup
64+
env:
65+
BASE_REF: ${{ github.base_ref }}
66+
run: |
67+
git config --global user.email "[email protected]"
68+
git config --global user.name "Zephyr Bot"
69+
rm -fr ".git/rebase-apply"
70+
rm -fr ".git/rebase-merge"
71+
git rebase origin/${BASE_REF}
72+
git clean -f -d
73+
git log --pretty=oneline | head -n 10
74+
west init -l . || true
75+
west config manifest.group-filter -- +ci
76+
west config --global update.narrow true
77+
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
78+
west forall -c 'git reset --hard HEAD'
79+
80+
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
81+
82+
- name: Install Python packages
83+
run: |
84+
pip install -r scripts/requirements-actions.txt --require-hashes
85+
86+
- name: Install system dependencies
87+
run: |
88+
sudo apt-get update
89+
sudo apt-get install -y bluez bluez-tools bluez-test-tools
90+
91+
- name: Load hci_vhci
92+
run: |
93+
echo "Runner: $RUNNER_NAME"
94+
echo "OS-Release:"
95+
cat /etc/os-release || true
96+
echo "Kernel: $(uname -a)"
97+
sudo apt-get install linux-modules-extra-$(uname -r) || true
98+
ls /lib/modules/$(uname -r)/kernel/drivers/bluetooth | grep vhci || true
99+
sudo modprobe hci_vhci || true
100+
ls -l /dev/vhci
101+
test -e /dev/vhci || (echo "/dev/vhci missing" && exit 1)
102+
103+
- name: Stop Bluetooth service
104+
run: |
105+
sudo systemctl stop bluetooth || true
106+
107+
- name: Make test scripts executable
108+
run: |
109+
find tests/bluetooth/classic/sim -name "*.sh" -type f \
110+
-exec chmod +x {} \;
111+
112+
- name: Run Bluetooth Classic Sim tests
113+
id: run_tests
114+
run: |
115+
export ZEPHYR_BASE=${PWD}
116+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
117+
tests/bluetooth/classic/sim/ci.bt.classic.sh
118+
119+
- name: Create Test Results
120+
run: |
121+
junit2html tests/bluetooth/classic/sim/test_logs/junit.xml tests/bluetooth/classic/sim/test_logs/junit.html
122+
123+
- name: Upload Unit Test Results in HTML
124+
if: always()
125+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
126+
with:
127+
name: HTML Unit Test Results
128+
if-no-files-found: ignore
129+
path: |
130+
tests/bluetooth/classic/sim/test_logs/junit.html
131+
132+
- name: Publish Unit Test Results
133+
uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf # v2.21.0
134+
with:
135+
check_name: Bluetooth Classic Simulation Test Results
136+
files: "tests/bluetooth/classic/sim/test_logs/junit.xml"
137+
comment_mode: off
138+
139+
- name: Upload test logs
140+
if: always()
141+
uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf # v2.21.0
142+
with:
143+
name: bluetooth-classic-sim-test-logs
144+
path: |
145+
tests/bluetooth/classic/sim/test_logs/
146+
bt_classic_sim/
147+
comment_mode: off
148+
149+
- name: Check test results
150+
if: always()
151+
run: |
152+
if [[ -f tests/bluetooth/classic/sim/test_logs/junit.xml ]]; then
153+
failures=$(grep -o 'failures="[0-9]*"' \
154+
tests/bluetooth/classic/sim/test_logs/junit.xml | \
155+
grep -o '[0-9]*')
156+
if [[ "$failures" -gt 0 ]]; then
157+
echo "::error::$failures test(s) failed"
158+
exit 1
159+
fi
160+
fi
161+
162+
- name: Cleanup
163+
if: always()
164+
run: |
165+
sudo pkill -9 btvirt || true
166+
sudo pkill -9 btmon || true
167+
sudo pkill -9 zephyr.exe || true
168+
sudo systemctl start bluetooth || true

0 commit comments

Comments
 (0)