diff --git a/cmake/local-ci/linux.Dockerfile b/cmake/local-ci/linux.Dockerfile index 04d934b3..5ffbcee1 100644 --- a/cmake/local-ci/linux.Dockerfile +++ b/cmake/local-ci/linux.Dockerfile @@ -25,7 +25,7 @@ RUN curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key -o /tmp/llvm.asc \ && . /etc/os-release \ && echo "deb [signed-by=/usr/share/keyrings/llvm.gpg] https://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list \ && apt-get update \ - && apt-get install -y --no-install-recommends clang-${LLVM_VERSION} clang-tidy-${LLVM_VERSION} lld-${LLVM_VERSION} \ + && apt-get install -y --no-install-recommends clang-${LLVM_VERSION} clang-tidy-${LLVM_VERSION} lld-${LLVM_VERSION} llvm-${LLVM_VERSION} \ libclang-rt-${LLVM_VERSION}-dev libc++-${LLVM_VERSION}-dev libc++abi-${LLVM_VERSION}-dev \ && rm -rf /var/lib/apt/lists/* /tmp/llvm.asc # Host UID/GID override this default in docker run; no privileged runtime is used. diff --git a/cmake/local-ci/windows_worker.py b/cmake/local-ci/windows_worker.py index fc24c6a0..4085e748 100644 --- a/cmake/local-ci/windows_worker.py +++ b/cmake/local-ci/windows_worker.py @@ -23,10 +23,19 @@ def ps(script, **kwargs): - encoded = base64.b64encode(("$ErrorActionPreference='Stop'; " + script).encode("utf-16-le")).decode() + # Windows PowerShell's redirected output need not use Python's locale encoding. + # Keep captured probes and their saved diagnostics readable on localized hosts. + prefix = ("$ErrorActionPreference='Stop'; $ProgressPreference='SilentlyContinue'; " + "[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false); ") + # -EncodedCommand serializes uncaught errors as CLIXML even with Text output. + # Format ErrorRecord inside PowerShell before the host can serialize it. + wrapped = prefix + "try {\n" + script + "\n} catch { [Console]::Error.WriteLine(($_ | Out-String)); exit 1 }" + encoded = base64.b64encode(wrapped.encode("utf-16-le")).decode() + if kwargs.get("text"): + kwargs["encoding"] = "utf-8" try: return command(["powershell.exe", "-NoLogo", "-NoProfile", "-NonInteractive", - "-EncodedCommand", encoded], **kwargs) + "-OutputFormat", "Text", "-EncodedCommand", encoded], **kwargs) except subprocess.CalledProcessError as error: # Probes capture output for parsing; preserve their actual diagnosis in the lane log. for output in (error.stdout, error.stderr): diff --git a/cmake/local-ci/worker.py b/cmake/local-ci/worker.py index b0c109f6..30b3b685 100644 --- a/cmake/local-ci/worker.py +++ b/cmake/local-ci/worker.py @@ -186,12 +186,33 @@ def executeInside(lane, jobs): command(["ccache", "--show-stats"]) +def mmapRandomBits(samples=96): + """Estimate vm.mmap_rnd_bits from the address span of fresh processes (the kernel file is root-only, mode 0600). + The borrow of the base address subtraction makes the span exceed the configured bits by exactly one.""" + code = "import mmap,ctypes;m=mmap.mmap(-1,4096);print(ctypes.addressof(ctypes.c_char.from_buffer(m)))" + addresses = [int(command([sys.executable, "-c", code], capture_output=True, text=True).stdout) for _ in range(samples)] + spread = 0 + for address in addresses: + spread |= address ^ addresses[0] + return spread.bit_length() - 12 - 1 + + +def hostSysctl(key): + try: + return command(["sysctl", "-n", key], capture_output=True, text=True).stdout.strip() + except subprocess.CalledProcessError: + if key != "vm.mmap_rnd_bits": + raise + # An unprivileged account cannot read it: measure the effective entropy instead. + return str(mmapRandomBits()) + + def runLane(args, matrix): lane = next(row for row in matrix["lanes"] if row["id"] == args.lane) if not lane["runtime"].startswith("container:"): raise ValueError("Native lanes are not implemented in delivery step 2") for key, expected in lane.get("host_requirements", {}).get("sysctl", {}).items(): - actual = command(["sysctl", "-n", key], capture_output=True, text=True).stdout.strip() + actual = hostSysctl(key) if actual != expected: raise ValueError(f"Host requires {key}={expected}; found {actual}. Ask its owner to configure it.") manifest = json.loads((ROOT / "dependencies/kit.json").read_text()) diff --git a/docs/LOCAL_CI.md b/docs/LOCAL_CI.md index c3d4f638..fe76ee9f 100644 --- a/docs/LOCAL_CI.md +++ b/docs/LOCAL_CI.md @@ -158,9 +158,12 @@ Host Mac IdentitiesOnly yes ``` -For both TSan lanes the **owner** must provision `vm.mmap_rnd_bits=28` on RyzenLinux. The worker checks `sysctl -n` before any +For both TSan lanes the **owner** must provision `vm.mmap_rnd_bits=28` on RyzenLinux. The worker checks it before any container starts and fails with the actual value and required setting when they differ. This is a host setting, not a Docker -namespace setting. The orchestrator never changes it. +namespace setting. The orchestrator never changes it. The kernel keeps the file root-only (mode 0600), so the dedicated +unprivileged account cannot run `sysctl -n` on it. The worker then measures the effective entropy of `mmap` over 96 fresh +processes and treats the span of their base addresses, minus the one bit that the base address subtraction's borrow adds, as the +value. The estimate is not an attestation of the sysctl; the owner remains responsible for provisioning it. ### Preparing the offline kit on the workstation @@ -255,7 +258,7 @@ provisioning workstation. Its context must contain the unpacked, checksum-verifi image with `LLVM_VERSION=21 CMAKE_VERSION=4.3.1` and the matching CMake archive for mddlog, and a desktop image with `BASE_IMAGE=ubuntu@sha256: GCC_VERSION=16` and CMake 4.4.4. Pin any overridden base **by digest**, never a tag. Both the default `gcc`/`g++` metapackages and the requested versioned compiler packages are installed and probed during image -construction. The LLVM archive key fingerprint is checked before enabling the apt repository. Package repositories are used only at image +construction. The versioned `llvm-N` package supplies `llvm-ar` and `llvm-ranlib`, which mddlog's `linux-clang21-libcxx` toolchain requires. The LLVM archive key fingerprint is checked before enabling the apt repository. Package repositories are used only at image build time; the saved image ID seals the resulting toolchain. Record each image's base, arguments and CMake archive checksum in `provision.json`. Save the images on the workstation with `docker save --output /images/.tar `. @@ -294,6 +297,10 @@ Although GitHub currently marks #346 closed, the full acceptance evidence remain ### Native Windows execution +The [Windows qualification record](LOCAL_CI_WINDOWS_QUALIFICATION.md) records PR #368's host observations, +prepared kit, localized PowerShell diagnostic fix, and owner setup commands. It distinguishes local validation from +qualification of the dedicated SSH/graphical account. + The Windows lane uses the same commit bundle, verified kit inventory, command metadata and result collection as Linux. It runs natively, with Ninja and the latest installed x64 MSVC toolset selected by `vswhere`, in the dedicated account's graphical session. It prints the effective compiler banner, CMake and WebView2 versions. CMake must match the lane's pinned @@ -462,8 +469,52 @@ python3 cmake/local-ci/run run --machines Mac --commit HEAD \ `LocalCiMacOS` covers command generation, LaunchAgent configuration, login/lock checks, version reporting, kit integrity, cache propagation, failure/timeout/cancellation, skipped sessions, cleanup retention and the full bundle/artifact protocol with -a native-session stand-in. On macOS it also exercises the real inherited socket policy, loopback and a child process. It does -not provision an account or register an actual LaunchAgent. Qualification still requires real SSH/Aqua/WKWebView execution, +a native-session stand-in. On macOS it also exercises the real inherited socket policy, loopback and a child process. When +the caller has an unlocked active Aqua session, a native lifecycle regression registers a uniquely named temporary LaunchAgent +running a harmless Python fixture, checks its inherited network restriction, boots it out with `--wait`, verifies that its +`sleep` descendant has terminated and repeats stop to check the missing-service diagnosis. It skips that lifecycle test when +no usable graphical session exists; it never provisions an account. Qualification still requires real SSH/Aqua/WKWebView execution, XPC network checks, disconnect recovery, cold/warm cache measurements, all eleven lanes across three hosts and comparison against GitHub on the same commit. The development Mac used for implementation has Command Line Tools rather than selected full Xcode, so it cannot qualify the advertised Xcode lane. + +### macOS qualification attempt (#368, 2026-10-25) + +Tested from `346-linux-qualification`, starting at `1151dc4`, on macOS 27.0.1 (26A434), ARM64. The development account has +an active Aqua session. This is a partial host investigation, not a passed `desktop-macos-clang-wkwebview` lane: + +- The 27 `TestLocalCiMacOS.py` tests pass, including the actual sandbox socket checks and the new LaunchAgent/descendant + lifecycle test. Real console ownership, CoreGraphics and IORegistry checks also accept the development session. +- The CEF-off Release build with Homebrew Clang 21.1.8 and CMake 4.3.1 passes all 265 CTest cases. This compiler and CMake + are different from the lane's Xcode AppleClang and CMake 4.4.4. No offline or SSH execution is claimed for this build. +- A separate Release build with the same Homebrew toolchain, `WEBFRONT_EMBED_WKWEBVIEW=ON` and + `WEBFRONT_WEBTEST_FRONTEND=WKWebView` passes all 340 CTest cases (195.54 seconds), including the Jasmine bridge suite, + native lifecycle cases, transport benchmark and developer environment. These browser tests ran in the principal account, + outside the worker's inherited network policy; they do not establish dedicated-account or WebKit XPC egress isolation. +- Ninja's Homebrew `clang-scan-deps` initially could not find SDK headers. Configuring with + `-DCMAKE_OSX_SYSROOT="$(xcrun --show-sdk-path)"` fixes the main build but exposed a missing SDK propagation in + `AddSubdirectoryConsumer`: that separate configure still failed on `time.h`. The test now forwards the explicit SDK and + passes. Module scanning was enabled for this supplementary build; the advertised lane disables it. +- `ssh -o BatchMode=yes -o ConnectTimeout=5 -- Mac true` returns 255 (`Connection refused`). The resolved SSH user is the + principal development account, and no dedicated standard CI account is provisioned on this host. +- `xcode-select -p` returns `/Library/Developer/CommandLineTools`; `xcodebuild -version` fails because full Xcode is not + selected. `/usr/bin/clang++` reports AppleClang 21.0.0, but Command Line Tools do not satisfy the Xcode requirement. + +To reproduce the supplementary CEF-off build (requires provisioned dependencies or network access during configure): + +```bash +cmake -S . -B build-macos-qualification -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON \ + -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \ + -DCMAKE_OSX_SYSROOT="$(xcrun --show-sdk-path)" +cmake --build build-macos-qualification --parallel 4 +ctest --test-dir build-macos-qualification --output-on-failure --parallel 4 --output-junit test-results.xml +``` + +For the supplementary browser build, use a separate build directory with the same options plus +`-DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView`, then build and run its full CTest suite. + +Full qualification remains blocked on provisioning key-only SSH to a dedicated standard account with an active Aqua session, +full selected Xcode, CMake 4.4.4 and a verified macOS dependency kit. Then run the orchestrator command above, measure cold and +warm caches, exercise SSH disconnect/recovery, and compare against GitHub on the same commit. WebKit XPC public egress and +the combined eleven-lane matrix remain unqualified. diff --git a/docs/LOCAL_CI_WINDOWS_QUALIFICATION.md b/docs/LOCAL_CI_WINDOWS_QUALIFICATION.md new file mode 100644 index 00000000..40f65b3f --- /dev/null +++ b/docs/LOCAL_CI_WINDOWS_QUALIFICATION.md @@ -0,0 +1,174 @@ +# Windows qualification of PR #368 + +## Scope and host + +Qualification started on 2026-10-25 from `1151dc4f798d0c2b2e8adf0065e6a65d36d2fcc9`, the head of PR #368. +The host is Curmudgeon, running Windows 11 Pro for Workstations, version `10.0.22631`. +The development account has a non-elevated token but belongs to Administrators. It is **not** the dedicated standard +account required by [the local CI contract](LOCAL_CI.md#native-windows-execution). + +Observed tools: MSVC `19.44.35229` for x64, Ninja, Python `3.10.11`, and WebView2 Evergreen `155.0.4283.60` / `155.0.4283.62`. +The installed CMake was `4.3.4` and sccache was absent from PATH. Portable CMake `4.4.4` and sccache `0.18.0` were prepared +under the ignored `build-local-ci/windows-qualification-tools/` directory. The CMake ZIP was checked against Kitware's +release SHA-256 list; the sccache ZIP against the WinGet manifest SHA-256 +`8965c74d5e8a225244f741e18ad2f3f504f48228dc1bac948fc22761a348363d`. +These local tools do not provision the dedicated account's PATH. + +## Findings + +The real session worker passes its desktop check, then fails before configure because +`WebFrontLocalCI-BlockPublic` is absent. It writes `{"code": 1}` to its result file. All three firewall profiles are enabled. +The SSH server, `CurmudgeonWindows` client alias, dedicated account and offline kit had not been provisioned. +No account, SSH service or firewall policy was changed by this qualification. + +This failure exposed unreadable localized PowerShell diagnostics: captured output used Python's locale encoding while +PowerShell emitted different bytes, and uncaught errors were serialized as CLIXML. The Windows probe helper now sets +UTF-8 explicitly on both sides, suppresses progress records, and formats caught errors as text while retaining exit code 1. +A real PowerShell regression first failed on accented/CJK output, then passed after the fix. It also checks that errors +preserve Unicode and are not CLIXML. This concerns the native worker's probes; binary artifact transport is unchanged. + +## Validation + +The initial CEF-off/WebView2 Release build with the installed CMake 4.3.4 passes **342/342 CTest cases**, including +73 cases labelled `web-integration` (477.26 seconds total). This includes Jasmine, native lifecycle, transport benchmark, +developer environment, independent consumer configuration and the local CI regressions. +The diagnostic fix separately passes **29/29 Windows worker regressions**, including real PowerShell and Job Object tests. +These run in the development session with public networking available; they do not qualify the dedicated SSH account. + +A second clean Release tree uses portable **CMake 4.4.4**, **sccache 0.18.0**, a new cache, and the extracted verified kit. +Its configuration uses the kit's preload, bootstrap and registry directories, `FETCHCONTENT_FULLY_DISCONNECTED=ON`, +`CPM_SOURCE_CACHE` in the environment and `CMAKE_CXX_COMPILER_LAUNCHER=sccache`, with module scanning disabled and four jobs. +Configuration passes in 10.6 seconds, compilation in 459.0 seconds (158 sccache misses, no failures), and **342/342 CTest +cases pass**, including the same 73 browser integration cases, in 341.33 seconds. JUnit records zero failures and zero skips. +The macOS follow-up `8e32530` is integrated, and the updated Windows worker regression runs in this suite. +Logs and JUnit remain in `build-local-ci/windows-qualification-{configure,build,test}.log` and +`build-368-windows-offline-kit/test-results.xml`. Public egress was not blocked for these direct development-session runs. +Their elapsed times are supplementary observations, not the dedicated-account or same-commit GitHub comparison. +After `cmake --build build-368-windows-offline-kit --target clean`, rebuilding the same tree with the retained cache +succeeds in **22.5 seconds**, with **155/155 sccache hits**, zero misses and zero compilation failures. This demonstrates +local persistent-cache reuse; it does not exercise a second SSH run or a new remote checkout. +The warm-build log is `build-local-ci/windows-qualification-warm-build.log`. + +## Prepared offline kit + +The local archive `build-local-ci/windows-1151dc4.tgz` contains 1,298 inventoried files (32,723,039 compressed bytes): + +```text +SHA-256 520f1ec91ec25da36fc8efb1c8ddc25aeab8d90a82f5a0d38bb8b84d653e039e +``` + +stdnet, stdexec and Catch2 were exported with `git archive` at their pinned revisions, without Git metadata. +The WebView2 SDK archive was checked against the SHA-256 in `WebView2Support.cmake`. The bootstrap and all 14 registry +archives were checked against their pinned SHA-512 values. CPM `0.43.2` was compared with its upstream release module. +The portable preload uses paths relative to itself. `provision.json` records source URLs, revisions and integrity. +Packing, Windows-safe extraction and verification of the extracted inventory all succeeded. + +## Owner preparation commands + +Apply the following only on a **dedicated CI host or VM**. The public egress block affects every user and program on that +host, including multicast/broadcast services as described in `LOCAL_CI.md`. Finish downloads and verify private-LAN SSH +before applying it. The commands are an owner procedure, not actions performed by the worker. + +In an administrator PowerShell: + +```powershell +$password = Read-Host 'Password for webfront-ci' -AsSecureString +New-LocalUser -Name webfront-ci -Password $password -Description 'WebFront qualification' +Get-LocalGroup -SID S-1-5-32-545 | Add-LocalGroupMember -Member webfront-ci +Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 +Set-Service sshd -StartupType Automatic +Start-Service sshd +``` + +Log on graphically as `.\webfront-ci` to create its profile. In that account, before blocking public egress: + +```powershell +winget install --exact --id Git.Git --accept-source-agreements --accept-package-agreements +winget install --exact --id Python.Python.3.13 --accept-source-agreements --accept-package-agreements +winget install --exact --id Ninja-build.Ninja --accept-source-agreements --accept-package-agreements +winget install --exact --id Mozilla.sccache --accept-source-agreements --accept-package-agreements +winget install --exact --id Kitware.CMake --version 4.4.4 --accept-source-agreements --accept-package-agreements +``` + +The host already has MSVC C++ x64 tools, a Windows SDK, `vswhere` and WebView2 Evergreen installed. On a new host, install +them separately. Reopen the terminal and verify `git --version`, `python.exe --version`, `ninja --version`, +`sccache --version` and `cmake --version`. `python.exe` must resolve to a real interpreter, not the Microsoft Store alias. +Also verify PATH through SSH; an interactive terminal alone does not demonstrate the SSH service sees these tools. + +On the orchestrator, create a key and display **only the public key**: + +```powershell +ssh-keygen -t ed25519 -f "$env:USERPROFILE\.ssh\webfront-ci" +Get-Content "$env:USERPROFILE\.ssh\webfront-ci.pub" +``` + +In the `webfront-ci` session, paste that public-key line into `authorized_keys`: + +```powershell +New-Item -ItemType Directory -Force "$env:USERPROFILE\.ssh" +notepad "$env:USERPROFILE\.ssh\authorized_keys" +``` + +Configure the orchestrator's `%USERPROFILE%\.ssh\config`, replacing the address with the host's private LAN address: + +```sshconfig +Host CurmudgeonWindows + HostName + User webfront-ci + IdentityFile ~/.ssh/webfront-ci + IdentitiesOnly yes +``` + +Verify the server fingerprint on the first connection and test key authentication: + +```powershell +ssh CurmudgeonWindows whoami +ssh -o BatchMode=yes CurmudgeonWindows python.exe --version +``` + +An encrypted private key must already be loaded into the orchestrator's SSH agent for the non-interactive run. + +To require key-only access for this account, append this block to the host's +`C:\ProgramData\ssh\sshd_config` in an administrator editor: + +```sshconfig +Match User webfront-ci + AuthenticationMethods publickey + PasswordAuthentication no +``` + +Validate the configuration before restarting the service, then repeat the connection test: + +```powershell +& "$env:WINDIR\System32\OpenSSH\sshd.exe" -t +if ($LASTEXITCODE -ne 0) { throw 'Invalid sshd configuration; do not restart' } +Restart-Service sshd +``` + +From the checkout, generate and review the firewall setup file: + +```powershell +py cmake/local-ci/windows_worker.py --print-firewall-setup | + Set-Content -Encoding UTF8 build-local-ci/windows-firewall-setup.ps1 +Get-Content build-local-ci/windows-firewall-setup.ps1 +``` + +Only after the preceding checks, run that reviewed file from an administrator PowerShell on the dedicated host: + +```powershell +& .\build-local-ci\windows-firewall-setup.ps1 +``` + +From the actual non-elevated SSH account, verify access to the effective firewall rule and all its filters, as required +by `checkNetwork`. Keep the same account's graphical desktop logged on and unlocked. Run from the orchestrator: + +```powershell +py cmake/local-ci/run run --commit HEAD --machines CurmudgeonWindows ` + --windows-kit build-local-ci/windows-1151dc4.tgz ` + --windows-kit-sha256 520f1ec91ec25da36fc8efb1c8ddc25aeab8d90a82f5a0d38bb8b84d653e039e ` + --jobs 4 --require-all +``` + +The kit matches the dependency pins of the examined commit. Rebuild it if those pins change. A Windows-only run still +reports the eleven-lane matrix as incomplete. Cold/warm runs over real SSH, task registration under the standard account, +disconnect/recovery, public egress checks, multicast/broadcast effects and comparison with GitHub timings remain required. diff --git a/docs/PROJECT_STATUS.md b/docs/PROJECT_STATUS.md index 41634a04..a91a9981 100644 --- a/docs/PROJECT_STATUS.md +++ b/docs/PROJECT_STATUS.md @@ -628,3 +628,24 @@ WKWebView lane with a verified Mac kit and inherited process network restriction System WebKit XPC services are outside that process restriction. Real Linux/Windows/macOS host qualification, XPC egress isolation, the complete eleven-lane run and comparison with GitHub timings remain open; this is not yet a qualified replacement for running any of the GitHub jobs. See [LOCAL_CI](LOCAL_CI.md). + +The macOS investigation for #368 (2026-10-25, macOS 27.0.1 ARM64) passes 27 worker regressions, including an actual temporary +Aqua LaunchAgent, its inherited socket restriction, descendant termination and repeated stop. A supplementary Homebrew +Clang 21.1.8/CMake 4.3.1 CEF-off Release build passes all 265 CTest cases after fixing explicit SDK propagation to +`AddSubdirectoryConsumer`; the supplementary WKWebView Release build passes all 340 cases, including the bridge, lifecycle, +benchmark and developer tests (195.54 seconds). Those browser tests run in the principal account outside the worker's network +policy. This is not the pinned AppleClang/Xcode lane: the development host has only selected Command Line +Tools, CMake differs from the lane's 4.4.4, SSH to `Mac` is refused, and no dedicated standard CI account is provisioned. +The exact-lane run, cold/warm timings, SSH recovery and WebKit XPC egress qualification remain pending. + +The Windows investigation for #368 (2026-10-25, Windows 11 build 22631, MSVC 19.44.35229) passes all 342 CTest cases in a +CEF-off/WebView2 Release build, including 73 browser integration cases, and 29 native-worker regressions. A real preflight +exposed localized PowerShell output corruption and CLIXML error logs; an explicit UTF-8/text diagnostic fix has a failing-then- +passing native regression. A second CMake 4.4.4/sccache 0.18.0 Release build using the packed, extracted and verified Windows +kit also passes all 342 CTest cases (341.33 seconds), with FetchContent disconnected and zero JUnit failures/skips. +Cleaning and rebuilding the same tree reuses 155/155 sccache entries and succeeds in 22.5 seconds; this is local cache reuse, +not a second SSH lane run. The development account has a non-elevated administrator token, not the required standard-account +boundary; no dedicated CI account or SSH server is +provisioned, and the required egress rule is absent. The real session worker correctly rejects that host before configure. +Dedicated-account SSH/task/network qualification, cold/warm timings and disconnect recovery remain pending. See the +[Windows qualification record and setup commands](LOCAL_CI_WINDOWS_QUALIFICATION.md). diff --git a/include/webfront/weblink/Messages.hpp b/include/webfront/weblink/Messages.hpp index 91dff8f7..81d508ee 100644 --- a/include/webfront/weblink/Messages.hpp +++ b/include/webfront/weblink/Messages.hpp @@ -5,6 +5,7 @@ #include "../http/BuffersPolicy.hpp" +#include #include #include #include diff --git a/test/cmake/TestLocalCi.py b/test/cmake/TestLocalCi.py index 8eef0c99..20394be2 100644 --- a/test/cmake/TestLocalCi.py +++ b/test/cmake/TestLocalCi.py @@ -324,6 +324,32 @@ def test_tsan_host_requirement_stops_before_docker(self): worker.runLane(args, self.matrix) cmd.assert_called_once_with(["sysctl", "-n", "vm.mmap_rnd_bits"], capture_output=True, text=True) + def test_unreadable_tsan_sysctl_is_measured_instead(self): + # The kernel keeps vm.mmap_rnd_bits root-only (mode 0600): an unprivileged account cannot read it. + denied = subprocess.CalledProcessError(1, "sysctl") + with patch.object(worker, "command", side_effect=denied), \ + patch.object(worker, "mmapRandomBits", return_value=32): + self.assertEqual(worker.hostSysctl("vm.mmap_rnd_bits"), "32") + with self.assertRaises(subprocess.CalledProcessError): + worker.hostSysctl("vm.other") + lane = self.lane("sanitizers-thread") + with patch.object(worker, "command", side_effect=denied), \ + patch.object(worker, "mmapRandomBits", return_value=32): + with self.assertRaisesRegex(ValueError, r"vm.mmap_rnd_bits=28; found 32"): + worker.runLane(argparse.Namespace(lane=lane["id"]), self.matrix) + + def test_measured_entropy_discounts_the_base_address_borrow(self): + # 28 configured bits randomize page numbers below bit 40; the subtraction's borrow reaches bit 40. + base = 0x7f0000000000 + addresses = [base, base ^ (1 << 12), base ^ (1 << 40)] + [base ^ (1 << 20)] * 93 + with patch.object(worker, "command", side_effect=[subprocess.CompletedProcess([], 0, f"{a}\n") for a in addresses]): + self.assertEqual(worker.mmapRandomBits(), 28) + + def test_llvm_image_provides_binutils_for_the_mddlog_toolchain(self): + # mddlog's linux-clang21-libcxx toolchain requires llvm-ar and llvm-ranlib from the versioned LLVM root. + dockerfile = (ci.HERE / "linux.Dockerfile").read_text() + self.assertIn("llvm-${LLVM_VERSION}", dockerfile) + def test_failure_timeout_and_interruption_are_nonzero(self): with tempfile.TemporaryFile() as log: with self.assertRaises(subprocess.CalledProcessError): diff --git a/test/cmake/TestLocalCiMacOS.py b/test/cmake/TestLocalCiMacOS.py index b3d1ae35..bfe6e47a 100644 --- a/test/cmake/TestLocalCiMacOS.py +++ b/test/cmake/TestLocalCiMacOS.py @@ -1,4 +1,4 @@ -"""Offline macOS driver regressions; no real account/LaunchAgent changes.""" +"""macOS driver regressions, plus a temporary LaunchAgent in an available Aqua session.""" import argparse import ctypes import errno @@ -16,6 +16,7 @@ import threading import time import unittest +import uuid from unittest.mock import MagicMock, patch sys.dont_write_bytecode = True @@ -185,6 +186,45 @@ def test_selected_xcode_and_versions_are_reported(self): with self.assertRaisesRegex(ValueError, 'CMake version'): mac.reportToolchain(self.lane, io.StringIO()) + @unittest.skipUnless(sys.platform == 'darwin', 'macOS LaunchAgent lifecycle') + def test_real_launchagent_applies_policy_and_stops_descendants(self): + self.uid.stop() # The actual caller's gui domain, never the fixture UID. + try: + mac.checkDesktop() + except mac.NoDesktop as error: + self.skipTest(str(error)) + self.root = self.root / ('native-' + uuid.uuid4().hex) + self.root.mkdir() + # This harmless worker needs neither Xcode nor an offline dependency kit. + # Keep the real start/stop path, sandbox, environment and process ownership. + (self.root / 'worker.py').write_text('''import json,pathlib,subprocess,sys,time +sys.dont_write_bytecode = True +sys.path.insert(0, sys.argv[sys.argv.index('--sha') + 1]) +import macos_worker as mac +mac.checkNetwork() +child = subprocess.Popen(['/bin/sleep', '120']) +pathlib.Path('started.tmp').write_text(json.dumps({'child': child.pid})) +pathlib.Path('started.tmp').replace('started.json') +time.sleep(120) +''', encoding='utf-8') + self.args.sha = str(ci.HERE) + self.args.timeout = 30 + marker = self.root / 'started.json' + try: + mac.startTask(self.root, self.args) + deadline = time.monotonic() + 15 + while not marker.exists() and time.monotonic() < deadline: + time.sleep(.1) + launchLog = self.root / (self.args.lane + '.launch.log') + self.assertTrue(marker.exists(), launchLog.read_text() if launchLog.exists() else 'No launch log') + pid = json.loads(marker.read_text())['child'] + self.assertEqual(subprocess.run(['/bin/kill', '-0', str(pid)], capture_output=True).returncode, 0) + finally: + mac.stopTask(self.root, self.args.lane) + self.assertNotEqual(subprocess.run(['/bin/kill', '-0', str(pid)], capture_output=True).returncode, 0, + 'LaunchAgent descendant survived bootout --wait') + mac.stopTask(self.root, self.args.lane) # Real missing-service diagnosis is idempotent. + def test_session_exports_offline_cache_and_preserves_nonzero_test(self): def execute(invocation, log, timeout): self.assertEqual(os.environ['CPM_SOURCE_CACHE'], str(self.root.parent.parent / 'cache/cpm')) diff --git a/test/cmake/TestLocalCiWindows.py b/test/cmake/TestLocalCiWindows.py index 5441da9e..5630a2c5 100644 --- a/test/cmake/TestLocalCiWindows.py +++ b/test/cmake/TestLocalCiWindows.py @@ -354,6 +354,16 @@ def invoke(arguments, log, timeout): self.args.timeout = 30 self.assertEqual(windows.session(self.root, self.args, self.lane), 0) + @unittest.skipUnless(os.name == "nt", "Native Windows transport") + def test_real_powershell_probes_preserve_unicode_and_plain_error_diagnostics(self): + result = windows.ps("Write-Output 'caf\u00e9 \u6f22\u5b57'", capture_output=True, text=True, timeout=20) + self.assertEqual(result.stdout.strip(), "caf\u00e9 \u6f22\u5b57") + with self.assertRaises(subprocess.CalledProcessError) as failure, \ + patch.object(sys, "stderr"): + windows.ps("Write-Error 'caf\u00e9 \u6f22\u5b57'", capture_output=True, text=True, timeout=20) + self.assertIn("caf\u00e9 \u6f22\u5b57", failure.exception.stderr) + self.assertNotIn("CLIXML", failure.exception.stderr) + @unittest.skipUnless(os.name == "nt", "Native Windows transport") def test_real_powershell_preserves_binary_stdin_stdout_and_arguments(self): invocation = ci.remote("CurmudgeonWindows", [sys.executable, "-c", diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index a8088823..53eacb41 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -160,6 +160,11 @@ endif() if(DEFINED CMAKE_CXX_SCAN_FOR_MODULES) list(APPEND _consumer_dependency_args -DCMAKE_CXX_SCAN_FOR_MODULES:BOOL=${CMAKE_CXX_SCAN_FOR_MODULES}) endif() +# Homebrew clang-scan-deps needs the same explicit SDK as the parent build. +# A separate configure otherwise loses -isysroot and cannot find system headers. +if(APPLE AND DEFINED CMAKE_OSX_SYSROOT) + list(APPEND _consumer_dependency_args "-DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT}") +endif() # Read the actual target's launcher at generation time, including an explicitly # configured or auto-discovered cache. Do not depend on Cache.cmake's local variable. add_test(NAME AddSubdirectoryConsumer