Skip to content

Commit 7a3d1f0

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 7a3d1f0

File tree

3 files changed

+748
-0
lines changed

3 files changed

+748
-0
lines changed
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
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: Set up Python
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version: '3.11'
67+
68+
- name: Install Python packages
69+
run: |
70+
pip install -r scripts/requirements-actions.txt --require-hashes
71+
72+
- name: Install system dependencies
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install -y \
76+
bluez \
77+
bluez-tools \
78+
git \
79+
cmake \
80+
ninja-build \
81+
gperf \
82+
ccache \
83+
dfu-util \
84+
device-tree-compiler \
85+
wget \
86+
python3-dev \
87+
python3-pip \
88+
python3-setuptools \
89+
python3-tk \
90+
python3-wheel \
91+
xz-utils \
92+
file \
93+
make \
94+
gcc \
95+
gcc-multilib \
96+
g++-multilib \
97+
libsdl2-dev \
98+
libmagic1
99+
100+
- name: Install West and dependencies
101+
run: |
102+
pip3 install --user -U west
103+
echo "$HOME/.local/bin" >> $GITHUB_PATH
104+
105+
- name: Install Zephyr SDK
106+
run: |
107+
cd ~
108+
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5/zephyr-sdk-0.16.5_linux-x86_64.tar.xz
109+
wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5/sha256.sum | shasum --check --ignore-missing
110+
tar xvf zephyr-sdk-0.16.5_linux-x86_64.tar.xz
111+
cd zephyr-sdk-0.16.5
112+
./setup.sh -t all -h -c
113+
114+
- name: Environment Setup
115+
env:
116+
BASE_REF: ${{ github.base_ref }}
117+
run: |
118+
git config --global user.email "[email protected]"
119+
git config --global user.name "Zephyr Bot"
120+
rm -fr ".git/rebase-apply"
121+
rm -fr ".git/rebase-merge"
122+
git rebase origin/${BASE_REF}
123+
git clean -f -d
124+
git log --pretty=oneline | head -n 10
125+
west init -l . || true
126+
west config manifest.group-filter -- +ci
127+
west config --global update.narrow true
128+
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)
129+
west forall -c 'git reset --hard HEAD'
130+
131+
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
132+
133+
- name: Install system dependencies
134+
run: |
135+
sudo apt-get update
136+
sudo apt-get install -y bluez bluez-tools bluez-test-tools
137+
138+
- name: Load hci_vhci
139+
run: |
140+
echo "Runner: $RUNNER_NAME"
141+
echo "OS-Release:"
142+
cat /etc/os-release || true
143+
echo "Kernel: $(uname -a)"
144+
sudo apt-get install linux-modules-extra-$(uname -r) || true
145+
ls /lib/modules/$(uname -r)/kernel/drivers/bluetooth | grep vhci || true
146+
sudo modprobe hci_vhci || true
147+
ls -l /dev/vhci
148+
test -e /dev/vhci || (echo "/dev/vhci missing" && exit 1)
149+
150+
- name: Stop Bluetooth service
151+
run: |
152+
sudo systemctl stop bluetooth || true
153+
154+
- name: Make test scripts executable
155+
run: |
156+
find tests/bluetooth/classic/sim -name "*.sh" -type f \
157+
-exec chmod +x {} \;
158+
159+
- name: Run Bluetooth Classic Sim tests
160+
id: run_tests
161+
run: |
162+
export ZEPHYR_BASE=${PWD}
163+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
164+
tests/bluetooth/classic/sim/ci.bt.classic.sh
165+
166+
- name: Create Test Results
167+
run: |
168+
junit2html tests/bluetooth/classic/sim/test_logs/junit.xml tests/bluetooth/classic/sim/test_logs/junit.html
169+
170+
- name: Upload Unit Test Results in HTML
171+
if: always()
172+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
173+
with:
174+
name: HTML Unit Test Results
175+
if-no-files-found: ignore
176+
path: |
177+
tests/bluetooth/classic/sim/test_logs/junit.html
178+
179+
- name: Publish Unit Test Results
180+
uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf # v2.21.0
181+
with:
182+
check_name: Bluetooth Classic Simulation Test Results
183+
files: "tests/bluetooth/classic/sim/test_logs/junit.xml"
184+
comment_mode: off
185+
186+
- name: Upload test logs
187+
if: always()
188+
uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf # v2.21.0
189+
with:
190+
name: bluetooth-classic-sim-test-logs
191+
path: |
192+
tests/bluetooth/classic/sim/test_logs/
193+
bt_classic_sim/
194+
comment_mode: off
195+
196+
- name: Check test results
197+
if: always()
198+
run: |
199+
if [[ -f tests/bluetooth/classic/sim/test_logs/junit.xml ]]; then
200+
failures=$(grep -o 'failures="[0-9]*"' \
201+
tests/bluetooth/classic/sim/test_logs/junit.xml | \
202+
grep -o '[0-9]*')
203+
if [[ "$failures" -gt 0 ]]; then
204+
echo "::error::$failures test(s) failed"
205+
exit 1
206+
fi
207+
fi
208+
209+
- name: Cleanup
210+
if: always()
211+
run: |
212+
sudo pkill -9 btvirt || true
213+
sudo pkill -9 btmon || true
214+
sudo pkill -9 zephyr.exe || true
215+
sudo systemctl start bluetooth || true

0 commit comments

Comments
 (0)