joeylib2/scripts/check-draw.sh

34 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# check-draw.sh - Host gate for the shared line and circle fallbacks
# (src/core/draw.c) at the far ends of their coordinates: the BLANK port
# built with the host cc, and tests/host/drawHost.c drawing a line whose
# ends are 40000 apart, a nearly vertical one as long, a circle of radius
# 20000 crossing the stage, and one far off it near the int16_t limit, each
# checked against the true geometry. (16-bit state once made the first two
# never finish and the third plot pixels far from itself.)
#
# Usage: scripts/check-draw.sh
# Exit: 0 PASS, 1 FAIL
set -euo pipefail
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
cc=${CC:-cc}
work=$(mktemp -d -t joeylib-draw.XXXXXX)
trap 'rm -rf "$work"' EXIT
cd "$repo"
"$cc" -O2 -DJOEYLIB_PLATFORM_BLANK \
-Iinclude -Iinclude/joey -Isrc/core -Isrc/codegen -Wall -Wextra -Werror \
src/core/*.c src/generic/*.c src/blank/blank.c tests/host/drawHost.c \
-lm -o "$work/drawHost"
if "$work/drawHost"; then
echo "check-draw: PASS (long lines finish and land on their rows, a huge circle stays on itself, a far one draws nothing)"
else
echo "check-draw: FAIL"
exit 1
fi