Repository navigation
470 lines (397 loc) · 18.2 KB
/
Copy pathnative-quality.yml
File metadata and controls
470 lines (397 loc) · 18.2 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
name: native-quality
on:
workflow_dispatch:
jobs:
strict-unix-build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Linux build dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y clang cmake
- name: Configure strict Unix build
run: >-
cmake -S src -B build/strict-unix
-DCMAKE_BUILD_TYPE=Release
-DFLUTTER_PTY2_BUILD_TESTS=ON
"-DCMAKE_C_FLAGS=-Wall -Wextra -Werror"
- name: Build strict Unix targets
run: cmake --build build/strict-unix --parallel 4
- name: Run Clang static analyzer
run: |
sources=(
src/include/dart_api_dl.c
src/common/pty_error.c
src/common/pty_event.c
src/common/pty_refcount.c
src/common/pty_debug_stats.c
src/common/pty_write_queue.c
src/unix/pty_unix_spawn.c
src/unix/pty_unix_session.c
)
for source in "${sources[@]}"; do
output="build/strict-unix/$(basename "${source}").sarif"
clang --analyze \
--analyzer-output sarif \
-std=gnu11 \
-DDART_SHARED_LIB \
-Isrc \
-Isrc/include \
-fno-color-diagnostics \
-o "${output}" \
"${source}"
done
python3 - <<'PY'
import json
from pathlib import Path
findings = []
for report_path in Path('build/strict-unix').glob('*.c.sarif'):
report = json.loads(report_path.read_text())
findings.extend(
result
for run in report.get('runs', [])
for result in run.get('results', [])
)
if findings:
print(json.dumps(findings, indent=2))
raise SystemExit(
f'Clang static analyzer found {len(findings)} issue(s).'
)
print('Clang static analyzer found no issues.')
PY
unix-fork-safety:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install dependencies
run: dart pub get
- name: Install Linux build dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake
- name: Build native library
run: >-
cmake -S src -B build/native
-DCMAKE_BUILD_TYPE=Release
&& cmake --build build/native --parallel 4
- name: Run Linux fork-safety test
if: runner.os == 'Linux'
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
run: dart test --concurrency=1 test/clean_slate_fork_safety_test.dart
- name: Run macOS fork-safety test
if: runner.os == 'macOS'
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.dylib
run: dart test --concurrency=1 test/clean_slate_fork_safety_test.dart
dart-lifecycle-stress:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install dependencies
run: dart pub get
- name: Install native build dependencies
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build
- name: Build native library
run: >-
cmake -S src -B build/native -G Ninja
-DCMAKE_BUILD_TYPE=Release
&& cmake --build build/native --parallel 4
- name: Run Dart fork-safety test
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
run: dart test --concurrency=1 test/clean_slate_fork_safety_test.dart
- name: Run Dart finalizer test
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
run: dart test test/clean_slate_finalizer_test.dart
- name: Run Dart lifecycle stress
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
run: dart test --concurrency=1 test/clean_slate_lifecycle_stress_test.dart
- name: Build integration fixture
run: >-
cmake -S test/fixtures/pty_test_child -B build/pty_test_child -G Ninja
&& cmake --build build/pty_test_child --parallel 4
- name: Run Dart randomized stress
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
PTY_TEST_CHILD: ${{ github.workspace }}/build/pty_test_child/pty_test_child
PTY_RANDOM_STRESS_OPERATIONS: 10000
run: dart test --concurrency=1 test/clean_slate_random_stress_test.dart
- name: Run exit-drain stress
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
PTY_TEST_CHILD: ${{ github.workspace }}/build/pty_test_child/pty_test_child
PTY_EXIT_DRAIN_CYCLES: 10000
run: dart test --concurrency=1 test/clean_slate_exit_drain_stress_test.dart
- name: Run 100 MiB transfer integration
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
PTY_TEST_CHILD: ${{ github.workspace }}/build/pty_test_child/pty_test_child
run: dart test --concurrency=1 test/clean_slate_large_transfer_test.dart
- name: Run 1 GiB transfer integration
env:
FLUTTER_PTY2_LIBRARY: ${{ github.workspace }}/build/native/libflutter_pty2.so
PTY_TEST_CHILD: ${{ github.workspace }}/build/pty_test_child/pty_test_child
PTY_LARGE_TRANSFER_BYTES: 1073741824
run: dart test --concurrency=1 test/clean_slate_large_transfer_test.dart
windows-runtime-stress:
strategy:
matrix:
os: [windows-2022, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install dependencies
run: dart pub get
- name: Build native library and tests
run: >-
cmake -S src -B build/native
-DCMAKE_BUILD_TYPE=Release
-DFLUTTER_PTY2_BUILD_TESTS=ON
&& cmake --build build/native --config Release --parallel 4
- name: Build integration fixture
run: >-
cmake -S test/fixtures/pty_test_child -B build/pty_test_child
&& cmake --build build/pty_test_child --config Release --parallel 4
- name: Run Windows native stress suite
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:PTY_TEST_CHILD_WINDOWS = $fixture.FullName
$env:PATH = "$($library.DirectoryName);$env:PATH"
ctest --test-dir build/native -C Release --output-on-failure
- name: Run clean-slate Windows integration
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:FLUTTER_PTY2_LIBRARY = $library.FullName
$env:PTY_TEST_CHILD = $fixture.FullName
$env:PATH = "$($library.DirectoryName);$env:PATH"
dart test --concurrency=1 test/clean_slate_windows_integration_test.dart
- name: Run Windows trailing-output integration through close worker
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:FLUTTER_PTY2_LIBRARY = $library.FullName
$env:PTY_TEST_CHILD = $fixture.FullName
$env:PTY_TEST_FORCE_PSEUDO_CONSOLE_CLOSE_WORKER = '1'
$env:PATH = "$($library.DirectoryName);$env:PATH"
dart test --concurrency=1 test/clean_slate_windows_integration_test.dart --plain-name 'keeps trailing ConPTY output available after process exit until done'
- name: Run Windows Dart lifecycle stress
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:FLUTTER_PTY2_LIBRARY = $library.FullName
$env:PTY_TEST_CHILD = $fixture.FullName
$env:PATH = "$($library.DirectoryName);$env:PATH"
dart test --concurrency=1 test/clean_slate_lifecycle_stress_test.dart
- name: Run Windows Dart finalizer test
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:FLUTTER_PTY2_LIBRARY = $library.FullName
$env:PTY_TEST_CHILD = $fixture.FullName
$env:PTY_TEST_FORCE_CLOSE_THREAD_FAILURE = '1'
$env:PATH = "$($library.DirectoryName);$env:PATH"
dart test test/clean_slate_finalizer_test.dart
- name: Run Windows randomized stress
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:FLUTTER_PTY2_LIBRARY = $library.FullName
$env:PTY_TEST_CHILD = $fixture.FullName
$env:PTY_RANDOM_STRESS_OPERATIONS = '10000'
$env:PATH = "$($library.DirectoryName);$env:PATH"
dart test --concurrency=1 test/clean_slate_random_stress_test.dart
- name: Run Windows exit-drain stress
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:FLUTTER_PTY2_LIBRARY = $library.FullName
$env:PTY_TEST_CHILD = $fixture.FullName
$env:PTY_EXIT_DRAIN_CYCLES = '10000'
$env:PATH = "$($library.DirectoryName);$env:PATH"
dart test --concurrency=1 test/clean_slate_exit_drain_stress_test.dart
- name: Run 1 GiB Windows transfer
shell: pwsh
run: |
$library = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/native" -Filter flutter_pty2.dll -Recurse | Select-Object -First 1
$fixture = Get-ChildItem -Path "$env:GITHUB_WORKSPACE/build/pty_test_child" -Filter pty_test_child.exe -Recurse | Select-Object -First 1
if ($null -eq $library) { throw 'flutter_pty2.dll was not built' }
if ($null -eq $fixture) { throw 'pty_test_child.exe was not built' }
$env:FLUTTER_PTY2_LIBRARY = $library.FullName
$env:PTY_TEST_CHILD = $fixture.FullName
$env:PTY_LARGE_TRANSFER_BYTES = '1073741824'
$env:PATH = "$($library.DirectoryName);$env:PATH"
dart test --concurrency=1 test/clean_slate_large_transfer_test.dart
android-build:
strategy:
matrix:
abi: [arm64-v8a, x86_64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Install Android NDK
run: sdkmanager --install "platforms;android-35" "ndk;28.2.13676358"
- name: Build Android native library (${{ matrix.abi }})
env:
ANDROID_NDK_VERSION: 28.2.13676358
run: >-
cmake -S src -B build/android
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION/build/cmake/android.toolchain.cmake"
-DANDROID_ABI=${{ matrix.abi }}
-DANDROID_PLATFORM=android-21
&& cmake --build build/android --parallel 4
android-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install dependencies
run: dart pub get
- name: Install example dependencies
working-directory: example
run: dart pub get
- name: Run Android emulator integration subset
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 35
target: google_apis
arch: x86_64
profile: pixel_2
script: |
cd example
flutter test -d emulator-5554 integration_test/clean_slate_android_integration_test.dart
sanitizer:
runs-on: ubuntu-latest
env:
ASAN_OPTIONS: halt_on_error=1:detect_leaks=1
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1
LSAN_OPTIONS: exitcode=23
steps:
- uses: actions/checkout@v4
- name: Install native dependencies
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build
- name: Configure sanitizer build
run: >-
cmake -S src -B build/sanitized -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DFLUTTER_PTY2_BUILD_TESTS=ON
"-DCMAKE_C_FLAGS=-fsanitize=address,undefined -fno-omit-frame-pointer"
-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address,undefined
-DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=address,undefined
- name: Build native tests
run: cmake --build build/sanitized --parallel 4
- name: Run native CTest suite
run: ctest --test-dir build/sanitized --output-on-failure
- name: Run full lifecycle stress
run: build/sanitized/tests/pty_unix_session_stress_test
env:
ASAN_OPTIONS: halt_on_error=1:detect_leaks=1
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1
LSAN_OPTIONS: exitcode=23
sanitizer-macos:
runs-on: macos-latest
env:
ASAN_OPTIONS: halt_on_error=1
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1
steps:
- uses: actions/checkout@v4
- name: Install native dependencies
run: brew list ninja >/dev/null 2>&1 || brew install ninja
- name: Configure sanitizer build
run: >-
cmake -S src -B build/sanitized-macos -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DFLUTTER_PTY2_BUILD_TESTS=ON
"-DCMAKE_C_FLAGS=-fsanitize=address,undefined -fno-omit-frame-pointer"
-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address,undefined
-DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=address,undefined
- name: Build native tests
run: cmake --build build/sanitized-macos --parallel 4
- name: Run native CTest suite
run: ctest --test-dir build/sanitized-macos --output-on-failure
- name: Run sanitizer lifecycle stress
run: build/sanitized-macos/tests/pty_unix_session_stress_test
env:
ASAN_OPTIONS: halt_on_error=1
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1
PTY_NATIVE_STRESS_CYCLES: 1000
thread-sanitizer:
runs-on: ubuntu-latest
env:
TSAN_OPTIONS: halt_on_error=1:second_deadlock_stack=1
PTY_CONCURRENT_SESSION_COUNT: 8
PTY_SKIP_THREAD_COUNT_CHECK: 1
steps:
- uses: actions/checkout@v4
- name: Install native dependencies
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build
- name: Configure ThreadSanitizer build
run: >-
cmake -S src -B build/thread-sanitized -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DFLUTTER_PTY2_BUILD_TESTS=ON
"-DCMAKE_C_FLAGS=-fsanitize=thread -fno-omit-frame-pointer"
-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=thread
-DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=thread
- name: Build native tests
run: cmake --build build/thread-sanitized --parallel 4
- name: Run ThreadSanitizer CTest suite
run: >-
ctest --test-dir build/thread-sanitized --output-on-failure
-E pty_unix_session_stress_test
- name: Run ThreadSanitizer lifecycle stress
run: build/thread-sanitized/tests/pty_unix_session_stress_test
env:
PTY_NATIVE_STRESS_CYCLES: 100