flutter_texture_rgba_renderer/windows/test/run_tests.sh
yunchan f38b9420ac B252: keep closed textures valid until the engine is done with them
Windows: closeTexture hands the texture to UnregisterTexture's callback and
frees its frame buffers there; frames pushed after close are dropped. Without
"recycle" the object is kept for the process lifetime (the session may still
hold its pointer); an engine that shuts down keeps its open textures the same
way. A duplicate createTexture key gets -1, getTexturePtr of an unknown key 0.

macOS: closeTexture drops the frame and closes the texture to later frames;
only "recycle" removes it from the plugin.

Linux: the frame handed to the engine last is freed at that engine's next
copy_pixels or once the engine has shut down, not at close: from Flutter 3.32
the raster thread can still be uploading it.

Tests: windows/test/run_tests.sh (plain, --asan, --tsan) and
linux/test/run_tests.sh (plain, --asan).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 03:19:05 +09:00

58 lines
2.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Kitedesk fork, 2026: builds windows/test/texture_rgba_renderer_plugin_test.cc
# on Linux with the plugin sources and the C++ client wrapper of the Flutter
# Windows engine, and runs each test in its own process. The engine files come
# from FLUTTER_WINDOWS_ENGINE, by default the windows-x64 engine artifacts of the
# Flutter SDK on PATH (or FLUTTER_ROOT) as `flutter precache --windows` leaves
# them: the C headers and cpp_client_wrapper/. No display, GPU or Windows needed.
# run_tests.sh -Wall -Werror build
# run_tests.sh --asan the same with AddressSanitizer and UBSan
# run_tests.sh --tsan the same with ThreadSanitizer
# OUT_DIR (default: a new temporary directory) receives the test binary.
set -euo pipefail
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
if [ -z "${FLUTTER_WINDOWS_ENGINE:-}" ]; then
root=${FLUTTER_ROOT:-$(dirname "$(dirname "$(readlink -f "$(command -v flutter)")")")}
FLUTTER_WINDOWS_ENGINE=$root/bin/cache/artifacts/engine/windows-x64
fi
engine=$FLUTTER_WINDOWS_ENGINE
wrapper=$engine/cpp_client_wrapper
[ -f "$engine/flutter_texture_registrar.h" ] && [ -f "$wrapper/core_implementations.cc" ] || {
echo "no Flutter Windows engine headers and client wrapper in $engine" \
"(flutter precache --windows, or set FLUTTER_WINDOWS_ENGINE)" >&2
exit 2
}
out=${OUT_DIR:-$(mktemp -d)}
mkdir -p "$out"
# The client wrapper headers expect <cstdint> to come with the standard headers,
# as MSVC's do; libstdc++'s do not.
flags=(-std=c++17 -Wall -Werror -O1 -g -pthread -include cstdint -DFLUTTER_PLUGIN_IMPL '-D__declspec(x)=')
case "${1:-}" in
"") ;;
--asan) flags+=('-fsanitize=address,undefined' -fno-omit-frame-pointer -fno-sanitize-recover=undefined) ;;
--tsan)
flags+=(-fsanitize=thread)
export TSAN_OPTIONS=${TSAN_OPTIONS:-halt_on_error=1}
;;
*) echo "usage: $0 [--asan | --tsan]" >&2; exit 2 ;;
esac
bin=$out/texture_rgba_renderer_plugin_test
"${CXX:-clang++}" "${flags[@]}" -I"$here/shim" -I"$wrapper/include" -I"$engine" \
"$here/texture_rgba_renderer_plugin_test.cc" \
"$here/../texture_rgba.cpp" "$here/../texture_rgba_renderer_plugin.cpp" \
"$here/../texture_rgba_renderer_plugin_c_api.cpp" \
"$wrapper/core_implementations.cc" "$wrapper/plugin_registrar.cc" "$wrapper/standard_codec.cc" \
-o "$bin"
count=0
failed=0
for test in $("$bin" --list); do
count=$((count + 1))
if "$bin" "$test"; then
echo "PASS $test"
else
echo "FAIL $test"
failed=$((failed + 1))
fi
done
echo "$count tests, $((count - failed)) passed, $failed failed"
[ "$failed" -eq 0 ]