Repository navigation
Add native artifact tests and dedicated Linux CI - #5366
Conversation
📦 Try the packages from this PRWarning Do not run these scripts without first reviewing the code in this PR. Step 1 — Download the packages bash / macOS / Linux: curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 5366PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 5366"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-5366/packages --name skiasharp-pr-5366More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-5366 |
|
📖 Documentation Preview Add the Removing the label removes the preview. While the label is present, each new commit updates it. This comment is automatically updated by the documentation staging workflow. |
📊 SkiaSharp benchmarks — PR #5366⭐ this PR (full source build) vs 🌙 nightly · Linux · macOS
Highlights⏱️ Time — 🔴 37 slower · 🟢 19 faster
Full per-OS benchmark deltasLinux⏱️ Time (vs 🌙 nightly
macOS⏱️ Time (vs 🌙 nightly
|
There was a problem hiding this comment.
🔵 Needs a closer look
Moving cross-platform validation out of native builds still needs maintainer review and the pending all-green production-artifact CI rerun.
0 open findings
What changed in this PR
Moves native-artifact validation from build assertions into a dedicated cross-platform test suite, without changing public APIs or runtime behavior.
Changes:
- Adds twelve static inspection cases, shared inventory checks, and an xUnit runner with TRX reporting.
- Adds Linux-container and Windows-host jobs to Test and Complete; Package remains build-only.
- Removes migrated Cake assertions. The HarfBuzz fix and runtime regression remain deferred to #5352.
| File | Description |
|---|---|
| tests/SkiaSharp.Tests.Native/SkiaSharp.Tests.Native.csproj | Configures the test executable and script deployment. |
| tests/SkiaSharp.Tests.Native/NativeTests.cs | Discovers and runs PowerShell cases with timeouts. |
| tests/SkiaSharp.Tests.Native/Cases/WindowsSymbols.ps1 | Validates PDB identities and CLI metadata. |
| tests/SkiaSharp.Tests.Native/Cases/WindowsRuntimeMarker.ps1 | Checks native runtime markers. |
| tests/SkiaSharp.Tests.Native/Cases/WindowsDependencies.ps1 | Checks prohibited hard imports. |
| tests/SkiaSharp.Tests.Native/Cases/WindowsDelayLoads.ps1 | Validates Direct3D delay imports. |
| tests/SkiaSharp.Tests.Native/Cases/WasmArtifacts.ps1 | Checks archive members and public symbols. |
| tests/SkiaSharp.Tests.Native/Cases/TizenArtifacts.ps1 | Checks ELF architecture and exports. |
| tests/SkiaSharp.Tests.Native/Cases/LinuxGlibcCompatibility.ps1 | Enforces architecture-specific GLIBC ceilings. |
| tests/SkiaSharp.Tests.Native/Cases/LinuxDependencies.ps1 | Validates fontconfig dependency policy. |
| tests/SkiaSharp.Tests.Native/Cases/Helpers.psm1 | Defines artifact inventories and inspection helpers. |
| tests/SkiaSharp.Tests.Native/Cases/ArtifactCoverage.ps1 | Rejects missing or unclaimed artifacts. |
| tests/SkiaSharp.Tests.Native/Cases/AppleArtifacts.ps1 | Validates Mach-O, dSYM, and framework contents. |
| tests/SkiaSharp.Tests.Native/Cases/AndroidPageAlignment.ps1 | Checks 16 KB page compatibility. |
| tests/SkiaSharp.Tests.Native/Cases/AndroidDebugSymbols.ps1 | Checks build IDs and debug links. |
| tests/SkiaSharp.Tests.Native.slnx | Adds a dedicated test solution. |
| scripts/infra/tests/tests-native.cake | Runs the native-artifact test project. |
| scripts/infra/tests/provision-native-windows.ps1 | Provisions Windows LLVM inspection tools. |
| scripts/infra/tests/docker/native/Dockerfile | Provides the Linux inspection environment. |
| scripts/infra/native/windows/windows-shared.cake | Removes migrated dependency exclusions. |
| scripts/infra/native/shared/native-shared.cake | Removes migrated dependency-check helpers. |
| scripts/infra/native/linux/docker/bionic/build-local.sh | Removes the obsolete verification argument. |
| scripts/infra/native/android/ndk.cake | Removes assertions while retaining symbol preparation. |
| scripts/azure-templates-stages-test.yml | Adds the native-test leaf stage. |
| scripts/azure-templates-stages-native-linux.yml | Removes migrated verification arguments. |
| scripts/azure-templates-jobs-tests-native.yml | Configures artifact downloads, execution, and reporting. |
| native/winui/build.cake | Removes migrated WinUI assertions. |
| native/winui-angle/build.cake | Removes migrated ANGLE assertions. |
| native/windows/build.cake | Removes migrated Windows assertions. |
| native/linuxnodeps/build.cake | Removes obsolete verification arguments. |
| native/linux/build.cake | Removes migrated Linux assertions and options. |
| build.cake | Exposes the native-test target. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
A globally loaded system HarfBuzz can preempt calls inside libHarfBuzzSharp.so and receive incompatible private objects. Bind internal function references locally with -Bsymbolic-functions. All 565 public hb_* exports in the tested library are functions. Both symbolic options eliminate the same 67 preemptible hb_* relocations, so function-only binding covers the conflict without changing data-symbol binding. Add a standalone native regression that loads conflicting functions globally before creating a bundled font and initializing OpenType functions. Validated Linux x64 source builds with libstdc++ and libc++/libc++abi, native load-order probes, Avalonia font initialization, and the unfiltered net10.0 Console solution: 6450 passed, 0 failed, and 38 existing skips. Other architectures, musl, nodeps/Bionic/Tizen variants, and release cross-images using static libc++ with GCC ABI remain unverified. LLD was tested only in the earlier libstdc++ comparison. The original complete GtkSharp reproduction, actual SourceGit GUI, and published packages were not tested.
Move existing Linux dependency/GLIBC and Windows dependency/delay-load/PDB-marker gates into a discoverable Python suite with JUnit reports. Check HarfBuzz exports and internal function relocations without executing cross-built binaries. Run isolated preemption probes against matching glibc and musl artifacts in dedicated images, including nodeps variants, with negative controls, libc/architecture guards and bounded subprocess cleanup. Publish gating results and include the suite in native cache keys. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Replace the Python inspection framework with one xUnit theory over copied case folders. Each case owns its Bash script and native sources; the runner resolves output/native automatically and reports subprocess failures through standard TRX. Restore native build images and existing Cake dependency gates. Run the initial HarfBuzz regression in one dedicated Linux test image and job, preserving its deterministic negative control. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Rename the project to SkiaSharp.Tests.Native.Console and use SkiaSharp.Tests.Native for its assembly and namespace, matching existing console-host conventions. Update Cake, pipeline report paths and documentation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Register SkiaSharp.Tests.Native.Console in SkiaSharp.Tests.Native.slnx so the Linux native suite has a solution entry point without adding compiler requirements to the cross-platform managed solution. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Use SkiaSharp.Tests.Native for the standalone native test project. Move its job into a Native Tests stage directly after native artifact merging and require it before packaging. The standalone Tests pipeline runs the stage after preparation, using the existing source artifacts. Forward the official container-template setting. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Include native tests only in Test and Complete pipelines. Preserve the Package pipeline dependency on native artifacts alone; Complete explicitly gates packaging on native tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Run native tests after native artifact merging without making packaging or downstream stages wait for them. Package remains build-only. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Add Linux dependency and build-matrix GLIBC ceiling checks, Android 16 KB alignment and split-debug identity checks, and Windows hard-import, delay-load and PDB runtime-marker checks. Inspect cross-built artifacts on the existing Linux test host using binutils and LLVM; no target execution is required for the new cases. Retain existing native build checks and leaf CI behavior. Keep PDB marker reporting limited to runtime provenance, not compiler mitigation guarantees. Validate all eight folder theories using compiled ELF/PE fixtures and negative controls. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Discover standalone scripts or scenario folders, share PowerShell helpers as a module, and bind repository paths through MSBuild runtime configuration. Keep the small process runner in NativeTests and document each case with readable multiline formatting. Require complete coverage of native and native_msvc outputs, including Apple, Tizen, WASM, PDB identities and materialized framework aliases. New or missing artifacts fail the coverage case. Remove duplicated Cake artifact assertions while preserving build transformations and toolchain checks; compatibility limits live directly in their test. Validate 13 xUnit cases against 277 compiled fixture artifacts plus 29 negative controls. Keep native tests as leaf stages in Test and Complete; Package remains build-only. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Add a Windows native-test job alongside Linux in the Test and Complete leaf stage, using the existing Windows pool without Docker. Provision a verified complete LLVM19.1.1 toolset when required, since the smaller installer omits llvm-readelf. Use LLVM ELF inspection consistently on both hosts. Linux/glibc-only runtime cases explicitly declare skips with exit77 and a reason; missing tools, artifacts and unexplained failures still fail. Preserve build-only Package behavior and separate TRX publication. Validate 13 passing Linux fixture cases and 12 passing portable cases plus one declared skip on macOS; real Windows CI execution remains to be run. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Keep this branch infrastructure-only by removing the symbolic-binding flag and its comment. Retain the HarfBuzz regression temporarily to confirm the expected CI failure against unfixed artifacts before deferring the case. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Production CI confirmed the expected Linux symbol-preemption failure and passed all twelve artifact inspections on Linux and Windows. Remove only the runtime regression from this infrastructure PR so it can land with the contributor linker fix; the case remains recoverable from 02c37d8. Retain the twelve static artifact cases and remove their unused Linux compiler packages. Update usage and current suite counts without introducing skips to hide the bug. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Drop the unneeded guide and its link from the container testing documentation. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Keep the independent native_tests leaf and its Linux/Windows jobs unchanged while removing the extra stage template. Forward the official container-template setting through the existing test-stage entry point; Package remains build-only. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Test jobs always use the standard templates. Keep 1ES selection only for native builds, not the test-stage or native-test job parameters. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Keep normal and native tests at the bottom of the shared stage entry point without changing leaf dependencies. Remove the redundant platform parameter and use buildAgent.pool.os for job naming and host setup. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Remove custom LLVM provisioning and let public and internal CI demonstrate whether the existing Windows toolset is sufficient. Missing required tools remain test failures; no skip or fallback is added. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Reject empty or non-glibc version inspection and verify Android ELF class/machine against its ABI directory. Require the published Windows ARM64 and HarfBuzz WASM alias paths directly instead of searching for alternative spellings. Keep declared tool dependencies fail-fast with no installation or alternate-tool fallback. Validate all twelve cases plus negative controls for missing tools, wrong ABI, empty GLIBC requirements and alternate paths. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Declare llvm-readobj --elf-output-style=GNU as the single ELF inspection API, using its native option names. Remove the llvm-readelf assertion wrapper and dependency rather than searching for an alternate tool. All twelve cases pass with llvm-readelf absent; missing readobj still fails even when readelf is available. Strict ABI, GLIBC and artifact-path negative controls remain passing. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
Keep the Linux native-test job, which inspects all platform artifacts, and defer the Windows host until the public image's LLVM setup is resolved. Do not change or skip any artifact cases or normal Windows test jobs. Co-authored-by: Copilot App <[email protected]> Copilot-Session: e108ef36-df39-44b3-8fa7-6ec8272316a5
a68229e to
32d724a
Compare
Bind bundled HarfBuzz functions locally on Linux (#5352) Fixes: #3038 Context: #2247 Context: #5366 Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1637759 Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1637595 Keep internal HarfBuzz calls within the bundled implementation and add a native regression that demonstrates the failure without depending on GTK, system HarfBuzz versions, fonts, or a managed-process crash. ~~ Prevent ELF preemption from mixing private HarfBuzz objects ~~ Using HarfBuzzSharp after GTK initialization can cause SIGSEGV or invalid pointer errors. GTK can load system HarfBuzz into the global symbol scope; ELF lookup can then redirect internal calls from libHarfBuzzSharp.so to that implementation, passing private objects between incompatible builds. Resolving the initial managed import from the intended library does not control the native calls made inside it. The earlier RTLD_DEEPBIND workaround lived in the custom library loader, so it did not protect the .NET import path reported in this regression. Apply -Wl,-Bsymbolic-functions in the common Linux HarfBuzz link recipe instead, following the native-binding diagnosis in the issue discussion. Choose function-only binding rather than -Bsymbolic: the observed conflict is in function references, and the narrower option avoids extending the change to global data binding. Keep the exported hb_* entry points and managed signatures unchanged rather than introducing prefixed wrappers. The nodeps and clang-cross recipes delegate to this common recipe and inherit the option; other native recipes are not changed. ~~ Make load-order regression failures observable in native CI ~~ Add HarfBuzzSymbolBinding as a folder-discovered PowerShell case in the SkiaSharp.Tests.Native project introduced by #5366. Separate the loader, conflicting exports, and intentionally preemptible control into probe.c, interposer.c, and control.c. The loader obtains entry points from the explicit library handle and exercises font creation and OpenType function initialization. Each probe runs in a fresh native process, optionally loading the interposer with RTLD_GLOBAL first. This keeps load-order state separate between probes and prevents a native failure from terminating the xUnit host. Have the interposer report the unexpectedly called function and exit 86, rather than relying on incompatible object layouts to produce a segfault. Require the fake control to pass alone and fail with that diagnostic and exit code before trusting the produced-library checks. This rejects a false pass caused by an inactive conflict. Validate the exact linux and linuxnodeps artifact paths, ELF class, endianness, machine, shared-library type, and glibc dependency before execution. Exercise both variants alone and with the conflicting exports. Declare a non-Linux runtime skip; unsupported Linux hosts, missing tools, missing artifacts, and failed native commands remain failures. Remove LD_PRELOAD and LD_AUDIT from the probe environment. Use the existing xUnit execution, timeout, and TRX reporting rather than adding another runner. Install gcc, glibc-devel, and binutils explicitly in the Linux test image alongside LLVM; GCC also needs the assembler and linker to compile these probes. A Linux ARM64 before/after run used identical test sources and image, substituting the standard HarfBuzz binary and its versioned alias. The unfixed production binary from build 1637595 passed alone but called the global hb_font_set_funcs_using with the interposer, producing exit 86: 12 native cases passed and this case failed. Restoring the fixed binary from contributor build 1637759 produced 13 passes with no skips; its nodeps HarfBuzz binary also passed both load orders. Those runtime checks used production-built HarfBuzz libraries; the other artifact inspections in that local run used retained fixtures. They do not establish a full GTK application run or runtime coverage of musl, Bionic, Tizen, or every cross-built architecture. Co-authored-by: vgm <[email protected]> Co-authored-by: Matthew Leibowitz <[email protected]> Co-authored-by: Nikita Tsukanov <[email protected]> Co-authored-by: Copilot App <[email protected]>
Description
Add a native-artifact suite using xUnit v3/Microsoft.Testing.Platform. Tests are PowerShell scripts under
Cases, eitherName.ps1orName/test.ps1when supporting files are needed. MSBuild runtime configuration supplies the repository path, and results use ordinary TRX reporting.Twelve inspection cases cover
nativeandnative_msvc: dependency policy, GLIBC compatibility, Android alignment/debug files, Windows imports/PDB identities, Apple framework/dSYM contents, Tizen ABI, and WASM archives. An inventory guard rejects missing artifacts and newly introduced binaries without inspection coverage. Shared helpers live inCases/Helpers.psm1.Run one Linux-container native-test job as a leaf in Test and Complete. Package remains build-only and neither runs nor waits for these tests. Move duplicated artifact assertions out of Cake while retaining compilation, stripping, symbol preparation, and build-input/toolchain validation. ELF inspection calls
llvm-readobj --elf-output-style=GNUdirectly; missing tools/APIs fail rather than selecting alternatives.Current verdict: after rebasing onto main
d29d6e6cd419, the native-test job at exact PR head32d724a04eecfcd75a37d04a2eb27f8ce3df9112passed 12/12 with no skips against freshly produced public artifacts. Public Complete run 1638964 nevertheless completed failed because Windows Host samples hitHttpClient.TimeoutinBasicSampleRunTests.WebSampleReturnsImage. This is different from the earlier Blazor cleared-page comparison failure. The full pipeline is not green; the timeout has not been established as pre-existing or flaky.Windows-hosted native execution is deferred because the public image's LLVM directory is not on PATH. Linux still runs the Windows DLL/PDB inspections; existing managed Windows jobs are unchanged. No case was skipped to hide missing tools, and no installer was restored.
The HarfBuzz runtime case was removed after CI confirmed the expected failure against unfixed artifacts, so it can arrive with the contributor's linker fix in #5352. Both fix and runtime case are excluded here. The pre-rebase case is recoverable from
02c37d85817; restoring it also needs compiler dependencies and the current reader API.Related issues
Related to #3038 and #5352. This infrastructure PR does not resolve the HarfBuzz bug itself.
Required skia PR
None.
Areas affected
binding/)externals/skia/src/c,include/c)Changes
No public API, ABI, or application runtime behavior changes. Artifact validation moves from native-build assertions to separate test jobs; Package stays build-only. PDB runtime markers are not proof of compiler mitigation or complete Spectre protection. The current suite performs static inspection without executing target libraries or requiring a C compiler.
Testing
Rebased current-head public build: native suite passed; sample timeout
Public Complete run 1638964, exact source
32d724a04eecfcd75a37d04a2eb27f8ce3df9112, completed failed:dotnet cake --target=tests-native— 12 passed, 0 failed, 0 skipped, published TRX 45519180, publisher log 2445. Individual results confirm all native inspections passed against fresh public artifacts.BasicSampleRunTests.WebSampleReturnsImageexceededHttpClient.Timeoutof 4 seconds, atRunningApp.cs:30/BasicSampleRunTests.cs:37. Evidence: task log 3279, job log 3289.The native test sources and stage semantics are unchanged by the rebase. Main now includes the browser screenshot/startup fixes, but that does not establish the separate HTTP sample timeout is resolved.
Earlier public artifact validation
Public run 1637595, pre-rebase source
a68229e50fd, passed all twelve native cases (TRX 45472836) but failed the Windows Host sample job'sBlazorWebAssemblyDrawingSampleDrawsAndClearscleared-page golden comparison: 1,906 / 1,152,000 pixels (0.165%), above 0.075%. This is historical evidence, not the current-head failure.Internal production-artifact validation
Internal run 3106805, pre-rebase source
a031953f728, succeeded against Package 3104558, version4.156.0-preview.0.26513.5+main, producer1d1d1b1db3dda7aeda1822377f2fbac76465b2a2:dotnet cake --target=tests-nativedotnet cake --target=tests-nativeNo Windows installation or PATH changes were used. This validates the strict ABI, GLIBC and artifact-path contracts against production artifacts.
Public Windows host investigation — not enabled in current CI
Public run 1637516, pre-rebase source
a031953, passed twelve Linux inspections (TRX 45470996), but public Windows reported 2 passed / 10 failed (TRX 45471274), all missing LLVM commands on PATH.Diagnostic 1637594 confirmed LLVM 22.1.3 tools exist and execute at
C:\Program Files\Microsoft Visual Studio\18\Enterprise\VC\Tools\Llvm\x64\bin, outside PATH. It performed no installation, PATH changes or recursive search. The Windows native-job invocation is removed, not artifact coverage.Historical 3106773 / 3106749 runs identified the earlier missing
llvm-readelfdependency. The suite now explicitly usesllvm-readobj, not fallback selection or installation.HarfBuzz red control before deferral
Run 3106713 used pinned unfixed Package 3104558:
hb_font_set_funcs_usingand exited 86.Local checks
dotnet build tests/SkiaSharp.Tests.Native.slnx --no-restore -v minimal— passed after rebase, zero warnings/errors.dotnet test tests/SkiaSharp.Tests.Native.slnx --no-restore -- --report-trx --report-trx-filename rebased-main.trx --results-directory /work/output/logs/testlogs/SkiaSharp.Tests.Native— passed after rebase: 12 passed, 0 failed, 0 skipped against compiled fixtures.llvm-readelfabsent; missingllvm-readobjfailed even withllvm-readelfavailable.pwsh -NoLogo -NoProfile -File /fixtures/inventory-build/negative-controls.ps1— 29 negative controls passed, plus strict controls for empty GLIBC output, musl substitutions, wrong ABI/debug pairs and alternate paths.dotnet cake native/linux/build.cake --showtree— passed; Android, nodeps, Windows, WinUI and ANGLE graph checks also passed after assertion migration.git diff --checkpassed. Rebase verification preserved the native-test sources, Linux-only leaf stage and build-only Package policy.No C API/submodule changes, binding regeneration, rendering screenshots or GPU validation apply. No full local native rebuild was performed.
Checklist
Changesabove lists all public API and behavioral changes (or "None.")///documentation and regenerated bindings when applicable — N/A: no public API changes.mono/skiaPR linked above and bindings regenerated — N/A: no C API or submodule changes.