-
Notifications
You must be signed in to change notification settings - Fork 1.6k
194 lines (165 loc) · 6.48 KB
/
android_e2e.yml
File metadata and controls
194 lines (165 loc) · 6.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Android E2E Tests
on:
pull_request:
branches: [ master, v2, v1 ]
push:
branches: [ master, v2, v1 ]
workflow_dispatch:
permissions:
contents: read
issues: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
android-e2e-tests:
runs-on: ubuntu-latest
name: Android E2E Tests
strategy:
matrix:
api-level: [35] # Android 15
target: [google_apis]
arch: [x86_64] # Use x86_64 for emulator (host arch matches)
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.6'
- name: Install Required Tools
run: |
sudo apt-get update
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-14 clang-14 flex bison linux-tools-common linux-tools-generic gcc libssl-dev linux-source libpulse0 xvfb libxcb-cursor0 libxkbcommon-x11-0
for tool in "clang" "llc" "llvm-strip"
do
sudo rm -f /usr/bin/$tool
sudo ln -s /usr/bin/$tool-14 /usr/bin/$tool
done
cd /usr/src
source_file=$(find . -maxdepth 1 -name "*linux-source*.tar.bz2")
source_dir=$(echo "$source_file" | sed 's/\.tar\.bz2//g')
sudo tar -xf $source_file
cd $source_dir
test -f .config || sudo make oldconfig
shell: bash
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0
- name: Build ecapture for Android
run: |
# Build for x86_64 (for emulator testing)
ANDROID=1 make clean
ANDROID=1 make env
echo "Building ecapture for Android (x86_64)..."
CROSS_ARCH=amd64 ANDROID=1 make nocore -j$(nproc)
# Verify binary
if [ ! -f bin/ecapture ]; then
echo "❌ Failed to build ecapture binary"
exit 1
fi
echo "=== Binary Info ==="
ls -lh bin/ecapture
file bin/ecapture
# Verify x86_64 architecture
if ! file bin/ecapture | grep -q "x86-64\|x86_64"; then
echo "❌ Binary is not x86_64"
exit 1
fi
echo "✓ ecapture built successfully for Android x86_64"
- name: Build Go test client for Android
run: |
cd test/e2e
echo "Building Go HTTPS client for Android..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o android/go_https_client_android go_https_client.go
if [ -f android/go_https_client_android ]; then
echo "✓ Go client built successfully"
ls -lh android/go_https_client_android
file android/go_https_client_android
else
echo "⚠️ Go client build failed (tests will use curl)"
fi
- name: Start Xvfb for headless display
run: |
echo "Starting Xvfb virtual display..."
sudo Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo "DISPLAY=:99" >> $GITHUB_ENV
sleep 2
echo "✓ Xvfb started on display :99"
- name: Enable KVM group permissions
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.arch }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
force-avd-creation: false
ram-size: 4096M
disk-size: 8192M
emulator-options: -no-window -no-snapshot-save -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: echo "Generated AVD snapshot for caching."
- name: Run Android E2E Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
force-avd-creation: false
ram-size: 4096M
disk-size: 8192M
emulator-options: -no-snapshot-save -noaudio -no-boot-anim -camera-back none -writable-system
disable-animations: true
script: |
echo "=== Android Emulator Info ==="
adb devices
adb shell getprop ro.build.version.release
adb shell getprop ro.build.version.sdk
adb shell uname -a
echo "=== Getting root access ==="
adb root
sleep 5
adb wait-for-device
echo "=== Checking root ==="
adb shell id
echo "=== Setting SELinux to permissive ==="
adb shell setenforce 0 || true
adb shell getenforce
echo "=== Setup environment ==="
bash test/e2e/android/setup_android_env.sh || true
echo "=== Checking ecapture startup (diagnostic) ==="
adb push bin/ecapture /data/local/tmp/ecapture
adb shell chmod 755 /data/local/tmp/ecapture
echo "--- Verifying eBPF / ecapture can start (3s sample) ---"
adb shell "setsid nohup /data/local/tmp/ecapture tls -m text > /data/local/tmp/ecapture_startup.log 2>&1 < /dev/null &"
sleep 3
adb shell "ps -A | grep ecapture || echo '(no ecapture process found)'"
adb shell "cat /data/local/tmp/ecapture_startup.log 2>/dev/null || echo '(no startup log)'"
adb shell "ps -A | grep ecapture | awk '{print \$2}' | while read p; do kill -9 \$p; done 2>/dev/null || true"
echo "--- ecapture diagnostic complete ---"
bash test/e2e/android/run_android_e2e_tests.sh
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: android-e2e-test-logs
path: /tmp/ecapture_android_*
retention-days: 7