From 14ca5b35d0fc477ba30f10b80f937b523fd7e930 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Sat, 21 Mar 2026 21:43:22 +0100 Subject: Interprocess pipe support (for stdout/stderr capture) (#866) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - **RAII pipe handles for child process stdout/stderr capture**: `StdoutPipeHandles` is now a proper RAII type with automatic cleanup, move semantics, and partial close support. This makes it safe to use pipes for capturing child process output without risking handle/fd leaks. - **Optional separate stderr pipe**: `CreateProcOptions` now accepts a `StderrPipe` field so callers can capture stdout and stderr independently. When null (default), stderr shares the stdout pipe as before. - **LogStreamListener with pluggable handler**: The TCP log stream listener accepts connections from remote processes and delivers parsed log lines through a `LogStreamHandler` interface, set dynamically via `SetHandler()`. This allows any client to receive log messages without depending on a specific console implementation. - **TcpLogStreamSink for zen::logging**: A logging sink that forwards log messages to a `LogStreamListener` over TCP, using the native `zen::logging::Sink` infrastructure with proper thread-safe synchronization. - **Reliable child process exit codes on Linux**: `waitpid` result handling is fixed so `ProcessHandle::GetExitCode()` returns the real exit code. `ProcessHandle::Reset()` reaps zombies directly, replacing the global `IgnoreChildSignals()` which prevented exit code collection entirely. Also fixes a TOCTOU race in `ProcessHandle::Wait()` on Linux/Mac. - **Pipe capture test suite**: Tests covering stdout/stderr capture via pipes (both shared and separate modes), RAII cleanup, move semantics, and exit code propagation using `zentest-appstub` as the child process. - **Service command integration tests**: Shell-based integration tests for `zen service` covering the full lifecycle (install, status, start, stop, uninstall) on all three platforms — Linux (systemd), macOS (launchd), and Windows (SCM via PowerShell). - **Test script reorganization**: Platform-specific test scripts moved from `scripts/test_scripts/` into `scripts/test_linux/`, `test_mac/`, and `test_windows/`. --- scripts/test_scripts/block-clone-test-mac.sh | 43 ---------------------------- 1 file changed, 43 deletions(-) delete mode 100755 scripts/test_scripts/block-clone-test-mac.sh (limited to 'scripts/test_scripts/block-clone-test-mac.sh') diff --git a/scripts/test_scripts/block-clone-test-mac.sh b/scripts/test_scripts/block-clone-test-mac.sh deleted file mode 100755 index a3d3ca4d3..000000000 --- a/scripts/test_scripts/block-clone-test-mac.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# Test block-clone functionality on macOS (APFS). -# -# APFS is the default filesystem on modern Macs and natively supports -# clonefile(), so no special setup is needed — just run the tests. -# -# Usage: -# ./scripts/test_scripts/block-clone-test-mac.sh [path-to-zencore-test] -# -# If no path is given, defaults to build/macosx//debug/zencore-test -# relative to the repository root. - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" - -ARCH="$(uname -m)" -TEST_BINARY="${1:-$REPO_ROOT/build/macosx/$ARCH/debug/zencore-test}" - -if [ ! -x "$TEST_BINARY" ]; then - echo "error: test binary not found or not executable: $TEST_BINARY" >&2 - echo "hint: build with 'xmake config -m debug && xmake build zencore-test'" >&2 - exit 1 -fi - -# Verify we're on APFS -BINARY_DIR="$(dirname "$TEST_BINARY")" -FS_TYPE="$(diskutil info "$(df "$BINARY_DIR" | tail -1 | awk '{print $1}')" 2>/dev/null | grep "Type (Bundle)" | awk '{print $NF}' || true)" - -if [ "$FS_TYPE" != "apfs" ]; then - echo "warning: filesystem does not appear to be APFS (got: ${FS_TYPE:-unknown}), clone tests may skip" >&2 -fi - -TEST_CASES="TryCloneFile,CopyFile.Clone,SupportsBlockRefCounting,CloneQueryInterface" - -echo "Running block-clone tests ..." -echo "---" -"$TEST_BINARY" \ - --test-suite="core.filesystem" \ - --test-case="$TEST_CASES" -echo "---" -echo "All block-clone tests passed." -- cgit v1.2.3