#!/usr/bin/env bash ## Fixture test: the step-2c upload_progress patch in lsphp-src-build.sh flips only ## session.upload_progress.enabled (value on the line after the name), is a no-op ## when already "1", and the script keeps its 4b gate + fails closed if not found. set -euo pipefail HERE=$(cd "$(dirname "$0")/.." && pwd) S="$HERE/lsphp-src-build.sh" T=$(mktemp -d); trap 'rm -rf "$T"' EXIT fail=0 chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; } cat >"$T/session.c" <<'EOT' STD_PHP_INI_BOOLEAN("session.upload_progress.enabled", "0", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_enabled, php_ps_globals, ps_globals) STD_PHP_INI_BOOLEAN("session.upload_progress.cleanup", "0", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_cleanup, php_ps_globals, ps_globals) EOT ## Run the exact sed expression from the script. SEDLINE=$(grep -F "session\\.upload_progress\\.enabled" "$S" | grep '^ *sed -i' | head -n1) [ -n "$SEDLINE" ] || { echo "FAIL: sed line not found in script"; exit 1; } SRC="$T"; sed() { command sed "$@"; } eval "${SEDLINE//\$SRC\/ext\/session\/session.c/$T/session.c}" chk "enabled flipped to 1" "$(grep -A1 'upload_progress.enabled' "$T/session.c" | grep -c '"1"')" 1 chk "cleanup untouched" "$(grep -A1 'upload_progress.cleanup' "$T/session.c" | grep -c '"0"')" 1 eval "${SEDLINE//\$SRC\/ext\/session\/session.c/$T/session.c}" chk "idempotent" "$(grep -A1 'upload_progress.enabled' "$T/session.c" | grep -c '"1"')" 1 grep -q 'ini defaults differ from the packaged' "$S" && echo "ok 4b gate still present" || { echo "FAIL 4b gate missing"; fail=1; } grep -q 'could not apply the packaged session.upload_progress.enabled' "$S" && echo "ok fail-closed verify present" || { echo "FAIL verify missing"; fail=1; } exit $fail